akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main(){
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int dp[n+1];
    dp[1]=0;
    dp[2]=abs(a[1]-a[2]);
    for(int i=3;i<=n;i++){
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    ll left = 4*a*b;
    ll right = (c-a-b)*(c-a-b);
    if(c-a-b < 0){
        cout << "No" << endl;
        return 0;
    }
    if(left < right){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> arr;
int n;
int main()
{
scanf("%d",&n);
for(int i=1;i<=2*n;i++)
{int a;
scanf("%d",&a);
arr.push_back(a);
}
sort(arr.begin(),arr.end());
int ans=0;
for(int i=0;i<2*n;i+=2)
ans+=arr[i];
printf("%d\n",ans);
return 0;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
map<string,int> mp;//mp[string]
int num,n;
string s;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		if(mp[s]) mp[s]++;//出现次数
		else
		{
			num++;
			mp[s]=1;	
		} 
	}
	cout<<num;	
return 0;
}


Measured memory_bytes: 19208
#include "bits/stdc++.h"

using namespace std;

int main() {
  string S, T;
  cin >> S;
  cin >> T;

  for (int i = 0; i < S.length(); i++) {
    bool is_rotation = true;
    for (int j = 0; j < S.length(); j++) {
      if (S[(i + j) % S.length()] != T[j]) {
        is_rotation = false;
        break;
      }
    }
    if (is_rotation) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n,d;
  cin >> n >> d;
  
  int ans = 0;
  
  vector<double> x(n);
  vector<double> y(n);
  
  for(int i = 0;i<n;i++){
    cin >> x.at(i) >> y.at(i);
  }
  
  for(int i = 0;i<n;i++){
    if(sqrt(pow(x.at(i),2)+pow(y.at(i),2)) <= d){
      ans = ans + 1;
    }
       }
       cout << ans << endl;
}


Measured memory_bytes: 6428
program ABC058B
    implicit none
    integer(8)::i
    character(50)::O,E
    character(100)::L
    read(5,*)O,E

    do i=1,len_trim(O)+len_trim(E)
        if(mod(i,2)==1)then
            L(i:i)=O(i/2+1:i/2+1)
        else
            L(i:i)=E(i/2:i/2)
        end if
    end do

    print'(A)',L(1:len_trim(O)+len_trim(E))
end program ABC058B

Measured memory_bytes: 256
n, m = map(int, input().split())
a = [[1, int(x)] for x in input().split()]
bc = [list(map(int, input().split())) for x in range(m)]
a.extend(bc)
a = sorted(a, key=lambda x: x[1], reverse=True)
d = []
ans = 0
cnt = 0
for x in a:
    if cnt > n:
        break
    k = x[0]
    if cnt + k > n:
        k = n - cnt
    ans += x[1] * k
    cnt += k
print(ans)


Measured memory_bytes: 47060
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    for(int i=0; i<N; i++) cin >> l[i];

    sort(l.begin(), l.end());
    reverse(l.begin(), l.end());
    int ans = 0;
    for(int i=0; i<K; i++) ans += l[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n,i,j,m,f;
	char a[256],b[256],x;
	while(1){
	scanf("%d ",&n);
	if(n==0){
		break;
        }

	for(i=0;i<n;i++){
		scanf("%s%s",&a[i],&b[i]);
	}
	
	scanf("%d ",&m);
	for(i=0;i<m;i++){
		scanf("%s",&x);
		f=0;
		for(j=0;j<n;j++){
		 if(x==a[j]){
			printf("%c",b[j]);
			f=1;
			break;
		 }
	    }
	 if(f==0){
	    printf("%c",x);
	 }
	}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1008
#include <bits/stdc++.h>
using namespace std;

int main()
{
  string s;
  int n;
  int ai;

  cin >> s;
  n = s.size();
  for (int i = 0; i < n; i++)
  {
    if (s[i] == 'A')
    {
      ai = i;
      break;
    }
  }
  for (int i = 0; i < n; i++)
  {
    if (s[n - i - 1] == 'Z')
    {
      cout << n - i - ai << endl;
      break;
    }
  }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fl(i,a,b) for(int i=a;i<b;i++)
#define rfl(i,a,b) for(int i=a;i>b;i--)
#define cases() ll t;cin>>t;while(t--)
int main()
{
    ll n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    char a[2*n];
    ll j=0;
    fl(i,0,n)
    {
        a[j]=s[i];
        a[j+1]=t[i];
        j+=2;
    }
    fl(i,0,2*n)
        cout<<a[i];
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 101

int main(){
  int gin[N][N], gout[N + 1][N + 1];
  int n, i, j;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d%d", &gin[i][0], &gin[i][1]);
    for(j = 2; j < 2 + gin[i][1]; j++){
      scanf("%d", &gin[i][j]);
    }
  }

  for(i = 0; i < n; i++){
    for(j = 2; j < 2 + gin[i][1]; j++){
      gout[ gin[i][0] ][ gin[i][j] ] = 1;
    }
  }


  for(i = 1; i < n + 1; i++){
    for(j = 1; j < n ; j++){
      printf("%d ", gout[i][j]);
    }
    printf("%d\n", gout[i][j]);
  }

  return 0;
}

Measured memory_bytes: 676
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

int main() {
    string S;
    cin >> S;

    int cnt = 0;
    char cur = 'A';
    rep(i, S.size()) {
        if (cur != S[i]) {
            cur = S[i];
            cnt++;
        }
    }

    cout << (cnt - 1) << endl;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

int main() {
	int n;
   cin>>n;
  
  	double a[n];
  	rep(i,n)cin>>a[i];
  
  double ans;
  
  rep(j,n){
  	ans+=1/a[j];
  }
  
  cout<<1/ans<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int digit_sum(int num) {
    int sum = 0;
    while (num > 0)
    {
        sum += num % 10;
        num /= 10;
    }
    return sum;
}

int main() {
    int N;
    cin >> N;

    int minv = (1<<20), v;
    for (int i = 1; i < N; i++)
    {
        int j = N - i;
        v = digit_sum(i) + digit_sum(j);
        minv = min(minv, v);
    }

    cout << minv << endl;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;






int main(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll count=-1;
    for(int i=1;i<s.size();i++){
        if(s[i]=='x' && s[i-1]=='x'){
            count=i; break;
        }
    }
    if(count==-1){count=s.size();}
    cout<<count<<endl;
    
    return 0;
}



Measured memory_bytes: 3336
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

class Point {
  public:
  long double x, y;

  Point(long double x = 0, long double y = 0): x(x), y(y) {}

  Point operator + (Point &p) {
    return Point(x + p.x, y + p.y);
  }

  Point operator - (Point &p) {
    return Point(x - p.x, y - p.y);
  }

  Point operator * (long double k) {
    return Point(x * k, y * k);
  }

  Point operator / (long double k) {
    return Point(x / k, y / k);
  }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};

long double norm(Point p) {
  return p.x * p.x + p.y * p.y;
}

long double abs(Point p) {
  return sqrt(norm(p));
}

long double dot(Point p1, Point p2) {
  return p1.x * p2.x + p1.y * p2.y;
}

long double cross(Point p1, Point p2) {
  return p1.x * p2.y - p1.y * p2.x;
}

int ccw(Point p1, Point p2) {
  if (cross(p1, p2) > 0) return 1;
  else if (cross(p1, p2) < 0) return -1;
  else if (dot(p1, p2) < 0) return 2;
  else if (norm(p1) < norm(p2)) return -2;
  else return 0;
}

void print(int c) {
  if (c == 1) cout << "COUNTER_CLOCKWISE" << endl;
  else if (c == -1) cout << "CLOCKWISE" << endl;
  else if (c == 2) cout << "ONLINE_BACK" << endl;
  else if (c == -2) cout << "ONLINE_FRONT" << endl;
  else if (c == 0) cout << "ON_SEGMENT" << endl;
}

int main() {
  Point p0, p1, p2, v01, v02;
  int q, c;
  cin >> p0.x >> p0.y >> p1.x >> p1.y;
  v01 = p1 - p0;
  cin >> q;
  rep(i, q) {
    cin >> p2.x >> p2.y;
    v02 = p2 - p0;
    c = ccw(v01, v02);
    print(c);
  }

  
  return 0;
}


Measured memory_bytes: 3224
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>

using namespace std;
typedef long long ll;

ll N, K, fuc[2001] = {}, ans[2001] = {};

ll modpow(ll a) {
	if (a == 1) {
		return 1;
	}
	else {
		ll res = 1;
		ll m = 1000000005;
		while (m > 0) {
			if (m & 1)res = (res*a) % 1000000007;
			a = (a*a) % 1000000007;
			m >>= 1;
		}
		return res;
	}
}

int main() {
	cin >> N >> K;
	fuc[0] = 1;
	fuc[N] = 1;
	for (int i = 1; i <= N; i++) {
		fuc[N] *= i;
		fuc[N] %= 1000000007;
		fuc[i] = fuc[N];
	}
	for (int i = 1; i <= K; i++) {
		ll com1 = (((fuc[N - K + 1] * modpow(fuc[N - K + 1 - i])) % 1000000007) *modpow(fuc[i])) % 1000000007;
		ll com2 = (((fuc[K - 1] * modpow(fuc[K - 1 - i + 1])) % 1000000007)*modpow(fuc[i - 1])) % 1000000007;
		ans[i] = (com1*com2) % 1000000007;
	}
	for (int i = 1; i <= K; i++)cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
list($n, $a, $b) = explode(" ", fgets(STDIN));
$ans =0;
for($i=1; $i<=$n; $i++){
	$i_2 = str_split($i);
	$count = 0;
	foreach($i_2 as $i_1){
		$count += $i_1;
	}
	if($count <= $b && $a <= $count){
		$ans+=$i;
	}
}
echo $ans. "\n";
?>

Measured memory_bytes: 4604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            int n = Integer.parseInt(br.readLine());
            String s = br.readLine();
            int tmpNum = 0;
            int max = 0;
            for (int i = 0; i < n; i++) {
                String tmp = s.substring(i, i + 1);
                if ("I".equals(tmp)) {
                    tmpNum++;
                    if (max < tmpNum) {
                        max = tmpNum;
                    }
                } else {
                    tmpNum--;
                }
            }
            System.out.println(max);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 8276
NUM = 50
k = gets.to_i
div, mod = k.divmod(NUM)
base = NUM - 1
small_num = base + div - mod
large_num = base + div + NUM - (mod - 1)
ans = []
(NUM - mod).times { ans << small_num }
mod.times { ans << large_num }
puts NUM
puts ans.join(" ")


Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		var ans = new List<char>();
		while(N > 0)
		{
			N--;
			ans.Add((char)(N % 26 + 'a'));
			N /= 26;
		}
		ans.Reverse();
		WriteLine(string.Concat(ans));
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 27960
using System.Collections.Generic;
using System.Linq;
using System;

class A
{
    static void Main()
    {
        var AB = Console.ReadLine().Split(' ').Select(x => int.Parse(x));
        var A = AB.ElementAt(0);
        var B = AB.ElementAt(1);
        if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0)
        {
            Console.WriteLine("Possible");
        }
        else
        {
            Console.WriteLine("Impossible ");
        }
    }
}

Measured memory_bytes: 13396
using System.Linq;
using System;
using static System.Console;

class Program
{
  static void Main() => new Program().solve();

  void solve()
  {
    var c = Enumerable.Range(0, 5).Select(_ => int.Parse(ReadLine())).ToArray();

    var cSorted = c.OrderBy(i => (i % 10) == 0 ? 10 : (i % 10));

    var ans = cSorted.First() + cSorted.Skip(1).Select(i => ((i + 9) / 10) * 10).Sum();
    WriteLine(ans);
  }
}

Measured memory_bytes: 13396
import collections
N=int(input())
A=list(map(int,input().split()))

B=[0]
for i in range(1,N+1):
    B.append(A[i-1]+B[i-1])

b=collections.Counter(B)
ans=0
for key in b:
    n=b[key]
    ans+=n*(n-1)/2

print(int(ans))

Measured memory_bytes: 44324
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
const int inf = 0x3f3f3f3f;
int n, m, x, c[13], a[13][13], lv[13];
int ans = inf;

void dfs(int k, int f){
    if (k > n){
        int fg = 1;
        for (int i = 1; i <= m; i++) if (lv[i]<x) fg = 0;
        if (fg) ans = min(ans, f);
        return ;
    }
    dfs(k+1, f);
    for (int i = 1; i <= m; i++){
        lv[i] += a[k][i];
    }
    dfs(k+1, f+c[k]);
    for (int i = 1; i <= m; i++){
        lv[i] -= a[k][i];
    }
}

int main(){
    scanf("%d%d%d", &n, &m, &x);
    for (int i = 1; i <= n; i++){
        scanf("%d", &c[i]);
        for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]);
    }
    dfs(1, 0);
    if (ans < inf)
        printf("%d\n", ans);
    else
        printf("-1\n");
}


Measured memory_bytes: 3824
S = input()

false_char = 'L'
easy = True

for s in S:
	if s == false_char:
		easy = False
		# print(s, 'false!')
		break

	if false_char == 'R':
		false_char = 'L'
	else:
		false_char ='R'

if easy:
	print('Yes')
else:
	print('No')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N;
	char C;
	while (!isdigit(C = getchar_unlocked()));
	N = C - '0';
	while (isdigit(C = getchar_unlocked())) N = N * 10 + C - '0';

	int kotae = 1e9;
	int A = 0;
	rep(i, N) {
		if (getchar_unlocked() == 'W') kotae = min(kotae, A - i + ++A);
		else kotae = min(kotae, A + A - i);
	}

	co(kotae + N - 1 - A);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main() {
	std::vector<int> deg(4, 0);
	for(int i = 0; i < 3; i++) {
		int u, v;
		std::cin >> u >> v;
		u--;v--;
		deg[u]++;
		deg[v]++;
	}
	int one = 0, zero = 0;
	for(int i = 0; i < 4; i++) {
		if(deg[i] == 1) one++;
		if(deg[i] == 2) zero++;
	}
	if(one == 2 && zero == 2) std::cout << "YES\n";
	else std::cout << "NO\n";
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int p=1,c=1,n=1,r=1;
        int k=0;
        int[] ans = new int[10000];
        int[] part = new int[50];
        while(true){
            n = scan.nextInt();
            r = scan.nextInt();
            if(n==0 && r==0)break;
            int[] num = new int[n];
            for(int i=0;i<n;i++){
                num[i]=i+1;
            }
            for(int j=0;j<r;j++){
                p = scan.nextInt();
                c = scan.nextInt();
                for(int i=0;i<c;i++){
                    part[i]=num[n-p+1-c+i];
                }
                for(int i=0;i<p-1;i++){
                    num[i+n-p-c+1]=num[i+n-p+1];
                }
                
                for(int i=0;i<c;i++){
                    num[i+n-c]=part[i];
                }
            }
            ans[k]=num[n-1];
            k++;
        }
        for(int i =0;i<k;i++){
            System.out.println(ans[i]);
        }
    }
}


Measured memory_bytes: 36760
#include <iostream>
#include <stdio.h>

using namespace std;

int main(){
   int H, W;
   
   while(true){
       cin >> H >> W;
       if(H==0 && W==0) break;
       
       for(int i=0;i<H;i++){
           for(int j=0;j<W;j++){
               if((i+j) % 2 == 0) {
                   cout << "#";
               } else {
                   cout << ".";
               }
           }
           cout << endl;
       }
       cout << endl;
   }
   
   return 0;
}


Measured memory_bytes: 3088
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>

#define REP( i, n) for( int i = 0; i < (n); ++i)
#define FOR( i, a, b) for( int i = (a); i < (b); ++i)

#define pb push_back

const int INF = 100100100;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

std::vector<int> a;
int n,q;

bool solve( int i, int sum){
  bool res = false;
  if( i == n) return sum == 0;
  res = solve( i+1, sum-a[i]) || solve( i+1, sum);
  return res;
}



int main(){


  cin >> n;
  a.resize(n);
  REP( i, n){
    cin >> a[i];
  }

  cin >> q;
  REP( i, q){
    int m;
    cin >> m;
    if( solve( 0, m)){
      cout << "yes" << endl;
    }else{
      cout << "no" << endl;
    }
  }

}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;

int main()
{
    string s;
    cin >> s;

    if(s=="Sunny"){
        cout << "Cloudy" << endl;
    }else if(s=="Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*
    A - Double Helix
    https://atcoder.jp/contests/abc122/tasks/abc122_a
*/
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    char base;
    cin >> base;

    if (base == 'A')
        cout << 'T' << endl;
    else if (base == 'T')
        cout << 'A' << endl;
    else if (base == 'C')
        cout << 'G' << endl;
    else
        cout << 'C' << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstdlib>
using namespace std;
bool save[1010][1010];
bool die[1010];
struct line{
	int x,y;
}kill[100010];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) scanf("%d%d",&kill[i].x,&kill[i].y);
	for(int i=1;i<=n;i++)
	{
		save[i][i]=1;
		for(int j=m;j>=1;j--)
		{
			if(save[i][kill[j].x] && save[i][kill[j].y])
			{
				die[i]=true;
				break;
			}
			else if(save[i][kill[j].x]) save[i][kill[j].y]=true;
			else if(save[i][kill[j].y]) save[i][kill[j].x]=true;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	if(!die[i])
		for(int j=i+1;j<=n;j++)
		if(!die[j])
		{
			bool flag=true;
			for(int k=1;k<=n;k++)
			if(save[i][k] && save[j][k])
			{
				flag=false;
				break;
			}
			if(flag) ans++;
		}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main()
{
	int N;
	int H[100000];

	scanf("%d", &N);

	for (int i = 0; i < N; i++)
		scanf("%d", &H[i]);
	

	for (int i = 1; i < N; i++)
	{
		if ((H[i]-H[i - 1])>0)
			H[i]--;

		if ((H[i] - H[i - 1])<0)
		{
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,k,m,memo;
bool f=true;

signed main() {
    cin >> n >> k;m=(int)pow(2,n);
    rep(i,m) if (k^i) memo ^= i;
    if (k==0) {
        rep(i,m) rep(j,2) {
            if (f) cout << i,f=false;
            else cout << " " << i;
        }
        cout << endl;
    } else if (memo == k) {
        rep(i,m) if (i^k) {
            if (f) cout << i,f= false;
            else cout << " " << i;
        }
        cout << " " << k;
        repm(i,m) if (i^k) cout << " " << i;
        cout << " " << k << endl;
    } else cout << -1 << endl;
}


Measured memory_bytes: 1792
/*
    Created by Ezio112
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
//#define inf ll(10e16)
#define mod ll(10e8+7)
#define ff first
#define ss second
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    ll t;
    //cin>>t;
    t=1;
    while(t--)
    {
        ll n;
        cin>>n;
        vector<ll> vec(n+1);
        map<ll,ll> counter;

        for(ll i=1;i<=n;++i)
        {
            cin>>vec[i];
            counter[i-vec[i]]++;
        }
        ll count=0;

        for(ll i=1;i<=n;++i)
        {
            count+=counter[vec[i]+i];
            counter[i-vec[i]]--;
        }
        cout<<count<<endl;
    }
    return 0;
}


Measured memory_bytes: 27484
#include <cstdio>
#include <map>
#include <algorithm>

int main() {
  int N;
  scanf("%d", &N);

  std::map<int, int> map;
  for (int i=0; i<N; ++i) {
    int a;
    scanf("%d", &a);
    ++map[a];
  }

  int res=0;
  for (const auto &p: map) {
    if (p.first < p.second) {
      res += p.second - p.first;
    } else if (p.first > p.second) {
      res += p.second;
    }
  }
  printf("%d\n", res);
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
long long n,W,dp[105][100005];
int main(){
	scanf("%lld%lld",&n,&W);
	for (int i=1;i<=n;i++){
		long long  w,v;
		scanf("%lld%lld",&w,&v);
		for (int j=1;j<=W;j++) {
			if (j<w) dp[i][j] = dp[i-1][j];
			else dp[i][j] = max(dp[i-1][j],dp[i-1][j-w]+v);
		}
	}
	printf("%lld",dp[n][W]);
	return 0;
}

Measured memory_bytes: 79360
import java.util.Scanner;

public class Main {
    static int cnt;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        cnt = 0;
        int m = 1 + (int) (Math.log(n) * Math.log(2));
        int[] G = new int[m];
        G[0] = 1;
        for (int i = 1; i < m; i++) {
            G[i] = G[i - 1] * 3 + 1;
        }

        // G[i]のセット

        for (int i = m-1; i >= 0; i--) {
            insertionSort(a, G[i]);
        }

        println("");
        println(m + "");
        for (int i = m-1; i > 0; i--) {
            print(G[i] + " ");
        }
        println(G[0] + "");
        println(cnt + "");

        for (int i = 0; i < n; i++) {
            println(a[i] + "");
        }
    }

    static void insertionSort(int[] a, int g) {
        int len = a.length;

        for (int i = g; i < len; i++) {
            int temp = a[i];
            int j = i - g;
            while (j >= 0 && a[j] > temp) {
                a[j + g] = a[j];
                j -= g;
                cnt++;
            }
            a[j + g] = temp;
        }
//        printlnArray(a);
    }

    static void println(String str) {
        System.out.println(str);
    }

    static void print(String str) {
        System.out.print(str);
    }

    private static void printlnArray(int[] a) {
        for (int i = 0; i < a.length - 1; i++) {
            System.out.print(a[i] + " ");
        }
        System.out.println(a[a.length - 1]);
    }
}



Measured memory_bytes: 299764
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
int a,b,c,x;
cin >>a >>b >>c>>x;
int ans = 0;
for(int i=0;i<=a;i++){
   for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
         ll che = i*500+j*100+k*50;
         if(che==x)ans++;
      }
   }
}
cout << ans << endl;
}





Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int inf=1000000007;
int a[305][305];
int n,m;

int solve2(vector<bool>& ok){
  int ans=0;
  vector<int> sum(m+1,0);
  rep(i,n){
    int j=0;
    while(!ok[a[i][j]]){
      j++;
    }
    sum[a[i][j]]++;
  }
  int p;
  rep1(i,m){
    if(ans<sum[i]){
      ans=sum[i];
      p=i;
    }
  }
  ok[p]=false;
  return ans;
}
int solve1(vector<bool>& ok){
  int ans=inf;
  rep(i,m){
    int buf=solve2(ok);
    if(ans>buf){
      ans=buf;
      /*
      cout<<"ok"<<endl;
      rep1(i,m){
        cout<<ok[i]<<endl;
      }
      cout<<"ans"<<endl;
      cout<<ans<<endl;
      */
    }
    //ans=min(ans,solve2(ok));
  }
  return ans;
}
signed main(){
  cin>>n>>m;
  vector<bool> ok(m+1,true);
  rep(i,305){
    rep(j,305){
      a[i][j]=0;
    }
  }
  rep(i,n){
    rep(j,m){
      cin>>a[i][j];
    }
  }
  int ans=solve1(ok);
  //cout<<"ans"<<endl;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<i64>();
    let a = (s + 1000000000 - 1) / 1000000000;
    let b = if a == 0 {
        s
    } else {
        (s - 1000000000 * a).abs()
    };
    println!("0 0 1 1000000000 {0} {1}", a, b);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
#else

#endif

const int MAXN = 1e5 + 100;

int p[MAXN];

vector<int> aa[MAXN];

int cc_id[MAXN];
int cc_va[MAXN];

void esplora(int v, int c) {
    cc_id[v] = c;
    cc_va[p[v]] = c;
    for (int a : aa[v]) {
        if (cc_id[a] != 0) continue;
        esplora(a, c);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Togliere nei problemi con query online

    int N, M;
    cin >> N >> M;
    for (int i = 1; i <= N; i++) cin >> p[i];
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        aa[x].push_back(y);
        aa[y].push_back(x);
    }
    for (int i = 1; i <= N; i++) {
        if (cc_id[i] != 0) continue;
        esplora(i, i);
    }
    int res = 0;
    for (int i = 1; i <= N; i++) {
        if (cc_id[i] == cc_va[i]) res++;
    }
    cout << res << "\n";
}


Measured memory_bytes: 8960
n = int(input())

import math

N = math.ceil(math.sqrt(n))
from collections import defaultdict
counter = defaultdict(int)

from collections import defaultdict
counter = defaultdict(int)

for x in range(1,N + 1):
    answer_x = x * x
    for y in range(x, N + 1):
        answer_y = answer_x + y * y + x * y
        if answer_y > n:
            continue
        for z in range(y, N + 1):
            answer_z = answer_y + z * z + x * z + y * z
            if answer_z <= n:
                if x == y and x == z:
                    counter[answer_z] += 1
                elif x == y or x == z or y == z:
                    counter[answer_z] += 3
                else:
                    counter[answer_z] += 6

for i in range(1,n+1):
  print(counter[i])



Measured memory_bytes: 10052
#include <bits/stdc++.h>
using namespace std;

int main()
{
    double x, y;
    double a, b;
    cin >> x >> y;
    // 2a+2b=2x
    // 2a+4b=y
    b = (y - 2 * x) / 2;
    a = (4 * x - y) / 2;
    if (a - int(a) > 0 || a < 0 || b - int(b) > 0 || b < 0)
    {
        cout << "No\n";
    }
    else
    {
        cout << "Yes\n";
    }
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  int x,y;cin>>x>>y;
  cout << (x+y/2) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

bool fn_is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

struct UnionFind {
    vector<int> r;

    UnionFind(int N) {
        r = vector<int>(N, -1);
    }

    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x) {
        return -r[root(x)];
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

int main()
{
    int a, b , c , d; cin >> a >> b >> c >> d;
    cout << max(a*b, c*d) << endl;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] input = scanner.nextLine().split(" ");
        int r = Integer.valueOf(input[0]);
        int d = Integer.valueOf(input[1]);
        int x = Integer.valueOf(input[2]);
        for(int i = 1; i < 11; i++) {
            int result = (r * x) - d;
            x = result;
            System.out.println(result);
        }
    }
}

Measured memory_bytes: 21844
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let (a, b) = {
      let v: Vec<i64> = read_vec();
      (v[0], v[1])
    };

    if a >= 13 {
      println!("{}", b);
    }
    else if 6 <= a && a <= 12{
      println!("{}", b / 2);
    }
    else {
      println!("{}", 0);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define forn(i,a,b) for (int i = a; i <= b; i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
#define er erase
#define in insert
#define pi pair <int, int>
# define sz(x) (int)((x).size())
#define inf 1000000000
const ll mod = 1000000007;
const int N = 2e5 + 11;


int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0); cerr.tie(0); cout.tie(0);
	char c;
	cin>>c;
	cout<<(char((int)(c)+1))<<'\n';
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

int main(void)
{
    int a,b,c;
    cin >> a >> b >> c;

    rep(i,b){
        if(i*a%b == c){
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    vector<int> a(n);

    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    for(int i=n-1;i>0;i--)printf("%d ",a[i]);
    printf("%d\n",a[0]);
} 


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
 typedef long long ll;



int main() {
string S;
cin >> S;
int lo = S.size();
lo--;

if(S[lo] == '2' || S[lo] == '4' ||S[lo] == '5' ||S[lo] == '7' || S[lo] == '9') cout << "hon" <<endl;
else if(S[lo] == '3')cout << "bon";
else cout << "pon" << endl;
}


Measured memory_bytes: 3632
n, k = map(lambda x: int(x), input().split(" "))
Ps = list(map(lambda x: int(x), input().split(" ")))

result = 0
expected_list = []
temp_result = 0
for i, p in enumerate(Ps):
    temp = (p * (p + 1) / 2 )/ p
    expected_list.append(temp)
    temp_result += temp
    if i+1 >= k:
        result = max(result, temp_result)
        temp_result -= expected_list[i-k+1]

print(result)

Measured memory_bytes: 25604
h, w = map(int, input().split())

a = []

for y in range(h):
    a.append([_ for _ in input()])

rem_x = []
rem_y = []

for y in range(h):
    fl = 0
    for x in range(w):
        if a[y][x] == '#':
            fl = 1
    if fl == 1:
        rem_y.append(y)

for x in range(w):
    fl = 0
    for y in range(h):
        if a[y][x] == '#':
            fl = 1
    if fl == 1:
        rem_x.append(x)

for y in rem_y:
    for x in rem_x:
        print(a[y][x],end='')
    print()


Measured memory_bytes: 43368
#include <stdio.h>

int main() {
	int n, t, min;

	scanf("%d%d", &n, &t);
	min = 1024;
	while (n--) {
		int a, b;

		scanf("%d%d", &a, &b);
		if (min > a && b <= t)
			min = a;
	}
	if (min == 1024)
		printf("TLE\n");
	else
		printf("%d\n", min);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-6;
long double pi = acos(-1);


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n,k;
    cin>>n>>k;
    if((1<<n) <= k){
        cout << -1 << endl;
        return 0;
    }
    if(n==1){
        if(k)cout << -1 << endl;
        else cout << "0 0 1 1" << endl;
        return 0;
    }
    for(int i=0;i<(1<<n);i++){
        if(i==k)continue;
        cout << i << " ";
    }
    cout << k << " ";
    for(int i=(1<<n)-1;i>=0;i--){
        if(i==k)continue;
        cout << i << " ";
    }
    cout << k << endl;

    
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>

using namespace std;

int main(void) {
    long long N;
    cin >> N;
    vector<long long> A(N);
    for (long long i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    long long mod = 1000000007;

    long long sum = 0;
    long long right = A.at(N-1) % mod;
    for(long long i = N - 2; i >= 0; i--) {
        long long left = A.at(i) % mod;
        sum += (left * right) % mod;
        right += left;
        right = right % mod;
    }

    cout << sum % mod << endl;
}


Measured memory_bytes: 4836
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
int n,gab;
int a[200005][31];
int all_xor;
void find_xor(int num,int pla1,int pla2){
	if (num==0)  re;
	find_xor(num/2,pla1,pla2+1);
	a[pla1][pla2]=num%2;
}
signed main()
{
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>gab;
		find_xor(gab,i,0);
		all_xor^=gab;
	}
	find_xor(all_xor,n,0);
	for (int i=0;i<n;i++){
		int ans=0;
		for (int j=0;j<31;j++)
			if (a[i][j]!=a[n][j])
				ans+=(1<<j);
		if (i)  cout<<' ';
		cout<<ans;
	}
	re 0;
}

Measured memory_bytes: 51832
#include <iostream>
#include <algorithm>

using namespace std;

bool isPrime(int n){ 
        for(int i = 2; i*i <= n; i++) if(!(n%i)) return false;
        return true;
}
int nextPrime(int n){ 
        while(!isPrime(++n));
        return n;
}
int p(int *list, int n){ 
        if(list[n]){
                return list[n];
        }else{
                list[n] = nextPrime(p(list, n-1));
                return list[n];
        }   
}
int main(){
        int list[10001] = {0};
        list[1] = 2;
        int n;
        cin >> n;
        while(n){
                int s = 0;
                for(int i = 1; i <= n; i++) s += p(list, i); 
                cout << s << endl;
                cin >> n;
        }   
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if(A < C && C < B){
    cout << "Yes" << endl;
  }
  else if(B < C && C < A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
h,w,d = map(int, input().split())

from collections import defaultdict
G = defaultdict(list)
for i in range(h):
    l = list(map(int, input().split()))
    for n, item in enumerate(l):
        G[item] = [n,i]




# magic is just distance by 1

# if d is 4,
# 1,5,9 or 2,6,10.. make surplus to categorize
# query comes 10^5, so O(1) or O(logN) is limit -> cumulativesum

dp = [0 for i in range(h*w+1)]
for i in range(d): # 0,1,2,...d-1
    current_place = i+1
    while current_place + d <= h*w:
        x,y = G[current_place]
        next_place = current_place + d
        x1,y1 = G[next_place]
        magic = abs(x-x1) + abs(y-y1)
        dp[next_place] = magic + dp[current_place]
        current_place = next_place

q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    print(dp[r]-dp[l], flush=True)



Measured memory_bytes: 28352
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int main(){
    string s,s_rev;
    int n,j;
    cin >> s;
    n=s.length();
    if(s[n-1]=='1' || s[0]=='0'){
        cout << "-1";
        return 0;
    }
    s.erase(n-1);
    reverse(s.begin(),s.end());
    s_rev=s;
    reverse(s.begin(),s.end());
    if(s!=s_rev){
        cout <<"-1";
        return 0;
    }
    for(int i=0;i<n-1;i++){
        if(s[i]=='1'){
            cout << i+1 <<' '<< i+2 << '\n';
        } else {
            j=i;
            cout << i+1 <<' '<< i+2 << '\n';
            while(s[j]!='1'){
                cout << i+1 << ' ' << j+3 << '\n';
                j++;
            }
            i=j;
        }
    }
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>

#define FILE_NAME "B"
#define SZ(x) ((int) x.size())
#define pb push_back
#define ppb pop_back
#define x first
#define y second
#define mkp make_pair
#define show(x) cout << (#x) << ": " << x << endl

using namespace std;
// using namespace __gnu_pbds;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
template<typename T> using Array = vector<T>;
template<typename T> using Matrix = Array<Array<T>>;
using Graph = Matrix<int>;

// template<typename T> using Set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T> bool relax(T& r, const T& x) {
    if (x < r) {
        r = x;
        return true;    
    }
    return false;
}

template<typename T> bool heavy(T& h, const T& x) {
    if (h < x) {
        h = x;
        return true;            
    }
    return false;
}

const int DX[8] = {-1, +1, +0, +0, +1, -1, +1, -1};
const int DY[8] = {+0, +0, -1, +1, +1, -1, -1, +1};

/************************************************************
* find_by_order(k) = iterator to (k)-th greatest element    *
* order_of_key(k) = counts number of strictly less elements *
*************************************************************/                                                           

signed main() {
#ifdef LOCAL
    freopen(FILE_NAME".in", "r", stdin);
    freopen(FILE_NAME".out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> cnt;
    for (int& x : a) {
        cin >> x;    
        cnt[x]++;
    }
    int ans = 0;
    sort(a.begin(), a.end());
    for (int i = n - 1; i >= 0; i--) {
        int x = a[i];
        if (cnt[x] == 0)
            continue;
        cnt[x]--;
        /// ~get
        int k = 0;
        while ((1 << k) <= x)
            k++;
        int v = (1 << k);
        if (cnt[v - x]) {
            cnt[v - x]--;
            cnt[x]--;        
            ans++;
        }
        cnt[x]++;
    }
    cout << ans;
    return false;
}

Measured memory_bytes: 19840
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    *A, = map(int, readline().split())
    *B, = map(int, readline().split())
    v1 = v2 = 0
    for i in range(4):
        if A[i] == B[i]:
            v1 += 1
        for j in range(4):
            if i != j and A[i] == B[j]:
                v2 += 1
    write("%d %d\n" % (v1, v2))
try:
    while 1:
        solve()
except:
    ...



Measured memory_bytes: 5604
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
x, y = [0] * N, [0] * N

for i in range(N):
	x[i], y[i] = map(int, input().split())

pq = []
m = 0

if N == 1:
	print(1)
else:	
	for i in range(N):
		for j in range(N):
			if i == j:
				continue
				
			p, q = x[j] - x[i], y[j] - y[i]
			pq.append([p, q])
			
	for i in range(len(pq) - 1):
		n = 0
		for j in range(i + 1, len(pq)):
			if pq[i] == pq[j]:
				n += 1
				
		if n > m:
			m = n
			
	cost = N - m - 1
	print(cost)


Measured memory_bytes: 41324
#include<bits/stdc++.h>
using namespace std;

int main()
{
	int n,k;cin>>n>>k;
		int mi=1001010100;
	
	int h[n+1],dp[n+1];
	
	for(int i=0;i<n;i++)
{	cin>>h[i];dp[i]=mi;}
	
	dp[0]=0;
	
	
	for(int i=1;i<n;i++)
	{
	
		for(int j=1;j<=k;j++)
		{	if(i<j)
		break;
		dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		}
	}
		cout<<dp[n-1]<<endl;
	
	return 0;
}


Measured memory_bytes: 1024
function main(input) {
  const arg = input.split('\n')
  const number = arg[0]
  let items = arg.slice(1, number + 1)
  
  const set = new Set(items)
  const flatItems = Array.from(set)
 
  console.log(flatItems.length - 1)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 57668
<?php
$ch=[0,0,1,1];
for($i=4;$i<10000;$i+=2){$ch[]=0;$ch[]=1;}
for($i=3;$i<100;$i+=2) if($ch[$i]) for($j=$i<<1;$j<10000;$j+=$i) $ch[$j]=0;

$l=trim(fgets(STDIN));
$c=0;
for($i=0;$i<$l;$i++){
  $n=trim(fgets(STDIN));
  if($n<10000) $c+=$ch[$n];
  else $c+=isPn($n);
}

echo $c;

function isPn($n){
  if($n<2) return 0;
  if($n==2) return 1;
  if($n%2==0) return 0;
  $max=floor(sqrt($n));
  for($i=3;$i<=$max;$i+=2) if($n%$i==0) return 0;
  return 1;
}
?>

Measured memory_bytes: 16804
#include <stdint.h>
#include <stdio.h>

int main() {
    int N; 
    scanf("%d",&N);
    if(N == 1) {
        printf("Hello World\n");
    }else{
        int A,B;
        scanf("%d",&A);
        scanf("%d",&B);
        printf("%d\n",A+B);
    }
}


Measured memory_bytes: 128