akhauriyash/Code-Regression huggingface dataset:
#include <string>
 #include <vector>
 #include <algorithm>
 #include <iostream>
 #include <cstdio>
 #include <cstdlib>
 #include <cmath>
 #include <queue>
 #include <map>
 #define INF 100000000
 
 using namespace std;
 typedef long long ll;
 
 int main(){
 vector<int> a;
 for(int i=0;i<5;i++){
 int tmp;
 cin>>tmp;
 a.push_back(tmp);
 }
 sort(a.begin(),a.end());
 for(int i=4;i>=0;i--){cout<<a[i];if(i!=0)cout<<" ";}
 cout<<endl;
 return 0;
 }

Measured memory_bytes: 1224
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[100100],t[101000];
int as[101000],at[100100],bs[101000],bt[100100];
int main()
{
	scanf("%s%s",s,t);int lens=strlen(s),lent=strlen(t);
	for(int i=1;i<=lens;i++)
	{
		as[i]=as[i-1];bs[i]=bs[i-1];
		if(s[i-1]=='A')as[i]++;
		if(s[i-1]=='B')bs[i]++;
	}
	for(int i=1;i<=lent;i++)
	{
		at[i]=at[i-1];bt[i]=bt[i-1];
		if(t[i-1]=='A')at[i]++;
		if(t[i-1]=='B')bt[i]++;
	}
	int q;scanf("%d",&q);
	for(int i=1;i<=q;i++)
	{
		int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);
		if(((as[b]-as[a-1])+(bs[b]-bs[a-1])*2)%3==((at[d]-at[c-1])+(bt[d]-bt[c-1])*2)%3)puts("YES");
		else puts("NO");
	}
	return 0;
 } 

Measured memory_bytes: 2304
import sys

N_MAX = 200000 + 5
INF = 10**9 + 7
sys.setrecursionlimit(N_MAX)
MOD = 10**9 + 7

n = int(input())
Arr = list(map(int,input().split()))

K = 43

#
A = Arr[0]
B = Arr[1]

S = A + B
X = 0
for i in range(2, len(Arr)):
    X ^= Arr[i]

# print(S, X)

# 次を満たすa, b が見つかるか？
#  a+b=S, a^b=X, a<=A

# 桁DP : 桁を一つずつ決めていくようなDP
# dp[今の桁数 = 0:42][繰り上がりがあるか = 0,1][今までがA以下かどうか 0=以下、1=より大きい] = 最大値
# 値は最大値。満たすものがなければ -1
dp = [[[-1 for x in [0, 1]] for _ in [0, 1]] for _ in range(K)]

dp[0][0][0] = 0  # 最初

v = 1
for i in range(K - 1):  # 桁数
    cx = X & 1  # current X
    cs = S & 1  # current S
    ca = A & 1  # current A
    for j in range(2):  # 繰り上がりある／ない
        for k in range(2):  # 今までの範囲が A 以下かどうか
            if dp[i][j][k] == -1:  #
                continue

            for na in range(2):
                for nb in range(2):
                    ni = i + 1
                    nj = 0
                    nk = k
                    if na ^ nb != cx:  # a ^ b = A か？
                        continue

                    ns = na + nb + j
                    if ns % 2 != cs:  # a + b = S か？
                        continue

                    # ここで遷移は確定

                    if ns >= 2:  # 繰り上がり処理
                        nj = 1

                    if ca < na:
                        nk = 1
                    elif ca == na:
                        nk = k
                    else:
                        nk = 0

                    dp[ni][nj][nk] = max(dp[ni][nj][nk], dp[i][j][k] | (v * na))

    X >>= 1
    S >>= 1
    A >>= 1
    v <<= 1
    # print(v)

a = dp[K - 1][0][0]
if a == -1 or a == 0:
    print(-1)
else:
    print(Arr[0] - a)

Measured memory_bytes: 9268
N = int(input())
a = [list(map(int, input().split())) for _ in range(N)]

dp = [[0, 0, 0] for _ in range(100010)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k])
print(max(dp[N]))
#配るDP
# dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))

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

unsigned long long minMulti(int A, int B)
{
    unsigned long long result = A;
    unsigned long long i = 1;
    while(1) {
        unsigned long long  tmp = A * i;
        if (tmp % B == 0) {
            return tmp;
        }
        i++;
    }
}


int main()
{
    int A,B;
    cin >> A >> B;
    if (A < B) {
        cout << minMulti(B,A) << endl;
    } else if (A > B) {
        cout << minMulti(A,B) << endl;
    } else {
        cout << A << endl;
    }
    return 0;
}


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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'i' || c == 'u' ||
      c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else {
	  cout << "consonant" << endl;
  }
}

Measured memory_bytes: 3532
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int A, B, K;
    cin >> A >> B >> K;
    int min_num;
    vector<int> vc;
    int num = 0;
    min_num = min(A, B);
    for(int i = 1; i <= min_num; i++){
        if(A % i == 0 && B % i == 0){
            vc.push_back(i);
            num++;
        }
    }
    sort(vc.begin(), vc.end(), greater<int>());
    cout << vc[K - 1] << endl;
}

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

