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

bool is_prime(int k)
{
	for(int j=2;j*j<=k;j++){
		if(k%j==0) {
			return false;
		}
	}
    return true;
}


int main()
{
    stringstream ss;
    // 入力
    string s;
    int K;
    cin>>s>>K;

    string ans="zzzzz";

    int ss_found=0;
    string found_ss[5];
    for(int i=0;i<5;i++){
    	found_ss[i]="zzzzzz";
    }

	for(int k=0;k<K;k++){
		for(int i=1;i<=5;i++){
			if(i>s.size()) break;
		    for(int j=0;j<s.size()-i+1;j++){
		    	if(k==0){
		    		if(found_ss[0]>s.substr(j,i)) found_ss[0]=s.substr(j,i);
		    	}
				else if(s.substr(j,i)<found_ss[k] && s.substr(j,i)>found_ss[k-1]){
					found_ss[k]=s.substr(j,i);
				} 

			}
		}
	}
    cout<<found_ss[K-1]<<endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0, max_ = 0;
    rep(i, n){
        vector<bool> flag_f(26, false), flag_b(26, false);
        rep(k, i){
            flag_f.at(s.at(k)-'a') = true;
        }
        for(int j = i; j < n; j++){
            flag_b.at(s.at(j)-'a') = true;
        }
        rep(j, 26){
            if(flag_f.at(j)){
                if(flag_b.at(j)){
                    cnt++;
                }
            }
        }
        max_ = max(max_, cnt);
        cnt = 0;
    }
    cout << max_ << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (ll i = x; i < y; i++)
#define DEC(i, x, y) for (ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
using namespace std;
 
// Some typedef's
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<ii> vii;
 
template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
 
ll lcm(ll a, ll b) { return (a * (b / __gcd(a, b))); }
 
// Some contants
const ll inf = 1e12 + 7;
const double eps = 1e-9;
const double pi = 1.00 * acos(-1.00);

const int MAXN = 2e5;
vi v;
int arr[MAXN];

vi path;



void solve(ll k, ll n){
    clr(arr);
    path.clear();
    if (k <=n){
        ll t = 1; 
        while(k--){
            t = v[t-1];
        }
        cout << t << endl;
        return;
    }
    ll i = 0, tar;
    while(true){
       if(arr[i]){
            tar = i;
            break;
       } else{
          path.pb(i);
          arr[i]++;
          i = v[i] -1;
       }
    }
    bool ok = 1;
    ll sub = 0;
    vi ans;
    FOR(i, 0, path.size()){
        if(ok && path[i]!=tar){
            sub++;
        }else{
            ok = 0;
            ans.pb(path[i]);
        }
    }

    ll v = k-sub;
    v %= ans.size();
    cout << ans[v]+1 << endl;


}

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

        
    ll t, n;
    cin >> n >> t;
    v.clear();
    v.assign(n, 0);
    repc(i,n){
        cin >> v[i];
    }
    solve(t, n);
    return 0;
}
 
  




Measured memory_bytes: 6196
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int last = -1;
        int n = scanner.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = scanner.nextInt();
        }
        long ans = 0;
        for (int i = 0; i < n; i++) {
            int cur = nums[i];
            if (cur < last) {
                ans += (last - cur);
            } else {
                last = cur;
            }
        }
        System.out.println(ans);
    }
}

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

// ALDS1_5_B
public class Main {
	int SENTINEL = 1234567890;
	int sum = 0;
	void merge(int[]A, int left, int mid, int right) {
		int n1 = mid - left + 1;
		int n2 = right - mid;
		int[] L = new int[n1 + 1];
		int[] R = new int[n2 + 1];
		for (int i = 0; i < n1; i++) {
			L[i] = A[left + i];
		}
		for (int i = 0; i < n2; i++) {
			R[i] = A[mid + 1 + i];
		}
		L[n1] = SENTINEL;
		R[n2] = SENTINEL;
		int i = 0;
		int j = 0;
		for (int k = left; k <= right; k++) {
			sum += 1;
			if (L[i] <= R[j]) {
				A[k] = L[i];
				i = i + 1;
			} else {
				A[k] = R[j];
				j = j + 1;
			}
	    }
	}

	void mergeSort(int[] A, int left, int right) {
	    	if (left < right) {
	    		int mid = (left + right)/2;
	    		mergeSort(A, left, mid);
	    		mergeSort(A, mid + 1, right);
	    		merge(A, left, mid, right);
	  	}
	}
	    
	    
	void run() throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] S = new int[n];
		String[] str = br.readLine().split(" ");
		for (int i = 0; i < str.length; i++) {
			S[i] = Integer.parseInt(str[i]);
		}
		mergeSort(S, 0, n - 1);
		for (int i = 0; i < S.length; i++) {
    			if (i == S.length - 1) System.out.println(S[i]);
    			else System.out.print(S[i] + " ");
		}
		System.out.println(sum);
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
}



