akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Main{
    
    public static class CDisjointSet {
        public static int rank[];
        public static int p[]; //data
        
        CDisjointSet(int size){
            rank = new int[size];
            p = new int[size];
            for(int i=0; i<size;i++)makeSet(i);
        }
        
        public static void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }
        
        public static boolean same(int x, int y){
            return findSet(x) == findSet(y);
        }
        
        public static void unite(int x, int y){
            link(findSet(x),findSet(y));
        }
        
        public static void link(int x, int y){
            if(rank[x] > rank[y]){
                p[y] = x;    
            }else{
                p[x] = y;
                if (rank[x] == rank[y]){
                    rank[y]++;    
                }
            }
        }
        
        public static int findSet(int x){
            if (x != p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }    
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(); // size
        int q = in.nextInt(); // query size
       
        CDisjointSet ds = new CDisjointSet(n);

        for (int i = 0; i < q; i++){
            int t = in.nextInt(); // query
            int a = in.nextInt(); // query arg1
            int b = in.nextInt(); // query arg2  
            
            if (t == 0)ds.unite(a,b);
            else if(t==1){
                if(ds.same(a,b)) System.out.println("1");
                else System.out.println("0");
            }
        }
     
    }
}

Measured memory_bytes: 99200
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

char arr[57][57];
int main(){
	Lancer();
	ll n, sum = 0,t;
	cin >> n;
	t = n;
	while (n)
	{
		sum += (n % 10);
		n /= 10;
	}
	if (t%sum == 0)
		cout << "Yes";
	else
		cout << "No";
	cout << endl;
	return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

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

 int b = 1;
 forn(i,n){
 	int k; cin>>k;
 	if(k%2==0){
 		b&= k%3==0 || k%5==0;
 	}
 }
 cout<<(b?"APPROVED\n":"DENIED\n");
  return 0;
}

Measured memory_bytes: 384
N=int(input())
li_=[]
for i in range(N):
  A,B=map(int,input().split())
  li_.append((B,A))
li_.sort()
time=0
for i in range(N):
  time+=li_[i][1]
  if time>li_[i][0]:
    print("No")
    exit()
print("Yes")


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

fn main() {
    let (a, b) = scan!(i64, i64);
    let m = if a == 0 {
        0
    } else if (a - 1) % 2 == 0 {
        (((a - 2) / 2 + 1) % 2) ^ (a - 1)
    } else {
        (((a - 1) / 2 + 1) % 2)
    };
    let n = if b == 0 {
        0
    } else if b % 2 == 0 {
        (((b - 1) / 2 + 1) % 2) ^ b
    } else {
        (b / 2 + 1) % 2
    };

    println!("{}", m ^ n);
}


Measured memory_bytes: 4352
#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 1000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less<pair<ll,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 3.14159265358979323
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;
    x = x % p; 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 
  
ll inv(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 

const ll MAXN=200005;
ve<ve<ll>> vec(MAXN);
bool vis[MAXN];
ll dfs_timer=0;
ve<ll> time_in(MAXN);
ve<ll> time_out(MAXN);
ve<ll> par(MAXN);
ve<ll> siz(MAXN);
ve<ll> val(MAXN);

void dfs(ll v,ll p)
{
    vis[v]=true;
    ll s=1;
    par[v]=p;
    time_in[v] = dfs_timer++;
    for(auto i=vec[v].begin();i!=vec[v].end();i++)
        if(!vis[*i])
        {
            dfs(*i,v);
            s+=siz[*i];
        }
    time_out[v] = dfs_timer++;
    siz[v]=s;
    return;
}

void bfs(ll s, ll n) 
{ 
    for(int i = 0; i < MAXN; i++) 
        vis[i] = false; 
    deque<ll> q; 
    vis[s] = true; 
    q.push_back(s); 
    while(!q.empty()) 
    { 
        s = q.front(); 
        q.pop_front(); 
        for (auto i = vec[s].begin(); i != vec[s].end(); ++i) 
            if (!vis[*i]) 
            { 
                vis[*i] = true; 
                q.push_back(*i); 
            }
        if(s!=1)
            val[s]=(((val[par[s]]*siz[s])%A)*inv(n-siz[s],A))%A;
    }
    return;
}

int main() 
{
    FAST;
    ll n;
    cin>>n;
    ll a,b;
    for(int i=1;i<n;i++)
    {
        cin>>a>>b;
        vec[a].pb(b);
        vec[b].pb(a);
    }
    dfs(1,-1);
    ll f=1;
    for(int i=1;i<=n;i++)
    {
        f=(f*i)%A;
        f=(f*inv(siz[i],A))%A;
    }
    val[1]=f;
    bfs(1,n);
    for(int i=1;i<=n;i++)
        cout<<val[i]<<'\n';
    subt;   
    return 0;
}

Measured memory_bytes: 24432
N = int(input())
S = input()

dp = [[0]*N for _ in range(N)]

for v in range(N):
    for h in range(N):
        if h == 0 or v == 0:
            if S[v] == S[h]:
                dp[v][h] = min(1, abs(v-h))
        elif S[v] == S[h]:
            dp[v][h] = min(dp[v-1][h-1] + 1, abs(v-h))

ans = 0
for i in range(N):
    tmp = max(dp[i])
    if tmp > ans:
        ans = tmp

print(ans)

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



int main(int argc, char const* argv[])
{
  int M, N;
  cin >> N >> M;
  if(N >= M){
    cout << 0 << endl;
    return 0;
  }

  vector<int> x(M);
  for (int i = 0; i < M; i++) {
    cin >> x[i];
  }
  sort(x.begin(), x.end());

  vector<int> diff(M-1);
  for (int i = 0; i < M-1; i++) {
    diff[i] = x[i+1] - x[i];
  }
  sort(diff.begin(), diff.end());
  reverse(diff.begin(), diff.end()); 
  int sumblank = 0;
  for (int i = 0; i < N-1; i++) {
    sumblank += diff[i];
  }

  cout << x[M-1] - x[0] - sumblank << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  int X[N];
  int tmp;
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    X[tmp-1] = i + 1;
  }
  for (int i = 0; i < N; i++) {
    cout << X[i] << " ";
  }
  cout << endl;
  return 0;
}


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

