akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;




string a,b;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>a>>b;
    b.pop_back();
    if (a==b) out("Yes");
    out("No");
  

    return 0;
}


Measured memory_bytes: 3576
#include<iostream>
#include<deque>
#include<cstdint>

int main() {
  int64_t K; std::cin >> K;
  std::deque<int64_t> q;
  for(int i = 1; i <= 9; ++i) q.push_back(i);
  while(q.size() < K) {
    int64_t v = q.front(); q.pop_front(); --K;
    int64_t v10 = v*10, vm = v%10;
    if(vm != 0) q.push_back(v10+vm-1);
    q.push_back(v10+vm);
    if(vm != 9) q.push_back(v10+vm+1);
  }
  std::cout << q[K-1] << std::endl;
  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
struct Matrix{ 
	int a[2][2] = {{0,0},{0,0}};
	Matrix operator *(const Matrix& other){
		Matrix product;
		for(int i=0;i<2;i++){
			for(int j=0;j<2;j++){
				for(int k=0;k<2;k++){
						product.a[i][k] =product.a[i][k] + (ll)a[i][j]*other.a[j][k];
				}
			}
		}
		return product;
	}
};
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
const int ma = 1e6 + 7;
vector<bool> prime(ma,true);
void findprime()
{
	for(ll i=2;i<ma;i++)
	{
		if(prime[i])
		{
			for(ll j=i*i;j<ma;j+=i)
			{
				prime[j] = false;
			}
		}
	}
	prime[1] = false; 
}
int findCount(int n)
{
	int ans = 1;
	int cnt = 0;
	while(n%2==0)
	{
		n = n/2;
		cnt++;
	}
	ans = ans * (cnt + 1);
	for(int i=3;i<=sqrt(n);i+=2)
	{
		if(n%i == 0)
		{
			cnt = 0;
			while(n%i == 0)
			{
				cnt++;
				n = n/i;
			}
			ans = ans * (cnt + 1);
		}
		if(prime[n])
		break;
	}
	if(n != 1)
	{
		ans = ans * 2;
	}
	return ans;
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 findprime();
	 int n;
	 cin>>n;
	 
	 int ans = 0;
	 for(int c=1;c<=n-1;c++)
	 {
		 int ab = n - c;
		 ans += findCount(ab);
	 }
	 cout<<ans<<'\n';
	 return 0;
}


Measured memory_bytes: 3800
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
#define MAX_N 100000000
using namespace std;
bool debug=false;

int main(){
  int n;
  cin>>n;
  cout<<n<<":";
  while(n%2==0){
    cout<<" "<<2;
    n/=2;
  }
  for(int i=3;i<=sqrt(n);){
    if(n%i==0){
      cout<<" "<<i;
      n/=i;
    }else{
      i+=2;
    }
    if(n==1)break;
  }
  if(n!=1)cout<<" "<<n<<endl;
  else cout<<endl;
  return 0;
}

Measured memory_bytes: 3104
#include <iostream>
using namespace std;
bool binarySearch(int A[],int ans, int size);
int main() {
  int n, k;
  cin >> n;
  int* p = (int*)malloc(sizeof(int)*n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }

  cin >> k;
  int* t = (int*)malloc(sizeof(int)*k);
  for (int i = 0; i < k; i++) {
    cin >> t[i];
  }
  int counter = 0;
  for (int  i = 0; i < k; i++) {
    if(binarySearch(p, t[i], n)) counter++;
  }
  cout << counter << endl;
  free(p);
  free(t);
  return 0;
}
bool binarySearch(int A[],int ans, int size) {
  int left = 0;
  int right = size;
  int middle = (left+right)/2;
  while(left < right) {
    middle = (left+right)/2;
    if(A[middle] == ans) return true;
    else if(A[middle] < ans) {
      left = middle+1;
    } else if(A[middle] > ans) {
      right = middle;
    }
  }
  return false;
}


Measured memory_bytes: 3332
import fractions
a,b,c,d=map(int,input().split())

f1=fractions.gcd(c,d)
f2=c*d//f1

a=a-1
aa=a-a//c-a//d+a//f2
bb=b-b//c-b//d+b//f2

print(bb-aa)

Measured memory_bytes: 5048
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int ans = 0;
        String w = scan.nextLine();
        w = w.toLowerCase();
        while(true){
            String s = scan.next();
            if(s.equals("END_OF_TEXT"))break;
            s = s.toLowerCase();
            if(s.equals(w))ans++;
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 26344
#include<iostream>
using namespace std;

int main(){
    int a, b;
    char op;

    while(1){
        cin >> a >> op >> b;
        if(op=='?') break;
        if(op == '+') cout << a + b << endl;
        else if(op == '-') cout << a - b << endl;
        else if(op == '*') cout << a * b << endl;
        else if(op == '/') cout << a / b << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
  数値型から文字列に変換　to_string(number);これは簡単
  文字列から数値型に変換　stoi(number)  文字列からllに変換　stoll(number)*/
 
 
 int main(){
	 ll n , a, b ;
	 cin >> n >> a >> b;
	 vector<ll> X(n-1);
	 ll k ;
	 cin >> k;
	 ll K = 0; //i+2番目の町の座標を受け取る
	 rep(i,n-1){
		 cin >> K ;
		 X[i] = (K - k) * a;
		 k = K;
	 }
	 ll ans = 0;
	 rep(i,n-1){
		 if(X[i] <= b){
			 ans += X[i];
		 }
		 else ans += b;
	 }
	 cout << ans <<endl;
 }


Measured memory_bytes: 1024
#include<stdio.h>
 
int n,A[50];
 
int solve (int i, int m){
 if(m==0)return 1;
 if(i>=n)return 0;
 int res =solve(i+1,m)||solve(i+1,m-A[i]);
return res;
}
 
int main(){
 int q,M,i;
 scanf("%d",&n);
 for(i=0;i<n;i++)scanf("%d",&A[i]);
 scanf("%d", &q);
 for(i=0;i<q;i++){
 scanf("%d",&M);
 if(solve(0,M))printf("yes\n");
 else printf("no\n");
 }
  
return 0;
 }

Measured memory_bytes: 2676
#include <stdio.h>
#include <stdlib.h>

int main(){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(abs(a-c) <= d) printf("Yes\n");
  else if(abs(a-b)<=d && abs(b-c) <= d) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 128
k,n = map(int,input().split())
a = list(map(int,input().split()))

a += [a[0]+k]#aに要素を追加する

max_len = 0

for i in range(1,n+1):
    max_len = max(max_len,a[i]-a[i-1])

print(k-max_len)

Measured memory_bytes: 26420
import java.util.*;
import java.lang.*;

class Point{
    int x;
    int y;
    Point(int a,int b){
        this.x = a;
        this.y = b;
    }
}


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

            String[][] S = new String[H][W];
            int black = 0;
            for(int i = 0 ; i < H ; i++){
                String tmp = sc.next();
                for(int j = 0 ; j < W ; j++){
                    S[i][j] = tmp.substring(j,j+1);
                    if(S[i][j].equals("#")){
                        black++;
                    }
                }
            }
            sc.close();
            int count = 0;
            int[] dx = {1,0,-1,0};
            int[] dy = {0,1,0,-1};
            
            boolean flag = true;
            outside:
            for(int i = 0 ; i < H ; i++){
                for(int j = 0 ; j < W ; j++){
                    for(int k = 0 ; k < 4 ; k++){
                        int x = i+dx[k];
                        int y = j+dy[k];
                        
                        if(x >= 0 && x < H && y >= 0 && y < W){
                            if(S[i][j].equals("#") && S[x][y].equals(".")){
                                count++;
                            }
                        }

                    }
                  //  System.out.println(i + " " + j + " " + count);
                    if(i > 0 && j > 0 && count == 4){
                        flag = false;
                        break outside;
                    }
                    else if(i == 0 && j == 0 && count == 2|| i == 0 && j == W-1 && count == 2|| i == H-1 && j == 0 && count == 2|| i == H-1 && j == W-1&& count == 2){
                        flag = false;
                        break outside;
                    }
                    else if(i == 0 && count == 3 || j == 0 && count == 3){
                        flag = false;
                        break outside;    
                    }
                    else{
                        count=0;
                        if(i == H-1 && j == W-1){
                            break outside;
                        }
                    }

                }
            }

            if(flag){
                System.out.println("Yes");
            }
            else{
                System.out.println("No");
            }
        }
   }



Measured memory_bytes: 21716
#include <iostream>
#include <vector>
using namespace std;

class DisjointSet {
public:
    vector<int> rank, p;

    DisjointSet() {};
    DisjointSet(int s) {
        rank.resize(s, 0);
        p.resize(s, 0);
        for (int i = 0; i < s; i++) makeSet(i);
    }

    void makeSet(int x) {
        p[x] = x;
        rank[x] = 0;
    }

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

    void unite(int x, int y) {
        link(findSet(x), findSet(y));
    }

    void link(int x, int y) {
        if (rank[x] > rank[y]) {
            p[y] = x;
        } else {
            p[x] = y;
            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
    }

    int findSet(int x) {
        while (x != p[x]) {
            x = p[x];
        }
        return x;
    }
};

int main(void) {
    int n, q; cin >> n >> q;
    DisjointSet ds = DisjointSet(n);

    for (int i = 0; i < q; i++) {
        int com, x, y; cin >> com >> x >> y;
        if (com == 0) {
            ds.unite(x, y);
        } else {
            if (ds.same(x, y)) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1280
N=int(input())
a=list(map(int,input().split()))
b=[0]*N
sum=0
for i in range(N):
  b[a[i]-1]+=1

for i in range(N):
  sum+=b[i]*(b[i]-1)//2
for i in range(N):
  print(sum-b[a[i]-1]+1)

Measured memory_bytes: 26140
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N, A;
    cin >> N >> A;
    if (N % 500 <= A) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
tmp_sum = 0

for i in range(1, N+1):
  tmp_sum += i
  
if N % 2 == 1:
  S = sum(range(1, N))
else:
  S = sum(range(1, N)) - 1

count = 0
ans = []

for i in range(1, N):
  tmp_sum = sum(range(1, N+1)) - i
  exclude = tmp_sum - S
  for j in range(i+1, N+1):
    if j != int(exclude):
      count += 1
      ans.append((i, j))

print(count)
for item in ans:
  print(item[0], item[1])

Measured memory_bytes: 3956
#include <stdio.h>
#include <string.h>

int main()
{
    char string[11];
    scanf("%s",string);
    char modified[11];
    modified[0]='2';
    modified[1]='0';
    modified[2]='1';
    modified[3]='8';
    int i;
    for(i=4;i<strlen(string);i++)
    {
        modified[i]=string[i];
    }
    modified[i]='\0';
    printf("%s\n",modified);
    return 0;
}

Measured memory_bytes: 128
program sample
    implicit none
    character(19)::s
    integer(8) :: i,j,m,n,p,x
    integer(8),allocatable :: y(:),t(:)
  
    read(*,*) n
    allocate(t(n))
    read(*,*)t

    read(*,*)m
    do i=1,m
        read(*,*)p,x

        write(*,*)sum(t)-t(p)+x
    end do
    
    stop
end program sample
  



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

int main () {
	int N, M;
	int a[101] = { 0 }, b[100] = { 0 };
	int min=1,max=-1;
	int max_i;
	int x, y;
	cin >>N>> M;
	for(size_t i = 0; i < M; i++) {
		cin >> x >> y;
		b[i] = 1000 * x + y;
	}
	sort ( b, b + M );
	int i = 0;
	int count = 0;
	if(b[0] / 1000 != 1) {
		cout << "Impossible" << endl;
		return 0;
	}
	while(max != N) {
		while(b[i] / 1000 <= min&&i<M)i++;
		for(size_t j = 0; j < i; j++) {
			if(b[j] % 1000 > max) {
				max = b[j] % 1000;
				max_i = j;
				//cout << max << endl;
			}
		}
		min = max+1;
		if(max_i > M) {
			cout << "Impossible" << endl;
			return 0;
		}
		i = max_i;
		count++;
		if(count > M) {
			cout << "Impossible" << endl;
			return 0;
		}
		//cout << "!"<<max_i << endl;
	}
	cout << count << endl;
	return 0;
	/*for(size_t j = 0; j < M; j++) {
		cout << b[j] << endl;
	}
	getchar ();
	getchar ();
	*/
}

Measured memory_bytes: 1180
while True:
     k = int(input())
     if 1 <= int(k) <= 100:
         break;
     print ('Error Invalid Input for K')
#Check constraint k

while True:
     s = input()
     if 1 <= len(s) <= 100:
         break;
     print ('Error Invalid Input for s')
#Check constraint s

if len(s) > k:
    print(s[:k] + "...")  #append
else:
    print(s)

Measured memory_bytes: 9144
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int l = find(s.begin(), s.end(), 'A') - s.begin();
    int r = s.rend() - find(s.rbegin(), s.rend(), 'Z');
    cout << r - l << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int n, q;
string s;
vector<pair<char, char>> v;

bool check(int pos)
{
    rep(i, q)
    {
        char c1 = v[i].first, c2 = v[i].second;
        if (c1 != s[pos])
            continue;
        if (c2 == 'R')
            pos++;
        else
            pos--;
        if (pos == -1 || pos == n)
            return true;
    }
    return false;
}

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

    cin >> n >> q >> s;
    v.resize(q);
    rep(i, q) cin >> v[i].first >> v[i].second;
    int l = 0, r = n;
    while (r - l > 1)
    {
        int mid = (r + l) / 2;
        if (check(mid))
            l = mid;
        else
            r = mid;
    }
    int pos_l = l;
    l = 0, r = n;
    while (r - l > 1)
    {
        int mid = (r + l) / 2;
        if (check(mid))
            r = mid;
        else
            l = mid;
    }
    int pos_r = l;
    cout << max(0LL, pos_r - pos_l) << endl;
}

Measured memory_bytes: 976
H, W = map(int, input().split())
S = []
for i in range(H):
  S.append(input().split())
  
strl = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

for i in range(H):
  for j in range(W):
    if S[i][j] == "snuke":
      print(strl[j] + str(i+1))
      exit(0)

Measured memory_bytes: 3060
#include<stdio.h>
#include<ctype.h>
 
int main(){
  char b[100000];
  int i=0,c;
   
  while(1){
    c=getchar();
 
    if(c=='\n')
      break;
 
    if(islower(c))
      b[i++]=toupper(c);
    else if(isupper(c))
      b[i++]=tolower(c);
    else
      b[i++]=c;
  }
  b[i]='\0';
  printf("%s\n",b);
  return 0;
}

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

using namespace std;
int n,m,a,b,ans,x,y;
int fa[100100]; 
bool bo[100100];
int fi(int x)
{
	if(fa[x]==x)
		return x;
	return fa[x]=fi(fa[x]);
}
int main()
{
   	scanf("%d%d",&n,&m);
   	for(int i=1;i<=n;i++)
   		fa[i]=i;
	ans=n-1;
   	for(int i=1;i<=m;i++)
   	{
   		scanf("%d%d",&a,&b);
   		x=fi(a);
   		y=fi(b);
   		if(x!=y)
   		{
   			ans--;
			fa[x]=fa[y];
		}
	}
	printf("%d",ans);
    return 0;
}

Measured memory_bytes: 4244
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final long X = sc.nextLong();
		
		long pow = 0;
		for(int time = 0; pow < X; time++){
			pow += time;
			
			if(X <= pow){
				System.out.println(time);
				return;
			}
		}
		
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
		
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21076
from bisect import bisect_left

n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True)
dic={}
for val in arr:
  if val not in dic:
    dic[val]=1
  else:
    dic[val]+=1
arr2=[]
for i in range(40):
  arr2.append(2**i)
ans=0
for val in arr:
  pos=bisect_left(arr2,val)
  if val==arr2[pos]:
    persuit=arr2[pos+1]
  else:
    persuit=arr2[pos]
  if persuit-val==val:
    if val in dic:
      if dic[val]>=2:
        ans+=1
        dic[val]-=2
        if dic[val]==0:
          del dic[val]
      else:
        continue
    else:
      continue
  else:
    if val in dic and persuit-val in dic:
      ans+=1
      dic[val]-=1
      if dic[val]==0:
        del dic[val]
      dic[persuit-val]-=1
      if dic[persuit-val]==0:
        del dic[persuit-val]
    else:
      continue
print(ans)

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

using namespace std;

int main()
{
string s ,t;
cin>>s>>t;
int cnt =0;
for(int i=0; i<s.length(); i++) {
    if(s[i] == t[i]) continue;
    else {
        swap(s[i], t[i]);
        cnt++;
    }
}
cout<<cnt;
return 0;
}


Measured memory_bytes: 3912
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int first, second;
		first = sc.nextInt();
		second = sc.nextInt();
		
		if(first > 0 && first < 10 && second > 0 && second < 10)
			System.out.println(first * second);
		else
			System.out.println("-1");
	}
}

Measured memory_bytes: 23636
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;

int n,m;
char s[3005],t[3005],sol[3005];
int lcs[3005][3005];

int main(){

    cin>>(s+1)>>(t+1);

    n=strlen(s+1);
    m=strlen(t+1);

    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            lcs[i][j]=max(lcs[i-1][j],max(lcs[i][j-1],lcs[i-1][j-1]+(s[i]==t[j])));

    int i=n;
    int j=m;

    while(lcs[i][j]){

        if(lcs[i][j]==lcs[i-1][j-1]+(s[i]==t[j])){

            sol[lcs[i][j]]=s[i];
            --i; --j;
            continue;

        }

        if(lcs[i][j]==lcs[i-1][j]){

            --i;
            continue;

        }

        if(lcs[i][j]==lcs[i][j-1]){

            --j;
            continue;

        }

    }

    cout<<(sol+1);

}


Measured memory_bytes: 35456
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for(int i = 1; ; i++) {
            int x = sc.nextInt();
            if(x == 0) break;
            System.out.println("Case " + i + ": " + x);
        }
    }
}


Measured memory_bytes: 40416
import java.util.*;

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

        int n = sc.nextInt();
        int d = sc.nextInt();
        if (n % (d * 2 + 1) == 0)
            System.out.println(n / (d * 2 + 1));
        else
            System.out.println(n / (d * 2 + 1) + 1);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

ll f(ll a, ll b) {
    return max(to_string(a).size(), to_string(b).size());
}

int main()
{
    ll n; cin >> n;
    ll min_num = inf;
    for (size_t i = 1; i < sqrt(n) + 1; i++)
    {
        if (n % i != 0) continue;
        min_num = min(min_num, f(i, n / i));
    }
    cout << min_num << endl;
    
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,u,v,m,in,ru,cu,rn,cn,countu=0,countn=0;
    bool uw=false,nw=false;
    cin>>n>>u>>v>>m;
    vector<int> rowu(n,0),colu(n,0),crsu(2,0),rown(n,0),coln(n,0),crsn(2,0);
    vector<pair<int,int>> dicu(1000000,make_pair(-1,-1)),dicn(1000000,make_pair(-1,-1));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>in;
            dicu[in-1]=make_pair(i,j);
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>in;
            dicn[in-1]=make_pair(i,j);
        }
    }
    for(int i=0;i<m;i++){
        cin>>in;
        ru=dicu[in-1].first;
        cu=dicu[in-1].second;
        if(!(ru==-1||cu==-1)){
            rowu[ru]++;
            if(rowu[ru]==n)countu++;
            colu[cu]++;
            if(colu[cu]==n&&n!=1)countu++;
            if(ru==cu){
                crsu[0]++;
                if(crsu[0]==n&&n!=1)countu++;
            }
            if(n-1==ru+cu){
                crsu[1]++;
                if(crsu[1]==n&&n!=1)countu++;
            }
        }
        rn=dicn[in-1].first;
        cn=dicn[in-1].second;
        if(!(rn==-1||cn==-1)){
            rown[rn]++;
            if(rown[rn]==n)countn++;
            coln[cn]++;
            if(coln[cn]==n&&n!=1)countn++;
            if(rn==cn){
                crsn[0]++;
                if(crsn[0]==n&&n!=1)countn++;
            }
            if(n-1==rn+cn){
                crsn[1]++;
                if(crsn[1]==n&&n!=1)countn++;
            }
        }
        if(countu>=u)uw=true;
        if(countn>=v)nw=true;
        if(uw&&nw){
            cout<<"DRAW"<<endl;
            return 0;
        }
        if(uw){
            cout<<"USAGI"<<endl;
            return 0;
        }
        if(nw){
            cout<<"NEKO"<<endl;
            return 0;
        }
    }
    cout<<"DRAW"<<endl;
    return 0;
}



