akhauriyash/Code-Regression huggingface dataset:
import math

lis = list(input())
count = 0


lisA = lis[:math.floor(float(len(lis))/2)]
lisB = lis[math.ceil(float(len(lis))/2):]

lisB.reverse()



for i in range(int(len(lis)/2)):
    if lisA[i] != lisB[i]:
        count += 1
    

print(count)


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

int main()
{
        string A, B;
        cin >> A;
        cin >> B;
        if (A.length() > B.length()) {
                cout << "GREATER" << endl;
        }
        else if (A.length() < B.length()) {
                cout << "LESS" << endl;
        }
        else {
                for (int i = 0; i < A.length(); ++i) {
                        if (A[i] > B[i]) {
                                cout << "GREATER" << endl;
                                exit(0);
                        }
                        else if (A[i] < B[i]) {
                                cout << "LESS" << endl;
                                exit(0);
                        }
                }
                cout << "EQUAL" << endl;
        }


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j;
    scanf("%d",&n);
    int a[n+10],b[n+10],sa[n+10],sb[n+10];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(i==0)
        {
            sa[i]=a[i];
        }
        else
            sa[i]=sa[i-1]+a[i];
    }
    for(i=0;i<n;i++)
    {
        scanf("%d",&b[i]);
        if(i==0)
        {
            sb[i]=b[i];
        }
        else
            sb[i]=sb[i-1]+b[i];
    }
    int ans,ansmax=-1;
    for(i=0;i<n;i++)
    {
        ans=sa[i]+sb[n-1];
        if(i!=0)
        {
            ans-=sb[i-1];
        }

        if(ans>ansmax)
            ansmax=ans;
    }
    printf("%d",ansmax);
    return 0;

}


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

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

  ll x;
  cin >> x;

  ll big = x / 500 * 1000;
  ll small = x % 500 / 5 * 5;

  cout << big + small << "\n";
}

Measured memory_bytes: 256
n = int(input())
S = [input() for i in range(n)]

ref = "abcdefghijklmnopqrstuvwxyz"
out = ""
for i in range(26):
  countmin = []
  for j in range(n):
    countmin.append(S[j].count(ref[i]))
  minnum = min(countmin)
  for k in range(minnum):
    out += ref[i]
print(out)

Measured memory_bytes: 3060
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;

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

	for (int i = 0; i < N; ++i)
	{
		cout << S[i] << T[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            Set<Character> acgt = new HashSet<>();
            acgt.add('A');
            acgt.add('C');
            acgt.add('G');
            acgt.add('T');

            int len = 0, max = 0;
            for (char cc : in.next().toCharArray()) {
                if (acgt.contains(cc))
                    len++;
                else {
                    max = Math.max(max, len);
                    len = 0;
                }
            }

            out.println(Math.max(max, len));
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
            this.bufPointer = 0;
            this.bufLength = 0;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isPrintableChar(int c) {
            return c >= 33 && c <= 126;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();

            int b = readByte();
            while (!isPrintableChar(b))
                b = readByte();

            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }

            return sb.toString();
        }

    }
}



Measured memory_bytes: 21332
#include<cstdio>
const int N=1e5+5;
int n,i,a[N],ans;
int read(){
	char c=getchar();int k=0;for (;c<48||c>57;c=getchar());
	for (;c>47&&c<58;c=getchar()) k=(k<<3)+(k<<1)+c-48;return k;
}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int main(){
	for (n=read(),i=1;i<=n;i++) a[i]=read();
	if (n==1){puts("Second");return 0;}
	for (;;){
		int k0=0,k1=0,x;
		for (i=1;i<=n;i++)
			if (a[i]&1) k1++,x=i; else k0++;
		if (k0&1){ans^=1;break;}
		if (k1>1||a[x]==1) break;
		a[x]--;int k=a[1];ans^=1;
		for (i=2;i<=n&&k>2;i++) k=gcd(k,a[i]);
		for (i=1;i<=n;i++) a[i]/=k;
	}
	puts(ans?"First":"Second");
}

Measured memory_bytes: 512
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int
main()
{
  int A, B;
  cin >> A >> B;
  int price = 1;
  for (; price < 1100 && (int(price * 0.08) != A || int(price * 0.1) != B); price++)
  {
  }
  cout << (price == 1100 ? -1 : price) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

int main()
{
    int flag = 1;
    char a[10][10],b[10][10];
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    scanf("%s%s",a[0],a[1]);
    for(int i = 0;i < strlen(a[0]);i++){
        b[0][i] = a[1][strlen(a[1])-1-i];
        b[1][i] = a[0][strlen(a[1])-1-i];
    }
    for(int i = 0;i <strlen(a[0]);i++){
        if(a[0][i]!=b[0][i] || a[1][i]!=b[1][i]){
            flag = 0;
        }
    }
    if(flag == 0)
        printf("NO\n");
    else
        printf("YES\n");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
 public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int d=a/b;
    int r=a%b;
    double f=(double)a/b;
    System.out.print(d+" "+r+" "+String.format("%.8f", f));
  }
}



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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
        NodePointer x;
        for(x = nil->next ; x != nil ; x = x->next){
                if(x->key == key)return x;      
        }
        return x;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
        if(t == nil)return;
        t->prev->next = t->next;
        t->next->prev = t->prev;
        free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
        NodePointer x = nil->prev;
        if(x == nil)return;
        deleteNode(x);
}