using namespace std;

struct Human {
    int id, w;
    double h, bmi;
    void setter(int _id, int _w, double _h) {
        id = _id;
        w = _w;
        h = _h / 100.0;
        bmi = w / h / h;        
    }
};
bool operator <(const Human &a, const Human &b)
{
    return abs(22 - a.bmi) != abs(22 - b.bmi) ? abs(22 - a.bmi) < abs(22 - b.bmi) : a.id < b.id;
}

int main()
{
    int n;
    int id, h, w;

    while (cin >> n, n) {
        Human ans, tmp;

        cin >> id >> h >> w;
        ans.setter(id, w, h);

        for (int i = 0; i < n - 1; i++) {
            cin >> id >> h >> w;
            tmp.setter(id, w, h);

            if (tmp < ans)
                ans = tmp;
        }
        cout << ans.id << endl;
    }

    return 0;
}

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

int main(){
    int n, t, a;
    cin >> n >> t >> a;
    vector<int> h(n);
    vector<pair<double, int>> temp(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
        temp[i].first = abs(a - (t - h[i]*0.006));
        temp[i].second = i + 1;
    }
    sort(temp.begin(), temp.end());
    cout << temp[0].second << endl;
    return 0;
}


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

int main(){
    int n, l;
    cin >> n >> l;
    int L = l;
    int R = l + n - 1;
    int eat;
    if(R <= 0) eat = R;
    else if (L >= 0) eat = L;
    else eat = 0;

    cout << (R + L)*(R - L + 1)/2 - eat << endl;
    return 0;
}

Measured memory_bytes: 3616
A, B, C, X, Y = map(int, input().split())

best = 10**9
for c in range(max(X, Y)*2+1):
    a = X-c
    b = Y-c
    if a < 0:
        a = 0
    if b < 0:
        b = 0
    p = A*a + B*b + C*c*2
    if p < best:
        best = p

print(best)


Measured memory_bytes: 3060
n, y = map(int, input().split())
y = y/1000
ans = "-1 -1 -1"

for i in range(n+1):
 a = i
 b = (y-n-9*i)/4
 c = n-i-b
 #bが非負整数・cが非負となるか確認
 if  b==int(b) and b>=0 and c>=0:
  ans = "{0} {1} {2}".format(a, int(b), int(c))
  break
 
print(ans)

Measured memory_bytes: 3060
md1=input()
md2=input()

m1st,d1st=md1.split()
m2st,d2st=md2.split()


m1=int(m1st)
d1=int(d1st)

m2=int(m2st)
d2=int(d2st)



if d2==1:
  print('1')
else:
  print('0')

Measured memory_bytes: 3060
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

ll N;
vector<ll> A;

bool isOK(ll x) {
    if (x == 1) {
        for (ll i = 1; i < N; i++) {
            if (A[i - 1] >= A[i]) {
                return false;
            }
        }
        return true;
    }

    //入ってないところは0ということを示す
    map<ll, ll> mp;

    for (ll i = 1; i < N; i++) {
        if (A[i - 1] < A[i]) {
            //0を入れていくだけなので何もしない
            continue;
        }

        //先を全部消す
        mp.erase(mp.upper_bound(A[i - 1]), mp.end());

        //x - 1でない位置を見つける
        ll j = A[i];
        while (mp[j] == x - 1 && j > 0) {
            mp.erase(j--);
        }

        if (j == 0) {
            //全部ダメ
            return false;
        }

        //ここの桁の値を1上げる
        mp[j]++;
    }
    return true;
}

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

    cin >> N;
    A.resize(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    ll ng = 0, ok = N;
    while (ng + 1 != ok) {
        ll mid = (ng + ok) / 2;
        (isOK(mid) ? ok = mid : ng = mid);
    }
    cout << ok << endl;
}

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