Measured memory_bytes: 18424
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int N = S.Length;
		List<char> L = new List<char>();
		for(int i=0;i<N;i++){
			if(S[i] == 'A'){
				L.Add('A');
				continue;
			}
			if(i + 1 < N && S[i] == 'B' && S[i + 1] == 'C'){
				L.Add('D');
				i++;
				continue;
			}
			L.Add('X');
		}
//Console.WriteLine(String.Join(" ",L));		
		long ans = 0;
		long cnt = 0;
		for(int i=L.Count - 1;i>=0;i--){
			if(L[i] == 'X'){
				cnt = 0;
				continue;
			}
			if(L[i] == 'D'){
				cnt++;
				continue;
			}
			if(L[i] == 'A'){
				ans += cnt;
			}
		}
		Console.WriteLine(ans);
		
		
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

using namespace std;

double size[4] = {0.25, 0.5, 1, 2};

int main(){
	vector<int> v(4);
	int n;
	
	cin >> v[0] >> v[1] >> v[2] >> v[3] >> n;
	
	long long sum = 0;
	long long cost = 0;
	for(int i = 0;i < 4;i++){
		int mp = 0;
		for(int j = 1;j < v.size();j++){
			if(v[mp]/size[mp] > v[j]/size[j]){
				mp = j;
			}
		}
		
		long long need = n-sum;
		if(need > 0){
			long long buy = (long long)(need/size[mp]);
			sum += buy*size[mp];
			cost += buy*v[mp];
		}
		
		v[mp] = 1000000000;
	}
	
	cout << cost << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>

using namespace std;

int d[8][2] = {
	{-1, -1},
	{0, -1},
	{1, -1},
	{-1, 0},
	{1, 0},
	{-1, 1},
	{0, 1},
	{1, 1}
};

void func(int **a, int s, int t, int i, int j)
{
	if(a[i][j] == 0){
		return ;
	}
	a[i][j] = 0;
	
	for(int k = 0; k < 8; k++){
		if((i+d[k][0] >= 0 && i+d[k][0] < t) && (j+d[k][1] >= 0 && j+d[k][1] < s)){
			func(a, s, t, i+d[k][0], j+d[k][1]);
		}
	}
	
	return ;
}

int main(int argc, char **argv)
{
	int s, t, **a, c, t2, s2;
	
	while(1){
		cin >> s >> t;
		if(s == 0 && t == 0){
			break;
		} else if(s == 1 || t == 1){
			t2 = t+1;
			s2 = s+1;
		} else {
			t2 = t;
			s2 = s;
		}
		a = (int **)calloc(t2, sizeof(int));
		for(int i = 0; i < t; i++){
			a[i] = (int *)calloc(s2, sizeof(int));
			for(int j = 0; j < s; j++){
				cin >> c;
				a[i][j] = c;
			}
		}
		c = 0;
		
		for(int i = 0; i < t; i++){
			for(int j = 0; j < s; j++){
				if(a[i][j] == 1){
					c++;
					func(a, s, t, i, j);
				}
			}
		}
		cout << c << endl;
		
		for(int i = 0; i < t2; i++){
			free(a[i]);
		}
		free(a);
	}
	
	return 0;
}

Measured memory_bytes: 0
/*
 * 2020-02-16 atcoder C
 */
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>

#define L_STR 10

typedef struct dict Dict;
struct dict {
  char *str;
  int num;
};

static int
comp_dict_int(const void *p1, const void *p2)
{
  Dict **d1 = (Dict **) p1;
  Dict **d2 = (Dict **) p2;

  return ((*d1)->num < (*d2)->num);
}

static int
comp_str(const void *p1, const void *p2)
{
  char **s1 = (char **) p1;
  char **s2 = (char **) p2;
  return (strcmp(*s1, *s2));
}

int
main(int argc, char *argv[])
{
  int n, i, j;
  char str[L_STR + 1];
  char **a;
  Dict **d;
  int num_dict = 0;
  
  
  scanf("%d", &n);
  a = (char **) malloc(n * sizeof (char **));
  d = (Dict **) malloc(n * sizeof (Dict));

  for (i = 0; i < n; i++) {
    scanf("%s", str);
    a[i] = strdup(str);
  }

  qsort(a, n, sizeof(char *), comp_str);

  d[0] = (Dict *) malloc(sizeof (Dict));
  d[0]->str = a[0];
  d[0]->num = 1;
  num_dict = 1;
  j = 0;

  for (i = 1; i < n; i++) {
    if (strcmp(a[i], a[i-1]) == 0) {
      d[j]->num++;
    } else {
      d[++j] = (Dict *) malloc(sizeof (Dict));
      d[j]->str = a[i];
      d[j]->num = 1;
      num_dict++;
    }
  }

  qsort(d, num_dict, sizeof(Dict *), comp_dict_int);

  printf("%s\n", d[0]->str);
  for (i = 1; i < num_dict; i++) {
    if (d[i]->num != d[i-1]->num)
      return (0);
    printf("%s\n", d[i]->str);
  }
  return (0);
}
  
  
  


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

int main(){
	string s;
	cin >> s;
	int l = s.size();
	int r = 0;
	rep(i,s.size()){
		if(s[i] == 'A') l = min(l,i);
		if(s[i] == 'Z') r = max(r, i);
	}
	cout << r - l + 1<< endl;
    return 0;
}



Measured memory_bytes: 640
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
input = sys.stdin.readline

setrecursionlimit(1000000)

dp = defaultdict(lambda x:-1)

def main():
	n = int(input())
	for i in range(1,10):
		if(n%i == 0 and n//i < 10):
			print('Yes')
			return
	print('No')

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


Measured memory_bytes: 65516
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int n;
	cin >> n;
	bool card[4][13] = {};
	char suit[4] = {'S','H','C','D'};
	for(int i=0; i<n; i++){
		char suit;
		int num;
		cin >> suit >> num;
		if(suit == 'S') card[0][num-1] = 1;
		else if(suit == 'H') card[1][num-1] = 1;
		else if(suit == 'C') card[2][num-1] = 1;
		else if(suit == 'D') card[3][num-1] = 1;
	}
	for(int i=0; i<4; i++){
		for(int j=0; j<13; j++){
			if(!card[i][j]){
				cout << suit[i] << " " << j+1 <<endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3108
n = int(input())
edges = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)


from collections import deque
seen = [False for _ in range(n)]
child = [[] for _ in range(n)]
par = [0 for _ in range(n)]
order = []
que = deque()
que.append(0)
seen[0] = True

while que:
    v = que.popleft()
    order.append(v)
    for to in edges[v]:
        if not seen[to]:
            seen[to] = True
            par[to] = v
            que.append(to)
            child[v].append(to)

d = [-1 for _ in range(n)]
c = [0 for _ in range(n)]
for i in order:
    d[i] = d[par[i]] + 1
for i in order[::-1]:
    if len(child[i]) == 0:
        continue
    for ch in child[i]:
        c[i] += c[ch] + 1



point = n - 1
move_s = (d[n-1] - 1) // 2
move_f = d[n-1] - 1 - move_s
for i in range((d[n-1] - 1) // 2):
    point = par[point]

cnt_s = c[point]
cnt_f = n - (c[point] + 1) - 1


print('Fennec' if cnt_f > cnt_s else 'Snuke')

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

const int maxn = 200010 * 2;

int a[maxn], b[maxn];
int cnt[maxn];
int covertmp[maxn];
int x[maxn], y[maxn];

int main()
{
	//freopen("C.in","r",stdin);
	int n,m;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]), cnt[a[i]]++;
	int* cover = &(covertmp[maxn/2]); 
	for (int i=1;i<=n;i++)
	{
		if (!a[i]) continue;
		for (int j=i-cnt[i];j<i;j++) cover[j]++;
	}
	int l = 0;
	for (int i=0;i<n;i++)
		if (!cover[i]) l++;
	
	for (int i=1;i<=m;i++)
	{
		scanf("%d%d",&x[i],&y[i]);
		cover[a[x[i]] - cnt[a[x[i]]]]--; if (cover[a[x[i]] - cnt[a[x[i]]]] == 0 && a[x[i]] - cnt[a[x[i]]] >= 0) l++;
		cnt[a[x[i]]]--;
		a[x[i]] = y[i];
		cnt[a[x[i]]]++;
		cover[a[x[i]] - cnt[a[x[i]]]]++; if (cover[a[x[i]] - cnt[a[x[i]]]] == 1 && a[x[i]] - cnt[a[x[i]]] >= 0) l--;
		printf("%d\n",l);
	}
	return 0;
}


Measured memory_bytes: 9344
import numpy as np

N, M, C = [int(i) for i in input().split()]
B = np.array([int(i) for i in input().split()])
A = np.array([[int(x) for x in input().split()] for i in range(N)])

print(len([x for x in (np.dot(A, B.T) + C) if x >0]))

Measured memory_bytes: 12464
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;

vector<int> g[200200];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int left=0,right=n+1;
    while(right-left>1){
        int mid=(left+right)/2;
        vector<pair<int,int>> v;
        bool ok=true;
        for(int i=0;i<n;i++){
            int dif=a[i];
            if(i){
               dif-=a[i-1];
            }
            if(dif>0){
                v.push_back(make_pair(0,dif));
                continue;
            }
            while(dif<0){
                int take=min(v.back().second,-dif);
                dif+=take;
                v.back().second-=take;
                if(v.back().second==0){
                    v.pop_back();
                }
            }
            int k=0;
            while(v.size()&&v.back().first==mid-1){
                k+=v.back().second;
                v.pop_back();
            }
            if(v.empty()){
                ok=false;
                break;
            }
            int x=v.back().first;
            v.back().second--;
            if(v.back().second==0){
                v.pop_back();
            }
            v.push_back(make_pair(x+1,1));
            if(k>0){
                v.push_back(make_pair(0,k));
            }
        }
        if(ok){
            right=mid;
        }
        else{
            left=mid;
        }
    }
    cout << left+1 << endl;
}

Measured memory_bytes: 9396
#include<stdio.h>

void numChange(int num[]);

int main(void)
{
  int num[3];
    
  for(int i=0;i<3;i++){
    scanf("%d",&num[i]);
  }
    
  numChange(num);
    
  for(int i=0;i<2;i++){
    printf("%d ",num[i]);
  }
  printf("%d\n",num[2]);
}

void numChange(int num[])
{
  int tmp;
  int min;
    
  for(int i=0;i<3;i++){
    min=i;
    for(int j=i+1;j<3;j++){
      if(num[min]>num[j])
	min=j;
    }
    tmp=num[i];
    num[i]=num[min];
    num[min]=tmp;
  }
}



Measured memory_bytes: 2060
def f(k,r)
	if k==0 && r==0
		return 1
	elsif k==0
		return 0
	elsif k<=r
		return 1
	else
		return 0
	end
end
memo=[]

m=2003
mod=10**9+7
ds=gets.split(" ").map{|e| e.to_i}
b1=ds[1]
r1=ds[0]-ds[1]

(m+2).times{|i|
	memo<<[]
	(m+2).times{
		memo[i]<<0
	}
}


(0..m).each{|i|
	s1=0
	(i..m).each{|j|
		if i==0
			memo[i][j]=1
		elsif i==1
			memo[i][j]=1
		else
			memo[i][j]=(memo[i-1][j-1]+s1)%mod
			s1=(s1+memo[i-1][j-1])%mod
		end
	}
}

b1.times{|i|
	k=i+1
	ans=(f(k,r1)*f(k,b1)*memo[k][r1]*memo[k][b1]*2)%mod
	ans=(ans+f(k+1,r1)*f(k,b1)*memo[k+1][r1]*memo[k][b1])%mod
	ans=(ans+f(k-1,r1)*f(k,b1)*memo[k-1][r1]*memo[k][b1])%mod
	
	p ans%mod
}

Measured memory_bytes: 36860
#include<bits/stdc++.h>
#define ll long long
#define rgi register int
#define rgl register ll
#define maxn 100005
#define mod 998244353LL
#define inf 1000000007LL
namespace lib
{
	using namespace std;
	class fastio
	{
		private:
			#define _NUMLEN 111
			char _num[_NUMLEN],_ch;
			int _f,_head;
			bool _useSTD;
		public:
			inline void ioSTD()
			{
				_useSTD=1;
				ios::sync_with_stdio(false);
				cin.tie(0),cout.tie(0);
			}
			inline void gc(char & _c)
			{
				if(_useSTD)cin>>_c;
				else _c=getchar();
			}
			inline void pc(char _c)
			{
				if(_useSTD)cout<<_c;
				else putchar(_c);
			}
			template<typename _T> inline fastio & operator - (_T & _x)
			{
				if(_useSTD)cin>>_x;
				else
				{
					_x=0;
					while(!isdigit(_ch)) _f|=_ch=='-',gc(_ch);
					while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),gc(_ch);
					_f&&(_x=-_x,_f=0);
				}
				return *this; 
			}
			template<typename _T> inline fastio & operator + (_T _x)
			{
				if(_useSTD)cin>>_x;
				else
				{
					_T _k;
					if(_x==0) {pc('0'),pc(' ');return *this;}
					if(_x<0) pc('-'),_x=-_x;
					while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
					while(_head>0) pc(_num[_head]),--_head;
					pc(' ');
				}
				return *this; 
			}
			template<typename _T> inline fastio & operator >> (_T & _x) {cin>>_x;return *this;}
			template<typename _T> inline fastio & operator << (_T _x) {cout<<_x;return *this;}
			#define endln pc('\n')
		fastio() {_f=0,_head=0,_useSTD=0,_ch=' ';}
	}io;
	inline void fileio(string _r,string _w)
	{
		if(_r[0]!='-')freopen(_r.c_str(),"r",stdin);
		if(_w[0]!='-')freopen(_w.c_str(),"w",stdout);
	}
	#define mem(_x,_set) memset(_x,_set,sizeof(_x))
}using namespace lib;

int a[10],b[10],p[10];
signed main()
{
	// fileio("tt.in","tt.out");
	io.ioSTD();
	int n;
	int x=1,aa,bb;
	cin>>n;
	for(rgi i=1;i<=n;++i)
		p[i]=i,x*=i;
	for(rgi i=1;i<=n;++i)cin>>a[i];
	for(rgi i=1;i<=n;++i)cin>>b[i];
	for(rgi i=1;i<=x;++i)
	{
		bool t=1;
		for(rgi j=1;j<=n;++j)if(a[j]!=p[j])t=0;
		if(t)aa=i;
		t=1;
		for(rgi j=1;j<=n;++j)if(b[j]!=p[j])t=0;
		if(t)bb=i;
		if(i<x)next_permutation(p+1,p+1+n);
	}
	cout<<abs(aa-bb);
	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<(ll)(n);i++)
#define ALL(n) (n).begin(), (n).end()

int main(){
  ll N, ans=0; cin>>N;
  vector<ll> A(N), B(N), C(N);
  
  rep(i, N) cin>>A[i];
  rep(i, N) cin>>B[i];
  rep(i, N )cin>>C[i];
  
  sort(ALL(A));
  sort(ALL(C));
  
  rep(i, N){
    ll cnt = upper_bound(ALL(A), B[i]-1) - A.begin(), cnt2 = C.end() - lower_bound(ALL(C), B[i]+1);
    ans += cnt * cnt2;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cmath>

void inputVector(int*, const unsigned int&);
double minkowskiDistance(int, int*, int*, const unsigned int&);
double nRoot(int, unsigned long long , const int& );
double chebyshevDistance(int* , int*, const unsigned int& );

int main(){
	
	int n;
	int* ptrX;
	int* ptrY;
	double mDis;
	double eDis;
	double m3Dis;
	double cDis;

	std::cin >> n;

	ptrX = new int[n];
	ptrY = new int[n];

	inputVector(ptrX, n);
	inputVector(ptrY, n);

	mDis = minkowskiDistance(1, ptrX, ptrY, n);
	eDis = minkowskiDistance(2, ptrX, ptrY, n);
	m3Dis = minkowskiDistance(3, ptrX, ptrY, n);
	cDis = chebyshevDistance(ptrX, ptrY, n);

	std::printf("%0.5f\n%0.5f\n%0.5f\n%0.5f\n", mDis, eDis, m3Dis, cDis);

	delete[] ptrX;
	delete[] ptrY;
	return 0;
}

void inputVector(int* vec, const unsigned int& n){
	for (size_t i = 0; i < n; i++)
	{
		std::cin >> vec[i];
	}
}


double minkowskiDistance(int p, int* xVector, int* yVector, const unsigned int& n){
	long double result = 0;
	for (size_t i = 0; i < n; i++)
	{
		int tmp = 1;
		for (size_t j = 0; j < p; j++){
			tmp *= abs(xVector[i] - yVector[i]);
		}
		result += tmp;
	}
	return nRoot(p, result, 10);
}


double chebyshevDistance(int* xVector, int* yVector, const unsigned int& n){
	int result = 0;
	for (size_t i = 0; i < n; i++)
	{
		if (result < abs(xVector[i] - yVector[i])){
			result = abs(xVector[i] - yVector[i]);
		}
	}
	return result;
}

double nRoot(int rootNum, unsigned long long number, const int& SIGNIFICANT_DIGITS){
	double result = 0;
	double digitsOffset = 1;

	for (int i = 0; i < SIGNIFICANT_DIGITS + 1; i++){
		while (number >= std::pow(result + digitsOffset, rootNum)){
			result += digitsOffset;
		}
		digitsOffset /= 10;
	}
	return result;
}


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

int main(){
    int n;int a,b,c,d;cin>>n;
    a=n/1000;b=(n/100-(10*a));c=(n/10-(100*a+10*b));d=n%10;
    if(a+b+c+d==7){cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;}
    else if(a+b+c-d==7){cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;}
    else if(a+b-c-d==7){cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;}
    else if(a+b-c+d==7){cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;}
    else if(a-b+c+d==7){cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;}
    else if(a-b-c+d==7){cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;}
    else if(a-b+c-d==7){cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;}
    else if(a-b-c-d==7){cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;}
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int train,bus;
    int unchin[4];
    for(int i = 0;i < 4;i++){
        scanf("%d",&unchin[i]);
    }
    if(unchin[1] < unchin[0]){
        train = unchin[1];
    }
    else{
        train = unchin[0];
    }
    if(unchin[2] < unchin[3]){
        bus = unchin[2];
    }
    else{
        bus = unchin[3];
    }
    
    
    printf("%d\n",train + bus);
    
    return 0;
    
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans, cnt;



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

	ll N;
	cin >> N;
	
	string S;
	cin >> S;

	vector<ll> r, g, b;
	ll rcnt = 0, gcnt = 0, bcnt = 0;
	rep(i, N) {
		if (S[i] == 'R') {
			r.push_back(i);
			rcnt++;
		}
		else if (S[i] == 'G') {
			g.push_back(i);
			gcnt++;
		}
		else if (S[i] == 'B') {
			b.push_back(i);
			bcnt++;
		}
	}
	
	rep(i, r.size()) {
		rep(j, g.size()) {
			ll x = r[i];
			ll y = g[j];

			if (x > y) {
				if (x + x - y < N) {
					if (S[x + x - y] == 'B') {
						cnt++;
					}
				}
				if (y - (x - y) > 0) {
					if (y - (x - y) > 0) {
						if (S[y - (x - y)] == 'B') {
							cnt++;
						}
					}
				}
				if ((x + y) % 2 == 0) {
					if (S[(x + y) / 2] == 'B') {
						cnt++;
					}
				}
			}
			else {
				if (y + y - x < N) {
					if (S[y + y - x] == 'B') {
						cnt++;
					}
				}
				if (x - (y - x) > 0) {
					if (S[x - (y - x)] == 'B') {
						cnt++;
					}
				}
				if ((x + y) % 2 == 0) {
					if (S[(x + y) / 2] == 'B') {
						cnt++;
					}
				}
			}
		}
	}

	ans = rcnt * gcnt * bcnt - cnt;
	//cout << r.size() << " " << g.size() << " " << b.size() << endl;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3688
def listan(a,x):
    naga=len(a)
    if(x>=a[naga-1]):
        return -1
    if(x<a[0]):
        return a[0]
    left=0
    right=naga-1
    while(left<=right):
        center=(left+right)//2
        if(a[center]<=x and x<a[center+1]):
            return a[center+1]
        if(a[center+1]<=x):
            left=center+1
        if(a[center]>x):
            right=center-1


list=[0,1,4,5,7,9,11]
b=[1,5,10,13]
#print(listan(b,0))
s=input()
t=input()

sl=len(s)
tl=len(t)

taiou=[]
jisho=[]


kanou=True
for i in range(tl):
    temp=[]
    if(t[i] in jisho):
        num=jisho.index(t[i])
        taiou.append(jisho[num+1])
    else:
        for j in range(sl):
            
            if(t[i]==s[j]):
                temp.append(j)
        if(temp==[]):
            kanou=False
        jisho.append(t[i])
        jisho.append(temp)
        taiou.append(temp)
        
#print(jisho)
#print(taiou)
if(not kanou):
    print(-1)

if(kanou):
    gyou=0
    retu=-1
    for i in range(tl):
        ban=listan(taiou[i],retu)
        if(ban==-1):
            gyou+=1
            retu=taiou[i][0]
        else:
            retu=ban

    print(gyou*sl+retu+1)

Measured memory_bytes: 8296
<?php
list($n, $m, $r) = ints();
$rr = ints();
$dk = new Dijkstra($n);
for ($i = 0; $i < $m; ++$i) {
    list($a, $b, $c) = ints();
    $a--;
    $b--;
    $dk->connect($a, $b, $c);
    $dk->connect($b, $a, $c);
}
for ($i = 0; $i < $r; ++$i) {
    $rr[$i]--;
    $dk->solve($rr[$i]);
}
echo dfs($rr);

function dfs($arr, $p = -1)
{
    global $dk;

    if (count($arr) === 0) return 0;
    foreach ($arr as $i => $next) {
        $_arr = $arr;
        unset($_arr[$i]);
        if ($p >= 0) $res[] = $dk->dist($p, $next) + dfs($_arr, $next);
        else $res[] = dfs($_arr, $next);
    }
    return min($res);
}

function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}

class Dijkstra
{
    private $n;
    private $d; // 最短距離を格納
    private $cost; // ノード間の距離を格納
    private $root; // 最短経路を格納

    function __construct($n)
    {
        $this->n = $n;
        $this->cost = array_fill(0, $this->n, array_fill(0, $this->n, INF));
    }

    function connect($x, $y, $w)
    {
        $this->cost[$x][$y] = $w;
    }

    function solve($s = 0)
    {
        $this->d[$s] = array_fill(0, $this->n, INF);
        $this->d[$s][$s] = 0;
        $this->root[$s] = array_fill(0, $this->n, [$s]); // 各ノードまでの最短経路を格納
        $used = array_fill(0, $this->n, false);
        while (true) {
            $v = -1;
            // 残りのノードのうち最短で到達出来るノードを選択
            for ($i = 0; $i < $this->n; ++$i) {
                if (!$used[$i] && $v === -1) $v = $i;
                elseif (!$used[$i] && $this->d[$s][$i] < $this->d[$s][$v]) $v = $i;
            }
            if ($v === -1) break;
            for ($i = 0; $i < $this->n; ++$i) {
                if ($this->d[$s][$i] > $this->d[$s][$v] + $this->cost[$v][$i]) {
                    $this->d[$s][$i] = $this->d[$s][$v] + $this->cost[$v][$i];
                    $this->root[$s][$i] = array_merge($this->root[$s][$v], [$i]);
                }
            }
            $used[$v] = true;
        }
    }

    function dist($x, $y)
    {
        return $this->d[$x][$y];
    }

    function root($x, $y)
    {
        return $this->root[$x][$y];
    }
}


Measured memory_bytes: 10744
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0: 
        break
    for i in range(H):
        for j in range(W):
            if i == 0 or i == H - 1 or j == 0 or j == W - 1:
                print("#",end = "")
            else:
                print(".",end = "")
        print()
    print()


Measured memory_bytes: 7000
// https://atcoder.jp/contests/abc073/tasks/abc073_c

#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int N, A;
set<int> s;

int main()
{
  cin >> N;
  REP(i, N)
  {
    cin >> A;
    auto r = s.insert(A);
    if (!r.second)
      s.erase(A);
  }

  cout << s.size() << '\n';

  return 0;
}


Measured memory_bytes: 4864