Measured memory_bytes: 174092
#include <cstdio>

int main(){
    char a[200], b[200];
    int m, h, n;
    while(true){
        scanf("%s", a);
        if(a[0] == '-'){
            return 0;
        }
        scanf("%d", &m);
        for(int i = 0; a[i] != '\0'; i++){
            n = i;
        }
        n++;
        for(int i = 0; i<m; i++){
            scanf("%d", &h);
            for(int j = 0; j<n; j++){
                b[j] = a[(j+h)%n];
            }
            for(int j = 0; j<n; j++){
                a[j] = b[j];
            }
        }
        printf("%s\n", a);
    }
    return 0;
}


Measured memory_bytes: 2592
using System;
class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int b = int.Parse(input[0]);
		int c = int.Parse(input[1]);
      int sum = 0;
      if (b == 1) sum += 300000;
      if (b == 2) sum += 200000;
      if (b == 3) sum += 100000;
      if (c == 1) sum += 300000;
      if (c == 2) sum += 200000;
      if (c == 3) sum += 100000;
      if (b == 1 && c == 1) sum += 400000;
      Console.WriteLine(sum);
	}
}

Measured memory_bytes: 13140
using System;

class MyClass
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
            array[i] = int.Parse(str[i]);
        Array.Sort(array);

        int count = 0;
        foreach (int e in array)
        {
            Console.Write(e);
            count++;
            if (count != array.Length)
                Console.Write(" ");
        }
        Console.WriteLine();
    }
}

Measured memory_bytes: 9336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
ll a[maxn],b[maxn];
ll sum;
int main()
{
	int n;scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%lld%lld",&a[i],&b[i]);
		sum+=b[i];
		a[i]+=b[i];
	} 
	sort(a,a+n);
	reverse(a,a+n);
	sum=-sum;
	for(int i=0;i<n;i+=2)
	{
		sum+=a[i];
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    int ans = (n / 500) * 1000 + (n % 500 / 5) * 5;

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


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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b < c+d){
  cout << "Right" << endl;
  }
  else if(a+b == c+d){
  cout << "Balanced" << endl;
  }
  else{
  cout << "Left" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define INF (1e18)
#define C 55
#define N 505
using namespace std;

typedef pair<int,int> P;
typedef pair<P,P> P2;

int n, m, d[C][N][2], v0, a, b, c;

vector<P> G[N];

priority_queue<P2,vector<P2>,greater<P2> > q;

int dijkstra(){

  for(int i=0;i<C;i++)
    for(int j=0;j<N;j++)
      for(int k=0;k<2;k++) d[i][j][k]=INF;
  
  d[v0][0][0]=0;

  q.push(P2(P(0,v0),P(0,0)));

  while(!q.empty()){
    
    P2 t=q.top(); q.pop();

    int cost=t.first.first;

    int v=t.first.second;

    int node=t.second.first;

    int idx=t.second.second;

    if(d[v][node][idx]<cost) continue;

    if(idx&&node==0) return cost;
    
    if(!idx&&node==n-1){

      if(d[v][node][1]>cost){
	
	d[v][node][1]=cost;

	q.push(P2(P(cost,v),P(node,1)));
	
      }
      
    }
    
    for(int i=0;i<G[node].size();i++){

      int nnode=G[node][i].first;

      int nv=(a*v+b)%c;
      
      int ncost=cost+v*G[node][i].second;
      
      if(d[nv][nnode][idx]>ncost){
	
	d[nv][nnode][idx]=ncost;

	q.push(P2(P(ncost,nv),P(nnode,idx)));
	
      }
      
    }
    
  }
  
}

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

  for(int i=0;i<m;i++){

    int x, y, t;

    cin>>x>>y>>t;

    x--, y--;
    
    G[x].push_back(P(y, t));

    G[y].push_back(P(x, t));
    
  }

  cin>>v0;

  cin>>a>>b>>c;
  
  cout<<dijkstra()<<endl;
  
}

Measured memory_bytes: 11724
nn,m=map(int,input().split())
sc=[list(map(int,input().split())) for _ in range(m)]
def check(n):
    ss = str(n)
    if len(ss)!=nn:return False
    for s,c in sc:
        if ss[s-1]!=str(c): return False
    return True