int main(void) {
  int n, m, cnt, max = 0;
  char s[100][11], t[100][11];
  scanf("%d", &n);

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

  scanf("%d", &m);

  for (int i = 0; i < m; i++) {
    scanf("%s", t[i]);
  }

  for (int i = 0; i < n; i++) {
    cnt = 0;
    for (int j = 0; j < n; j++) {
      if (strcmp(s[i], s[j]) == 0) cnt++;
    }
    for (int j = 0; j < m; j++) {
      if (strcmp(s[i], t[j]) == 0) cnt--;
    }
    if (max < cnt) max = cnt;
  }
  
  printf("%d", max);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include<math.h>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main() {

    int N;
    cin >> N;

    vector<long long> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    vector<long long> B(N);
    for (int i = 0; i < N; ++i) {
        B[i] = A[i] - (i + 1);
    }

    sort(B.begin(), B.end());

    long long centerIndex = B.size() / 2;
    long long b = B[centerIndex];

    long long num = 0;
    for (int i = 0; i < N; ++i) {
        num += abs(B[i] - b);
    }

    cout << num << endl;
    return 0;
}

Measured memory_bytes: 3328
import math

N=int(input())

ans=0
arr=[]

tmp=1

#print(int(math.sqrt(N))+5)

for i in range(int(math.sqrt(N))+5):
    tmp=1

    while N % ((i+2)**tmp) == 0:
        N=N / ((i+2)**tmp)
        #print((i+2)**tmp)
        ans+=1
        tmp+=1

    while N % (i+2) == 0:
        N = N // (i+2)

if N > 1 :
    ans+=1

print(ans)


Measured memory_bytes: 9264
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define ld             long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
     int x = 1;
     while (b)
     {
          if (b & 1) x *= a;
          a *= a;
          b >>= 1;
     }
     return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a[N], n, m, k;

void solve()
{
     int i, j;
     cin >> n >> m;
     int g = __gcd(n, m);
     int x = n * m;
     x /= g;
     cout << x;

}

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

     cout << setprecision(9) << fixed;
     clock_t z = clock();
     solve();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

     return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
   int a,b,c,d;

   scanf("%d%d%d%d",&a,&b,&c,&d);
   if(a>b)
      a=b;
   if(c>d)
      c=d;
   printf("%d\n",a+c);

   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  long N;
  cin>>N;
  long i=sqrt(N);
 
  long a,b;
  while(i>0){
	if(N%i==0){
	a=i;
      b=N/i;
      break;
    }else{
      i--;
    }
  }
  cout<<a+b-2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
const double PI= acos(-1.0);
const int M = 1e5+7;
/*
int head[M],cnt;
void init(){cnt=0,memset(head,0,sizeof(head));}
struct EDGE{int to,nxt,val;}ee[M*2];
void add(int x,int y,int z){ee[++cnt].nxt=head[x],ee[cnt].to=y,ee[cnt].val=z,head[x]=cnt;}
*/
int n;
vector<int>v;
void dfs(int x,int u)
{
	if(x==n)
	{
		for(int i=0;i<v.size();i++)
		cout<<char('a'+v[i]);
		cout<<endl;
		return ;
	}
	for(int i=0;i<=u+1;i++)
	{
		v.pb(i);
		dfs(x+1,u+(i==u+1));
		v.pop_back();
	}
}
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	cin>>n;
  	dfs(0,-1);
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

const int MOD = 1e9 + 7;

string s;
long long k;

long long dp[301][301][301];
int n;

int main()
{
    cin >> s;
    cin >> k;
    n = s.size();
    long long as = 0;
    for (int i = 0; i < n; i++)
    {
        if (i > 0) dp[i][i - 1][0] = 0;
        dp[i][i][0] = 1;
        as = max(as, 1LL);
    }
    for (int len = 2; len <= n; len++)
    {
        for (int i = 0; i + len - 1 < n; i++)
        {
            int j = i + len - 1;
            for (int e = 0; e <= k; e++)
            {
                if (s[i] == s[j])
                {
                    dp[i][j][e] = max(dp[i][j][e], dp[i + 1][j - 1][e] + 2);
                }
                else
                {
                    if (e - 1 >= 0)
                        dp[i][j][e] = max(dp[i][j][e], dp[i + 1][j - 1][e - 1] + 2);
                }
                dp[i][j][e] = max(dp[i][j][e], dp[i][j - 1][e]);
                dp[i][j][e] = max(dp[i][j][e], dp[i + 1][j][e]);
                as = max(as, dp[i][j][e]);
            }
        }
    }
    cout << as;
}


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

void swap(int *a1, int *a2)
{
	int t = *a1;

	*a1 = *a2;
	*a2 = t;
}

int main(int argc, char *argv[])
{
	int a[3], i, flag;

	scanf("%d %d %d", &a[0], &a[1], &a[2]);

	do {
		for (i = 1, flag = 0; i < 3; i++) {
			if (a[i - 1] > a[i]) {
				swap(&a[i - 1], &a[i]);
				flag = 1;
			}
		}
	} while (flag == 1);

	printf("%d %d %d\n", a[0], a[1], a[2]);

	return 0;
}

Measured memory_bytes: 596
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    long d = sc.nextLong();
    long e = sc.nextLong();
    long ans = 4;
    long m = Math.min(a, Math.min(b, Math.min(c, Math.min(d, e))));
    long s = (n / m) + 1;
    if((n % m) == 0) s = (n / m);
    ans += s;
    System.out.println(ans);
  }
}