void delete(int key){
        NodePointer x = listSearch(key);
        deleteNode(x);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  x->prev = nil;
  nil->next->prev = x;
  nil->next = x;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L' ) deleteLast();
      } else {
        delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 33040
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios_base::sync_with_stdio(0);
    int n; ll d; cin >> n >> d;

    int cnt = 0;
    for (int i=0;i<n;i++) {
        ll x, y; cin >> x >> y;
        if (x*x+y*y<=d*d) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <cstring>

using namespace std;

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

typedef long long ll;

int ans[12];

int main(){
	double n;
	
	while (cin >> n, n != -1.0){
		n *= 16;
		
		int na = n;
		
		int flag = 1;
		
		REP(i,12){
			ans[i] = 0;
		}
		
		if (n >= 4096){
			flag = 0;
		}
		
		if ((double)na != n){
			flag = 0;
		}
		
		int base = 128*16;
		
		if (flag){
			REP(i,12){
				if (base <= na){
					ans[i] = 1;
					na -= base;
				}
				if (i == 11 && na){
					flag = 0;
				}
				base /= 2;
			}
		}
		
		if (flag){
			REP(i,12){
				printf("%d", ans[i]);
				if (i == 7){
					printf(".");
				}
			}
			puts("");
		}
		else {
			puts("NA");
		}
	}
	
	return 0;
}

Measured memory_bytes: 3200
def f;gets.to_i;end
while(n=f)>0
m,g=f,f
a=(1..n).to_a
b=[a.dup]
l=(1..f).map{i=0
(r=gets.chars).map{|c|c>?0&&(a[i],a[i+1]=a[i+1],a[i]);i+=1}
b<<a.dup
r
}
y=x=0
puts m==a[g-1]?0:l.find{|r|
r=[?0]+r
x+=1
y=(1..n-1).find{|j|(r[j-1,3].all?{|k|k<?1})&&(b[x-1][j-1,2]-[m,a[g-1]]==[])}
}?"#{x} #{y}":1
end

Measured memory_bytes: 6104
public class Main {

  private static void solve() {
    int n = ni();
    int ret = 0;
    for (int i = 1; i <= n; i++) {
      if (("" + i).length() % 2 == 1) {
        ret++;
      }
    }
    System.out.println(ret);

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



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

int main(void)
{
    int n;
    cin >> n;

    vector<string> kname(n, "0");

    string tmp;
    
    for(int i = 0; i < n; ++i)
    {
        cin >> tmp;
        kname.at(i) = tmp;
    }
    std::sort(kname.begin(), kname.end());
    kname.erase(std::unique(kname.begin(), kname.end()), kname.end());
    cout << kname.size() << endl;

    

    return 0;
}



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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& e : a) cin >> e;
  int ans = 1000000;

  for (int i = 1; i <= 100; i++) {
    int s = 0;
    for (int j = 0; j < n; j++) {
      int t = a[j] - i;
      s += t * t;
    }
    ans = min(ans, s);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
#include<vector>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<algorithm>
#include<functional>
using namespace std;

long double a=0;

int main()
{

    while(cin>>a)
    {
    
   long double s=0;
      
    s=a;
    for(int i=0;i<4;i++)
    {
    a=2*a;
    s=s+a;
    a=a/3;
    s=s+a;
  
    }
    s=s+a*2;
    cout<<setprecision(10)<<s<<endl;
    }
    return 0;
}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
using namespace std;

int cost[5000], idou[5000], mincost[5000];
vector<int>rinsetu[5000];
bool operator <(P a, P b) {
	return a.first < b.first;
}
signed main()
{
	int a, b;
	cin >> a >> b;
	fill(mincost + 1, mincost + a, LLONG_MAX / 3);
	for (int c = 0; c<a; c++) { scanf("%lld%lld", &cost[c], &idou[c]); }
	for (int d = 0; d<b; d++) {
		int e, f;
		scanf("%lld%lld", &e, &f);
		e--; f--;
		rinsetu[e].push_back(f);
		rinsetu[f].push_back(e);
	}
	priority_queue <P>Q;
	Q.push(P(0, 0));
	while (Q.size()) {
		P g = Q.top(); Q.pop();
		if (mincost[g.first]<g.second)continue;
		int h[5000];
		memset(h, -1, sizeof(h));
		h[g.first] = 0;
		queue<P>que;
		que.push(P(g.first, 0));
		while (que.size()) {
			P o = que.front(); que.pop();
			if (o.second>idou[g.first])break;
			for (int r = 0; r<rinsetu[o.first].size(); r++) {
				if (h[rinsetu[o.first][r]] == -1) { que.push(P(rinsetu[o.first][r], o.second + 1)); h[rinsetu[o.first][r]] = o.second + 1; }
			}
		}
		for (int i = 0; i<a; i++) {
			if (h[i]!=-1&&h[i] <= idou[g.first] && mincost[i]>g.second + cost[g.first]) { mincost[i] = g.second + cost[g.first]; Q.push(P(i, mincost[i])); }
		}
	}
	cout << mincost[a - 1] << endl;
}

Measured memory_bytes: 3836
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=y;i>=x;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
//	ios::sync_with_stdio(false);
//	cin.tie(0);
const int maxx = 2e5+7;
const int maxn = 1e9+7;
typedef long long ll;
using namespace std;
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
long double t,n,res=1,op=1e18;
long double a[maxx];
int main(){
		ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	int f=0,ff=0;
	rept(i,1,n){
		cin>>a[i];
		if(a[i]==0)f=1;
	}
	if(f)cout<<0<<endl;
	else {
		rept(i,1,n){
			if(res*a[i]>op){
				ff=1;
				break;
			}else res*=a[i];
		}
	//	cout<<ff<<endl;
		if(ff)cout<<-1<<endl;
		else cout<<(ll)(res)<<endl;
	}
	return 0;
}


Measured memory_bytes: 5288
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return ReadLine().Split().Select(int.Parse).ToList(); }

        static int N;
        static List<int>[] Tree;
        static long[,,] dp;
        static readonly long Mod = 1000000000 + 7;
        static void Main(string[] args)
        {
            N = Sarray()[0];
            Tree = new int[N].Select(_ => new List<int>()).ToArray();
            for (var i = 0; i < N - 1; ++i)
            {
                var xy = Sarray();
                Tree[xy[0] - 1].Add(xy[1] - 1);
                Tree[xy[1] - 1].Add(xy[0] - 1);
            }

            dp = new long[N, 2, 2];
            for (var i = 0; i < N; ++i)
                for (var j = 0; j < 2; ++j)
                    for (var k = 0; k < 2; ++k)
                        dp[i, j, k] = -1;
            var r = 0;
            WriteLine(calckazu(r, -1, 1, 1));

        }

        //dp[i]=\prod(子の数) iが白の場合の数 　+prod(子の数) iが黒の場合の数 
        //dp[i,sirokazu,kurokazu]=sirokazu\prod dp[i+1,kurokazu+sirokazu,sirokazu] +kurokazu*\prod dp[i+1,sirokazu,0]
        //if(葉)return sirokazu+kurokazu
        static long calckazu(int vno, int preno, int wnum, int bnum)
        {
            if (dp[vno, wnum, bnum] != -1)
                return dp[vno, wnum, bnum];
            long wclc = 1;
            long bclc = 1;
            foreach (var nv in Tree[vno])
            {
                if (nv != preno)
                {
                    if (wnum != 0)
                        wclc *= calckazu(nv, vno, 1, 1);
                    if (bnum != 0)
                        bclc *= calckazu(nv, vno, 1, 0);
                    wclc %= Mod;
                    bclc %= Mod;
                }
            }
            return dp[vno, wnum, bnum] = ((wnum * wclc) + (bnum * bclc)) % Mod;
        }
    }
}

Measured memory_bytes: 47744
//you**can**do**anything 
#include <bits/stdc++.h> 
#define ll long long
#define pk push_back		
const ll maxn=2e5+1;
using namespace std;   
void solve()
{
	
}

int main()
{


ll n ,x , t  ,ans =0 ,count =0;
cin>>n>>x>>t ;

while(ans< n)
{
 ans+= x; 
 count+= t ;	
}

cout<<count;

}

Measured memory_bytes: 3628
import java.util.*;
class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    int x=sc.nextInt();
    int result=0;
    if(x>=400&&x<=599)
      result=8;
    else if(x>=600&&x<=799)
      		result=7;
    else if(x>=800&&x<=999)
      		result=6;
    else if(x>=1000&&x<=1199)
      		result=5;
    else if(x>=1200&&x<=1399)
      		result=4;
    else if(x>=1400&&x<=1599)
      		result=3;
    else if(x>=1600&&x<=1799)
      		result=2;
    else if(x>=1800&&x<=1999)
      		result=1;
    System.out.println(result);
  }
}