for i in range(1000):
    if check(i):print(i);exit()
print(-1)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
    int n, T;
    std::cin >> n >> T;

    std::vector<int> routes;
    int c, t;
    for(int i = 0; i < n; ++i){
        std::cin >> c >> t;
        if(t <= T){
            routes.push_back(c);
        }
    }

    std::sort(routes.begin(), routes.end());
    if(0 == routes.size()){
        std::cout << "TLE" << std::endl;
    }else{
        std::cout << *routes.begin() << std::endl;
    }

    return 0;
}


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

int main(void){
    int N,M;
    cin >> N >> M;
    vector<vector <int>> a(N);
    for(int i = 0;i<M;i++){
        int x,y;
        cin >> x >> y;
        a[x-1].push_back(y);
        a[y-1].push_back(x);
    }
    /*BFS*/
    vector<int> ans(N-1,0);
    vector<int> dist(N, -1);
    queue<int> q;
    dist[0] = 0;
    q.push(1);
    bool enable = false;
    while(!(q.empty())){
        int v = q.front();
        q.pop();
        for(int p: a[v-1]){
            if(dist[p-1] == -1){
                dist[p-1] = dist[v-1] + 1;
                ans[p-2] = v;
                q.push(p);
            }else{
                if(dist[v-1] > dist[p-1] + 1){
                    enable = true;
                    break;
                }
            }
        }
        if(enable==true) break;
    }
    if(enable == true){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
        for(int i = 0; i<N-1; i++){
            cout << ans[i] << endl;
        }
    }

}

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

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

using namespace std;

int main(){
	string s; cin>>s;
	cout<<(s[1]==s[2]&&(s[0]==s[1]||s[3]==s[1])?"Yes":"No")<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    int X, A;

    cin >> X >> A;
    cout << (X < A ? 0 : 10) << endl;

    return 0;
}


Measured memory_bytes: 764
N, M = map(int, input().split())
ps = [[] for _ in range(N)]
for _ in range(M):
    p, s = input().split()
    ps[int(p)-1].append(s)

WAc = 0
ACc = 0
temp = 0
for i in range(N):
    for j in range(len(ps[i])):
        if ps[i][j] == "WA": 
            temp += 1
        else:
            ACc += 1
            WAc += temp
            temp = 0
            break
    else:
        temp = 0
print(ACc, WAc)

Measured memory_bytes: 20272
#include<iostream>
#include <string> 
using namespace std; 
int main(){
unsigned long long a,b,x,i,a_1,b_1, sum;
cin >>a>>b>>x;
if(x == 0){
cout << 0;
return 0;
}
else{
b_1= b/x;
a_1=a/x;
sum=b_1-a_1;

if((a%x)==0){
sum = sum+1;
}

cout << sum;
return 0;
}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void) {
  int i = 0;

  while(true){
    int num;
    i++;
    cin >> num;
    if(num == 0){
      break;
    }
    cout << "Case " << i << ": " << num << endl;
  }
  return 0;
}



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

typedef long  long ll;
#define FF first
#define SS second
#define INF 2000000000


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int k, n;
    cin >> k >> n;
    if(n > 500*k){
        cout << "No" << "\n";
    }
    else{
        cout << "Yes" << "\n";
    }
}



Measured memory_bytes: 256
fn main(){
  let _: usize = read();
  let ta: Vec<f64> = read_vec();
  let t: f64 = ta[0];
  let a: f64 = ta[1];
  let h: Vec<f64> = read_vec();
  let mut sh: Vec<(usize,f64)> = h.iter().enumerate().map(|(i, &x)| (i+1, (t - x * 0.006 - a).abs())).collect();
  sh.sort_by(|a, b| a.1.partial_cmp(&(*b).1).unwrap());
  println!("{}", sh[0].0);
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
vector<int>data(N);
  for(int i=0;i<N;i++){
 	cin>>data.at(i);
 } 
  sort(data.begin(),data.end());
  int a=data.at(0);
  reverse(data.begin(),data.end());
  int b=data.at(0);
  cout<<b-a<<endl;
}

Measured memory_bytes: 256
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 X = sc.nextInt();
   int Y = sc.nextInt();
   
   int[] xi = new int[N];
   int[] yi = new int[M];
   
   for(int i = 0;i<N;i++) xi[i] = sc.nextInt();
   for(int i = 0;i<M;i++) yi[i] = sc.nextInt(); 
   Arrays.sort(xi);
   Arrays.sort(yi);
   int maxX = xi[N-1];
   int minY = yi[0];

   boolean flg = false;
   if(maxX<minY)
   {
     for(int i = maxX+1;i<=minY;i++)
     {
       if(X<i&&i<=Y)
       {
         flg = true;
         break;
       }
     }
   }
   if(flg) System.out.println("No War");
   else System.out.println("War");
 }
}

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