Measured memory_bytes: 23508
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var ab = lines[0].split(' ');
 var a = Number(ab[0]);
 var b = Number(ab[1]);

 console.log(a * b);
 
});

Measured memory_bytes: 30104
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
#define MODSIZE 1000000007
priority_queue<int, vector<int>, greater<int> > PQ; // 昇順PQ
// priority_queue<int> PQ;

int main(){
  int x,n;
  int p[105];
  int cnt[105];

  scanf("%d %d", &x, &n);
  int i;

  for(i = 0;i <= 101;i++) cnt[i] = 0;
  for(i = 0;i < n;i++){
    scanf("%d", &p[i]);
    cnt[p[i]]++;
  }

  if(n == 0){
    printf("%d\n", x);
    return 0;
  }

  // printf("#");

  int mn = 999999;
  int s = 0;

  for(i = 0;i <= 101;i++){
    if(cnt[i] == 0 && abs(x - i) < mn){
      mn = abs(x - i);
      s = i;
    }
  }

  printf("%d\n", s);

  return 0;
}

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

int main(int argc, char const *argv[]) {
  int n, m, l;
  long nm[101][101] = {0}, ml[101][101] = {0};
  long nl[101][101] = {0};

  cin >> n >> m >> l;

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

  for (int i = 0; i < m; i++) {
    for (int j = 0; j < l; j++) {
      cin >> ml[i][j];
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < l; j++) {
      for (int k = 0; k < m; k++) {
        nl[i][j] += nm[i][k] * ml[k][j];
      }
    }
  }

  for (int i = 0; i < n; i++) {
    cout << nl[i][0];
    for (int j = 1; j < l; j++) {
      cout << " " << nl[i][j];
    }
    cout << endl;
  }

  return 0;
}

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

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    cout << (((a[a.length() - 1] == b[0]) && (b[b.length() - 1] == c[0])) ? "YES" : "NO") << endl;
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define fp(i,a,b) for(int i=a ; i<b ; i++)
#define fn(i,a,b) for(int i=a ; i>=b ; i--)
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

const int M=1e5+5;
const ll INF=1e15;
const int MOD=1e9+5;

int n,W;
ll dp[M][105],valor[105],peso[105];

ll ks(int w,int x){
  if (w < 0) return -INF;
  if (x > n) return 0;
  if (dp[w][x] != -1) return dp[w][x];
  dp[w][x] = max(ks(w,x+1) , valor[x] + ks(w-peso[x],x+1));
  return dp[w][x];
}

void ini(){
  fp(i,0,M)
    fp(j,1,n+1) dp[i][j] = -1;
}

int main(){

	fastio;
  cin >> n >> W;
  ini();
  fp(i,1,n+1) cin >> peso[i] >> valor[i];
  cout << ks(W,1) << "\n";

	return 0;
}


Measured memory_bytes: 85576
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

void ans(map<int, set<int>> &tree, VI &cnt, int t, int parent) {
    // if (tree[t].empty()) return;

    for (int s : tree[t]) {
        if (s == parent) continue; // 親で出てたらcontinue
        cnt[s-1] += cnt[t-1];
        ans(tree, cnt, s, t);
    }
}

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

int N, Q; cin >> N >> Q;
VP ab(N-1), px(Q);
rep(i,0,N-1) cin >> ab[i].first >> ab[i].second;
rep(i,0,Q) cin >> px[i].first >> px[i].second;

map<int, set<int>> tree;
rep(i, 0, N-1){
    tree[ab[i].first].insert(ab[i].second);
    tree[ab[i].second].insert(ab[i].first); // 親か子かわからないので，双方向に記録
}

// sort(ALL(px));

VI cnt(N, 0);
rep(i, 0, Q){
    cnt[px[i].first - 1] += px[i].second;
}

ans(tree, cnt, 1, -1);

