akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int Maxn = 4;
int N,M;
int s[Maxn];
int c[Maxn];
int main()
{
	cin>>N>>M;
	bool failed = false;
	for(int i=1;i<=M&&!failed;i++)
	{
		int a,b;
		cin>>a>>b;
		if(c[a]==0)	//没有被注册过 
		{
			if(a==1)
			{	
				if(b==0)
				{
					if(N!=1)
					failed = true;
					else
					{
						c[a] = 1;
						s[a] = b;		
					}
				}
				else
				{
					c[a] = 1;
					s[a] = b;	
				}
			}
			else
			{
				c[a] = 1;
				s[a] = b;
			}
		}
		else
		{
			if(s[a]!=b)
				failed = true;
			else
				continue;
		}
	}
	if(failed)	printf("-1");
	else
	{
		for(int i=1;i<=N;i++)
		{
			if(i==1)
			{
				if(c[1]==0)
				{
					if(N==1) printf("0");
					else
						 printf("1");
				}
				else
					printf("%d",s[1]);
			}
			else
			{
				if(!c[i])
					printf("0");
				else
					printf("%d",s[i]);
			}	
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int N, A, B;

int fun(int n) {
  int res = 0;
  while (n > 0) {
    res += n % 10;
    n /= 10;
  }
  return res;
}

int main(){
    cin >> N >> A >> B;
    int result = 0;
    int ct = 0;
    for (int i = 1; i <= N; ++i) {
      result = fun(i);
      if (result >= A && result <= B) {
        ct += i;
      }
    }
    cout << ct; 
    return 0;
}


Measured memory_bytes: 256
//WA need to printf("%s\n",ans);
#include <bits/stdc++.h>
using namespace std;

const int maxn = 3e3+100;
char str1[maxn],str2[maxn];
int dp[maxn][maxn];
int len1,len2;

void print(int x,int y) {
    if(!x || !y) return;
    if(dp[x-1][y] != dp[x][y]) {
        for(int i=1; i<=len2; i++) {
            if(dp[x][i] == dp[x][y]) {
                y = i;
                break;
            }
        }
        print(x-1,y-1);
        printf("%c",str2[y-1]);
    } else print(x-1,y);
    return;
}

int main() {
    scanf("%s",str1);
    scanf(" %s",str2);
    len1 = strlen(str1);
    len2 = strlen(str2);
    for(int i=0; i<len1; i++) {
        for(int j=0; j<len2; j++) {
            if(str1[i] == str2[j]) dp[i+1][j+1] = dp[i][j] + 1;
            else {
                dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
            }
        }
    }
    print(len1,len2);
    return 0;
}


Measured memory_bytes: 37120
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        long a=fsc.nextLong();
        long b=fsc.nextLong();
        long k=fsc.nextLong();
        fsc.close();
        if(a>=k){
            System.out.println((a-k)+" "+b);
        }
        else{
            System.out.println(0+" "+Math.max((b-(k-a)), 0));
        }
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 23252
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	int n;
	while(scanf("%d", &n) != EOF){
		n = 2*n + ((n-1)*(n-2))/2;
		printf("%d\n", n);
	}
	return 0;
}
	

Measured memory_bytes: 596
#include<stdio.h>
int main()
{
	int R,C,i,j,r[105]={0},c[105]={0},t;
	scanf("%d%d",&R,&C);
	for(i=0;i<=R;i++)
		for(j=0;j<=C;j++)
		{
			if(i<R&&j<C)
			{
				scanf("%d",&t);
				r[i]+=t;c[j]+=t,c[C]+=t;
			}
			printf("%d%s",i==R?c[j]:j==C?r[i]:t,j==C?"\n":" ");
		}
	return 0;
}



Measured memory_bytes: 2044
A=[]
for i in range(3):
    A.append(list(map(int,input().split())))
N=int(input())
for i in range(N):
    b=int(input())
    for ii in range(3):
        for iii in range(3):
            if A[ii][iii]==b:
                A[ii][iii]=0

flag=False
for i in range(3):
    if A[i][:]==[0,0,0]:
        flag=True
    elif A[0][i]==0 and A[1][i]==0 and A[2][i]==0:
        flag=True
    elif A[1][1]==0:
        if A[0][2]==0 and A[2][0]==0:
            flag=True
        elif A[0][0]==0 and A[2][2]==0:
            flag=True
if flag:
    print('Yes')
else:
    print('No')

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

int main() {
	int N, D, X; cin >> N >> D >> X;
	
	D--;
	
	int A;
	for( int i = 0; i < N; i++ ){
		cin >> A;
		X += D/A;
		X++;
	}
	
	cout << X << endl;
}

Measured memory_bytes: 256
import numpy as np

c = [[], [], []]
for i in range(3):
    c[i] = list(map(int, input().split()))
d = np.array(c)

if len(set(d[1]-d[0])) == 1 and len(set(d[2]-d[0])) == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14428
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int mod = 1000000007;
	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			Integer[] primes = MathUtils.getPrimes(n);
			int[] count = new int[primes.length];

			for (int i = 1; i <= n; i++) {
				int t = i;
				for (int j = 0; j < primes.length; j++) {
					while (t % primes[j] == 0) {
						count[j]++;
						t = t / primes[j];
					}
				}
			}

			long ans = 1;
			for (int i = 0; i < count.length; i++) {
				ans = (ans*(count[i]+1)%mod);
			}

			out.println(ans);

		}
	}

	static class MathUtils {
		public static Integer[] getPrimes (int n) {
	        boolean[] isPrime = new boolean[n+1];
	        Arrays.fill(isPrime, true);
	        isPrime[0] = isPrime[1] = false;
	        for (int i = 2; i < isPrime.length; i++) {
	            if (!isPrime[i]) continue;
	            for (int j = i + i; j < isPrime.length; j += i) {
	                isPrime[j] = false;
	            }
	        }

	        List<Integer> list = new ArrayList<>();
	        for (int i = 1; i < isPrime.length; i++) {
				if (isPrime[i]) {
					list.add(i);
				}
			}
	        return list.toArray(new Integer[list.size()]);
		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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

int main() {
    int L, R; cin >> L >> R;
    
    if (R - L >= 2018) {
        cout << 0 << endl;
        return 0;
    }

    int out = 2019;
    for (int i = L; i < R; i++) {
        for (int j = i + 1; j <= R; j++) {
            out = min(out, ((i % 2019) * (j % 2019)) % 2019);
        }
    }

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 256
/**
 * Created by iainws on 4/09/16.
 */

import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.InputStream;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReaderMain in = new InputReaderMain(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskMain solver = new TaskMain();
        solver.solve(1, in, out);
        out.close();
    }
}
class TaskMain {
    public void solve(int taskNumber, InputReaderMain in, PrintWriter out) {
        int a;
        int b;
        int h;
        a = in.nextInt();
        b = in.nextInt();
        h = in.nextInt();
        System.out.println(((a + b) * h) / 2);
    }
}

class InputReaderMain {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReaderMain(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

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

    public int nextInt() {
        return Integer.parseInt(next());
    }

}

Measured memory_bytes: 7764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  int x = N % 1000;
  int ans = x == 0 ? 0 : 1000 - x;

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int n;
bool prime(int x){
	if(x==2)return 1;
	if(x%2==0)return 0;
	for(int i=3;i*i<=x;i+=2)
	if(x%i==0)return 0;
	return 1;
}
int main(){
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	in(n);
	for(int i=n;i;i++){
		if(prime(i)){
			printf("%d\n",i);return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n){
        cin>>a[i];
    }
    int ans=0,con=0;
    rep(i,n){
        if(a[i]==i+1){
            con++;
        }
        else{
            if(con%2==0){
                ans+=con/2;
            }
            else{
                ans+=con/2+1;
            }
            con=0;
        }
    }
    if(con%2==0){
        ans+=con/2;
    }
    else{
        ans+=con/2+1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
input = readlines()

length = input.shift.chomp.to_i
list = input.shift.chomp.split("\s").map{|x| x.to_i}

l_max = list.max

ary = Array.new(l_max, true)

list.sort!
prev = nil
list.each do |l1|
  next if ary[l1 - 1] == false
  cnt = 2
  y = l1 * 2
  while(y <= l_max)
    ary[y - 1] = false
    cnt += 1
    y = l1 * cnt
  end
  ary[l1 - 1] = false if l1 == prev
  prev = l1
end

t = 0
list.each do |l1|
  t += 1 if ary[l1 - 1] == true
end

p t


Measured memory_bytes: 38064
#include<stdio.h>
int main(void){
	int a,b,c,x,y,z;
  scanf("%d %d %d",&a,&b,&c);

  if(a > b){
    x = a;
    a = b;
    b = x;
  }

  if(b > c){
    y = b;
    b = c;
    c = y;
  }

  if(a > b){
    z = a;
    a = b;
    b = z;
  }

  printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int cnt[200010];
int a[200010];
int flux[200010];
int n;
int ans;

void solve() {
	for(int i = 0; i <= n; i++) {
		cnt[i] = 0;
		flux[i] = 0;	
	}
	for(int i = 1; i <= n; i++) {
		cnt[a[i]] += 1;
	}
	for(int i = 1; i <= n; i++) {
		if(cnt[i] > i) {
			ans += cnt[i] - i;
		}	
		flux[max(0, i - cnt[i])] += 1;
		flux[i] -= 1;
	}
	for(int i = 0; i <= n; i++) {
		if(i) flux[i] += flux[i - 1];
		if(flux[i] > 0) ans += flux[i] - 1;
	}
	return ;
}

void del(int x) {
	if(x - cnt[x] < 0) {
		--ans;
	} else {
		int y = x - cnt[x];
		if(flux[y] > 0) ans -= flux[y] - 1;
		flux[y] -= 1;
		if(flux[y] > 0) ans += flux[y] - 1;
	}
	--cnt[x];
}
void add(int x) {
	if(x - cnt[x] <= 0) {
		++ans;
	} else {
		int y = x - cnt[x] - 1;
		// cout << y << endl;
		if(flux[y] > 0) ans -= flux[y] - 1;
		flux[y] += 1;
		if(flux[y] > 0) ans += flux[y] - 1;
	}
	++cnt[x];
}
int main(int argc, char const *argv[])
{
	int m;
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	solve();
	for(int i = 1; i <= m; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		del(a[x]);
		a[x] = y;
		add(a[x]);
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <utility>
#include <set>
using namespace std;

typedef vector <bool> VB;
typedef vector <int> VI;
typedef vector <VI> VVI;
typedef pair <int,int> PII;
typedef vector <PII> VPII;

VPII dominoes;
VVI connected;
VB visited;
int visited_count;
int n;
int now;
int cur; 

bool is_match( int t, PII domino )
{
	if ( t == domino.first || t == domino.second ) return true;
	else return false;
}

int get_next( int t, PII domino )
{
	if ( t == domino.first ) return domino.second;
	else return domino.first;
}

bool search( int no, int c )
{
	if ( visited_count == n ) return true;
	for ( VI::iterator it = connected[cur].begin(); it != connected[cur].end(); it++ )
	{
		if ( visited[*it] ) continue;
		if ( is_match( now, dominoes[*it] ) == false ) continue;
		now = get_next( now, dominoes[*it] );
		cur = *it;
		visited[*it] = true;
		visited_count++;
		if ( search( now, cur ) ) return true;
		now = no; cur = c;
		visited_count--;
		visited[*it] = false;
	}
	return false;
}

bool solve()
{
	visited = VB( n, false );
	visited_count = 0;
	for ( int i = 0; i < n; i++ )
	{
		for ( int j = 0; j < 2; j++ )
		{
			now = j ? dominoes[i].first : dominoes[i].second;
			cur = i;
			visited[i] = true;
			visited_count++;
			if ( search( now, cur ) ) return true;
			visited_count--;
			visited[i] = false;
		}
	}
	return false;
}

void input_dominoes( int n )
{

	for ( int i = 0; i < n; i++ )
	{
		char left, right; cin >> left >> right;
		int l = (int)(left - '0'), r = (int)(right - '0');
		dominoes[i] = make_pair( l, r );
	}
}

int main( void )
{
	while ( cin.eof() == false )
	{
		cin >> n;
		if ( cin.eof() ) break;

		dominoes = VPII( n );
		input_dominoes( n );

		connected = VVI( n );
		for ( int i = 0; i < n; i++ )
		{
			for ( int j = i+1; j < n; j++ )
			{
				if ( i == j ) continue;
				if ( is_match( dominoes[i].first, dominoes[j] ) || is_match( dominoes[i].second, dominoes[j] ) )
				{
					connected[i].push_back( j );
					connected[j].push_back( i );
				}
			}
		}

		bool result = solve();
		if ( result ) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
using namespace std;
int n;I int gcd(CI x,CI y) {return y?gcd(y,x%y):x;}
int main()
{
	return scanf("%d",&n),printf("%d\n",360/gcd(360,n)),0;
}

Measured memory_bytes: 3832
#include <iostream>

int main(int argc, char **argv)
{
	int n = 0;
	int a = 0;
	int oddCount = 0;

	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> a;
		if (a % 2 > 0) {
			oddCount++;
		}
	}

	if (oddCount % 2 > 0) {
		std::cout << "NO";
	}
	else {
		std::cout << "YES";
	}

	return 0;
}

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

int main(){
   int n, query, x;
   vector<int> vec;

  cin>>n;
  
  for(int i = 0; i < n; i++){
    cin>>query;
    
    if(query == 0){
      cin>>x;
      vec.push_back(x);
    } else if(query == 1){
      cin>>x;
      cout<<vec.at(x)<<endl;
    } else{
      vec.pop_back();
    }
  }
  return 0;
}


Measured memory_bytes: 3860
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

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

    if((n == 1 && a != b) || (a > b)){
        cout << 0 << endl;
        return 0;
    }

    long long lower = a + b + a * (n-2);
    long long upper = a + b + b * (n-2);

    cout << upper - lower + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	int i;
	cin>>a;
	for(i=0;i<a.length();i++)
		if(a[i]=='C')
			break;
	for(;i<a.length();i++)
	{
		if(a[i]=='F')
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;	
}

Measured memory_bytes: 256
// In The Name Of The Queen
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 19, Mod = 1e9 + 7;
ll n, k, Mn;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> k;
    Mn = n;
    if (n >= k)
        n %= k, Mn = min(Mn, n);
    Mn = min(Mn, k - n);
    printf("%lld\n", Mn);
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
vector<T> compress(vector<T>&a, vector<T>&b) {
	vector<T>ret;
	ret.insert(ret.end(), all(a));
	ret.insert(ret.end(), all(b));
	sort(all(ret));
	ret.erase(unique(all(ret)), ret.end());
	rep(i, 0, a.size())a[i] = distance(ret.begin(), lower_bound(all(ret), a[i]));
	rep(i, 0, b.size())b[i] = distance(ret.begin(), lower_bound(all(ret), b[i]));
	return ret;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int>x1(N), y1(N), x2(N), y2(N);
	rep(i, 0, N)cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
	auto zipx = compress(x1, x2), zipy = compress(y1, y2);
	vector<vector<int>>field(zipx.size(), vector<int>(zipy.size(), 0));
	dump(zipx); dump(zipy); dump(x1); dump(y1); dump(x2); dump(y2);
	rep(i, 0, N) {
		field[x1[i]][y1[i]]++;
		field[x2[i]][y2[i]]++;
		field[x1[i]][y2[i]]--;
		field[x2[i]][y1[i]]--;
		dump(field)
	}
	rep(i, 0, zipx.size())rep(j, 1, zipy.size())field[i][j] += field[i][j - 1];
	dump(field);
	rep(i, 0, zipy.size())rep(j, 1, zipx.size())field[j][i] += field[j - 1][i];
	dump(field);
	int ans(0);
	rep(i, 0, zipx.size() - 1)rep(j, 0, zipy.size() - 1) {
		if (field[i][j])ans += (zipx[i + 1] - zipx[i])*(zipy[j + 1] - zipy[j]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 128184
// 問題の URL を書いておく
// 

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <numeric>
using namespace std;

//#define ENABLE_PRINT

template<typename T>
T Input()
{
    T v;
    cin >> v;
    return v;
}

template<typename T>
vector<T> InputVector(int n)
{
    vector<T> v(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    return v;
}

template<typename T>
void InputArray(T* begin, int n)
{
    for(int i = 0; i < n; ++i)
    {
        cin >> begin[i];
    }
}

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

int main(int, const char**)
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    auto a = (h2 * 60 + m2) - (h1 * 60 + m1) - k;
    a = a < 0 ? 0 : a;
    cout << a << endl;
    return 0;
}


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

class Main {

	public static void main(String[] args) throws IOException {

		char[] line;
		char[] alphabets = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
				's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };

		BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));

		String s = stdIn.readLine();
		StringBuilder sb = new StringBuilder();
		while (s != null) {
			sb.append(s);
			s = stdIn.readLine();
		}
		line = sb.toString().toLowerCase().toCharArray();
		

		for (int i = 0; i < 26; i++) {
			int count = 0;

			for (char c : line) {
				if (c == alphabets[i]) {
					count++;
				}
			}
			System.out.println(alphabets[i] + " : " + count);
		}
		stdIn.close();
	}

}

Measured memory_bytes: 24312
#include <bits/stdc++.h>
#define  ren(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) ren(i,0,(n))
#define  all(a) begin(a),end(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
 
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*b,c*d)<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	nketa := 0
	ans := 0
	for i := n; 0 < i; i /= 10 {
		nketa++
	}

	// 奇数桁だけ
	for i := 1; i < nketa; i++ {
		if i%2 == 1 {
			ans += 9 * pow(10, i-1)
		}
	}

	if nketa%2 == 1 {
		ans += n - pow(10, nketa-1) + 1
	}

	fmt.Println(ans)
}

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1772
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int c = 0;
        if (n < 10) {
            c = n;//1..n
        } else if (n < 100) {
            c = 9;//1...9
        } else if (n < 1_000) {
            c = n - 90;// 1..9,100..n -> n - 99 + 9
        } else if (n < 10_000) {
            c = 909;//1..9,100..999 -> 999 - 99 + 9
        } else if (n < 100_000) {
            c = n - 9090;//1..9,100..999,10000..n -> n - 9999 + 999 - 99 + 9
        } else {
            c = 90909;//1..9,100..999,10000..99999 -> 99999 - 9999 + 999 - 99 + 9
        }
        System.out.println(c);
    }
}


Measured memory_bytes: 23124
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <cmath>
using namespace std;

#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647

int main() {
	int N;
	cin >> N;
	map<int, int> mp;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		mp[a]++;
	}

	vector<long long > vec;
	for (auto iter = --mp.end(); iter != --mp.begin(); --iter) {
		if (2 <= iter->second) {
			vec.push_back(iter->first);
			iter->second -= 2;
			++iter;
		}

		if (vec.size() == 2) {
			break;
		}
	}

	if (vec.size() < 2) {
		cout << 0 << endl;
	}
	else {
		cout << vec[0] * vec[1] << endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
	int n;
	ll B[100];
	
	cin >> n;
	for (int i = 0; i < n - 1; i++)	cin >> B[i];
	ll sum =B[0]+B[n-2];

	for (int i = 1; i < n-1 ; i++){
		sum+=min(B[i-1],B[i]);
	}

	cout << sum << endl;
	
	return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

const ll MOD = 1e9 + 7;

namespace tottori{
    // until C++17
    template <typename T, size_t N>
    constexpr size_t size(const T (&array)[N]){
        return N;
    }
};

template <typename T>
T expt(T a, T n, T mod = std::numeric_limits<T>::max()){
    T res = 1;
    while(n){
        if(n & 1){res = res * a % mod;}
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template <typename T>
T inverse(T n, T mod){
    return expt(n, mod-2, mod);
}

ll fact[200200], inv[200200];

// nPr
template <typename T>
T nPr(T n, T r, T mod = std::numeric_limits<T>::max()){
    if(n < r){return 0;}
    return fact[n] * inv[r] % mod;
}

// nCk
template <typename T>
T nCk(T n, T k, T mod = std::numeric_limits<T>::max()){
    if(n < k){return 0;}
    return fact[n] * inv[k] % mod * inv[n-k] % mod;
}

template <typename T>
T nHk(T n, T k, T mod = std::numeric_limits<T>::max()){
    if(n == 0 && k == 0){return 1;}
    return nCk(n+k-1, k);
}

void initFactAndInv(ll mod){
    fact[0] = 1;
    inv[0] = 1;

    for(int i=1;i<tottori::size(fact);i++){
        fact[i] = fact[i-1] * i % mod;
        inv[i] = inverse(fact[i], mod);
    }
}

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

    initFactAndInv(MOD);

    int N, M;
    std::cin >> N >> M;

    if(abs(N - M) > 1){
        std::cout << 0 << std::endl;
        return 0;
    }

    ll res = fact[N] * fact[M] % MOD;
    if(N == M){res = res * 2 % MOD;}
    std::cout << res << std::endl;
}


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

#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcd(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int n, m;
  cin >> n >> m;
  vt<int> k(m);
  vvt<int> s(m);
  rep(i, 0, m) {
    cin >> k[i];
    rep(j, 0, k[i]) {
      int tmp;
      cin >> tmp;
      tmp--;
      s[i].push_back(tmp);
    }
  }
  vt<int> p(m);
  rep(i, 0, m) cin >> p[i];

  int ans = 0;
  rep(bit, 0, (1 << n)) {
    bool ok = true;
    rep(i, 0, m) {
      int sum = 0;
      rep(j, 0, k[i]) {
        if(bit & (1 << s[i][j])) sum++;
      }
      if(sum % 2 != p[i]) ok = false;
    }
    if(ok) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }


int main() {
	ll n;
	string S[50];
	cin >> n;
	REP(i, n) {
		cin >> S[i];
	}
	for (char c = 'a'; c <= 'z'; c++) {
		int small = 5000;
		REP(i, n) {
			int count = 0;
			REP(j, S[i].size()) {
				if (S[i][j] == c) {
					count++;
				}
			}
			small = min(small, count);
		}
		REP(k, small) {
			cout << c;
		}
	}
	cin >> n;

	return 0;
}

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

using namespace std;

typedef long long ll; // ll  is 64bit same as double

int main() {
	
	// make input and output more efficient
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int x, y;
	
	cin >> x >> y;
	
	if(y<=x) {
		cout << "No\n";
		return 0;
	}
	
	for(int i = 0; i <= x; i++) {
		for(int j = x-i; j>=0; j--) {
			if(y == 2*i + 4*j && i+j==x){
				cout << "Yes\n";
				return 0;
			}
		}
	}
				
	cout << "No\n";
	
	return 0;
}


Measured memory_bytes: 3608
# coding: utf-8

N = int(input())
S = input()

count = 0
candidate = ["00" + str(i) for i in range(1000)]

for i in candidate:
    first = S.find(i[-3])
    #second = min(S.find(i[-2]),S.rfind(i[-2]))
    third = S.rfind(i[-1])
    if first==-1 or third==-1:
        continue
    elif first<third:
        if i[-2] in S[first+1:third]:
            count+=1
print(count)


Measured memory_bytes: 3188
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<char,int>;

const ll MOD = INF + 7;

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    int na = 0, nb = 0, nc = 0;
    int sa = a.size(), sb = b.size(), sc = c.size();
    int now = 0;
    while(1){
        if(now == 0){
            if(a[na] == 'a'){
                now = 0;
                na++;
            }
            else if(a[na] == 'b'){
                now = 1;
                na++;
            }
            else if(a[na] == 'c'){
                now = 2;
                na++;
            }
            if(na == sa && now == 0){
                cout << 'A';
                return 0;
            }
        }
        else if(now == 1){
            if(b[nb] == 'a'){
                now = 0;
                nb++;
            }
            else if(b[nb] == 'b'){
                now = 1;
                nb++;
            }
            else if(b[nb] == 'c'){
                now = 2;
                nb++;
            }
            if(nb == sb && now == 1){
                cout << 'B';
                return 0;
            }
        }
        else if(now == 2){
            if(c[nc] == 'a'){
                now = 0;
                nc++;
            }
            else if(c[nc] == 'b'){
                now = 1;
                nc++;
            }
            else if(c[nc] == 'c'){
                now = 2;
                nc++;
            }
            if(nc == sc && now == 2){
                cout << 'C';
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3008
X = int(input())
flag = 0
for A in range(0, 6001):
  if(flag == 1):
    break
  for B in range(-6001, 6001):
    if(flag == 1):
      break
    if(A**5 - B**5 == X):
      print(A, B)
      flag = 1
      break

Measured memory_bytes: 64836
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
	string s; cin >> s;
	int count[3] = {};
	for(int i = 0; i < s.size(); ++i) ++count[s[i] - 'a'];
	int m = 1e5+1;
	for(int i = 0; i < 3; ++i) m = min(m, count[i]);
	for(int i = 0; i < 3; ++i) count[i] -= m;
	int po = 0;
	for(int i = 0; i < 3; ++i){
		if(count[i] == 1) ++po;
		else if(count[i] > 1) po += 3;
	}
	cout << (po >= 3 ? "NO\n" : "YES\n");
	return 0;
}

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

#define ll long long
#define pb push_back

const int maxn = 1e3 + 20;
const int dx[] = {-1 , 1 , 0 , 0};
const int dy[] = { 0 , 0 , 1 ,-1};

string s[maxn];

int n , m , d[maxn][maxn];

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

	cin >> n >> m;
	for(int i = 0; i < n; i++)
		cin >> s[i];

	memset(d , 63 , sizeof d);
	queue<pair<int , int> > q;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			if(s[i][j] == '#')
				d[i][j] = 0 , q.push({i , j});

	int res = 0;
	while(!q.empty())
	{
		int x = q.front().first , y = q.front().second;
		q.pop();
		res = max(res , d[x][y]);

		for(int i = 0; i < 4; i++)
		{
			int nx = x + dx[i] , ny = y + dy[i];

			if(0 <= nx && nx < n && 0 <= ny && ny < m && d[nx][ny] > d[x][y] + 1)
				d[nx][ny] = d[x][y] + 1 , q.push({nx , ny});
		}
	}

	cout << res << endl;
}



















Measured memory_bytes: 13584
#include <bits/stdc++.h>
//#define cin (type == 0?cin:fin)
//#define cout (type == 0?cout:fout)
#define tcn cin.tie(0);
#define tct cout.tie(0);
#define r_0 return 0
#define ll long long
#define TIME ios_base::sync_with_stdio(0);
using namespace std;

const long long N = 2e3 + 7;
const long long MrBeast = 1e9;

ll T = 1, n, m, ans, x, cnt, a[N];
vector < ll > v, t;
int type = 0;
set< ll > st;
pair< ll ,ll > p[N];
int main()
{
    TIME
    //ifstream  fin("swap.in");
    //ofstream  fout("swap.out");
    cin >> n >> m;
    if ( n > m ){
        if ( n % m == 0 ){
            cout << n % m;
        }
        else{
            cout << abs( (n % m) - m );
        }
    }
    else{
        cnt = abs(n - m);
        cout << min(cnt , m - cnt);
    }
}


Measured memory_bytes: 256
from collections import deque


n = int(input())
lst_a = list(map(int, input().split()))
b = deque([])


for i in range(n):
    if n % 2 ==0:
        if i % 2 == 0:
            b.append(lst_a[i])
        else:
            b.appendleft(lst_a[i])
    else:
        if i % 2 == 0:
            b.appendleft(lst_a[i])
        else:
            b.append(lst_a[i])


print(*b)

Measured memory_bytes: 25528
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>
#include<math.h>
#include<set>
#include<map>

int main()
{
	char x, y;
	scanf("%c %c", &x, &y);
	if (x < y)
		printf("<\n");
	else if (x == y)
		printf("=\n");
	else
		printf(">\n");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload3(_1, _2, _3, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) for (ll i = (a); i < (n); ++i)
#define rep(...) _overload3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> inline void print(const T& x) {cout << x << "\n";}
template<typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
struct Init {Init() {cin.tie(nullptr); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} init;

int main() {
    ll h, w, n;
    cin >> h >> w >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    ll l = 0;
    vvi res(h, vi(w, 0));
    rep(i, h) {
        rep(j, w) {
            ll k;
            if (i % 2 == 0) k = w - j - 1;
            else k = j;
            if (a[l] == 0) l++;
            a[l]--;
            res[i][k] = l + 1;
        }
    }
    rep(i, h) {
        rep(j, w) {
            cout << res[i][j] << " ";
        }
        cout << "\n";
    }
}

Measured memory_bytes: 3640
n,k=[int(c) for c in input().split()]
MOD = 998244353
segs = []
for _ in range(k):
    a,b=[int(c) for c in input().split()]
    segs.append((a,b))


dp=[0 for i in range(n+5)]
dp[0] = 1

for i in range(n):
    # dp[i] = dp[i] + dp[i-1]
    if dp[i] < 0:
        dp[i]+=MOD
    for a,b in segs:
        if i+a <=n:
            dp[i+a]+=dp[i]
        if i+b+1 <= n:
            dp[i+b+1]-=dp[i]
    dp[i]%=MOD
    if i !=0:
        dp[i+1] = dp[i+1]+dp[i]

print(dp[n-1]%MOD)


Measured memory_bytes: 117932
def nCr(n,r,fac,finv):
    mod = (10**9)+7
    ans = fac[n] * (finv[r] * finv[n-r] % mod) % mod
    return ans
k = int(input())
s = input()
l = len(s)
n = l+k+1
# als = list(map(int,input().split()))
# als.sort()
ans = 0
mod = (10**9)+7
fac = [1,1]+[0]*n
finv = [1,1]+[0]*n
inv = [1,1]+[0]*n
for i in range(2,n+1):
    fac[i] = fac[i-1] * i % mod
    inv[i] = mod - inv[mod%i] * (mod//i) % mod
    finv[i] = finv[i-1] * inv[i] % mod
for i in range(k+1):
    ans += nCr(l-i+k-1,l-1,fac,finv)*pow(26,i,mod)*pow(25,k-i,mod)
    ans %= mod
print(ans)

Measured memory_bytes: 149004
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;
bool cmp(string fs,string ss){
    for(int i = 0; i < fs.length();i++){
        if(fs[i] == ss[i]){

        }else if(fs[i] < ss[i]){
            return true;
        }else{
            return false;
        }
    }
    return fs.length()-ss.length();
}


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

    int n,L;
    cin >> n >> L;
    vector<string> sl(n);

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

    sort(sl.begin(),sl.end(),cmp);

    for(int i = 0; i < sl.size();i++){
        cout << sl[i];
    }
    cout << endl;



    return 0;
}

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

int main(){
	int N;
	cin >> N;
	vector<long long> A(N + 1);
	vector<long long> B(N);
	for(int i = 0; i < N + 1; i++){
		cin >> A.at(i);
	}
	for(int i = 0; i < N; i++){
		cin >> B.at(i);
	}
	long long sum = 0;
	for(int i = 0; i < N; i++){
		long long ans = min(A.at(i) + A.at(i + 1), B.at(i));
		if(A.at(i) + A.at(i + 1) < B.at(i)){
				A.at(i + 1) = 0;
		} else {
			if(A.at(i) < B.at(i)){
				long long n = B.at(i) - A.at(i);
				A.at(i + 1) = A.at(i + 1) - n;
			}
		}
		sum += ans;
	}
	cout << sum << endl;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  int cnt_odd = 0;
  ll A;
  for(int i = 0; i < N; i++){
    cin >> A;
    if(A%2 == 1){
      cnt_odd++;
    }
  }

  if(cnt_odd%2 == 1){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }

  return 0;
}


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

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

	if (d == 25) cout << "Christmas" << endl;
	else if (d == 24) cout << "Christmas Eve" << endl;
	else if (d == 23) cout << "Christmas Eve Eve" << endl;
	else cout << "Christmas Eve Eve Eve" << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
num = list(map(int, input().split()))

while True:
  num = sorted(num)
  for j in range(N):
    min = num[j]
    if min != 0:
      break
  for i in range(j+1,N):
    num[i] -= (num[i]//min)*min

  if num[N-1] == sum(num):
    break

print(sum(num))

Measured memory_bytes: 14224
import java.util.*;

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

		int nAmount = getnc2(n);
		int mAmount = getnc2(m);

		System.out.println((nAmount + mAmount));
	}

	static int getnc2(int n) {
		return n * (n - 1) / 2;
	}
}

Measured memory_bytes: 21332
s=list(input())
count=0
if s[0]!='A':
    count+=2
for i in range(2,len(s)-1):
    if s[i]=='C':
        count+=1

if count==1:
    s.remove('A')
    s.remove('C')    
    res=''.join(s)
    print('AC' if res.islower()==True else 'WA') #str.islower():全部小文字ならTrue

else:
    print('WA')

Measured memory_bytes: 3060
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		FastScanner scn = new FastScanner(System.in);
		int count = scn.nextInt();
		int[] mochi = new int[count];
		for (int i = 0; i < count; i++) {
			 mochi[i] = scn.nextInt();
		}
		//int[] mochiSort = new int[count];
		Arrays.sort(mochi);
		int total = 0;
		int tmp = 0;
		for (int i = 0; i < mochi.length; i++) {
			if(tmp != mochi[i] ) {
				tmp = mochi[i];
				total++;
			}
		}
		System.out.println(total);

	}

}


class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 32776
import java.util.Scanner;

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

        int K = scanner.nextInt();
        String S = scanner.next();

        scanner.close();

        if (S.length() <= K) {
            System.out.println(S);
        } else {
            System.out.println(S.substring(0, K) + "...");
        }

    }
}

Measured memory_bytes: 38740
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
const int N=200005;
typedef long long ll;
using namespace std;
struct node{
    int u,v,w,nxt;
}edge[N];
int head[N],mcnt;
void add_edge(int u,int v,int w){
    mcnt++;
    edge[mcnt].u=u;
    edge[mcnt].v=v;
    edge[mcnt].w=w;
    edge[mcnt].nxt=head[u];
    head[u]=mcnt;
}
int sz[N],mx[N];
int n;
void dfs1(int u,int fa){
    sz[u]=1;
    for(int i=head[u];i;i=edge[i].nxt){
        int v=edge[i].v;
        if(v==fa)
            continue;
        dfs1(v,u);
        sz[u]+=sz[v];
        mx[u]=max(mx[u],sz[v]);
    }
    mx[u]=max(mx[u],n-sz[u]);
}
ll ans;
void dfs(int u,int fa,ll z){
    sz[u]=1;
    ans+=z;
    for(int i=head[u];i;i=edge[i].nxt){
        int v=edge[i].v;
        if(v==fa)
            continue ;
        dfs(v,u,z+edge[i].w);
        sz[u]+=sz[v];
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        int u,v,w;
        scanf("%d%d%d",&u,&v,&w);
        add_edge(u,v,w);
        add_edge(v,u,w);
    }
    dfs1(1,1);
    int g;
    for(int i=1;i<=n;i++)
        if(mx[i]<=n/2)
            g=i;
    dfs(g,0,0);
    ll mn=1e18;
    for(int i=head[g];i;i=edge[i].nxt){
        if(sz[edge[i].v]==(n+1)/2){
            mn=edge[i].w;
            break;
        }
        else
            mn=min(mn,1ll*edge[i].w);
    }
    printf("%lld\n",ans*2-mn);
}


Measured memory_bytes: 8704