int main(){
    int c[10][10];
    int H,W,A,res=0;
    cin >> H >> W;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin >> c[i][j];
        }
    }
    for(int k=0;k<10;k++){
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                c[i][j] = min(c[i][j],c[i][k] + c[k][j]);
            }
        }
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> A;
            if(A != -1) res += c[A][1];
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 768
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

def conb(n,r): 
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,m = inpl()
a = inpl()
odd = even = 0
for x in a:
    if x%2: odd += 1
    else: even += 1
res = pow(2,even)
ores = eres = 0
for i in range(odd+1):
    if i%2 == 0:
        eres += conb(odd,i)
    else:
        ores += conb(odd,i)
if m:
    print(ores*res)
else:
    print(eres*res)

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

int a, b, m, t, pm = 100000, qm = 100000;
int p[100000], q[100000];

int main()
{
	cin >> a >> b >> m;

	for (int i = 0; i < a; i++) {
		cin >> p[i];
		pm = min(pm, p[i]);
	}

	for (int i = 0; i < b; i++) {
		cin >> q[i];
		qm = min(qm, q[i]);
	}

	t = pm + qm;

	for (int i = 0; i < m; i++) {
		int x, y, c;

		cin >> x >> y >> c;

		t = min(t, p[x - 1] + q[y - 1] - c);
	}

	cout << t << endl;
}


Measured memory_bytes: 1152
#include<stdio.h>

#define PEOPLE_MAX 3
#define MAX_LENGTH 101
int main(int argc, char *argv[])
{
	int i, turn = 0;
	int position[PEOPLE_MAX] = {0};
	char s[PEOPLE_MAX][MAX_LENGTH];
	
	for (i = 0; i < PEOPLE_MAX; ++i) {
		scanf("%s", s[i]);
	}
	
	while(1) {
		++position[turn];
		turn = s[turn][position[turn] - 1] - 97;
		if (s[turn][position[turn]] == '\0') {
			break;
		}
	}
	printf("%c\n", turn + 65);
	
	return 0;
}


Measured memory_bytes: 128
s = int(input())

def func(n):
    if n%2 == 0:
        return int(n / 2)
    else:
        return 3 * n + 1

a = [s]
i = 0
flg = 1

while(flg):
    a.append(func(a[i]))
    #print(a)
    for k in range(len(a)):
        for l in range(1, len(a)-k): 
            if a[k] == a[k+l]:
                print(k+l+1)
                break
        else:
            continue
        break
    else:
        i += 1
        continue
    break

Measured memory_bytes: 3064
n = int(input())
s = input()
s = s + "0"
s2 = input()
MOD = 10**9 + 7

al = []
a0 = 1
for i in range(n):
    if s[i] != s[i+1]:
        al.append(a0)
        a0 = 1
    else:
        a0 += 1

if al[0] == 1:
    ans = 3
else:
    ans = 6

for i in range(len(al)-1):
    if al[i] == 1:
        ans = ans * 2 % MOD
    else:
        if al[i+1] == 2:
            ans = ans * 3 % MOD
            
print(ans)

Measured memory_bytes: 38384
K = int(input())
if K % 2 == 0 or K % 5 == 0:
  print(-1)
else: 
    state = 7 
    state %= K
    cou = 1
    while True:
        if state == 0:
            print(cou)
            break
        state = state *  10 + 7
        state %= K 
        cou+= 1

Measured memory_bytes: 9112
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>

using namespace std;

typedef long long int LL;
typedef pair<int, int> PII;

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

  int cnt = 0;
  int tmp_a, tmp_b, tmp_c;
  while (1) {
    if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
      cout << cnt << endl;
      break;
    }
    if (a == b && b == c) {
      cout << "-1" << endl;
      break;
    }

    tmp_a = (b + c) / 2;
    tmp_b = (a + c) / 2;
    tmp_c = (a + b) / 2;
    a = tmp_a;
    b = tmp_b;
    c = tmp_c;
    cnt ++;
  }


  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007


int main()
{
	int n;
	cin >> n;
	long long int a[51];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);
	reverse(a, a + n);
	long long int ans = 0;
	while(a[0] >= n){
		long long int s = 0;
		for(int i = 0; i < n; i++){
			s += a[i] / n;
		}
		ans += s;
		for(int i = 0; i < n; i++){
			a[i] = (a[i] % n) + s - (a[i] / n);
		}
		sort(a, a + n);
		reverse(a, a + n);
	}
	cout << ans << endl;
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