long long mod = 1e9+7;
int main(){
    long long n;
    cin >> n;
    long long a[n];
    map<long long, long long> T;
    for(long long i = 0; i < n; i++){
        cin >> a[i];
        if(T.find(a[i]) == T.end()){
            T[a[i]] = 1;
        }
        else{
            T[a[i]]++;
        }
    }

    map<long long, long long>::iterator it;
    bool flag = true;
    if(n % 2 != 0){
        for(it = T.begin(); it != T.end(); it++){
            if(it->first == 0){
                if(it->second != 1){
                    flag = false;
                    break;
                }
            }
            else{
                if(it->second != 2){
                    flag = false;
                    break;
                }
            }
        }
    }
    else{
        for(it = T.begin(); it != T.end(); it++){
            if(it->second != 2){
                flag = false;
                break;
            }
        }
    }

    if(flag == false){
        printf("0\n");
    }
    else{
        long long ans = 1;
        if(n % 2 == 0){
            for(long long i = 0; i < n/2; i++){
                ans *= 2;
                ans %= mod;
            }
        }
        else{
            for(long long i = 0; i < n/2; i++){
                ans *= 2;
                ans %= mod;
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll x = s.size();
    REP(i, x) {
        int nxt = ((s[i] - 'A') + n) % 26;
        char res = ('A' + nxt);
        cout << res;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <algorithm>
#include <functional>
#include <limits.h>
#include <bitset>

#include <tuple>
#include <unordered_map>

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int INF = 1 << 29;
const double EPS = 1e-9;

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

struct edge {
  int tar;
  int cost;
  edge() {}
  edge(int tar, int cost) : tar(tar), cost(cost) {}
};
bool visit[MAX_N];
vector<edge> edges[MAX_N];
int dp[MAX_N][2];
int N;
int memo(int pos) {
  visit[pos] = true;
  int res = 0;
  for (int i = 0; i < edges[pos].size(); i++) {
    edge e = edges[pos][i];
    if (visit[e.tar])
      continue;
    res = max(res, memo(e.tar));

    if (dp[pos][0] < dp[e.tar][0] + e.cost) {
      dp[pos][1] = dp[pos][0];
      dp[pos][0] = dp[e.tar][0] + e.cost;
    } else if (dp[pos][1] < dp[e.tar][0] + e.cost) {
      dp[pos][1] = dp[e.tar][0] + e.cost;
    }
    res = max(res, dp[pos][0] + dp[pos][1]);
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  for (int i = 0; i < N - 1; i++) {
    int s, t, w;
    cin >> s >> t >> w;
    edges[s].push_back(edge(t, w));
    edges[t].push_back(edge(s, w));
  }
  cout << memo(0) << endl;
  return 0;
}

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

int N;
string S;

void solve() {
    //cout.precision(10);
    cin >> N >> S;
    S.push_back('#');
    int ans = 0;
    for(int i = 0; i + 1 < S.size(); i++) {
        if(S[i] != S[i+1]) ans++;
    }
    cout << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

#define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()
#define sz(x) ((long long)x.size())
#define arr array

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e10;


void pre(){



}

string s;
int k,n;
int dp[105][105][2];
bool vis[105][105][2];

int go(int pos,int cnt,int flg){
    if(pos >= n){
        return cnt == k;
    }
    if(vis[pos][cnt][flg])
        return dp[pos][cnt][flg];
    vis[pos][cnt][flg] = true;
    int limit = 9;
    if(flg) limit = s[pos]-'0';
    int ans=0;
    for(int d=0;d<=limit;d++){
        int isNonZero = (d == 0) ? 0 : 1;
        if(flg and d == limit){
            ans += go(pos+1,cnt + isNonZero,1);
        }else{
            ans += go(pos+1,cnt + isNonZero,0);
        }
    }
    return dp[pos][cnt][flg] = ans;
}

void solve(){  

    cin >> s >> k;
    n = s.size();
    int ans = go(0,0,1);
    cout << ans << endl;

}   

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input00.txt","r",stdin);
    #endif
    IOS;
    pre();
    ll T = 1;   
    //cin>>T;
    ll tt = 1;
    while(T--){  
        //cout << "Case #" << tt << ": "; 
        tt++;
        solve();
    }
    return 0;
}

Measured memory_bytes: 3668
#define _GLIBCXX_DEBUG
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <random>
#include <utility>
#include <map>
#include <vector>
#include <queue>
#include <bitset>
#include <sstream>

using namespace std;

#define REP(i,x) for(int i=0; i<(x); i++)
#define all(x) (x).begin(),(x).end()
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;


int main(int argc, const char * argv[]) {
    
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vi p(a), q(b), r(c);
    REP(i, a)cin >> p[i];
    REP(i, b)cin >> q[i];
    REP(i, c)cin >> r[i];

    sort(all(p));
    sort(all(q));
    
    REP(i, x){
        r.push_back(p.back());
        p.pop_back();
    }
    REP(i, y){
        r.push_back(q.back());
        q.pop_back();
    }
    sort(all(r));
    ll ans = 0;
    REP(i, x+y){
        ans += r.back();
        r.pop_back();
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 2552
#include <stdio.h>
int euclide(int a,int b){
    int max,min,tmp;
    if(a<=b){//代入
        max=b;
        min=a;
    }else{
        max=a;
        min=b;
    }

    while(1){
        if(max % min == 0){
            return min;
        }
        //printf("max=%d min=%d max %% min=%d \n",max,min,max%min);
        max = max % min;
        tmp = max;
        max = min;
        min = tmp;
    }
}
int main(void)
{
    int n;
    int i,j,k;;
    unsigned long int sum=0;
    scanf("%d",&n);

    for(i=1;i<=n;i++){
        for(j=i;j<=n;j++){
           for(k=j;k<=n;k++){
                //printf("a=%d b=%d c=%d\n",i,j,k);
                if(i==j && j==k){
                    sum += euclide(euclide(i,j),k);    
                }else if(i==j || j==k || i==k){
                    sum += euclide(euclide(i,j),k) * 3;
                }else{
                    sum += euclide(euclide(i,j),k) * 6;
                }  
                //printf("%ld\n",sum);         
            }
        }
    }

    printf("%ld\n",sum);
    return 0;
}

Measured memory_bytes: 1708
#include <stdio.h>
 
int main(void) {
 
int H,W,x,y;char s;
scanf("%d %d\n",&H,&W);
while((H!=0)||(W!=0)){
for(y=1;y<=H;y++){
s=((y==1)||(y==H))?'#':'.';
printf("#");
for(x=1;x<=W-2;x++){
printf("%c",s);
}
printf("#\n");
}
printf("\n");
scanf("%d %d\n",&H,&W);
}
return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
	int N, i, j;
	scanf("%lld", &N);
	vector<int> L(N);
	vector<int> S(3001, 0);
	for(i = 0; i < N; i++){
		scanf("%lld", &L[i]);
		S[L[i]]++;
	}
	for(i = 1; i <= 3000; i++){
		S[i] += S[i - 1];
	}
	int ans = 0;
	for(i = 0; i < N; i++){
		for(j = i + 1; j < N; j++){
//			printf("(L[i], L[j]) = (%lld, %lld)\n", L[i], L[j]);
			int M = L[i] + L[j];
			int m = max(L[i] - L[j], L[j] - L[i]);
//			printf("(M, m) = (%lld, %lld)\n", M, m);
			ans += S[M - 1] - S[m];
			if(m < L[i] && L[i] < M){
				ans--;
			}
			if(m < L[j] && L[j] < M){
				ans--;
			}
//			printf("ans= %lld\n", ans);
		}
	}
	printf("%lld\n", ans / 3);
	return 0;
}

Measured memory_bytes: 256
import bisect
import sys
sys.setrecursionlimit(10**9)

N = int(input())
A = list(map(int, input().split()))

tree = [[] for i in range(N)]
for i in range(N-1):
  u, v = map(int, input().split())
  tree[u-1].append(v-1); tree[v-1].append(u-1)


ans = [0] * N
ans[0] = 1
INF = 10**10
dp = [INF] * N
dp[0] = A[0]
def dfs(node, par, n):
  global ans
  global dp
  children = tree[node]
  for child in children:
    if child == par:
      continue
    num = A[child]
    idx = bisect.bisect_left(dp, num)
    _idx, _num = idx, dp[idx] # 巻き戻し用に退避
    dp[idx] = num
    _n = max(n, idx + 1)
    ans[child] = _n
    dfs(child, node, _n)
    # 巻き戻し
    dp[_idx] = _num

dfs(0, -1, 1)
print(*ans, sep='\n')

Measured memory_bytes: 232924
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c,k,answer;
    cin>>a>>b>>c>>k;
    if(a+b>=k){
    if(a<=k){
    cout<<a<<endl;}
    else{
    cout<<k<<endl;}}
    else{ 
    answer=a-(k-(a+b));
    cout<<answer<<endl;}
  return 0;
    }


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,X;
  cin >> N >> X;
  int D=0,ans=1;
  for (int i=0;i<N;i++){
    int x;
    cin >> x;
    D+=x;
    if (D<=X){
      ans++;
    }
    else {
      break;
    }
  }
  cout << ans << endl;
}

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

int main(){
	string input;

	while(getline(cin, input)){
	//getline(cin, input);
		while(1){
			for(int i = 0; i < input.size(); i++){
				if('a' <= input[i] && input[i] <= 'z'){
					if(input[i] != 'z'){
						input[i] += 1;
					}else{
						input[i] = 'a';
					}
				}
			}
			if(input.find("the") != string::npos || input.find("this") != string::npos || input.find("that") != string::npos){
				cout << input << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>
#include <time.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n;
  int p[10];
  cin >> n;
  for(int i = 0; i < n; i++) cin >> p[i];

  int mx = 0;
  int sum = 0;
  for(int i = 0; i < n; i++) {
    mx = max(mx, p[i]);
    sum += p[i];
  }

  cout << sum - mx / 2 << endl;
}


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

int main() {
  int N; cin >> N;
  string S; cin >> S;
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    auto v1 = vector<bool>(26, false);
    auto v2 = vector<bool>(26, false);
    for (int j = 0; j < i; ++j) v1[S[j] - 'a'] = true;
    for (int j = i; j < N; ++j) v2[S[j] - 'a'] = true;

    int cnt = 0;
    for (int j = 0; j < 26; ++j) if (v1[j] && v2[j]) ++cnt;
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main(void) {
  int debt = 100000;
  int interest = 5;
  int money = debt;
  int n;
 
  scanf("%d", &n);
  while (n--) {
    money += money * interest / 100;
    money = ceil(money / 1000.0) * 1000;
  }
 
  printf("%d\n", money);
 
  return 0;
}

Measured memory_bytes: 592
#include <cstdio>

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

	int a[100];
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}

	for (int i = n-1; i >= 0; --i) {
		if (i != n-1) printf(" ");
		printf("%d", a[i]);
	}
	printf("\n");
}

Measured memory_bytes: 1028
#include <stdio.h>
int a[200010];
int main()
{
  int n;
  scanf("%d",&n);
  for (int i=0;i<n;++i)
    scanf("%d",&a[i]);
  long long ans=0;
  for (int i=1;i<n;++i){
    if (a[i]<a[i-1]){
      ans+=a[i-1]-a[i];
      a[i]=a[i-1];
    }
  }
  printf("%lld\n",ans);
}

Measured memory_bytes: 2472
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#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 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 set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  ll H,W,N;
  cin >> H >> W >> N;
  vector<ll> ans(10,(ll)0);
  ans[0] = (ll)(H-2) * (ll)(W-2);
  map<P,int> mp;
  rep(i,N) {
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    srep(dx,-1,2) {
      srep(dy,-1,2) {
        int x = a + dx;
        int y = b + dy;
        if(x >= 1 && x < H-1&& y >= 1 && y < W-1) {
          ans[mp[P(x,y)]]--;
          mp[P(x,y)]++;
          ans[mp[P(x,y)]]++;
        }
      }
    }
  }
  rep(i,10) {
    cout << ans[i] << endl;
  }
  return 0;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<vector<int>> dp(n+5,vector<int>(n+5,0));
	for(int i = n - 1; i >= 0; i--){
		for(int j = n - 1; j >= 0; j--){
			if(s[j] == s[i]){
				dp[i][j] = dp[i+1][j+1] + 1;
			}
		}
	}
	int ans = 0;
	rep(i,n){
		rep(j,n){
			if(i >= j) continue; // i < j だけ見たい
			int now = min(dp[i][j], j-i);
			ans = max(ans, now);
		} 
	}
	cout << ans << endl;
}


Measured memory_bytes: 98304
import sys

n, m = map(int, input().split())
x_list = list(map(int, input().split()))
x_list.sort()
gap_list = []
ans = 0

if n >= m:
    print(ans)
    sys.exit(0)
elif n < m:
    for i in range(1, len(x_list)):
        gap_list.append(abs(x_list[i - 1] - x_list[i]))

    gap_list.sort()
    ans = sum(gap_list[0:m - n])

print(ans)

Measured memory_bytes: 13960
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  long long sum=0;
  for(int i=1;i<=n;i++){
    if(i%3==0 || i%5==0){
      continue;
    }
    else{
      sum+=i;
    }
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 3672
(let* ((n (read))
       (a (loop for i from 1 to n collect (read)))
       (b (loop for i from 1 to n collect (read)))
       (c (loop for i from 1 to (1- n) collect (read)))
       (s 0))
  (loop for i from 0 to (1- n)
        do (incf s (+ (nth (1- (nth i a)) b)
                      (if (equal (1+ (nth i a)) (nth (1+ i) a))
                          (nth (1- (nth i a)) c)
                          0))))
  (format t "~A~%" s))

Measured memory_bytes: 7012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

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

int main() {
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    int ans[55][55] = {};
    for (int i = 0; i < h; ++i) {
        cin >> s[i];
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            int cnt = 0;
            for (int k = 0; k < 8; ++k) {
                int nx,ny;
                nx = i+dx[k];
                ny = j+dy[k];
                if(nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
                if(s[nx][ny] == '#') cnt++;
            }
            ans[i][j] = cnt;
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if(s[i][j] != '#') cout << ans[i][j];
            else cout << '#';
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    //Scaner sc=new Scanner(System.in);
    val a=sc.nextInt()
    val b=sc.nextInt()

    if(a<9&&b<9)
        println("Yay!")
    else
        println(":(")
}

Measured memory_bytes: 36420
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

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

class BipartiteGraph {
private:
  int V;
  vector<int>* G;
  int* match;
  bool* used;
public:
  BipartiteGraph(int n){
    V = n;
    match = new int[n];
    used = new bool[n];
    G = new vector<int>[n];
  }

  ~BipartiteGraph(){
    delete[] match;
    delete[] used;
    delete[] G;
  }

  void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
  }

  bool dfs(int v){
    used[v] = true;
    for(int i=0;i<G[v].size();i++){
      int u = G[v][i];
      int w = match[u];
      if(w < 0 || (!used[w] && dfs(w))){
	match[v] = u;
	match[u] = v;
	return true;
      }
    }
    return false;
  }

  int bipartite_matching() {
    int res = 0;
    fill(match,match+V,-1);
    for(int v=0; v < V;v++){
      if(match[v] < 0){
	fill(used,used+V,false);
	if(dfs(v)){
	  res++;
	}
      }
    }
    return res;
  }
};

int main(){
  int total_blue_cards;
  int total_red_cards;
  while(~scanf("%d %d",&total_blue_cards,&total_red_cards)){
    if(total_blue_cards == 0 && total_red_cards == 0) break;

    int red_cards[501];
    int blue_cards[501];

    for(int blue_card_idx = 0; blue_card_idx < total_blue_cards; blue_card_idx++){
      int num;
      scanf("%d",&num);
      blue_cards[blue_card_idx] = num;
    }
    for(int red_card_idx = 0; red_card_idx < total_red_cards; red_card_idx++){
      int num;
      scanf("%d",&num);
      red_cards[red_card_idx] = num;
    }

    BipartiteGraph bg(total_blue_cards + total_red_cards);
    for(int blue_card_idx = 0; blue_card_idx < total_blue_cards; blue_card_idx++){
      for(int red_card_idx = 0; red_card_idx < total_red_cards; red_card_idx++){
	int div = gcd(blue_cards[blue_card_idx],red_cards[red_card_idx]);
	if(div != 1){
	  bg.add_edge(blue_card_idx,total_blue_cards+red_card_idx);
	}
      }
    }

    printf("%d\n",bg.bipartite_matching());
  }
}

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

int main(void) {
	int i;
	char s[1001]="";
	int sum;

	while (1) {
		scanf("%s", &s);
		sum = 0;
		for (int k = 0; s[k] != '\0'; k++) {
			i = ((int)s[k])-48;

			if (i == 0 && s[1] == '\0') {
				return 0;
			}


			sum += i;
		}

		printf("%d\n", sum);
	}
	return 0;
}


Measured memory_bytes: 2104
# include "cmath"
# include "queue"
# include "cstdio"
# include "cstring"
# include "iostream"
# include "algorithm"
# define Maxn 1005
# define fi first
# define se second
# define P pair<int,int>
# define rep(i,x,y) for(int i=x;i<=y;i++)
# define rep_d(i,x,y) for(int i=x;i>=y;i--)
# define rep_t(u) for(int i=head[u];i;i=f[i].next)
using namespace std;
typedef long long ll;
inline int read()
{
	int ok=1,k=0;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')
		ok=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		k=k*10+c-'0';
		c=getchar();
	}
	return ok*k;
}
int f[Maxn];
int main()
{
	int n;
	n=read();
	rep(i,1,n)
	f[i]=read();
	sort(f+1,f+n+1);
	int ans=0;
	rep(x,1,n-2)
	{
		rep(y,x+1,n-1)
		{
			int l=y;
			int c=f[y]+f[x];
			int r=lower_bound(f+y+1,f+n+1,c)-f-1;
//			cout<<x<<' '<<y<<' '<<l<<' '<<r<<endl;
			if(f[l]>=f[y]+f[x])
			continue;
			ans+=r-l;
//			cout<<x<<' '<<y<<' '<<r<<' '<<l<<endl; 
		}
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   char s[100];
   cin>>s;
   if(strcmp(s,"SUN")==0)
    cout<<7<<endl;
   if(strcmp(s,"MON")==0)
    cout<<6<<endl;
    if(strcmp(s,"TUE")==0)
    cout<<5<<endl;
    if(strcmp(s,"WED")==0)
    cout<<4<<endl;
    if(strcmp(s,"THU")==0)
    cout<<3<<endl;
    if(strcmp(s,"FRI")==0)
    cout<<2<<endl;
    if(strcmp(s,"SAT")==0)
    cout<<1<<endl;
    return 0;
}


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

#define int long long
#define uint unsigned int
#define pii pair<int, int>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define ALL(c) ((c).begin()), ((c).end())

#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)

#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))

#define PW(n) (1LL << (n))

using namespace std;

template <class T> inline bool CHMIN(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline void SORT(T &a) { sort(a.begin(), a.end()); }
template <class T> inline void REV(T &a) { reverse(a.begin(), a.end()); }
template <class T> inline void UNI(T &a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }

template <class S, class T> ostream& operator << (ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")"; return os;
}

const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

/* ---------------------------------------------------------------------------------------------------- */

int N, Q;
string S;
char t[200010], d[200010];

bool check(string s, int x, int b) {
  REP(i, Q) {
    if (t[i] == s[x]) {
      if (b > 0) {
        if (d[i] == 'L') x--;
        else x++;
      } else {
        if (d[i] == 'L') x++;
        else x--;
      }
      if (x < 0) return true;
    }
  }
  return false;
}

int calc(string s, int b) {
  int ok = -1, ng = N;
  while (ng - ok > 1) {
    int m = (ok + ng) / 2;
    if (check(s, m, b)) ok = m;
    else ng = m;
  }
  return ng;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> Q >> S;
  REP(i, Q) cin >> t[i] >> d[i];
  int L = calc(S, 1);
  reverse(ALL(S));
  int R = calc(S, -1);
  cout << N - L - R << endl;

  return 0;
}

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

using namespace std;

const int N = 200 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n = 100000, m;
vector<int> g[N];
int cnt[2];
bool used[N];

bool read() {
    if (!(cin >> m))
        return false;

    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].emplace_back(n + v);
        g[n + v].emplace_back(u);
    }

    return true;
}

void dfs(int v) {
    used[v] = true;
    ++cnt[(v - 1) / n];

    for (auto to : g[v])
        if (!used[to])
            dfs(to);
}

void solve() {
    auto ans = 0ll;

    for (int x = 1; x <= n; ++x)
        if (!used[x]) {
            cnt[0] = cnt[1] = 0;
            dfs(x);
            ans += 1ll * cnt[0] * cnt[1];
        }
    
    cout << ans - m << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 10240
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	v := getNextInt(scanner)
	p := getNextInt(scanner)
	aa := make([]int, n)
	ss := make([]int64, n+1)

	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	sort.Ints(aa)
	for i := 0; i < n; i++ {
		ss[i+1] = ss[i] + int64(aa[i])
	}

	ans := p
	var horobiyo int64
	for i := 0; i < n-p; i++ {
		if aa[i]+m < aa[n-p] {
			continue
		}
		// m*vだけ増える
		horobiyo = int64(m) * int64(v)
		// 自分以下
		horobiyo -= int64(i+1) * int64(m)
		// P番目より大きい
		horobiyo -= int64(p-1) * int64(m)
		// i+1番目～n-p番目はaa[i]+mまで加算できる
		horobiyo -= int64(aa[i]+m)*int64(n-p-i) - (ss[n-p+1] - ss[i+1])
		if horobiyo <= 0 {
			ans++
			continue
		}
	}

	fmt.Fprintln(writer, ans)
}


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

typedef pair <int, int> pii;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;

int N, M;
int x[MAXN], y[MAXN];
vector <pii> v;
vector <int> comp;
int f[MAXN];

void load() {
	scanf("%d%d", &N, &M);
	for (int i = 0; i < N; i++)
		scanf("%d", x + i);
	for (int i = 0; i < M; i++)
		scanf("%d", y + i);
}

inline int add(int x, int y) {
	x += y;
	if (x >= MOD)
		x -= MOD;
	return x;
}

void update(int x, int val) {
	for (x++; x < MAXN; x += x & -x)
		f[x] = add(f[x], val);
}

int get(int x) {
	int res = 0;
	for (x++; x; x -= x & -x)
		res = add(res, f[x]);
	return res;
}

int solve() {
	for (int i = 0; i < N; i++) 
		if (x[i] > y[0] && x[i] < y[M - 1]) {
			int pos = lower_bound(y, y + M, x[i]) - y;
			v.push_back({x[i] - y[pos - 1], x[i] - y[pos]});
		}
	
	sort(v.begin(), v.end());
	v.resize(unique(v.begin(), v.end()) - v.begin());
	
	for (auto &it : v) {
		it.second *= -1;
		comp.push_back(it.second);
	}
	
	sort(comp.begin(), comp.end());		
	
	int sol = 1;
	for (auto it : v) {
		int tmp = lower_bound(comp.begin(), comp.end(), it.second) - comp.begin();
		int dp = add(get(tmp - 1), 1);
		sol = add(sol, dp);
		update(tmp, dp);
	}
	
	return sol;
}

int main() {
	load();
	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 3060
N, M, L = map(int, input().split())
D = [[1000000000000]*N for i in range(N)]
for i in range(N):
  D[i][i] = 0
for i in range(M):
  A, B, C = map(int, input().split())
  A, B = A-1, B-1
  D[A][B] = C
  D[B][A] = C
for k in range(N):
  for i in range(N):
    for j in range(N):
      D[i][j] = min(D[i][j], D[i][k]+D[k][j])
E = [[1000000000000]*N for i in range(N)]
for i in range(N):
  E[i][i] = 0
for i in range(N):
  for j in range(N):
    if D[i][j] <= L:
      E[i][j] = 1
for k in range(N):
  for i in range(N):
    for j in range(N):
      E[i][j] = min(E[i][j], E[i][k]+E[k][j])
Q = int(input())
for i in range(Q):
  s, t = map(int, input().split())
  s, t = s-1, t-1
  if E[s][t] == 1000000000000:
    r = -1
  else:
    r = E[s][t]-1
  print(r)


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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define PRINT(s) cout<<s
#define PRINTS(s) cout<<s<<' '
#define PRINTL(s) cout<<s<<endl
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long

using namespace std;



int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int n;
    cin>>n;
    int min=INF,max=0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(min>a)min=a;
        if(max<a)max=a;
    }

    cout<<max-min<<endl;

    return 0;
}




Measured memory_bytes: 256
N = int(input())
a = sorted(map(lambda x, y: [int(y), x], range(1, N+1), input().split()))
 
m = N // 2
am = a[m][0]
amp = a[m-1][0]

a = sorted(zip(a, range(N)), key=lambda x:x[0][1])
for _, i in a:
  print(am if i < m else amp)

Measured memory_bytes: 60484
#include<bits/stdc++.h>
using namespace std;
typedef pair<double,int> P;

int main(){
	vector<P>a,b,c;
	for(int i=0;i<8;i++){
		int num;
		double t;
		cin>>num>>t;
		a.push_back(P(t,num));
		}
	for(int i=0;i<8;i++){
		int num;
		double t;
		cin>>num>>t;
		b.push_back(P(t,num));
		}	
	for(int i=0;i<8;i++){
		int num;
		double t;
		cin>>num>>t;
		c.push_back(P(t,num));
		}	
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	sort(b.begin(),b.end());
	reverse(b.begin(),b.end());
	sort(c.begin(),c.end());
	reverse(c.begin(),c.end());
	cout<<a[7].second<<' '<<a[7].first<<endl;
	cout<<a[6].second<<' '<<a[6].first<<endl;
	cout<<b[7].second<<' '<<b[7].first<<endl;
	cout<<b[6].second<<' '<<b[6].first<<endl;
	cout<<c[7].second<<' '<<c[7].first<<endl;
	cout<<c[6].second<<' '<<c[6].first<<endl;
	for(int i=0;i<2;i++)a.pop_back();
	for(int i=0;i<2;i++)b.pop_back();
	for(int i=0;i<2;i++)c.pop_back();
	
	for(int i=0;i<6;i++)a.push_back(b[i]);
	for(int i=0;i<6;i++)a.push_back(c[i]);
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	cout<<a[17].second<<' '<<a[17].first<<endl;
	cout<<a[16].second<<' '<<a[16].first<<endl;
	
	return 0;
		
	}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define rof(i,a,b) for(int (i)=(a);(i) > (b); --(i))
#define rep(i, c) for(auto &(i) : (c))
#define x first
#define y second
#define pb push_back
#define PB pop_back()
#define iOS ios_base::sync_with_stdio(false)
#define sqr(a) (((a) * (a)))
#define all(a) a.begin() , a.end()
#define error(x) cerr << #x << " = " << (x) <<endl
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define errop(a) cerr<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define L(x) ((x)<<1)
#define R(x) (((x)<<1)+1)
#define umap unordered_map
#define double long double
typedef long long ll;
typedef pair<int,int>pii;
typedef vector<int> vi;
typedef complex<double> point;
template <typename T> using os =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>  inline void smax(T &x,T y){ x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){ x = min((x), (y));}
int main(){
	iOS;
	ll n, x;
	cin >> n >> x;
	x = __gcd(x, n);
	ll ans = 3 *  (n-x);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N;
  cin >> N;
 
    int x, y, c1, c2;
  c1 = 0;
    cin >> x;
    while(x%2==0) {
      x /=2;
      c1 ++;
    }
  for (int i=0;i<N-1;i++){
    c2 =0;
    cin >> y;
  while(y%2==0) {
      y /=2;
      c2 ++;
    }
    if(c1>=c2) c1 = c2;
  }
    cout << c1 << endl;

 }
   


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


int main()
{
    ll X, Y, Z, K; cin >> X >> Y >> Z >> K;
    vll A(X); rep(i, X) cin >> A[i];
    vll B(Y); rep(i, Y) cin >> B[i];
    vll C(Z); rep(i, Z) cin >> C[i];
    sort(all(A));
    sort(all(B));
    sort(all(C));
    reverse(all(A));
    reverse(all(B));
    reverse(all(C));

    priority_queue<pair<ll, vector<ll>>> que;

    que.push({A[0] + B[0] + C[0], {0, 0, 0}});
    vvll used;

    rep(i, K) {
        pair<ll, vector<ll>> elem;
        do {
            elem = que.top(); que.pop();
        } while (find(all(used), elem.second) != used.end());
        used.push_back(elem.second);
        ll a = elem.second[0], b = elem.second[1], c = elem.second[2];
        cout << elem.first << endl;
        if (a < A.size()-1) {
            que.push({A[a + 1] + B[b] + C[c], {a + 1, b, c}});
        }
        if (b < B.size()-1) {
            que.push({A[a] + B[b + 1] + C[c], {a, b + 1, c}});
        }
        if (c < C.size()-1) {
            que.push({A[a] + B[b] + C[c + 1], {a, b, c + 1}});
        }
    }
    return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = a * b;
		
		if(c % 2 == 1) {
			System.out.println("Odd");
		}else if(c % 2 == 0) {
			System.out.println("Even");
		}
	}

}

Measured memory_bytes: 22740
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  while(n!=0){
    int i;
    double s[1000]={},sum=0,a=0;
    for(i=0;i<n;i++){
      cin >> s[i];
      sum+=s[i];
    }
    for(i=0;i<n;i++){
      a+=((sum/n)-s[i])*((sum/n)-s[i])/n;
    }
    printf("%.5f\n",sqrt(a));
    cin >> n;
  }
  
  return 0;
}



Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int ans;
  if(n%1000==0) ans=0;
  
  else 
  {
    ans=1000-(n%1000);
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3620
// 2020-07-26 05:25:43
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

const int MX = 15;
int x[MX], y[MX], p[MX], dx[1<<MX][MX], dy[1<<MX][MX];
ll ans[MX+1];
void answer() {
  int n;
  cin >> n;
  rep(i, n) cin >> x[i] >> y[i] >> p[i];
  rep(s, 1<<n) {
    rep(i, n) {
      dx[s][i] = abs(x[i]);
      dy[s][i] = abs(y[i]);
      rep(j, n) {
        if((s>>j)&1) {
          chmin(dx[s][i], abs(x[i] - x[j]));
          chmin(dy[s][i], abs(y[i] - y[j]));
        }
      }
    }
  }
  repc(k, n) ans[k] = ll(1e18);
  rep(s, 1<<n) {
    int k = __builtin_popcount(s);
    for(int sx = s; sx >= 0; sx--) {
      sx &= s;
      int sy = s - sx;
      ll tot = 0;
      rep(i, n) {
        if(!((s>>i)&1)) {
          tot += ll(p[i]) * min(dx[sx][i], dy[sy][i]);
        }
      }
      chmin(ans[k], tot);
    }
  }
  repc(k, n) cout << ans[k] << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 7428
/**
 *    Author:  Oak_limy
 *    Created: 2020-08-29 21:25:15
**/
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
       if(x%i==0)return false;
   }return true;
}bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline int readint() {
    char c = getchar(); int w = 1; int x = 0;
    while (!isdigit(c))
        (c == '-') && (w = -w), c = getchar();
    while (isdigit(c))
        x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
    x *= w;
    return x;
}
inline ll readll() {
    char c = getchar(); ll w = 1; ll x = 0;
    while (!isdigit(c))
        (c == '-') && (w = -w), c = getchar();
    while (isdigit(c))
        x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
    x *= w;
    return x;
}
void fl(string name){
    freopen((name+".in").c_str(),"r",stdin);
    freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
          dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
#define MAXN 1000100
ll n,m,p,tree[200010];
ll a[MAXN],f[MAXN];
int main(){
    cin>>n;ll g;
    rp(i,1,n){
        cin>>a[i];
        f[a[i]]=1;
        if(i==1)g=a[i];
        else g=gcd(a[i],g);
    }
    if(g>1){
        cout<<"not coprime"<<endl;
        return 0;
    }
    rp(i,2,1000000){
        ll flag=0;
        for(int j=i;j<=1000000;j+=i){
            if(f[j])flag++;
        }
        if(flag>=2){
            cout<<"setwise coprime"<<endl;
            return 0;
        }
    }
    cout<<"pairwise coprime"<<endl;
    return 0;
}
/* stuff to remember
    * int overflow, array bounds
    * special cases (n=1? n=0?)
    * do something instead of nothing and stay organized
    * USE STATIC ARRAYS
    * DEFINING ARRAYS BEFORE main()
    * DO NOT DEFINE ARRAYS IN main()
    * USE INT INSTEAD OF LL,NOTICE THE MLE
*/


Measured memory_bytes: 19032
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    int n;
    cin>>n;
    vector<int> as(n);
    rep(i, n) cin>>as[i];

    vector<int> bs;
    vector<int> cs;
    rep(i, n) {
        if (i % 2 == 0) bs.push_back(as[i]);
        else cs.push_back(as[i]);
    }
    if (n % 2 == 0) {
        reverse(cs.begin(), cs.end());
        rep(i, cs.size()) cout<<cs[i]<<endl;
        rep(i, bs.size()) cout<<bs[i]<<endl;
    }
    else {
        reverse(bs.begin(), bs.end());
        rep(i, bs.size()) cout<<bs[i]<<endl;
        rep(i, cs.size()) cout<<cs[i]<<endl;
    }
}

Measured memory_bytes: 4592
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }


int main(){
    int n, r; cin >> n >> r;
    if(n>=10) cout << r << ln;
    else cout << r + (100*(10-n)) << ln;
}


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

long long gcd(long long x,long long y){
	return (y==0?x:gcd(y,x%y));
}

int main(){
	long long a,b;
	while(scanf("%lld%lld",&a,&b)!=EOF){
		printf("%lld %lld\n",gcd(a,b),a/gcd(a,b)*b);
	}
	return 0;
} 

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

using namespace std;

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

    int val = 0;
    for (int i = 0; i < n; i++) {
        int tmp;
        scanf("%d", &tmp);

        val = max(val, tmp);
    }

    if (val <= k-val+1) printf("0");
    else printf("%d", val - (k-val+1));
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  for(int i=0; i<N; i++) {
    string S;
    cin >> S;
    if(S=="Y") {
      cout << "Four" << endl;
      break;
    }
    else if(i!=N-1) {
      continue;
    }
    else {
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 256
import fractions
from functools import reduce
n=int(input())
numbers=list(map(int,input().split()))
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
l=0
x=lcm_list(numbers)
for i in range(n):
    l+=(x//numbers[i])
print(l%(10**9+7))


Measured memory_bytes: 6116