Measured memory_bytes: 35676
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};


bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll N,c=0,a[101],res=999999999999900;
  cin >> N;
  REP(i,N)cin >> a[i];
  for(int i=-100;i<=100;i++){
    c = 0;
    for(int j=0;j<N;j++){
      c += (a[j]-i)*(a[j]-i);
    }
    res = min(c,res);
  }
  cout << res << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

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

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x=0;
    scanf("%d", &x);
    for(int i=0;i<=100000;i++){
        if(i*i==x){
            printf("%d", x);
            return 0;
        }
        if(i*i>x){
            printf("%d", (i-1)*(i-1));
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back

using namespace std;
template<class T, class T1> int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }
template<class T, class T1> int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    long long n;
    char ch;
    string s1,s2;
    cin>>s1>>s2;
    n = s1.size();
    int ans = 0;
    for(int i = 0;i<n;i++)
    {
        if(s1[i]!=s2[i])
        ans++;
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 3784
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KyoPro
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            int first = Convert.ToInt32( S.Substring(0, 2));
            int last = Convert.ToInt32( S.Substring(2, 2));

            if (CanBeYear(first))
            {
                if (CanBeYear(last))
                {
                    Console.WriteLine("NA");
                }
                else
                {
                    Console.WriteLine("YYMM");
                }
            }
            else if (CanBeYear(last))
            {
                Console.WriteLine("MMYY");
            }
            else
            {
                Console.WriteLine("AMBIGUOUS");
            }
        }

        static bool CanBeYear(int n) =>  !(0 < n && n < 13);
       
    }
}