rep(i, 0, N) cout << cnt[i] << ' ';
cout << endl;

return 0;
}

// 境界，出力文字列 チェック



Measured memory_bytes: 62592
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define RFOR(i, begin, end) for(int i=(end)-1, i##_begin_=(begin);i>=i##_begin_;i--)
#define rep(i, N) FOR(i, 0, N)
#define rrep(i, N) RFOR(i, 0, N)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long int;
using V = vector<ll>;
using P = pair<ll, ll>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
constexpr int mod = 1e9+7;
ll gcd(ll a, ll b) { return b? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}

ll n;

int main() {
    cin >> n;
    V a(n), b(n), c(n);
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }
    rep(i, n) cin >> b[i];
    rep(i, n-1) cin >> c[i];
    c.pb(0);
    ll ret = 0;
    FOR(i, 1, n) {
        ret += b[a[i-1]];
        if (a[i-1] + 1 == a[i]) {
            ret += c[a[i-1]];
        }
    }
    ret += b[a[n-1]];
    cout << ret << endl;
    return 0;
}


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

using namespace std;

int MOD = 1e9 + 7;
long long *fact;
long long *inv;
long long *fact_inv;

void init_nCk(int size) {
    fact = new long long [size];
    inv = new long long [size];
    fact_inv = new long long [size];
    fact[0] = fact[1] = 1;
    inv[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    for (int i = 2; i < size; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}

long long nCk(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
}

int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    init_nCk(w + h);
    long long ans = 0;
    for (int i = 0; i < w - b; i++) {
        ans += nCk(h - a - 1 + b + i - 1 + 1, h - a - 1) * nCk(a - 1 + w - b - i - 1, a - 1) % MOD;
        ans %= MOD;
    }
    cout << ans;
}


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

int main(){
    int n,l;
    cin>>n>>l;
    vector<string> s(n);
    rep(i,n) cin>>s[i];
    sort(s.begin(),s.end());
    rep(i,n){
        cout << s[i];
    }
    
    return 0;
}


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

using ll=long long;
 
constexpr long long INF64 = 1e18;

int main(){
  int N;
  cin >> N;
  vector<int> cap(N);

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

  int Q;
  cin >> Q;
  vector<int> box(N);
  for (int i = 0; i < Q; i++) {
    int t, x, d;
    cin >> t >> x >> d; x--;
    switch (t) {
      case 1:
        box[x] += d;
        if (cap[x] < box[x]) {
          cout << x + 1 << endl;
          return 0;
        }
        break;
      case 2:
        box[x] -= d;
        if (box[x] < 0) {
          cout << x + 1 << endl;
          return 0;
        }
        break;
    }
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
/**CLICK ss---> ctrl+j**/
#define PI 2.0*acos(0.0)
#define ll              long long int
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define MOD             1000000007
#define mx              123456789
using namespace std;
void solve()
{
   int a[5];
   int i, j, k, l;
   for(i=0; i<5; i++)
   {
       cin>>a[i];
   }
   int pos=0;
   for(i=0; i<5; i++)
   {
       if(a[i]==0)
       {
           pos=i+1;
           break;
       }
   }
   cout<<pos<<endl;
}
int main()
{
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char b;
    cin >> b;
    if(b=='A'){
        cout << 'T' <<endl;
    }else if(b=='T'){
        cout << 'A' <<endl;
    }else if(b=='C'){
        cout << 'G' <<endl;
    }else{
        cout << 'C' <<endl;
    }
    return 0;
    
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        Pair[] data = new Pair[N];
        for (int i = 0; i < N; i++) {
            String s = scan.next();
            int p = scan.nextInt();
            data[i] = new Pair(i+1, s, p);
        }
        Arrays.sort(data, new PairComparator());
        for (int i = 1; i <= N; i++) {
            Pair p = data[i-1];
            System.out.println(p.id);
        }
    }
    class Pair {
        String S;
        int P;
        int id;
        Pair(int id, String S, int P) {
            this.id = id;
            this.S = S;
            this.P = P;
        }
    }
    class PairComparator implements Comparator<Pair> {
        @Override
        public int compare(Pair o1, Pair o2) {
            if (!o1.S.equals(o2.S)) {
                return o1.S.compareTo(o2.S);
            }
            return -Integer.compare(o1.P, o2.P);
        }
    }
}


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


long long N;

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

int main(){
	cin >> N;
	long long cur = -1;
	for(long long i = 0; i < N; i++){
		long long a;
		cin >> a;
		if(cur < 0){
			cur = a;
		}else{
			cur = gcd(cur, a);
		}
	}
	cout << cur << endl;

}


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

int main(){
    string s;
    cin >> s;
    deque<char> deq;

    for(int i = 0;i < s.size();i++){
        if(s[i] == 'B'){
            if(!deq.empty()){
                deq.pop_back();
            }
        }else{
            deq.push_back(s[i]);
        }
    }

    while(!deq.empty()){
        cout << deq.front();
        deq.pop_front();
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
using namespace std;
int main(){
	string str;
	ll ans = 114514;
	cin>>str;
	if(str.size()==1){
		cout<<0<<endl;
		return 0;
	}
	for(int i=0;i<str.size();i++){
		char tar = str[i];
		string tmp = str;
		ll res = 0;
		while(1){
			ll fl=0;
			for(int j=0;j<tmp.size();j++){
				if( tmp[j] != tar)fl=1;
			}
			if(fl==0)goto end;
			res++;
			string t="";
			for(int j=0;j<tmp.size()-1;j++){
				if(tmp[j] == tar || tmp[j+1] == tar){
					t.pb(tar);
				}
				else{
					t.pb(tmp[j]);
				}
			}
			tmp=t;
		}
		end: ans = min(ans,res);
	}
	cout<<ans<<endl;	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;

int main(){
vector<int> t={read(),read(),read()};
sort(t.begin(),t.end());
int k=t[2]-t[0]+t[2]-t[1];
write(k&1?(k+3>>1):k/2);
}

Measured memory_bytes: 256
a,b,c,x,y=map(int,input().split())
ans=min(x*a+y*b,2*max(x,y)*c)
if x>=y:
    ans=min(ans,2*y*c+(x-y)*a)
else:
    ans=min(ans,2*x*c+(y-x)*b)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define dF2(i,a,b) for(int i=a;i>(b);--i)
#define eF(i,u) for(int i=h[u];i;i=nxt[i])
#define ll long long
#define ld double
using namespace std;

ll Sx,Sy,Tx,Ty;
ll ansi,ansp=0;
int n,cnt,P[200001],Ans;
ll x[200001],y[200001];
ll X[200001],Y[200001],tmp[200001];
ll t[200001];
inline bool cmp(int p1,int p2){return X[p1]<X[p2];}

inline int BS(ll k){
	int l=0,r=cnt,mid,ans;
	while(l<=r){
		mid=l+r>>1;
		if(tmp[mid]>k) ans=mid, l=mid+1;
		else r=mid-1;
	}
	return ans;
}

int main(){
	scanf("%lld%lld%lld%lld",&Sx,&Sy,&Tx,&Ty);
	ansi=abs(Sx-Tx)+abs(Sy-Ty); ansi*=10;
	scanf("%d",&n);
	F(i,1,n) scanf("%lld%lld",x+i,y+i);
	if(Sx==Tx){
		if(Sy>Ty) swap(Sy,Ty);
		F(i,1,n) if(x[i]==Sx&&Sy<y[i]&&y[i]<Ty) ansi-=2, ansp+=10;
		printf("%.15lf",10.*ansi+acos(-1)*ansp); return 0;
	}
	if(Sy==Ty){
		if(Sx>Tx) swap(Sx,Tx);
		F(i,1,n) if(y[i]==Sy&&Sx<x[i]&&x[i]<Tx) ansi-=2, ansp+=10;
		printf("%.15lf",10.*ansi+acos(-1)*ansp); return 0;
	}
	if(Sx>Tx) swap(Sx,Tx), swap(Sy,Ty);
	if(Sy<Ty)
		F(i,1,n) if(Sx<=x[i]&&x[i]<=Tx&&Sy<=y[i]&&y[i]<=Ty) X[++cnt]=x[i], Y[cnt]=y[i], P[cnt]=cnt;
	if(Sy>Ty)
		F(i,1,n) if(Sx<=x[i]&&x[i]<=Tx&&Ty<=y[i]&&y[i]<=Sy) X[++cnt]=x[i], Y[cnt]=y[i], P[cnt]=cnt;
	F(i,1,cnt) t[i]=Y[i];
	sort(t+1,t+cnt+1);
	F(i,1,cnt) Y[i]=lower_bound(t+1,t+cnt+1,Y[i])-t;
	sort(P+1,P+cnt+1,cmp);
	if(Sy<Ty){
		memset(tmp,0x3f,sizeof tmp);
		tmp[0]=0;
		F(i,1,cnt){
			int k=lower_bound(tmp,tmp+cnt+1,Y[P[i]])-tmp;
			tmp[k]=min(tmp[k],Y[P[i]]);
			Ans=max(Ans,k);
		}
		if(Ans==min(abs(Sx-Tx),abs(Sy-Ty))+1) printf("%.15lf",10.*(ansi-2*Ans)+acos(-1)*5*Ans+5*acos(-1));
		else printf("%.15lf",10.*(ansi-2*Ans)+acos(-1)*5*Ans);
	}
	else{
		tmp[0]=0x3f3f3f3f;
		F(i,1,cnt){
			int k=BS(Y[P[i]]);
			tmp[k+1]=max(tmp[k+1],Y[P[i]]);
			Ans=max(Ans,k+1);
		}
		if(Ans==min(abs(Sx-Tx),abs(Sy-Ty))+1) printf("%.15lf",10.*(ansi-2*Ans)+acos(-1)*5*Ans+5*acos(-1));
		else printf("%.15lf",10.*(ansi-2*Ans)+acos(-1)*5*Ans);
	}
	return 0;
}

Measured memory_bytes: 10368
def yakusu(num):
  ret =0 
  for i in range(1,num+1):
    if(num%i==0): ret+=1
      
  return ret
N = int(input())
if(N<105):
  print(0)
  exit()
elif(N==105):
  print(1)
  exit()
else:
  ans=1
  for i in range(106,N+1):
    if(yakusu(i)==8 and i%2==1):
      ans +=1
print(ans)
      

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <numeric>
#include <queue>
#include <set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
  ll n, k;
  cin >> n >> k;
  if (k == 1)
  {
    cout << 0 << endl;
    return 0;
  }
  cout << n - k << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
 
 
 
 
 
 
 







int dp[200][200];
int x[100][100],y[100][100];
int main()
{
    int n;
    cin>>n;
    int a[n];
    int mx=0;
    for(int i=0;i<n;i++){cin>>a[i];
    mx=max(mx,a[i]);}
    if(a[0]!=0){cout<<0;return 0;}
    int ct[100005]={0};
    for(int i=0;i<n;i++){
         ct[a[i]]++;
    }
    if(ct[0]!=1){cout<<0;return 0;}
    
    ll res=1LL;
    for(int i=0;i<mx;i++){
         for(int j=0;j<ct[i+1];j++){
              
              res=(res*(ct[i]%mod2))%mod2;
              res%=mod2;
         }

    }
    cout<<res;
}


























Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int n;
    cin >> n;
    if (n == 1) {
        cout << "Hello World" << endl;
    } else {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int partition(int A[],int p,int r){
  int x,i,j,key;

  x = A[r];
  i = p - 1;
  
  for(j=p;j<=r-1;j++){
    if(A[j]<=x){
      i++;
      key=A[i];
      A[i]=A[j];
      A[j]=key;
    }
  }
  key=A[i+1];
  A[i+1]=A[r];
  A[r]=key; 

  j = i+1;
    
  for(i=0;i<r;i++){
    if(i==j)printf("[%d] ",A[i]);
    else printf("%d ",A[i]);
  }printf("%d\n",A[i]);
  
}

int main(){
  int A[100000],i,j,n;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);

  partition(A,0,n-1);
   
  return 0;
}

Measured memory_bytes: 988
N = int(input())
S = input()
ans = S.count("R") * S.count("G") * S.count("B")
for i in range(N):
    for j in range(i, N):
        k = 2*j - i
        if N > k and S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            ans -= 1
print(ans)


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

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

    if(a <= b)
    {
        for(int i = 0; i < b; i++)
        {
            cout << a;
        }
    }
    else 
    {
        for(int i = 0; i < a; i++)
        {
            cout << b;
        }
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
# C - Green Bin

n = int(input())
s = dict()

for i in range(0, n):
    char = list(input())
    char.sort()
    _str = ''.join(char)
    cnt = s[_str] + 1 if _str in s else 1
    s[_str] = cnt

ret = 0
for key, val in s.items():
    if val > 1:
        ret += sum([x for x in range(0, val)])

print(ret)

Measured memory_bytes: 17928
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    int ans = INT_MAX;
    for(int i = -100; i <= 100; i++){
        int t = 0;
        for(auto x:a){
            t += (x-i)*(x-i);
        }
        ans = min(t,ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
using ll=long long int;
using ppi=pair<ll,ll>;
using pql =priority_queue<ll, vector<ll>, greater<ll>>;
using pq=priority_queue<ll>;

int main()
{
 int n;cin>>n;
 vector<int> a(n);
 rep(i,n){
     cin>>a[i];
 }
 sort(a.begin(),a.end());
 rep(i,n-1){
     if(a[i]==a[i+1]){
         cout<<"NO"<<endl;
         return 0;
     }
 }
 cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x " "
#define debugln(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define vvdebug(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	ll K, A, B; cin >> K >> A >> B;
	ll ans;
	if (K >= A - 1 && B - A > 2) ans = A + (B - A) * ((K- A + 1) / 2) + (K - A + 1) % 2;
	else ans = 1 + K;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"from collections import deque;h,w=map(int,input().split());m=[input()for _ in[0]*h];v=[[-1]*w for _ in[0]*h];q=deque([[0,0]]);v[0][0]=0;c=sum(t.count('#')for t in m)\n"
"while q:\n"
" y,x=q.popleft()\n"
" for i,j in([1,0],[-1,0],[0,1],[0,-1]):\n"
"  t,u=y+i,x+j\n"
"  if t+1and t<h and u+1and u<w and m[t][u]=='.'and v[t][u]<0:v[t][u]=v[y][x]+1;q.append([t,u])\n"
"print(-1*(v[h-1][w-1]<0)or h*w-c-v[h-1][w-1]-1)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3652
w = gets.to_i
n = gets.to_i
d = Array.new
w.times do |i|
  d.push(i+1)
end
n.times do
  line = gets
  s = line.split(",").map(&:to_i)
  d[s[0]-1], d[s[1]-1] = d[s[1]-1], d[s[0]-1]
end
w.times do |i|
  puts d[i]
end

Measured memory_bytes: 6100
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	string s;
	cin >> s;
	cout << s.substr(0, 3) << endl;

	return 0;
}


Measured memory_bytes: 3128
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[][] mapA = new int[m+1][n+1];
		int[][] mapB = new int[m+1][n+1];
		int[][] mapC = new int[m+1][n+1];
		for(int i = 0; i < m; i++) {
			char[] in = sc.next().toCharArray();
			for(int j = 0; j < n; j++) {
				if(in[j] == 'J') mapA[i+1][j+1] = 1;
				if(in[j] == 'O') mapB[i+1][j+1] = 1;
				if(in[j] == 'I') mapC[i+1][j+1] = 1;
			}
		}
		for(int i = 0; i < m+1; i++) {
			for(int j = 1; j < n+1; j++) {
				mapA[i][j] += mapA[i][j-1];
				mapB[i][j] += mapB[i][j-1];
				mapC[i][j] += mapC[i][j-1];
			}
		}
		for(int i = 0; i < n+1; i++) {
			for(int j = 1; j < m+1; j++) {
				mapA[j][i] += mapA[j-1][i];
				mapB[j][i] += mapB[j-1][i];
				mapC[j][i] += mapC[j-1][i];
			}
		}
		for(int i = 0; i < k; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int d = sc.nextInt();
			System.out.print((mapA[c][d] + mapA[a-1][b-1] - mapA[a-1][d] - mapA[c][b-1]));
			System.out.print(" " + (mapB[c][d] + mapB[a-1][b-1] - mapB[a-1][d] - mapB[c][b-1]));
			System.out.print(" " + (mapC[c][d] + mapC[a-1][b-1] - mapC[a-1][d] - mapC[c][b-1]));
			System.out.println();
		}
		
		
		
	}
	
	
	
}

Measured memory_bytes: 177860
# include <stdio.h>

long long t;//this must use long long. otherwise the answer will be wrong.

long long f(int x)
{
	if(x==0)
		return 2;
	else
		return f(x-1)+(t*=2);
}

int main(void)
{
	long long x;
	scanf("%lld", &x);
	t = 2;
	printf("%lld\n", f(x));
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;
vvi a,c,g;
vector<vvi> b;
vi match,used;

bool BM_dfs(int v){
	used[v]=1;
	for(auto u:g[v]){
		int w=match[u];
		if(w<0||!used[w]&&BM_dfs(w)){
			match[v]=u;
				match[u]=v;
			return 1;
		}
	}
	return 0;
}
int BM(){
	int res=0;
	match=vi(2*n,-1);
	for(int i=0;i<n;i++) if(match[i]<0){
		used=vi(2*n);
		if(BM_dfs(i)) res++;
	}
	return res;
}
void Change(int u){
	int v=match[u];
	match[u]=match[v]=-1;
	vi g_;
	for(auto w:g[u]) if(w!=v) g_.push_back(w);
	g[u]=g_;
	g_.clear();
	for(auto w:g[v]) if(w!=u) g_.push_back(w);
	g[v]=g_;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m;
	a=c=vvi(n,vi(m));
	b=vector<vvi>(n,vvi(n));
	g=vvi(2*n);
	for(int i=0;i<n;i++) for(int j=0;j<m;j++){
		int t;
		cin>>t;
		t--;
		a[i][j]=t;
		b[i][t/m].push_back(t);
	}
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(!b[i][j].empty()){
		g[i].push_back(n+j);
		g[n+j].push_back(i);
	}
	for(int i=0;i<m;i++){
		BM();
		for(int j=0;j<n;j++){
			c[j][i]=b[j][match[j]-n].back();
			b[j][match[j]-n].pop_back();
			if(b[j][match[j]-n].empty()) Change(j);
		}
	}
	for(int i=0;i<n;i++) for(int j=0;j<m;j++) cout<<c[i][j]+1<<" \n"[j==m-1];
	for(int i=0;i<m;i++){
		vi d(n);
		for(int j=0;j<n;j++) d[j]=c[j][i];
		sort(d.begin(),d.end());
		for(int j=0;j<n;j++) c[j][i]=d[j];
	}
	for(int i=0;i<n;i++) for(int j=0;j<m;j++) cout<<c[i][j]+1<<" \n"[j==m-1];
}

Measured memory_bytes: 1152