akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int> vi;
const int mod = 1000000007;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,y,total=0;
    cin>>n>>y;
    if(y%10000==0 && y/10000 ==n){
        cout<<y/10000<<" "<<0<<" "<<0;
        return 0;
    }
    for(int i = 0; 10000*i <=y && i<=n;i++){
        total = 10000*i;
        int cpy2 = total;
        for(int j =0;10000*i + 5000*j <=y && i+j <=n;j++){
            total+=5000*j;
            int cpy1 = total;
            for(int k =0;10000*i + 5000*j + 1000*k <=y && i+j+k<=n;k++){
                total+=1000*k;
                if(total==y && i+j+k==n){
                    cout<<i<<" "<<j<<" "<<k<<endl;
                    return 0;
                }
                total = cpy1;
            }
            total=cpy2;
        }
    }
    cout<<"-1 -1 -1"<<endl;













}







Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int D = sc.nextInt();
      int E = 25 - D;
      String F = "Christmas";
      String G = " Eve";
      for(int i=0;i<E;i++){
        F = F+G;
      }
      System.out.println(F);
    }
}

Measured memory_bytes: 39084
import math
n, d = map(int, input().split())

pos=[]
for _ in range(n):
  pos.append(
    list(map(int, input().split()))
  )

ans=0
for i in range(n):
  for j in range(i + 1, n):
    temp = 0
    for xi,xj in zip(pos[i], pos[j]):
      temp+=(xi-xj)**2
    if int(math.sqrt(temp)) ** 2 == temp:
      ans+=1
      
print(ans)

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



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

    vector<long long> t(n);
    vector<long long> x(n);
    vector<long long> y(n);

    for(int i=0;i<n;i++){
        cin>>t.at(i)>>x.at(i)>>y.at(i);
    }

    long long pt=0,px=0,py=0;
    long long dt,dx,dy,dist;
    int ra,rb,jud=0;


    for(int i=0;i<n;i++){
        dt = t.at(i) - pt;
        dx = abs(x.at(i) - px);
        dy = abs(y.at(i) - py);

        dist = dx + dy;

        if(dist<=dt){
            ra = dist%2;
            rb = dt%2;
            if(ra!=rb){
                jud=1;
            }
            pt = t.at(i);
            px = x.at(i);
            py = y.at(i);
        }else{
            jud=1;
        }
        if(jud==1){
            cout<<"No"<<endl;
            break;
        }


    }
    if(jud==0){
        cout<<"Yes"<<endl;
    }
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