Measured memory_bytes: 27376
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N;
    long long D;
    cin >>N>>D;
    vector<double> x,y;
    
    rep(i,N){
        double tmpx,tmpy;
        cin>>tmpx>>tmpy;
        x.push_back(tmpx);
        y.push_back(tmpy);    
    }    
    int ans=0;
    rep(i,N){
        if(x[i]*x[i]+y[i]*y[i]<=D*D){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6852
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	cin>>n;
	ll a[n],sum=0;
	// unordered_map<ll,ll> mp;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		// mp[a[i]]++;
		sum^=a[i];
	}
	for(int i=0;i<n;i++)
		cout<<(a[i]^sum)<<" ";
		
	return 0;
	
}

Measured memory_bytes: 5148
#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))


T_ = []
A_ = []

T_.append(("=", T[0]))
for i in range(1, N):
    if T[i-1] == T[i]:
        T_.append(("<=", T[i]))
    else:
        T_.append(("=", T[i]))

for i in range(N-1):
    if A[i] == A[i+1]:
        A_.append(("<=", A[i]))
    else:
        A_.append(("=", A[i]))
A_.append(("=", A[N-1]))


count = 1
for i in range(N):
    t0, t1 = T_[i]
    a0, a1 = A_[i]
    if t0 == "=" and a0 == "=":
        if t1 == a1:
            continue
        else:
            print(0)
            exit()
    elif t0 == "=":
        if t1 > a1:
            print(0)
            exit()
        else:
            continue
    elif a0 == "=":
        if a1 > t1:
            print(0)
            exit()
        else:
            continue
    else:
        count = (count * min(t1, a1)) % (10**9+7)

print(count)


Measured memory_bytes: 98020
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int nmax = 201000;
int main(){
    long long n, a[nmax];
    long long answer = 0;
    long long step = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=1;i<n;i++){
        step = max((long long)0,  (a[i-1] + step) - a[i] );
        answer += step;
    }
    
    cout << answer;


}

Measured memory_bytes: 5204
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n;
	cin>>n;
	vector<int> a(n);
	for (int i = 0; i < n; i++){
		cin>>a[i];
	}

	int x = *max_element(all(a));
	int second = 0;
	bool flag = false;
	for (int i = 0; i < n; i++){
		if(a[i] == x){
			if(!flag) flag = true;
			else second = x;
		}else{
			second = max(a[i],second);
		}
	}
	for (int i = 0; i < n; i++){
		if(a[i] == x) cout << second<<endl;
		else cout << x << endl;
	}

	return 0;
}

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

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int LINF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1e18;



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



    int binary_search_self(ll key, vector<ll> &vc)
{
    int left = -1; int right = sz(vc);
    int mid;
    while (right-left>1)
    {
        int mid = left + (right-left)/2;
        if(isOK(mid, key, vc))
        {
            right = mid;
        }else
        {
            left = mid;
        }
    }
    return right;
}

ll mn_gen(int index, ll key, vector<ll> &vc)
{
    if (index == -1)
    {
        return vc[0];
    }
    if (index == sz(vc))
    {
        return vc[index - 1];
    }
    return min(abs(key - vc[index]), abs(key - vc[index - 1]));
}