template<typename T> void ckmin(T& a, const T& b) { a = min(a, b); }
template<typename T> void ckmax(T& a, const T& b) { a = max(a, b); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N;
    cin >> N;
    vector<pair<int, int>> jobs(N);

    for (int i = 0; i < N; i++) {
        cin >> jobs[i].second >> jobs[i].first;
    }

    sort(all(jobs));

    bool good = true;

    ll time = 0;
    for (auto j : jobs) {
        time += j.second;
        if (time > j.first)
            good = false;
    }

    cout << (good ? "Yes\n" : "No\n");

    return 0;
}



Measured memory_bytes: 1792
a = int(input())
strings =[input() for i in range(a)]

b = 0
c = 1
#finish = strings[b][-1:]
#start = strings[c][0:1]

if len(strings) == len(set(strings)):
    while c <= a - 1:
        finish = strings[b][-1:]
        start = strings[c][0:1]
        if finish == start:
            b += 1
            c += 1
            if c == a:
                print("Yes")
        else:
            print("No")
            break
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main(void){
	int a, b, c;
	cin >> a >> b >> c;
	if(a + b == c || a + c == b || b + c == a){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = (int)998244353;
const int MAXN = (int)3003;
const int infint = (int)1e9 + 3;
const ll inf = (ll)1e18;
ll a, b, c;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> a >> b >> c;
	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
		return cout << 0, 0;
	cout << min(min(a * b, a * c), b * c);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();
    
    int n, m;
    cin >> n >> m;
    n -= m;
    int s = pow(2, m);
    cout << (1900 * m + n * 100) * s << "\n";
}

Measured memory_bytes: 256
import math
a,b=map(int,input().split())
c=[]
for _ in range(a):
    c.append(list(map(int,input().split())))
ans=0
for i in range(a):
    for j in range(i):
        n=c[i]
        m=c[j]
        result=[(x-y)**2 for (x,y) in zip(n,m)]
        if math.sqrt(sum(result))%1==0:
            ans+=1
print(ans)


Measured memory_bytes: 9192
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
typedef pair<ll, double> Pb;

bool comp(const Pb &a, const Pb &b){
  if(a.second != b.second)return a.second < b.second;
  else return a.first < b.first;
}

ll sum(ll n){
  ll res = 0;
  while(n){
    res += n % 10;
    n /= 10;
  }
  return res;
}

ll calc(ll n) {
  vector<Pb> vec;
  vec.pb(mk(n, (double)n/(double)sum(n)));
  ll curr = 1;
  while(n >= curr){
    int dval = n / curr % 10;
    for(int i = dval + 1; i < 10; i++){
      ll tmp = (n / (curr * 10)) * curr * 10 + i * curr + curr - 1;
      vec.pb(mk(tmp, (double)tmp/double(sum(tmp))));
    }
    curr *= 10;
  }
  sort(vec.begin(), vec.end(), comp);
  return vec[0].first;
}

int main(int argc, char const* argv[])
{
  ll k;
  cin >> k;
  cout << 1 << endl;
  ll curr = 1;
  for(ll i = 1; i < k; i++){
    curr = calc(curr + 1);
    cout << curr << endl;
  }
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

void intsertSort(int *array,int num){
	int i,j,k,tmp;
	for(i=1;i<num;i++){
		
		//********
		for(k=0;k<num;k++){
			printf("%d",array[k]);
			if(k!=num-1){
				printf(" ");
			}
		}printf("\n");
		//********
		
		tmp = array[i];
		j=i-1;
		while(j>=0 && array[j]>tmp){
			array[j+1] = array[j];
			j--;
		}
		array[j+1]=tmp;
		
	}
	
	//********
	for(k=0;k<num;k++){
		printf("%d",array[k]);
		if(k!=num-1){
			printf(" ");
		}
	}printf("\n");
	//********
}

int main(){
	int num,i,array[100];
	
	scanf("%d",&num);
	
	for(i=0;i<num;i++){
		scanf("%d",&array[i]);
	}
	
	intsertSort(array,num);
	
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
unordered_map<int,list<int> > um;
int fun(int src,int *dist)
{
    if(dist[src]!=-1)return dist[src];
    int d=0;
    for(int i: um[src]){
        d=max(fun(i,dist)+1,d);
    }
    return dist[src]=d;
}
void solve()
{
    int n,m;
    cin>>n>>m;
    int dist[n];
    for(int i=0; i<n; i++)dist[i]=-1;
    for(int i=0; i<m; i++){
        int x,y;
        cin>>x>>y;
        um[--x].push_back(--y);
    }
    for(int i=0; i<n; i++){
        if(dist[i]==-1){
            fun(i,dist);
        }
    }
    cout<<*max_element (dist,dist+n);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
}


Measured memory_bytes: 14940
#include<stdio.h>

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

	char s[h][w];

	for (i=0; i < w+2; i++) {
		printf("#");
	}
	printf("\n");
	
	for (i=0; i<h; i++) {
		scanf("%s",s[i]);
		printf("#%s#\n",s[i]);
	}

	for (i=0; i<w+2; i++) {
		printf("#");
	}
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mod = 1e9+7;
LL f[200005], rf[200005];
LL sum[200005];
LL pw(LL a, LL b){
    LL res = 1;
    while(b){
        if(b%2 == 1) res = (res*a)%mod;
        a = (a*a)%mod;
        b/=2;
    }
    return res;
}
LL ncr(int a, int b){
    return f[a]*rf[b]%mod*rf[a-b]%mod;
}
int main(){
    f[0] = 1;
    for(int i=1;i<=200000;i++) f[i] = (f[i-1]*i)%mod;
    for(int i=0;i<=200000;i++) rf[i] = pw(f[i], mod-2);
    for(int i=1;i<=200000;i++) sum[i] = (sum[i-1] + i)%mod;
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    LL ans = 0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            int ri = m-j;
            ans = (ans + sum[ri]%mod*ncr(n*m-2, k-2)%mod*ncr(n, 1))%mod;

            ri = n-i;
            ans = (ans + sum[ri]%mod*ncr(n*m-2, k-2)%mod*ncr(m, 1))%mod;
        }
    }   
    printf("%lld\n", ans);
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
char a[N];
int main(){
	scanf("%s",a);
	int l=strlen(a);
	for(int i=0;i<l-1;i++){
		if(a[i]==a[i+1]){
			printf("%d %d\n",i+1,i+2);
			return 0;
		}
		if(a[i]==a[i+2]){
			printf("%d %d\n",i+1,i+3);
			return 0;
		}
	}
	puts("-1 -1");
	return 0;
}

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

int main(){
  ll x ;
  cin >> x ;
  ll start = 100 ;
  for( ll i = 1 ; ; i++ ){
    start = start + start/100 ;
    if( start >= x ){
      cout << i << endl ;
      return 0 ;
    }
  }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int sop(int k);
int32_t main()
{
      IOS;
      ll i,n,flag=0,nut=1,jump=1,q,j,cnt=0,cnt1=0,cnt2=0,cnt3=0,cnt4=0,cnt5=0,m,x,y,h,l,z,k,h1,h2,m1,m2,t;
      cin>>n;
      float sum;
      ll a[n];
      for(i=0;i<n;i++)
      {
          cin>>a[i];

      }
      sort(a,a+n);
      sum=a[0];
      for(i=1;i<n;i++)
      {
          sum=(sum+a[i])/2;
      }
      cout<<sum;



    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int abs(int n){
		if(n<0){
		return -1*n;}else
		return n;}
int main(void)
{int N,A,M,B,C,x,i,a,b,l,r,g,m,tmp;
	scanf("%d%d",&A,&B);
	a=0;
	for(i=A;i<=B;i++){
	if(i/10000==i-(i/10)*10&&(((i/1000)-(i/10000)*10)==(i/10-(i/100)*10)))
	a++;}
	printf("%d",a);
	

	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>

intmax_t isqrt(intmax_t n) {
  if (n <= 1) return n;
  intmax_t lb = 0;
  intmax_t ub = 2e9;
  while (ub-lb > 1) {
    intmax_t mid = (lb+ub) >> 1;
    ((mid*mid <= n)? lb: ub) = mid;
  }
  return lb;
}

int solve_testcase() {
  intmax_t a, b;
  scanf("%jd %jd", &a, &b);

  if (a > b) std::swap(a, b);

  intmax_t lb = 0;
  intmax_t ub = b;
  while (ub-lb > 1) {
    intmax_t mid = (lb+ub) >> 1;
    (((a*b-1)/mid > a)? lb: ub) = mid;
  }
  intmax_t res = a-1+lb;
  intmax_t x = isqrt(a*b);
  if (x < lb) {
    res = a-1 + x + ((a*b-1)/x-a)-1;
  }

  printf("%jd\n", res);
  return 0;
}

int main() {
  size_t q;
  scanf("%zu", &q);

  while (q--) solve_testcase();
}


Measured memory_bytes: 128
#![allow(unused_macros)]
#![allow(non_snake_case)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// N M
// input! {
//     N: i32,
//     M: i32,
// }

// N
// a1, ..., aN
// input! {
//     N: i32,
//     A: [i32, N],
// }

// H W
// a11 ... a1W
// ...
// aH1 ... aHW
// input! {
//     H: i32,
//     W: i32,
//     A: [[i32, W], H],
// }

// S
// input! {
//     S: chars,
// }

fn main() {
    input! {
        R: i32,
        G: i32,
        B: i32,
        N: i32,
    };

    let mut ans: i32 = 0;

    for r in 0..3001 {
        for g in 0..3001 {
            let b: i32 = N - r * R - g * G;
            if b % B == 0 && b >= 0 {
                ans += 1;
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <utility>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    long long int n;
    cin>>n;
    vector<long long int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<long long int>b(a);
    sort(b.begin(),b.end());
    long long int s=b[(n/2)-1],l=b[n/2];
    for(int i=0;i<n;i++){
        long long int tmp=lower_bound(b.begin(),b.end(),a[i])-b.begin();
        if(tmp<=(n/2)-1){
            cout<<l<<"\n";
        }else{
            cout<<s<<"\n";
        }
    }
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

int main(void) {
  int K, S;
  cin >> K >> S;

  int ans=0;
  rep(x,K+1){
    rep(y,K+1){
      if(S-x-y>-1 && S-x-y<K+1) ans++;
    }
  }

  prt(ans);
}


Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args){
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String[] line = br.readLine().split(" ");
			int a1 = Integer.parseInt(line[0]);
			int a2 = Integer.parseInt(line[1]);
			int[][] n = new int [a1][a2];
			int[] b = new int[a2];

			
			for(int i = 0;i < a1;i++){
				String[] str = br.readLine().split(" ");
				for(int j = 0;j < a2;j++){
					int f = Integer.parseInt(str[j]);
					n[i][j] += f;
				}
			}
			
			for(int i = 0;i < a2;i++){
				int f = Integer.parseInt(br.readLine());
				b[i] += f;
			}
			
			for(int i = 0;i < a1;i++){
				int matrix = 0;
				for(int j = 0;j < a2;j++){
				matrix += n[i][j]*b[j];
				}
			System.out.println(matrix);	
			}
		} catch(Exception e){
		}
	}
}
				 
			

Measured memory_bytes: 27436
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <utility>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <sys/time.h>
#include <vector>


using namespace std;
#define REP(i,n,m) for( long long int i = (n); i < (m); i++ )
#define REP_(i,n,m) for( long long int i = (n); i <= (m); i++ )
#define CNT(i,n) for( long long int i = (n); i > 0; i-- )
#define CNT_(i,n) for( long long int i = (n); i >= 0; i-- )
#define SKIP(i,n,m) for( long long int i = (n); i < (m) ; i+=2 )
#define ll long long
#define ld long double
#define ft first
#define sd second
#define ALL(a) (a).begin(), (a).end()
#define srt(v) sort( v.begin(), v.end() );
#define sz(v) ( int ) v.size()
#define erase( v, i ) v.erase( v.begin() + i)
#define last(v) v[sz(v)-1]
#define swap( v, i, j ) int buf = v[j]; v[j] = v[i]; v[i] = buf;
#define out(a) printf( " %.16f¥n ", a );
#define vi vector<int>
#define vd vector<double>
#define vl vector<long long>
#define pa pair<int, int>
#define mulM( a, b, c ) a = a * b % c;
#define mp make_pair
#define pb push_back
#define iinp(a) int a; cin >> a;
#define sinp(a) string a; cin >> a;
#define ios() ios_base::sync_with_stdio(0); cin.tie(0);
#define EPS (1e-10)
#define PI 3.14159265358979323846

int MOD=1000000007;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

void solve(){
  iinp( x )
  if ( x == 3 || x == 5 || x == 7 ){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

signed main() {
    ios()
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main()
{
    int n, a, b, check;
    std::cin >> n >> a >> b;
    int sum = 0;
    for(int i = 1; i <= n; i++){
        check = i % 10 + (i / 10) % 10 + (i / 100) % 10 + (i / 1000) % 10 + (i / 10000) % 10;
        if(a <= check && check <= b){
            sum = sum + i;
        }
    }
    std::cout << sum << std::endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// 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 (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  ll X;
  cin >> X;

  ll c = (X / 500) * 1000;
  ll mod = X % 500;

  c += (mod / 5) * 5;

  cout << c << endl;

  return 0;
}


Measured memory_bytes: 256
#define ll long long
#define ffor(i, a, b) for (int i = (a); i < (b); i++)
#define rfor(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

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

  int a[4];
  cin >> a[0] >> a[1] >> a[2];

  sort(a, a + 3);

  cout << a[0] + a[1] << endl;

  return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



string a,b;
void solve(){
	cin >> a >> b;
	if(a.size() < b.size()){
		cout << "LESS" << endl;
		return;
	}
	if(a.size() > b.size()){
		cout << "GREATER" << endl;
		return;
	}
	
	if(a < b){
		cout << "LESS" << endl;
	}
	if(a > b){
		cout << "GREATER" << endl;
	}
	if(a == b){
		cout << "EQUAL" << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; 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)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
using LP = pair<int, ll>;

int main() {
  int n;
  priority_queue<LP> q;
	cin >> n;
  vl a(n),b(n);
	rep(i, n) {
		cin >> a[i] >> b[i];
		q.push({ a[i] + b[i],i });
	}
	int x = 0;
	ll ans = 0;
	while (!q.empty()) {
		LP p = q.top(); q.pop();
		if (x) {
			ans -= b[p.second];
		}
		else {
			ans += a[p.second];
		}
		x ^= 1;
	}
	cout << ans << endl;
	//stop
	return 0;
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    string s;cin >> s;
    ll n=s.size();
    if(s[n-1]=='1')cout << -1 <<endl,exit(0);
    if(s[0]=='0'||s[n-2]=='0')cout << -1 <<endl,exit(0);
    bool check=false;
    rep(i,n-1){
        if(s[i]!=s[n-2-i])check=true;
    }
    if(check)cout << -1 <<endl,exit(0);
    ll focus=1;
    rep(i,n-1){
        cout << focus << " " << i+2 <<endl;
        if(s[i]=='1')focus=i+2;
    }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define INF 10000000000000009
#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

int Ans=0;

//レベルLの
//バーガーの全長:4*2^L-3
//バーガーに含まれるバンズ:2*2^L-1

int eat(int R,int L){//レベルLのバーガーの下からR枚を食べる
    //cout << R << " " << L << endl;
    if(L==0){
        Ans++;//レベル0のバーガーはパティ1枚
        return R-1;
    }
    int f=1;REP(i,L){f*=2;}
    int Len=((2*f)-3);//レベルL-1バーガーの長さとパティ数
    int Pat=(f-1);
    //cout << Len << " " << Pat << endl;
    R--;//上バンズ
    if(R==0)return 0;
    if(R<Len){//上バーガー
        R=eat(R,L-1);
    }else{
        R-=Len;
        Ans+=Pat;
    }
    if(R==0)return 0;
    R--;Ans++;//中パティ
    if(R==0)return 0;
    if(R<=Len){//下バーガー
        R=eat(R,L-1);
    }else{
        R-=Len;
        Ans+=Pat;
    }
    if(R==0)return 0;
    
    R--;//下バンズ
    return R;
}

signed main(){
    int N,X;
    cin >> N >> X;
    //cout << (1<<50ll) << endl;
    eat(X,N);
    cout << Ans << endl;
    return 0;
}   


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

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

		List<String> list = new ArrayList<String>();
		List<Integer> cnt = new ArrayList<Integer>();

		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		String str;
		str=br.readLine();
		String[] sp = str.split(" ");

		for(int i = 0; i < sp.length; i++){
			list.add(sp[i]);
		}

		for(int i = 0; i < sp.length; i++){
			cnt.add(0);
			for(int j = 0; j < sp.length; j++){
				if(list.get(i).equals(list.get(j))){
					cnt.set(i, cnt.get(i) + 1);
				}
			}
		}

		int max1 = 0;
		int max2 = 0;
		String ans1 = "";
		String ans2 = "";

		for(int i = 0; i < sp.length; i++){
			if(max1 < cnt.get(i)){
				max1 = cnt.get(i);
				ans1 = list.get(i);
			}

			if(max2 < list.get(i).length()){
				max2 = list.get(i).length();
				ans2 = list.get(i);
			}
		}

		System.out.println(ans1 + " " + ans2);
	}
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    string S;
    cin>>S;
    rep(i,S.length()){
        cout<<'x';
    }
    cout<<endl;

    return 0;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  for(int i = 0; i < s.size(); i++) {
    if(s == t) {
      cout << "Yes" << endl;
      return 0;
    }
    rotate(s.rbegin(),s.rbegin()+1,s.rend());
   
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256