map<int, int> prime_factor(int n) {
    map<int, int> res;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    map<int, int> pf = prime_factor(m);
    
    vector<ll> f(n + 100), fi(n + 100);
    f[0] = 1;
    for (int i = 1; i < n + 100; i++) {
        f[i] = f[i - 1] * i % MOD;
    }
    fi[n + 99] = modpow(f[n + 99], MOD - 2);
    for (int i = n + 99; i > 0; i--) {
        fi[i - 1] = fi[i] * i % MOD;
    }

    ll ans = 1;
    for (auto& p : pf) {
        (ans *= f[n + p.second - 1] * fi[p.second] % MOD * fi[n - 1] % MOD) %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
h,w = map(int,input().split())
n = int(input())
L = list(map(int,input().split()))

li = []
for i in range(n):
    for j in range(L[i]):
        li.append((i+1))
#print(L,li)
l = h*w-len(li)
li = li + [0]*l
ans = []
for i in range(h):
    ans.append(li[i*w:(i+1)*w])

for i in range(h-1):
    if ans[i][-1] == ans[i+1][0]:
        ans[i+1] = ans[i+1][::-1]
#print(ans)
for i in range(h):
    print(*ans[i])

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

int main(){

	int n;
	std::cin >> n;

	for (int i = 0; i < n; i++){
		int x, y, b, p;

		std::cin >> x >> y >> b >> p;

		std::cout << std::min(x*b + y*p, (int)((x*std::max(b, 5) + y*std::max(p, 2))*0.8)) << std::endl;

	}

	return 0;
}

Measured memory_bytes: 1164
#include <cstdio>

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

	int t=25-d;
	printf("Christmas ");

	for(int i=0;i<t;i++){
		printf("Eve");
		if(i==t-1) printf("\n");
		else printf(" ");
	}

	return 0;
}


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

int main(){
    int A,B,a,b,ans;
    ans=0;
    scanf("%d%d",&A,&B);

    for (int i=A;i<=B;i++){
        a = i%100;
        b = i/1000;
        if (i%10 == 0){
            continue;

        }if ((a+b)%11 == 0 && (a-b)%9 ==0){
                ans++;
            }
        A++;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String[] b = a.split("");
		List<String> word = new ArrayList<String>();
		List<String> rev_word = new ArrayList<String>();

		for(int s=0;s<b.length;s++) {
			word.add(b[s]);
			rev_word.add(b[s]);
		}
		Collections.reverse(rev_word);
		int count=0;
		for(int i=0;i<word.size();i++) {
			if(!word.get(i).equals(rev_word.get(i))) count++;
		}
		System.out.println(count/2);
	}
}

Measured memory_bytes: 23764
#include<stdio.h>
int i = 0; char list[26];
 
int check(char s){
  int j;
  for (j = 0; j < i; j++){
    if(list[j] == s){
      return j;
    }
  }
  list[i++] = s;
  return i - 1;
}
 
int main(){
  char w[101];
  int len = 0, flag = 1, count[26] = {0}, j;
  scanf("%s", w);
  while(w[len]){
    count[check(w[len])]++;
    len++;
  }
  
  for (j = 0; j < i; j++){
    if(count[j]%2 == 1){
      flag = 0;
      break;
    }
  }
  
  if(flag == 1){
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#define MOD 1000000007
#define MAX_N 100000
#define INF 100000

#define ll long long
#define forall(i,a,b) for(int i = a; i < b; ++i)
#define sd(s) scanf("%d", &s)
#define sc(s) scanf("%c", &s)
#define sll(s) scanf("%lld", &s)
#define mp(a,b) make_pair(a,b)

using namespace std;

struct edge {
	int u;
	int v;
	int cost;

	// Decending Order 
	bool operator<(const edge& r) const {
		return cost > r.cost;
	}
};

int N;
vector <ll> Arr;
int main() {
	int c;
	sd(N);
	forall(i, 0, N) {
		sd(c);
		Arr.push_back(c);
	}
	sort(Arr.begin(), Arr.end());

	int i = N - 1;
	while (i > 0) {
		if (Arr[i] == Arr[i - 1]) break;
		--i;
	}

	int j = i - 2;
	while (j > 0) {
		if (Arr[j] == Arr[j - 1]) break;
		--j;
	}

	if (j > 0) cout << Arr[i] * Arr[j];
	else cout << 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>

using namespace std;

int main()
{
    int n, k;
    long long int cnt0 = 0, cntk = 0;
    long long int ans = 0;

    cin >> n >> k;

    for (int i = 1; i <= n; i++) {
        if (i % k == 0) {
            cnt0++;
        }
        if (i % k == k/2) {
            cntk++;
        }
    }

    ans += cnt0 * cnt0 * cnt0;

    if (!(k%2)) {
        ans += cntk * cntk * cntk;
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a,b,c;
    long d=1000000,e=-1000000,f=0;
    scanf("%d",&a);
    for(b=0;b<a;b++){
        scanf("%d",&c);
        if(d>c){
            d=c;
        }
        if(e<c){
            e=c;
        }
        f+=c;
    }
    printf("%ld %ld %ld\n",d,e,f);
    return 0;
}



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

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

    int sum = 0;
   for(int i=1; i<=K; i++){     //gcd(i,j,k)
       for(int j=1;j<=K; j++){
           for(int l=1; l<=K; l++){
            int s=gcd(i,j);
             sum += gcd(s,l);
        
           }
        }

   }
   cout << sum;
}

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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	
	static int n;
	static long x, ans;
	static long thick[], pnum[];
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		n = fs.nextInt();
		x = fs.nextLong();

		thick = new long[51];
		thick[0] = 1;
		for(int i=0;i<50;i++) {
			thick[i+1] = 2 * thick[i] + 3;
		}
		
		pnum = new long[51];
		pnum[0] = 1;
		for(int i=0;i<50;i++) {
			pnum[i+1] = 2 * pnum[i] + 1;
		}
	
		dfs(x, n);
		System.out.println(ans);
	}
	static void dfs(long x, int l) {
		if(x == 1) {
			if(l==0)ans++;
			return;
		}
		if(x == thick[l]) {
			ans += pnum[l];
			return;
		}
		if(x >= (thick[l]+1)/2) {
			ans += pnum[l-1]; 
			ans += 1;
			if(x == (thick[l]+1)/2) return;
			dfs(x- (thick[l]+1)/2, l-1);
		}
		else {
			dfs(x-1, l-1);
		}
	}
}

//高速なScanner
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 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: 21204
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

public class Main{
	static Scanner s=new Scanner(System.in);
	static long[] fal_rnd(int size){
		AtomicInteger l=new AtomicInteger(-1),r=new AtomicInteger(size);
		long[] res=new long[size];
		INS(size).unordered().parallel().mapToLong(Long::parseLong).forEach(v->res[ThreadLocalRandom.current().nextBoolean()?l.incrementAndGet():r.decrementAndGet()]=v);
		return res;
	}
	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}
	static Stream<String> INS(long size){
		return StreamSupport.stream(Spliterators.spliterator(s,size,Spliterator.NONNULL&Spliterator.IMMUTABLE),false).limit(size);
	}
	
	public static void main(String[] __){
		while(true){
			final String in=s.nextLine();
			if(in.equals(".")) break;
			System.out.println(solve(in));
		}
	}
	static String solve(String v){
		v=v.replaceAll("[^\\[\\]()]","");
		ArrayDeque<Character> deque=new ArrayDeque<>();
		char c;
		for(int i=0;i<v.length();i++){
			switch(c=v.charAt(i)){
			case '[':
			case '(':
				deque.add(c);
				break;
			case ']':
				if(deque.isEmpty()||deque.pollLast()!='[')
					return "no";
				break;
			case ')':
				if(deque.isEmpty()||deque.pollLast()!='(')
					return "no";
				break;
			}
		}
		return deque.isEmpty()?"yes":"no";
	}
}

Measured memory_bytes: 54708
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskD {
        private final int mod = 1_000_000_007;
        private long[] fact;

        public void solve(int testNumber, InputReader in, PrintWriter out) {

            int n = in.nextInt();
            int[] a = new int[n + 2];
            int[] cnt = new int[n + 1];

            int sz = 0;

            for (int i = 1; i <= n + 1; ++i) {
                a[i] = in.nextInt();
                if (cnt[a[i]] != 0) {
                    sz = i - cnt[a[i]] + 1;
                }
                cnt[a[i]] = i;
            }

            fact = new long[n + 2];

            fact[0] = 1L;

            for (int i = 1; i <= n + 1; ++i) {
                fact[i] = (fact[i - 1] * i) % mod;
            }

            for (int i = 1; i <= n + 1; ++i) {
                long ans = ncr(n + 1, i);
                if ((n + 1 - sz) >= (i - 1)) {
                    ans -= ncr((n + 1 - sz), i - 1);
                    ans += mod;
                    ans %= mod;
                }
                out.println(ans);
            }

        }

        private long ncr(int n, int r) {

            if (n < r)
                return 0;
            if (r == 0)
                return 1;
            if (r == 1)
                return n;

            return fact[n] * bin_pow(fact[r] * fact[n - r], mod - 2) % mod;

        }

        private long bin_pow(long base, int exp) {

            long ans = 1L;

            while (exp != 0) {
                if (exp % 2 != 0) ans = ans * base % mod;
                exp >>= 1;
                base %= mod;
                base = base * base % mod;
            }

            return ans;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(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: 42996
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args)
	{
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);
 
 		int x =fr.nextInt() ,y =fr.nextInt() ,a =fr.nextInt() ,b =fr.nextInt() ,c =fr.nextInt() ,n =a+b+c ,i ,j ;
 		long d[][] =new long[a+b+c][2] ,sm =0l ;
 		for (i =0 ; i<a ; ++i) {
 			d[i][0] =fr.nextLong() ;	d[i][1] =0 ;
 		}
 		for ( ; i<a+b ; ++i) {
 			d[i][0] =fr.nextLong() ;	d[i][1] =1 ;
 		}
 		for ( ; i<a+b+c ; ++i) {
 			d[i][0] =fr.nextLong() ;	d[i][1] =2 ;
 		}
 		sort (d , 0 , n-1) ;	a =b =c =0 ;	i =n-1 ;	j =x+y ;
 		while (j-->0) {
 			if (d[i][1]==0)	{
 				++a ;
 				if (a<=x)	sm += d[i][0] ;
 			}
 			else if (d[i][1]==1) {
 				++b ;
 				if (b<=y)	sm += d[i][0] ;
 			}
 			else {
 				++c ;	sm += d[i][0] ;
 			}
 			--i ;
 		}
 		if (a>x) {
 			b += c ;
 			for ( ; i>-1 ; --i) {
 				if (d[i][1]!=0) {
 					++b ;	sm += d[i][0] ;
 				}
 				if (b==y)	break;
 			}
 		}
 		else if (b>y) {
 			a += c ;
 			for ( ; i>-1 ; --i) {
 				if (d[i][1]!=1) {
 					++a ;	sm += d[i][0] ;
 				}
 				if (a==x)	break;
 			}
 		}
		op.println(sm) ;	op.flush();	op.close();
	}
	public static void sort(long[][] arr , int l , int u)
	{
		int m ;
 
		if(l < u){
			m =(l + u)/2 ;
 
			sort(arr , l , m);	sort(arr , m + 1 , u);
 
			merge(arr , l , m , u);
		}
	} 
	public static void merge(long[][]arr , int l , int m , int u)
	{
		long[][] low = new long[m - l + 1][2];
 
		long[][] upr = new long[u - m][2];
 
		int i ,j =0 ,k =0 ;
 
		for(i =l;i<=m;i++){
			low[i - l][0] =arr[i][0];
			low[i - l][1] =arr[i][1];
		}
 
		for(i =m + 1;i<=u;i++){
			upr[i - m - 1][0] =arr[i][0];
			upr[i - m - 1][1] =arr[i][1];
		}
 
		i =l;
 
		while((j < low.length) && (k < upr.length))
		{
			if(low[j][0] < upr[k][0])
			{
				arr[i][0] =low[j][0];
				arr[i++][1] =low[j++][1];
			}
			else
			{
				arr[i][0] =upr[k][0];
				arr[i++][1] =upr[k++][1];
			
			}
		}
 
		while(j < low.length)
		{
			arr[i][0] =low[j][0];
			arr[i++][1] =low[j++][1];
		}
 
		while(k < upr.length)
		{
			arr[i][0] =upr[k][0];
			arr[i++][1] =upr[k++][1];
		}
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br =new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st==null || (!st.hasMoreElements())) 
			{
				try
				{
					st =new StringTokenizer(br.readLine());
				}
				catch(IOException e)
				{
					e.printStackTrace();
				}
				
			}
			return st.nextToken();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

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

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

Measured memory_bytes: 118616
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll N, K, Q;
  cin >> N >> K >> Q;
  vec<ll> A(Q);
  REP(i, Q) cin >> A[i];

  vec<ll> x(N, K - Q);
  REP(i, Q) x[A[i] - 1]++;
  REP(i, N) cout << (x[i] > 0 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 4760
from itertools import combinations

n, k = map(int, input().split())
a = list(map(int, input().split()))

cnt_in_one = 0
cnt_in_two = 0

for ai, aj in combinations(a, 2):
    if ai > aj:
        cnt_in_one += 1
    if ai < aj:
        cnt_in_two += 1
       
mod = 10 ** 9 + 7
print((cnt_in_one * (k + k * (k - 1) // 2) + cnt_in_two * k * (k - 1) // 2) % mod)

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


int main() {
    int s;
    cin>>s;
    vector<int> F(s+1, 0);
    for(int i = 3; i <= s; ++i) {
        F[i] = 1;
    }
    int mod = 1e9 + 7;
    for(int i = 1; i <= s; ++i) {
        for(int j = 0; j < i; ++j) {
            if (j >= 3 && i - j >= 3) {
                F[i] = (F[i] + F[j]) % mod;
            }
        }
    }
    cout<<F[s]<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define repi(i,a,n) for(int i = (int)a; i < (int)(n); i++)

typedef long long ll;

int main(void){
    int a;
    std::cin >> a ;
    
    std::cout << a*a << std::endl;
}

Measured memory_bytes: 256
use io::*;
use std::collections::HashSet;

fn main() {
    let input = read_string();
    let mut sc = Scanner::new(&input);
    let n: usize = sc.next();
    let mut ws: HashSet<Vec<char>> = HashSet::new();
    let w0 = sc.next_vec_char();
    let mut prev = *w0.last().unwrap();
    ws.insert(w0);
    for i in 1..n {
        let w = sc.next_vec_char();
        if ws.contains(&w) || w[0] != prev {
            println!("No");
            return;
        }
        prev = *w.last().unwrap();
        ws.insert(w);
    }
    println!("Yes");
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }

        pub fn next_mat<T: FromStr>(&mut self, w: usize, h: usize) -> Vec<Vec<T>> {
            (0..h).map(|_| self.next_vec(w)).collect()
        }

        pub fn next_vec_char(&mut self) -> Vec<char> {
            self.next::<String>().chars().collect()
        }

        pub fn next_mat_char(&mut self, n: usize) -> Vec<Vec<char>> {
            (0..n).map(|_| self.next_vec_char()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 4352
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    alice = 0
    bob = 0

    a.sort(reverse=True)

    for i in range(n):
        if i % 2 == 0:
            alice += a[i]
        else:
            bob += a[i]

    print(alice-bob)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int A, B;
int C[110][110];

void solve() {
	cin >> A >> B;
	cout << 100 << " " << 100 << "\n";
	rep(i, 0, 100) {
		rep(j, 0, 50) {
			C[i][j] = 1;
		}
	}
	A--;
	B--;
	if(B > 0) { 
	for(int i = 1; i < 99; i += +2) {
		for(int j = 1; j < 49; j += 2) {
			C[i][j] = 0;
			B--;
			if(B == 0) break;
		}
		if(B == 0) break;
	}
	}
	if(A > 0) {
	for(int i = 1; i < 99; i += 2) {
		for(int j = 51; j < 99; j += 2) {
			C[i][j] = 1;
			A--;
			if(A == 0) break;
		}
		if(A == 0) break;
	}
	}
	rep(i, 0, 100) {
		rep(j, 0, 100) {
			if(C[i][j]) cout << '.';
			else cout << "#";
		}
		cout << "\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    total = sum(A)
    ans = INF
    s = 0
    for a in A[:-1]:
        s += a
        if ans > abs(total - 2 * s):
            ans = abs(total - 2 * s)

    print(ans)
    return


if __name__ == '__main__':
    main()


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

#define all(x) (x).begin(), (x).end()
#define li long long
#define itn int

using namespace std;

inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

int main(){

	cin.sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	vector<string> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];

	cout.sync_with_stdio(0);
	for (int _ = 0; _ < 2; _++){
		if (_)
			cout << "\n";
		for (int i = 0; i < n; i++){
			string tmp = "";
			if (_ == 0)
				tmp += "#";
			else
				tmp += ".";
			for (int j = 1; j < m - 1; j++){
				if (i % 2 == _)
					tmp += "#";
				else
					tmp += a[i][j];
			}
			if (_ == 1)
				tmp += "#";
			else
				tmp += ".";
			cout << tmp << "\n";
		}
	}

	return 0;
}


Measured memory_bytes: 1024
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn can_make(n: i32, v: &Vec<i32>) -> bool {
    let mut keta = Vec::new();
    let mut tn = n;
    while 0 < tn {
        keta.push(tn % 10);
        tn /= 10;
    }

    'outer: for i in keta.iter() {
        for j in v.iter() {
            if *i == *j {
                continue 'outer;
            }
        }
        return false;
    }
    true
}
fn main() {
    let (n, _k) = get!(i32, i32);
    let v = get!([i32]);
    let mut like = Vec::new();
    let mut ptr = 0;
    for i in 0..10 {
        if v[ptr] != i {
            like.push(i);
        } else {
            if ptr < v.len() - 1 {
                ptr += 1;
            }
        }
    }
    //eprintln!("like {:?}", like);
    let mut ans = n;
    loop {
        if can_make(ans, &like) {
            break;
        }
        ans += 1;
    }
    println!("{}", ans);
}


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

if 400 <= n <= 599:
    print(8)
if 600 <= n <= 799:
    print(7)
if 800 <= n <= 999:
    print(6)
if 1000 <= n <= 1199:
    print(5)
if 1200 <= n <= 1399:
    print(4)
if 1400 <= n <= 1599:
    print(3)
if 1600 <= n <= 1799:
    print(2)
if 1800 <= n <= 1999:
    print(1)

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


int main(){
    int n;
    cin>>n;
    int arr[10][10]={0};
        
    for (int i = 1; i <= n; i++)
    {
        string s=to_string(i);
        //cout << s.back() << s << endl;
        arr[s[0] - '0'][s.back() - '0']++;
    }
    long long int ans = 0;
    for(int i=0;i< 10;i++){
        for (int j = 0; j < 10; j++)
        {
            ans += arr[i][j] * arr[j][i];
        }        
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{
    public void Proc()
    {
        int age = int.Parse(Reader.ReadLine());
        string ans = "Hello World";
        if (age == 2) {
            int num1 = int.Parse(Reader.ReadLine());
            int num2 = int.Parse(Reader.ReadLine());
            ans = (num1 + num2).ToString();
        }
        Console.WriteLine(ans);



    }




    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"






";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 11092
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int M = sc.nextInt();

		int[] seq = new int[N];
		int[] run = new int[M];

		for (int i = 0; i < seq.length; i++) {
			seq[i] = sc.nextInt();
		}

		for (int i = 0; i < run.length; i++) {
			run[i] = sc.nextInt();
		}
		sc.close();

		int zero = swap(seq.clone(), run, 0);
		int one = swap(seq.clone(), run, 1);
		System.out.println(Math.min(zero, one));

	}

	static int swap(int[] clone, int[] run, int now) {
		int swapNum = 0;
		int k = 0;
		for (int i = 0; i < run.length; i++) {
			for (int j = 0; j < run[i]; j++) {
				if (clone[k] != now) {
					if (k == clone.length - 1) {
						return Integer.MAX_VALUE;
					}
					for (int l = k + 1; l < clone.length; l++) {
						if (clone[l] == now) {
							int tmp = clone[l];
							clone[l] = clone[k];
							clone[k] = tmp;

							swapNum += l - k;
							break;
						}
						if (l == clone.length - 1) {
							return Integer.MAX_VALUE;
						}
					}
				}

				k++;
			}
			now = (now + 1) % 2;
		}
		return swapNum;
	}
}

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

int main() {
    ll A,B,C,K; cin >> A >> B >> C >> K;
    if(K<=A) cout << K << endl;
    else if(K <=A+B) cout << A << endl;
    else cout << A-(K-A-B) << endl; 
}


Measured memory_bytes: 3560
#include <iostream>

#define u unsigned
#define ll long long
#define ull u ll
#define REP( i, a, b) for (int i = (a); i < (b); i++)
#define REPR( i, a, b) for (int i = (a-1); i >= (b); i--)

using namespace std;

u int solution(u int X);

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

    u int X;
    cin >> X;

    cout << solution(X) << "\n";

    return 0;
}

u int solution(u int X)
{
    ull int res = (X / 500) * 1000;
    X %= 500;
    res += (X / 5) * 5;

    return res;
}

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

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

if(x>=y){
while(x%y!=0){
  tmp = x%y;
  x = y;
  y = tmp;
}
cout << y << endl;
}
 else if(x<=y){
while(y%x!=0){
  tmp = y%x;
  y = x;
  x = tmp;
}
cout << x << endl;
}
}



Measured memory_bytes: 3100
"use strict";

const main = arg => {
    const inputList = arg.trim().split("\n");
    // 回答を記述
    const K = parseInt(inputList[0]);
    const A = parseInt(inputList[1].split(" ")[0])
    const B = parseInt(inputList[1].split(" ")[1])
    if (A % K == 0) {
        console.log("OK");
    } else {
        let i = 0;
        i = Math.floor(A / K) + 1;
        if (K * i <= B) {
            console.log("OK");
        } else {
            console.log("NG");
        }
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29632
#include<cstring>
#include<cstdio>
int a[107],sum[107]={0};
int main ()
{
    int n,mmin=1e9;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        sum[i]=sum[i-1]+a[i];
    }
    for(int i=1;i<=n;i++)
    {
        int k;
        k=sum[n]-2*sum[i];
        if(k<0) k*=-1;
        if(k<mmin)
            mmin=k;
    }
    printf("%d\n",mmin);
    return 0;
}


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

const int INF=0x3f3f3f3f;

int dp[2000000][2];

int main(){
	string s;cin>>s;
	memset(dp,0x3f,sizeof(dp));
	s="0"+s;
	dp[s.size()][0]=0;
	for(int i=s.size();i>0;i--)rep(j,2){
		if(dp[i][j]==INF)continue;
		for(int k=0;k<=9;k++){
			int x=k-(int)(s[i-1]-'0')-j;
			bool b=0;
			if(x<0)b=1,x+=10;
			dp[i-1][b]=min(dp[i-1][b],dp[i][j]+k+x);
		}
	}
	cout<<dp[0][0]<<endl;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int x, a, b;
    cin >> x >> a >> b;

    cout << max(0, x - a - (x - a) / b * b) << '\n';
    return 0;
}


Measured memory_bytes: 3628
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

ll H;
ll solve(ll h){
	if(h == 1) return 1;
	return solve(h/2)*2+1;
}
signed main(){
	cin >> H;
	cout << solve(H) << endl;
}

Measured memory_bytes: 256
import math
           
def koch(n, x1, y1, x2, y2):
  if n == 0:
    return
  
  theta60 = math.radians(60)
          
  sx = ( 2 * x1 + x2 ) /3
  sy = ( 2 * y1 + y2 ) /3
  tx = ( 2 * x2 + x1 ) /3
  ty = ( 2 * y2 + y1 ) /3
  ux = ( tx - sx ) * math.cos( theta60 ) - ( ty - sy ) * math.sin( theta60 ) + sx
  uy = ( tx - sx ) * math.sin( theta60 ) + ( ty - sy ) * math.cos( theta60 ) + sy
           
  koch(n-1, x1, y1, sx, sy)
  print sx, sy
  koch(n-1, sx, sy, ux, uy)
  print ux, uy
  koch(n-1, ux, uy, tx, ty)
  print tx, ty
  koch(n-1, tx, ty, x2, y2)
    
n = input()
           
p1x = float(0.)
p1y = float(0.)
p2x = float(100.)
p2y = float(0.)
           
print p1x, p1y
koch(n, p1x, p1y, p2x, p2y)
print p2x, p2y

Measured memory_bytes: 6716
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a, Ts... ts) {return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

// gcd: 最大公約数, lcm: 最小公倍数
template<typename T>
T euclidean(T a, T b){
    if(a < b) swap(a, b);
    T r = a % b;
    while(r != 0){
        a = b; b = r; r = a % b;
    }
    return b;
}
template<typename T>
T gcd(T a, T b){
    return euclidean(a, b);
}
template<typename T>
T lcm(T a, T b){
    T g = gcd(a, b);
    return a / g * b;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    LL a, b, c, d;
    cin >> a >> b >> c >> d;
    LL e = lcm(c, d);

    LL cc = (b / c) * (c - 1) + b % c;
    cc -= ((a-1) / c) * (c - 1) + (a-1) % c;
    LL dd = (b / d) * (d - 1) + b % d;
    dd -= ((a-1) / d) * (d - 1) + (a-1) % d;
    LL ee = (b / e) * (e - 1) + b % e;
    ee -= ((a-1) / e) * (e - 1) + (a-1) % e;

    cout << cc+dd-ee << endl;
}

Measured memory_bytes: 256
#include <map>
    #include <set>
    #include <cmath>
    #include <queue>
    #include <stack>
    #include <cstdio>
    #include <string>
    #include <vector>
    #include <cstdlib>
    #include <cstring>
    #include <sstream>
    #include <iostream>
    #include <algorithm>
    #include <functional>
    using namespace std;
    #define MX 100000
    #define ll long long
    bool cmd(ll a,ll b){
    	return a>b;
    }
    int main(){
    	ll	 N,A[110000];
    	cin>>N;
    	for(int i=0;i<N;i++){
    		scanf("%d",&A[i]);
    	}
    	sort(A,A+N,cmd);
    	int flag=0;
    	int n=0;
    	ll tp1,tp2,sum;
    	for(int i=0;i<N;i++){
    		if(A[i]==A[i+1])
    		{
    			i++;
    			n++;
    			if(n==1)
    			tp1=A[i];
    			else{
    				sum=tp1*A[i];
    				cout<<sum;
    				return 0;
    			}
    		}
    	}
    	cout<<"0";
    	return 0;
    }

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    int a, b;
    scanf("%d %d", &a, &b);
    if(a > b){
        printf("a > b\n");
    }else if(a < b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

// static int mi[100000];
// static ll ms[100000];

int main(){
	ll n;
	int x, m;
	cin>>n>>x>>m;

	vector<ll> mi(m, -1);
	vector<ll> ms(m);
	// rep(i, m) mi[i]= -1;

	ms[x]=x;
	mi[x]=1;
	int c=x;
	ll s=x;
	bool skipped=false;
	for(ll i=2; i<=n; i++){
		c=(ll)c*c%m;
		s+=c;
		if(mi[c]!= -1){
			if(!skipped){
				ll len=i-mi[c];
				ll ds= s-ms[c];
				ll b=(n-i)/len;
				s+= ds*b;
				i+= b*len;
				skipped=true;
			}
		}
		else{
			mi[c]=i;
			ms[c]=s;
		}
	}

	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 4836
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		String[] Sarray = S.split("");

//		for (int i = 0; i < 3; i++) {
//			Sarray[i] = S.charAt(i);
//		}


		int count = 0;
		if(!(Sarray[0].equals("R")) && !(Sarray[1].equals("R")) && !(Sarray[2].equals("R"))){
			count = 0;
			System.out.println(count);
			return;
		}
		if(Sarray[0].equals("R") && Sarray[1].equals("R") && Sarray[2].equals("R")){
			count = 3;
			System.out.println(count);
			return;
		}
		if(Sarray[0].equals("R") && Sarray[1].equals("R")){
			count = 2;
			System.out.println(count);
			return;
		}
		if(Sarray[1].equals("R") && Sarray[2].equals("R")){
			count = 2;
			System.out.println(count);
			return;
		}

		if(Sarray[0].equals("R")){
			count = 1;
			System.out.println(count);
			return;
		}
		if(Sarray[1].equals("R")){
			count = 1;
			System.out.println(count);
			return;
		}
		if(Sarray[2].equals("R")){
			count = 1;
			System.out.println(count);
			return;
		}



		System.out.println(count);
	}

}


Measured memory_bytes: 35476
l=input().split()
L,R=int(l[0]),int(l[1])
a=0
if R-L<2019:
    a=2018
    for i in range(L,R):
        n=i%2019
        m=(i+1)%2019
        s=(n*m)%2019
        if s<a:
            a=s
        for j in range(R-i-1):
            s+=n
            s=s%2019
            if s<a:
                a=s   
print(a)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll power(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)

//your code here!

int main(void){
    ll N, M, a[200100]={0}, b[200100]={0}, S, G;
    scanf("%lld %lld", &N, &M);
    rep(i, M) {
        scanf("%lld %lld", &S, &G);
        if(1==S) a[i] = G;
        if(N==G) b[S]++;
    }
    rep(i, M) if(a[i] && b[a[i]]) {
        puts("POSSIBLE");
        return 0;
    }
    puts("IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 3328
import sys

a, b, c, k = map(int, input().split())

ans = 0
tmp = k
if a < k:
    ans += a
    tmp -= a
else:
    ans += k
    print(ans)
    sys.exit()

if b < tmp:
    tmp -= b
else:
    print(ans)
    sys.exit()

if c < tmp:
    ans -= c
else:
    ans -= tmp
print(ans)

Measured memory_bytes: 9116
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

int main() 
{
    FAST;
    ll n;
    cin>>n;
    ll a[n],b[n];
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i];
    sort(a,a+n);
    sort(b,b+n);
    if(n%2==1)
        cout<<(b[n/2]-a[n/2])+1;
    else
        cout<<(b[(n/2)]+b[(n/2)-1])-(a[(n/2)]+a[(n/2)-1])+1;
    subt;
    return 0;
}

Measured memory_bytes: 6956
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>

#define INF 100000
using namespace std;
typedef long long ll;

const int org=5000;
int main(){
	int dp[10000];
	int n, ma, mb;
	for (int i = 0; i < 10000; i++) {
		dp[i] = INF;
	}
	cin >> n >> ma >> mb;
	for (int i = 0; i < n; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		int temp = mb * a - ma * b;
		if (temp > 0) {
			for (int j = 10000- 1; j >= 0; j--) {
				if (dp[j] != INF) {
					dp[j + temp] = min(dp[j + temp], dp[j] + c);
				}
			}
			dp[temp+org] = min(dp[temp+org], c);
		}
		else {
			for (int j = 0; j < 10000; j++) {
				if (dp[j] != INF) {
					dp[j + temp] = min(dp[j + temp], dp[j] + c);
				}
			}
			dp[temp+org] = min(dp[temp+org], c);
		}

	}
	if (dp[org] == INF) {
		cout << "-1" << endl;
	}
	else {
		cout << dp[org] << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/








int N, H[20];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> H[i];

	int ans = 0;
	int ma = -1;
	rep(i, 0, N) {
		if (ma <= H[i]) ans++;
		chmax(ma, H[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#define MAX_N 10000
#define MAX_M 6
using namespace std;

string dp[MAX_M+1][MAX_N+1];
int nums[] = { 0,2,5,5,4,5,6,3,7,6 };

int comp(const string &s1, const string &s2) {
  return s1.size() == s2.size() ? s1 < s2 : s1.size() < s2.size();
}

int main() {
  int N,M; cin >> N >> M;
  vector<int> A(M);
  for (int i=0; i<M; ++i) cin >> A[i];
  
  map<int,int> m;
  for (int i=0; i<M; i++) {
    m[nums[A[i]]] = (m.count(nums[A[i]]) == 1) ? max(m[nums[A[i]]],A[i]) : A[i];
  }

  for (int i=0; i<=MAX_M; ++i) for (int j=0; j<=MAX_N; ++j) dp[i][j] = "\0";
  int i = 0;
  for (const auto& e : m) { dp[i+1][e.first] = to_string(e.second); i++; }

  i = 0;
  for (const auto& e : m) {
    int key = e.first;
    string value = to_string(e.second);
    for (int j=1; j<=N; ++j) {
      dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
      if (j >= key) {
	if (dp[i][j-key] != "\0") {
	  dp[i+1][j] = max({dp[i+1][j], dp[i][j-key] + value, value + dp[i][j-key]},comp);
	}
	if (dp[i+1][j-key] != "\0") {
	  dp[i+1][j] = max({dp[i+1][j], dp[i+1][j-key] + value, value + dp[i+1][j-key]},comp);
	}
      }
    }
    i++;
  }

  cout << dp[m.size()][N] << endl;
}


Measured memory_bytes: 39296
N,M=map(int,input().split())
graph=[]
def find(x):
  if par[x]==x:
    return x
  else:
    par[x]=find(par[x])
    return par[x]
def union(a,b):
  x=find(a)
  y=find(b)
  if x!=y:
    if size[x]<size[y]:
      par[x]=par[y]
      size[y]+=size[x]
    else: 
      par[y]=par[x]
      size[x]+=size[y]
  else:
    return
for i in range(M):
  a,b=map(int,input().split())
  graph.append((a-1,b-1))
bridge=0
from collections import Counter
for i in range(M):
  par=[i for i in range(N)]
  size=[1 for i in range(N)] 
  for j in range(M):
    if j!=i:
      union(graph[j][0],graph[j][1])
  if N not in size:
    bridge+=1
print(bridge)

Measured memory_bytes: 73884
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,j,x;
    string a,b,k;
    cin>>n>>m;
    pair<ll,ll>arr[m];
    ll ans[m];
    vector<pair<ll,ll> >vect[n];
    for(ll i=0;i<m;i++){
        cin>>arr[i].first>>arr[i].second;
        vect[arr[i].first-1].push_back({arr[i].second,i});
    }
    for(ll i=0;i<n;i++){
        sort(vect[i].begin(),vect[i].end()),j=1;
        for(auto x:vect[i])ans[x.second]=j++;
    }
    for(ll i=0;i<m;i++){
        a=to_string(arr[i].first),b=to_string(ans[i]);
        x=6-(ll)a.length(),k="";
        for(ll j=0;j<x;j++)k+="0";
        k+=a,a=k;
        x=6-(ll)b.length(),k="";
        for(ll j=0;j<x;j++)k+="0";
        k+=b,b=k,a+=b;
        cout<<a<<'\n';
    }
    return 0;
}


Measured memory_bytes: 9344
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n,x,t;
  	cin>>n>>x>>t;
  	long long count=0;
  	if(n%x==0){
      count=count+(n/x);
    }
  else{
    count=count+(n/x)+1;
  }
  cout<<count*t<<endl;
}

Measured memory_bytes: 3580