int main()
{
    int a,b,q;
    cin >> a >> b >> q;
    vector<ll> s;
    vector<ll> t;
    vector<ll> x;
    
    x.resize(q);
    s.push_back(-LLINF);
    ll temp;
    rep(i,a)
    {
        
        cin >> temp;
        s.push_back(temp);
    }
    s.push_back(LLINF);
    t.push_back(-LLINF);
    rep(i, b)
    {
        cin >> temp;
        t.push_back(temp);
    }
    t.push_back(LLINF);
    rep(i,q)
    {
        cin >> x[i];
    }

    vector<ll> ans(q);
    rep(i,q)
    {
        
        auto s_index = lower_bound(s.begin(), s.end(),x[i]);
        auto t_index = lower_bound(t.begin(), t.end(),x[i]);
        ll ans_temp = LLINF;
        for(auto u: {*s_index, *(s_index-1)})
        {
            for (auto v : {*t_index, *(t_index - 1)})
            {
                ans_temp =min(ans_temp, min(abs(x[i] - u) + abs(v - u),abs(x[i] - v) + abs(v - u)));
            }
        }
        ans[i] = ans_temp;
    }
    rep(i,q)
    {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 4596
N = int(input())
S = input().strip()
E = [0 for _ in range(N+1)]
W = [0 for _ in range(N+1)]
for i in range(N):
    if S[i] == "E":
        E[i+1] = E[i]+1
        W[i+1] = W[i]
    else:
        W[i+1] = W[i]+1
        E[i+1] = E[i]
cmin = 10**6
for i in range(N):
    cmin = min(cmin,W[i]+E[-1]-E[i+1])
print(cmin)

Measured memory_bytes: 65252
def md(n):
    d=[]
    da=d.append
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            da(i)
            if i!=n//i:da(n//i)
    return len(d)

N = int(input())
if N<105:
    print(0)
else:
    c = 0
    for i in range(105,N+1,2):
        if md(i) == 8:c+=1
    print(c)

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

map<ll, int> prime_factor(ll n) {
    ll a = 2;
    map<ll, int> ans;
    while (n >= a * a) {
        if (n % a == 0) {
            ++ans[a];
            n /= a;
        } else {
            a++;
        }
    }
    ++ans[n];
    return ans;
}

void prime_factor(ll n, map<ll, int>& ans) {
    ll a = 2;
    while (n >= a * a) {
        if (n % a == 0) {
            ++ans[a];
            n /= a;
        } else {
            a++;
        }
    }
    ++ans[n];
}

signed main() {
    int n;
    cin >> n;
    map<ll, int> mp;
    inc(i, 2, n+1) prime_factor(i, mp);
    ll ans = 1;
    for(auto& e : mp){
        ans *= (e.second + 1);
        ans %= MOD;
    }
    cout << ans << nl;
}


Measured memory_bytes: 256
N,K=list(map(int,input().split()))
child=[False] * N
for _ in range(K):
    d=int(input())
    ppp = list(map(int,input().split()))
    for p in ppp:
        child[p-1]=True
ans = 0
for t in child:
    if not t:
        ans += 1
print(ans)


Measured memory_bytes: 67684
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
#define ll long long int
using namespace std;

int dig(int N) {//桁数
	int dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}

int main() {
	int R, G, B, N; cin >> R >> G >> B >> N;

	int cnt = 0;
	int r = N / R;
	int g = N / G;
	for (int i = 0; i <=r ; i++) {
		for (int j = 0; j <= g; j++) {
			int x = N - R * i - G * j;
			if (x >= 0 && x % B == 0) {
				cnt++;
			}
		}
	}

	cout << cnt << endl;
}


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

vector<int>adj[200005];
int vis[200005];
int dis[200005];

int t;
void bfs(int s)
{
    queue<int>q;

    q.push(s);
    vis[s]=1;
    dis[s]=0;

    while(!q.empty())
    {
        int u=q.front();
        q.pop();

        for(int i=0; i<adj[u].size(); i++)
        {
            int v=adj[u][i];
            if(vis[v]==0)
            {
                vis[v]=1;
                dis[v]=u;
                q.push(v);
            }
        }
    }
}

void add(int u, int v)
{
    adj[u].push_back(v);
    adj[v].push_back(u);
}

int main()
{
    vector<int>v;
    int node,a, b, i, s, edge, sum=0;

    cin>>node>>edge;

    for(i=0; i<edge; i++)
    {
        cin>>a>>b;
        add(a,b);
    }
    bfs(1);
    for(i=2; i<=node; i++)
    {
        if(vis[i])
        {
            v.push_back(dis[i]);
        }
    }
    if(v.size()!=(node-1))
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
        for(auto p : v)cout<<p<<endl;
    }
}

Measured memory_bytes: 13408
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;

int main() {
    int n; cin >> n;
    vector<int> da(n);
    rip(i,n,0) cin >> da[i];
    int k = 0;
    rip(i,n,0) k ^= da[i];
    vector<int> ans(n);
    rip(i,n,0) ans[i] = k^da[i];
    vdeb(ans);
}

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

using namespace std;

typedef long long ll;

#define int ll

typedef pair<int, int> ii;

const int N = 1e5+100;

ii a[N];

signed main(){
    ios::sync_with_stdio(0), cin.tie(0);
    int n;cin >> n;
    int ans=0;
    multiset<int> ls, rs;
    for(int i=0 ; i<n ; i++){
    	cin >> a[i].first >> a[i].second;
    	ls.insert(a[i].first);
    	rs.insert(a[i].second);
    }
    for(int i=0 ; i<n ; i++){
        ls.erase(ls.find(a[i].first));
    	rs.erase(rs.find(a[i].second));
    	int cur=0;
    	if(!ls.empty())
    		cur = max(*rs.begin() - *ls.rbegin() + 1, cur);
    	ans = max(ans, a[i].second - a[i].first + 1 + cur);
    	ls.insert(a[i].first);
    	rs.insert(a[i].second);
    }
    sort(a, a+n);
    int l=-2e9, r=2e9;
    for(int i=0 ; i<n-1 ; i++){
    	l = max(l, a[i].first);
    	r = min(r, a[i].second);
    	ls.erase(ls.find(a[i].first));
    	rs.erase(rs.find(a[i].second));
    	int cur = max(r-l + 1, 0LL) + max(*rs.begin() - *ls.rbegin() + 1, 0LL);
    	ans = max(ans, cur);
    }
    cout << ans << "\n";
}

























Measured memory_bytes: 11264
#include <stdio.h>

int main(void)
{
	int A,B,C,D,time;
	
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	scanf("%d",&D);
	
	if((D-A)>0&&(B-C)>0)
	  if(A<C&&B>D)
	    time=D-C;
	  else if(C<A&&B<D)
	    time=B-A;
	  else if(A>C)
	    time=D-A;
	  else
	    time=B-C;
	else
	  time=0;
	  
	printf("%d",time);
	
	return 0;
	
}

Measured memory_bytes: 128
#include <cstring>
#include <iostream>
#include <string>
using namespace std;

int main(){
	int n, m, cnt, ioi[1000005];
	string s;
	while (1){
		for (int i = 0; i < 1000005; i++) ioi[i] = 0;
		cnt = 0;
		cin >> n;
		if (!n) break;
		cin >> m >> s;
		for (int i = s.size() - 3; i >= 0; i--){
			if (s[i] == 'I' && s[i + 1] == 'O' && s[i + 2] == 'I') ioi[i] = ioi[i + 2] + 1;
		}
		for (int i = 0; i < 1000005; i++){
			if (ioi[i] >= n) cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	int X, N;
	int min_abs = 100;
	int answer;
	int tmp;
	cin >> X >> N;

	set<int> p;
	vector<int> rest;

	for (int i = 0; i < N; i++) {
		cin >> tmp;
		p.insert(tmp);
	}

	rest.push_back(0);
	for (int i = 1; i <= 100; i++) {
		if (p.count(i) == false) {
			rest.push_back(i);
		}
	}

	rest.push_back(101);


	for (int i : rest) {
		if (abs(i - X) < min_abs) {
			min_abs = abs(i - X);
			answer = i;
		}
	}

	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 3636
<?php

while ($line = fgets(STDIN)) {
   $array[] = trim($line);
}
$array1 = explode(" ",$array[1]);
$count = 0;
 while(true){
  for($i = 0; $i < count($array1);  $i++){
    if($array1[$i]%2 !=0){
      echo $count;
      exit;
    }
  }
  for($i = 0; $i < count($array1);  $i++){
    $array1[$i] = $array1[$i]/2 ;
  }
    $count = $count+1;
}
?>

Measured memory_bytes: 16200
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const int mod=1e9+7;
const int inf = (1<<30);
string toBin(ll a);
void printMat(int arr[], int n);
void printMat(vector<int> arr, int n);
void printMat(vector<vector<int> > arr, int n, int m);
void printMat(vector<int> arr[], int n);
//void printMat(int arr[][], int n, int m);

void solve(){
	ll i, n;
	cin>>n;
	ll arr[n];
	ll x=0;
	for(i=0;i<n;i++){
		cin>>arr[i];
		x^=arr[i];
	}
	for(i=0;i<n;i++){
		cout<<(x^arr[i])<<" ";
	}cout<<endl;
}

int main()
{
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}
string toBin(ll a){
	string s="";
	while(a>0){
		if(a&1){
			s="1"+s;
		}else{
			s="0"+s;
		}
		a>>=1;
	}
	return s;
}
void printMat(int arr[], int n){
	for(int i=0;i<n;i++){
		cout<<arr[i]<<" ";
	}cout<<endl;
}
void printMat(vector<int> arr, int n){
	for(int i=0;i<n;i++){
		cout<<arr[i]<<" ";
	}cout<<endl;
}
void printMat(vector<int> arr[], int row, int col){
	for(int i=0;i<row;i++){
		for(int j=0;j<col;j++){
			cout<<arr[i][j]<<" ";
		}cout<<endl;
	}cout<<endl;
}
void printMat(vector<vector<int> > arr, int row, int col){
	for(int i=0;i<row;i++){
		for(int j=0;j<col;j++){
			cout<<arr[i][j]<<" ";
		}cout<<endl;
	}cout<<endl;
}

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

int main(){
	int x,y,z;
	cin >> x>>y>>z;

	cout << z << " "<< x <<" "<< y<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h> 


 int main(){
	 int a, b, c;
	    int tmp;
	     scanf("%d %d %d", &a, &b, &c);
	     if (a>b){
		         tmp = a;
		         a = b;
		         b = tmp;
		
	}
	     if (b>c){
		         tmp = b;
		         b = c;
		         c = tmp;
		
	}  
		         if (a>b){
		         tmp = a;
		         a = b;
		         b = tmp;
		
	}
	     printf("%d %d %d\n", a, b, c);
          return 0;
	
}

Measured memory_bytes: 2756
#include<cstdio>

#define	rep(i,n)	for(int i=0;i<n;i++)

using namespace std;

#define	bit(a,i)	(((a)>>(i))&1)

int main(){
	int T;	scanf("%d",&T);
	while(T--){
		int N[9]; rep(i,9) scanf("%x",N+i);
		int K=0;
		rep(i,32){
			int sum=0;
			rep(j,8)	sum+=N[j]^K;
			if(bit(sum,i)!=bit(N[8]^K,i))	K|=1<<i;
		}
		printf("%x\n",K);
	}
	return 0;
}

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

#define STRMAX 127

void xtonumstr( char str[STRMAX], int keta, int i );
int whichmax( int val1, int val2, char num1[STRMAX], char num2[STRMAX] );
int makeans( char tpans[STRMAX], char num1[STRMAX], char num2[STRMAX], int keta );
int issame( char tpans[STRMAX], char ans[STRMAX] );
void initary( char str[STRMAX] );

void xtonumstr( char str[STRMAX], int keta, int i )
{
	for ( int j = 0 ; j < keta ; j++ ) {
		if ( str[j] == 'X' ) {
			str[j] = i + '0';
		}
	}
}

int whichmax( int val1, int val2, char num1[STRMAX], char num2[STRMAX] )
{
	int diff;
	if ( val1 == val2 ) {
		return val1;
	} else if ( val1 > val2 ) {
		diff = val1 - val2;
		for ( int i = val2-1 ; i >= 0 ; i-- ) {
			num2[i+diff] = num2[i];
		}
		for ( int i = 0 ; i < diff ; i++ ) {
			num2[i] = '0';
		}
		return val1;
	} else {
		diff = val2 - val1;
		for ( int i = val1-1 ; i >= 0 ; i-- ) {
			num1[i+diff] = num1[i];
		}
		for ( int i = 0 ; i < diff ; i++ ) {
			num1[i] = '0';
		}
		return val2;
	}
}

int makeans( char tpans[STRMAX], char num1[STRMAX], char num2[STRMAX], int keta )
{
	int carry = 0, i;
	int tpas = 0;
	for ( i = keta-1 ; i > -1 ; i-- ) {
		tpas = carry + num1[i]-'0' + num2[i]-'0';
		if ( tpas >= 10 ) {
			tpans[i] = tpas%10 + '0';
			carry = 1;
		} else {
			tpans[i] = tpas + '0';
			carry = 0;
		}
	}

	if ( carry == 1 ) {
		for ( i = keta ; i > 0 ; i-- ) {
			tpans[i] = tpans[i-1];
		}
		tpans[0] = '1';
	}
	return carry;
}

int issame( char tpans[STRMAX], char ans[STRMAX] )
{
	int tpanslen = strlen( tpans );
	int anslen = strlen( ans );
	if ( tpanslen != anslen ) { return 0; }

	int i = anslen;
	while ( i >= 0 ) { 
		if ( tpans[i] != ans[i] ) {
			return 0;
		}
		i--;
	}
	return 1;
}

void initary( char str[STRMAX] )
{
	for ( int i = 0 ; i < STRMAX ; i++ ) {
		str[i] = '\0';
	}
}

int main()
{
	char num1[STRMAX] = {}, num2[STRMAX] = {}, ans[STRMAX] = {};
	char tmp1[STRMAX] = {}, tmp2[STRMAX] = {}, tpans[STRMAX] = {}, tmp[STRMAX] = {};
	int keta1 = 0, keta2 = 0, ketaans = 0;
	int i = 0;
	int flag = 0, max = 0, carry = 0;

	while ( fscanf( stdin, "%[0-9X]+%[0-9X]=%[0-9X]\n", num1, num2, ans ) != EOF ) {
		flag = -1;

		keta1 = strlen( num1 );
		keta2 = strlen( num2 );
		ketaans = strlen( ans );
		initary( tmp ); initary( tmp1 ); initary( tmp2 ); initary( tpans );

		for ( i = 0 ; i < 10 ; i++ ) {
			strcpy( tmp1, num1 ); xtonumstr( tmp1, keta1, i );
			strcpy( tmp2, num2 ); xtonumstr( tmp2, keta2, i );
			strcpy( tpans, ans ); xtonumstr( tpans, ketaans, i );

			carry = 0;
			max = whichmax( keta1, keta2, tmp1, tmp2 );
			carry = makeans( tmp, tmp1, tmp2, max );
			// printf( "%lu %lu %lu %lu\n", strlen( tmp1 ), strlen( tmp2 ), strlen( tmp ), strlen( tpans ) );
			// printf( "%s+%s=%s | ans = %s\n", tmp1, tmp2, tmp, tpans );	
			if ( issame( tmp, tpans ) == 1 ) {
				flag = i;
				break;
			}
		}

		if ( flag == -1 ) {
			printf( "NA\n" );
		} else {
			printf( "%d\n", flag );
		}
	}
	return 0;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y;
  cin>>x>>y;
  
vector<int>vec1={1,3,5,7,8,10,12};
vector<int>vec2={4,6,9,11};
  
  int sum1=0;
  int sum2=0;
  
  
  
  for(int i=0;i<vec1.size() ;i++ ){
    if(vec1.at(i)==x||vec1.at(i)==y){
      sum1++;
    }
    
  }
    for(int j=0;j<vec2.size(); j++){
    if(vec2.at(j)==x||vec2.at(j)==y){
      sum2++;
    }
    }
  
      
  
      
   
  if(sum1==2||sum2==2){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

    
      
    

    

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

typedef struct {
	double x, y, z, r;
} Coord;

// typedef struct {
// 	int parent, rank;
// } Node;

typedef struct {
	int from, to;
	double weight;
} Edge;

Coord coord[ 100 ];
// Node node[ 100 ];
int node[ 100 ];
Edge edge[ 4950 ];

int compare( const void *a, const void *b ) {
	double at = (*(Edge *)a).weight, bt = (*(Edge *)b).weight;

	if ( at < bt )
		return -1;
	if ( at > bt )
		return 1;
	return 0;
}

int find( int x ) {
	if ( node[ x ] == x )
		return x;
	else
		return node[ x ] = find( node[ x ] );
}

double kruskal( int v, int e ) {
	int i;
	double sum;

	qsort( edge, e, sizeof(Edge), &compare );

	for ( i = 0; i < v; i++ )
		node[ i ] = i;

	sum = 0.0;
	for ( i = 0; i < e; i++ ) {
		int set1 = find( edge[ i ].from ), set2 = find( edge[ i ].to );
		if ( set1 != set2 ) {
			node[ set2 ] = set1;
			sum += edge[ i ].weight;
		}
	}

	return sum;
}

int main( void ) {
	int i, j;
	int n, cnt;

	while ( scanf( "%d", &n ), n ) {
		for ( i = 0; i < n; i++ )
			scanf( "%lf %lf %lf %lf", &coord[ i ].x, &coord[ i ].y, &coord[ i ].z, &coord[ i ].r );

		cnt = 0;
		for ( i = 0; i < n; i++ )
			for ( j = i + 1; j < n; j++ ) {
				edge[ cnt ].from = i;
				edge[ cnt ].to = j;
				edge[ cnt ].weight = fmax( sqrt( ( coord[ i ].x - coord[ j ].x ) * ( coord[ i ].x - coord[ j ].x ) + ( coord[ i ].y - coord[ j ].y ) * ( coord[ i ].y - coord[ j ].y ) + ( coord[ i ].z - coord[ j ].z ) * ( coord[ i ].z - coord[ j ].z ) ) - coord[ i ].r - coord[ j ].r, 0.0 );
				cnt++;
			}

		printf( "%.3f\n", kruskal( n, n * ( n - 1 ) / 2 ) );
	}

	return 0;
}

Measured memory_bytes: 872
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
const int MAXN = 1000001;
vector<int> adj[MAXN];
int power(int x, int y, int p = mod){ 
    int res = 1; 
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0) {  
        if (y & 1) res = (res*x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
} 
int modFact(int n, int p = mod) 
{ 
    if (n >= p) 
        return 0; 
  
    int result = 1; 
    for (int i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result; 
} 
int32_t main(){
    SPEED;
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        int u, v;
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    for(int i = 1; i <= n; ++i){
        cout << adj[i].size() << endl;
    }
}
// check indices of loop
// check for overflow


Measured memory_bytes: 27068
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;
 
int main(){
    string N;
    cin>>N;
    if(N[0]==N[1]&&N[1]==N[2])cout<<"Yes";
    else if(N[1]==N[2]&&N[2]==N[3])cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int r = sc.nextInt();

		if (n <= 10) {
			System.out.println((100 * (10 - n)) + r);
		} else {
			System.out.println(r);
		}

		sc.close();
	}
}


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

ll mod=1e9+7;

int main() {
  string l;
  cin >> l;
  vector<vector<ll>> dp(l.size(),vector<ll>(2));
  dp[0][0]=1;
  dp[0][1]=2;
  for(ll i=1;i<l.size();i++) {
    if(l[i]=='1') {
      dp[i][1]=dp[i-1][1]*2%mod;
      dp[i][0]=dp[i-1][1];
    }
    else {
      dp[i][1]=dp[i-1][1];
    }
    dp[i][0]=(dp[i][0]+dp[i-1][0]*3)%mod;
  }
  ll ans=(dp[l.size()-1][0]+dp[l.size()-1][1])%mod;
  cout << ans << endl;
}

Measured memory_bytes: 5760