akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
/*
*****************code written By**********************
..................Marajul islam.......................
...................BSMRSTU,CSE........................
*/ 
 
int sc1() {int x; scanf("%d", &x); return x;}
 
long long sc2() {long long x; scanf("%lld", &x); return x;}
 
 
 
#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>
 
 
const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll)a * b % mod;}
 
ll mx=1e9;
 
 
int solve() {
 

 	int n,k,s;
 	cin>>n>>k>>s;
 	for(int i=0;i<n;i++){
 		if(k>0) cout<<s;
 		else{
 			if(s==mx) cout<<mx-1;
 			else cout<<mx;
 		}
 		if(i!=n-1) cout<<" ";
 		k--;
 		

 	}
	return 0;
}
 
 
 
 
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




Measured memory_bytes: 1280
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// # pragma GCC optimize "-O3"
# define int long long
using namespace std;
  
const int N = 2 * 1e6 + 7;
const int mod = 1e9 + 7;

void solve() {
	int k;
	cin >> k;
	string s;
	cin >> s;
	int n = s.size();
	for ( int i = 0; i < min( n, k ); i++ ) {
		cout << s[i];
	}
	if ( n > k ) {
		cout << "...";
	}
}

int32_t main() {
    speed;
    int T = 1;
    // cin >> T;
    while ( T-- ) {
    	solve();
    }
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a[3][3];
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++)
            cin >> a[i][j];
    int n;
    cin >> n;
    int b;
    for(int x = 0; x < n; x++){
        cin >> b;
        for(int i=0;i<3;i++)
            for(int j=0;j<3;j++)
                if(b ==a[i][j]){
                    a[i][j] = -1;
                }
    }
    bool f = false;
    for(int i=0;i<3;i++){
        // 横
        if(a[i][0] == a[i][1] && a[i][1] == a[i][2])
            f = true;        
        // 縦
        if(a[0][i] == a[1][i] && a[1][i] == a[2][i])
            f = true;
    }
    // ナナメ
    if(a[0][0] == a[1][1] && a[1][1] == a[2][2]) f = true;
    if(a[2][0] == a[1][1] && a[1][1] == a[0][2]) f = true;
    cout << (f?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main(void){
	int h, w;
	while (cin >> h >> w, h!=0 || w!=0){
	string str1="", str2="";
	for (int i=0; i < (w+1)/2; i++){
		str1.append("#.");
		str2.append(".#");
	}
	str1 = str1.substr(0, w);
	str2 = str2.substr(0, w);
	for (int i = 0; i < h; i++)
		if (i % 2 == 0) cout << str1 << endl;
		else cout << str2 << endl;
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
	ll i, j;
	ll N;
	cin >> N;
	ll ans = INF;
	for (i = 1; i <= sqrt(N); i++) {
		if (N % i == 0) {
			ans = min(ans, i - 1 + N / i - 1);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
# Title: /\/\/\/
# Link: https://arc103.contest.atcoder.jp/tasks/arc103_a

import sys
import collections

sys.setrecursionlimit(10 ** 6)

read_single_int = lambda: int(sys.stdin.readline().strip())
read_list_int = lambda: list(map(int, sys.stdin.readline().strip().split(' ')))


def solution(n: int, vs: list):
    map_a = collections.defaultdict(lambda: 0)
    map_b = collections.defaultdict(lambda: 0)

    for i in range(0, n, 2):
        map_a[vs[i]] += 1
        map_b[vs[i+1]] += 1


    pair_a = [(k, map_a[k]) for k in map_a.keys()]        
    pair_b = [(k, map_b[k]) for k in map_b.keys()]

    pair_a = sorted(pair_a, key=lambda x: x[1], reverse= True)
    pair_b = sorted(pair_b, key=lambda x: x[1], reverse= True)

    first_a, second_a = pair_a[0], (0, 0) if len(pair_a) == 1 else pair_a[1]
    first_b, second_b = pair_b[0], (0, 0) if len(pair_b) == 1 else pair_b[1]

    if first_a[0] != first_b[0]:
        return n//2-first_a[1] + n//2-first_b[1]
    else:
        if first_a[1] + second_b[1] < second_a[1] + first_b[1]:
            return n//2-second_a[1] + n//2-first_b[1]
        else:
            return n//2-first_a[1] + n//2-second_b[1]

    return 0


def main():
    n = read_single_int()
    vs = read_list_int()
    print(solution(n, vs))


if __name__ == '__main__':
    main()

Measured memory_bytes: 21524
import java.io.*;
import java.io.IOException;
import java.util.*;

@SuppressWarnings({"rawtypes", "unchecked"})
class Main {
    final static int INF = 1 << 28;
    final static long LNF = 1L << 60;
    final static double EPS = 1e-9;
    final static double GOLDEN_RATIO = (1.0 + Math.sqrt(5)) / 2.0;

    static final long MOD = 1_000_000_007;
    public static void main(String[] args) throws Exception {
        final MyScanner sc = new MyScanner();
        int n;
        int k;
        n = sc.nextInt();
        k = sc.nextInt();

        int d;
        int[] ans = new int[n];
        Arrays.fill(ans, 1);
        for (int i = 0; i < k; i++) {
            d = sc.nextInt();
            for (int j = 0; j < d; j++) {
                ans[sc.nextInt()-1] = 0;
            }
        }

        int ans1 = 0;
        for (int i : ans) {
            ans1 += i;
        }
        System.out.println(ans1);
    }


    static class MyScanner {
 
        BufferedReader br;
        StringTokenizer st;
 
        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }
 
        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        String next() {
            return nn();
        }

        String nextLine() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }
 
        char nextChar() {
            return nn().charAt(0);
        }
 
        int nextInt() {
            return Integer.parseInt(nn());
        }
 
        long nextLong() {
            return Long.parseLong(nn());
        }
 
        double nextDouble() {
            return Double.parseDouble(nn());
        }
 
        Integer[] niArr0(int n) {
            Integer[] ar = new Integer[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Integer[] niArr1(int n) {
            Integer[] ar = new Integer[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Long[] nlArr0(int n) {
            Long[] ar = new Long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
 
        Long[] nlArr1(int n) {
            Long[] ar = new Long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
    }

}


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

int main(int argc, char const* argv[])
{
    int A, B;
    char op;
    cin >> A >> op >> B;

    if (op == '+') {
        cout << A + B << endl;
    } else {
        cout << A - B << endl;
    }

    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ll N,K;
	cin >> N >> K;
	vector<ll> x(N);
	for(int i=0; i<N; i++){
		cin >> x[i];
	}
	ll ans=1e15;
	for(int i=0; i+K<=N; i++){
		ll tmp=min(abs(x[i])+abs(x[i+K-1]-x[i]), abs(x[i+K-1])+abs(x[i+K-1]-x[i]));
		ans=min(ans,tmp);
	}
	cout << ans << endl;

	

    return 0;
}


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

int main(){
    std::string s, t;
    cin >> s >> t;

    for(int i = 0; i < s.size(); i++){
        char tmp = s[s.size() - 1];
        s.pop_back();
        s = tmp + s;

        if(s == t){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
# python3
# -*- coding: utf-8 -*-
import sys
import math
#from math import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
sys.setrecursionlimit(1000000000)


def lcm(a, b):
    return (a * b) // gcd(a, b)


# main
n = ii()
a = mis()

for aa in a:
    if aa%2==0:
        if aa%3==0 or aa%5==0:
            pass
        else:
            print('DENIED')
            exit(0)

print('APPROVED')


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

int main() {
  int N;
  int M;
  cin >> N >> M;
  vector<int> hw(M);
  int S=0;
  for (int i=0; i<M; i++){
      cin >> hw.at(i);
      S=S+hw.at(i);
  }
  if (S<=N){
      cout << N-S <<endl;
  
  }
  else {
      cout << -1 << endl;
  }
}


Measured memory_bytes: 3672
#include<stdio.h>

#define MIN(a,b) ((a)<(b)?(a):(b))

int main(void){
    int n;
    scanf("%d",&n);
    int a[n+1];
    for(int i = 0;i <= n;i++)scanf("%d",&a[i]);
    int b[n];
    for(int i = 0;i < n;i++)scanf("%d",&b[i]);
    int tmp = MIN(a[0],b[0]),tmp_ = MIN(a[n],b[n-1]);
    long long ans = tmp+tmp_;
    b[0] -= tmp;
    b[n-1] -= tmp_;
    a[0] -= tmp;
    a[n] -= tmp_;
    for(int i = 0;i < n;i++){
        ans += MIN(b[i],a[i+1]);
        if(i != n-1 && b[i] < a[i+1]){
            ans += MIN(b[i+1],a[i+1]-b[i]);
            if(b[i+1]>=a[i+1]-b[i])b[i+1]-=(a[i+1]-b[i]);
            else b[i+1]=0;
        }
    }
    printf("%llu",ans);
    return 0;
}

Measured memory_bytes: 896
def func(n,b,ans):
    for i in range((n-1)):
        if i+1 < (n-1) and b[i]<=b[i+1]:
            ans.append(b[i])
        elif i+1 < (n-1) and b[i]>b[i+1]:
            ans.append(b[i+1])
        else:
            ans.append(b[i])
    return ans

if __name__=='__main__':
    n=int(input())
    b=list(map(int,input().split()))
    ans=[]
    ans=func(n,b,ans)
    print(sum(ans)+b[0])

Measured memory_bytes: 3064
INF = 999999999999999999L
EPS = 1e-12

def read():
    return raw_input().strip()

def read_ints():
    return map(int,read().split())

s = read()
if len(s) < 26:
    for i in range(26):
        c = chr(ord("a")+i)
        if c not in s:
            print s+c
            break 
            
else:
    for i in reversed(range(len(s))):
        c = ord(s[i]) - ord("a")
        found = False
        for j in range(c+1,26):
            cc = chr(ord("a")+j)
            if cc not in s[:i]:
                print s[:i]+cc 
                found = True 
                break 
        if found:
            break
    if not found:
        print -1 


Measured memory_bytes: 2952
//Bismillahir Rahmanir Rahim
#define ll long long
#include<bits/stdc++.h>
using namespace std;
ll mark[100005];
vector<string>v;
vector<ll>res;
map<string,ll>mp;


void permute(string s)
{
   // cout<<s<<endl;
   do
   {
    if(mp[s]==0){
      v.push_back(s);
      mp[s]=1;
    }
   }
   while(next_permutation(s.begin(),s.end()));
}


ll convert(string st)
{
  ll j=st.size()-1,num=0,x;
  ll  p=1;
  for(ll i = j;i>=0;i--)
  {
      x = st[i]-'0';
      num +=(p*x);
      p*=10;
  }
  return num;
}

void distribute(ll n)
{
    ll i,j,k,l;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {
            if((i+j+k)>n)break;
               string s;
               for(l=1;l<=i;l++)s.push_back('3');
               for(l=1;l<=j;l++)s.push_back('5');
               for(l=1;l<=k;l++)s.push_back('7');

               permute(s);
            }
        }
    }
}


int main()
{
    ll n,i,j,k,l;
    cin>>n;

    for(i=3;i<=9;i++)
    {
        distribute(i);
    }
  for(i=0;i<v.size();i++)
  {
      ll x = convert(v[i]);
      res.push_back(x);
  }

 sort(res.begin(),res.end());
 ll cnt=0;
 for(i=0;i<res.size();i++)
 {
     if(res[i]>n)break;
     else
        {
           // cout<<res[i]<<endl;
            cnt++;
        }
 }
 cout<<cnt<<endl;
}



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

int main() {
  int n, m, x;
  string s, t;
  map<string, int> mp;
  
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    mp[s] += 1;
  } 
  
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> t;
    mp[t] -= 1;
  } 
  
  x = 0;
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    if (x < itr->second) x = itr->second;
  } 
  cout << x << endl;
} 

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
#include<numeric>
using namespace std;
typedef long long int lli;
#define rep(i,n) for(lli i = 0;i<((lli)(n));i++)
#define reg(i,a,b) for(lli i = ((lli)(a));i<=((lli)(b));i++)
#define irep(i,n) for(lli i = ((lli)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(lli i = ((lli)(b));i>=((lli)(a));i--)
typedef pair<lli, lli> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprllif(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

#define MOD 1000000007ll

lli fact[100005];

void f(void){
	fact[0] = 1;
	reg(i, 1, 100000) fact[i] = (fact[i-1]*i)%MOD;
	return;
}

int main(void){
	lli n, m;
	cin >> n >> m;
	if(n > m) swap(n, m);
	f();
	if(m - n > 1) cout << 0 << endl;
	else if(m - n == 1) cout << (fact[m]*fact[n])%MOD << endl;
	else cout << (((2*fact[m])%MOD)*fact[n])%MOD << endl;
	
	return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	static Main main = new Main();

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		Prime prime = main.new Prime(50000);

		while (!(line = br.readLine()).equals("0")) {

			int n = Integer.parseInt(line);
			int c = 0;

			for (int v : prime.values) {
				if (v * 2 > n) {
					break;
				}
				if (prime.indexes[v] && prime.indexes[n - v]) {
					c++;
				}
			}
			System.out.println(c);
		}

	}

	class Prime {

		int max;
		int count = 0;
		boolean[] indexes;
		int[] values;

		Prime(int max) {
			this.max = max;
			setIndexes();
			setValues();
		}

		void setIndexes() {

			indexes = new boolean[max + 1];
			Arrays.fill(indexes, true);

			for (int i = 2; i < max + 1; i++) {
				if (indexes[i]) {
					count++;
					for (int j = 2; j <= max / i; j++) {
						indexes[i * j] = false;
					}
				}
			}

		}

		void setValues() {

			values = new int[count];
			int j = 0;
			for (int i = 2; i < max + 1; i++) {
				if (indexes[i]) {
					values[j] = i;
					j++;
				}
			}

		}

	}

}

Measured memory_bytes: 25816
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll n; cin >> n;
    map<string, ll> m;
    REP(i, n) {
        string tmp;
        cin >> tmp;
        sort(ALL(tmp));
        if (m.find(tmp) == m.end()) {
            m[tmp] = 0;
        }
        m[tmp]++;
    }
    ll res = 0;
    for (auto e : m) {
        if (e.second > 1) {
            res += e.second * (e.second - 1) / 2;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 11260
#include <map>
#include <queue>
#include <vector>
#include <iostream>
using namespace std;
struct edge { int to; long long cost; };
struct state { int to, height; long long cost; };
bool operator<(const state& e1, const state& e2) {
	return e1.cost < e2.cost;
}
int N, M, X, H[100009], a, b, c; vector<edge> G[100009]; long long dist[100009]; int ht[100009];
int main() {
	scanf("%d%d%d", &N, &M, &X);
	for (int i = 0; i < N; i++) scanf("%d", &H[i]);
	for (int i = 0; i < M; i++) {
		scanf("%d%d%d", &a, &b, &c); a--, b--;
		G[a].push_back(edge{ b, c });
		G[b].push_back(edge{ a, c });
	}
	priority_queue<state> que; que.push({ 0, X, 0 });
	fill(dist + 1, dist + N, 1LL << 60); dist[0] = -X;
	fill(ht + 1, ht + N, 1999999999); ht[0] = X;
	while (!que.empty()) {
		state u = que.top(); que.pop();
		for (edge e : G[u.to]) {
			int h = ht[u.to] - e.cost; long long cost = dist[u.to] + e.cost * 2;
			if (h < 0 && u.height - h > H[u.to]) continue;
			if (h < 0) h = 0;
			if (h > H[e.to]) cost += (h - H[e.to]) * 2, h = H[e.to];
			if (dist[e.to] > cost) {
				dist[e.to] = cost; ht[e.to] = 1999999999;
				que.push(state{ e.to, h, -cost });
			}
			if (dist[e.to] == cost) ht[e.to] = min(ht[e.to], h);
		}
	}
	long long ret = dist[N - 1] + H[N - 1];
	printf("%lld\n", ret >= (1LL << 60) ? -1 : ret);
	return 0;
}

Measured memory_bytes: 23132
map$q[$_]+=$q[$N]/@$N,@{/ /,push@
$`,$' for<>;$N=$_}for++$q[1]..<>;$e[$N]=1+${$b=0;$b+=$_/@@for@@=sort@e[@$N];b},$a<($~=$q[$N]*=$#@&&($b-@@[-1])/$#@)or$a=$~while--$N;print"@e"+$a

Measured memory_bytes: 42368
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define test() ull t;cin>>t;while(t--)
#define puu pair<ull,ull>
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define ins insert
#define Vint vector<int>
#define Vull vector<ull>
#define nl cout<<endl
#define sp cout<<" "
#define MOD 1000000007
#define all(x) x.begin(),x.end()
vector<int> cache(100005);
int fact(int k)
{
	if(k<2)
		return 1;
	if(cache[k]!=0)
		return cache[k];
	return cache[k] = k*fact(k-1) % MOD;
}
int main() 
{
	 // #ifndef ONLINE_JUDGE
  //       freopen("input.txt", "r", stdin);
  //       freopen("output.txt", "w", stdout);
  //   #endif
  //   fastio();
    int a,b;
    cin>>a>>b;
    if(a>=13)
    	cout<<b;
    else if(a<13 && a>=6)
    	cout<<b/2;
    else
    	cout<<0;
}

Measured memory_bytes: 640
import collections
import math

#****************************************************************
def comb(n):
    if n < 2:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
#****************************************************************

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

c = collections.Counter(A)
full_ans = sum(list(map(comb, c.values())))

for a in A:
    print(full_ans - c[a] + 1)


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

int main() {
int x,y;
cin >> x >> y;
if (x > y) {
cout <<"a > b"<< endl;
} else if (x < y) {
cout <<"a < b"<< endl;
} else {
cout <<"a == b"<< endl;
}

return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<"\n";
}


Measured memory_bytes: 3648
program rgb_triplets
  implicit none
  integer :: n, i, j, a(4000) = 0, p, q
  integer(8) :: c(3) = 0_8, x = 0_8
  character(4000) :: s
  read(*,*) n
  read(*,*) s
  do i = 1, n
    if (s(i:i) == "R") then
      a(i) = 1
    else if (s(i:i) == "G") then
      a(i) = 2
    else
      a(i) = 3
    end if
  end do
  do i = 1, n
    p = mod(a(i),3)+1
    q = mod(p,3)+1
    x = x+c(p)*c(q)
    c(a(i)) = c(a(i))+1_8
  end do
  do j = 1, n
    do i = 1, n
      p = i+j
      q = p+j
      if (q > n) exit
      if (a(i) == a(p) .or. a(p) == a(q) .or. a(q) == a(i)) cycle
      x = x-1_8
    end do
  end do
  write(*,'(i0)') x
end program rgb_triplets

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

typedef int64_t Int;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n), b(n);
    for (Int i = 0; i < (Int)n; i++) {
        cin >> a[i] >> b[i];
    }
    vector<tuple<Int, Int, Int>> v(n);
    for (Int i = 0; i < (Int)n; i++) {
        v[i] = make_tuple(a[i] + b[i], a[i], b[i]);
    }
    sort(all(v), greater<tuple<Int, Int, Int>>());
    Int res = 0;
    for (Int i = 0; i < (Int)n; i++) {
        if (i % 2 == 0) {
            res += get<1>(v[i]);
        } else {
            res -= get<2>(v[i]);
        }
    }
    print(res);
    return 0;
}

Measured memory_bytes: 4096
#include <stdio.h>

int main(){
  int N;
  int A[100001], B[100000];
  long long int sum=0;
  
  scanf("%d", &N);

  for(int i=0;i<=N;i++)
    scanf("%d", &A[i]);

  for(int i=0;i<N;i++)
    scanf("%d", &B[i]);

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

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


Measured memory_bytes: 896
#include<iostream>
#include<stdio.h>
#include<fstream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<set>
#include<string>
#include<queue>
#include<map>
#include<iomanip>
#include<cassert>
#include<complex>
#include<functional>
#include<list>
#include<cmath>
#include<stack>
#include<assert.h>
#define LL long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define F first
#define S second
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<vector<int> > g(n);
	for(int i=0;i<n-1;i++){
		int a,b;
	 	cin>>a>>b;
	 	a--;
	 	b--;
	 	g[a].PB(b);
	 	g[b].PB(a);
	}
	vector<int> d(n,-1);
	priority_queue<PII,vector<PII>,greater<PII> > pq;
	int k;
	cin>>k;
	while(k--){
		int v,p;
		cin>>v>>p;
		v--;
		d[v]=p;
		pq.push(PII(p,v));
	}
	while(!pq.empty()){
		PII p=pq.top();
		pq.pop();
		int u=p.S;
		for(int i=0;i<g[u].size();i++){
			int v=g[u][i];
				if(d[v]==-1){
					d[v]=d[u]+1;
					pq.push(PII(d[v],v));
				}
			}
	}
	for(int u=0;u<n;u++)
		for(int i=0;i<g[u].size();i++){
			int v=g[u][i];
			if(abs(d[u]-d[v])!=1){
				cout<<"No";
				return 0;
			}
		}
	cout<<"Yes\n";
	for(int u=0;u<n;u++)
		cout<<d[u]<<"\n";
	return 0;
}

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


int a[101][101];
int main(){
int r,c,m;
cin>>r>>c;
for(int i=0;i<r;i++)
	{for(int i2=0;i2<c;i2++)
		{cin>>a[i][i2];
		}
	}
for(int i=0;i<=r;i++)
	{m=0;
	for(int i2=0;i2<=c;i2++)
		{m+=a[i][i2];
		}
	a[i][c]=m;
	}
for(int i=0;i<=c+1;i++)
	{m=0;
	for(int i2=0;i2<=r;i2++)
		{m+=a[i2][i];
		}
	a[r][i]=m;
	}
for(int i=0;i<=r;i++)
	{for(int i2=0;i2<=c;i2++)
		{if(i2!=0) cout<<" ";
		cout<<a[i][i2];
		}
	cout<<endl;
	}
return 0;
}


Measured memory_bytes: 3124
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

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

		// 入力
		int n = sc.nextInt();
		int[] b = new int[n-1];

		int result = 0;
		int pre = 0;
		for(int i = 0; i < n - 1; i++){
		    b[i] = sc.nextInt();
		    if(i == 0) result = result + b[i];
		    if(i > 0){
		        result = result + min(pre, b[i]);
		    }
		    if(i == n - 2) result = result + b[i];
		    pre = b[i];
		}

		// 計算

		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 23636
import collections as col


n,x,y = map(int,input().split())
dist = []
for i in range(1,n+1):
    for j in range(i+1,n+1):
        a = abs(i - j)
        b = abs(i - x) + 1 + abs(j - y)
        c = abs(i - y) + 1 + abs(j - x)
        dist.append(min(a,b,c))

cnt = col.Counter(dist)
for i in range(1,n): print(cnt[i])


Measured memory_bytes: 118904
#include <cstdio>
int main()
{
  int a[5];
  scanf("%d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5]);
  int sum=a[0]*1+a[1]*5+a[2]*10+a[3]*50+a[4]*100+a[5]*500;
  if(sum>=1000) printf("1\n");
  else printf("0\n"); 
  return 0;
}

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

#define pb emplace_back
#define mk make_pair
#define sc second
#define fr first

using namespace std;

typedef int ll;

const int N = (int) 1e5 + 5;
const int mod = (int) 1e9 + 7;

int a,b;
vector<int> v,v1;
string c;

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

        if(a <= b){
                cout << "Impossible" << endl;
                fflush(stdout);
                return 0;
        }
        int n = a + b;
        v.pb(1);

        for(int i = 2; i <= n; i ++){
                if(v.empty())
                        v.pb(i);
                else{
                        cout << "? " << v.back() - 1 << " " << i - 1 << endl;
                        fflush(stdout);
                        cin >> c;
                        if(c == "Y")
                                v.pb(i);
                        else
                                v.pop_back();
                }
        }
        string st = "! ";
        for(int i = 1; i <= n; i ++){
                cout << "? " << v.back() - 1 << " " << i - 1 << endl;
                fflush(stdout);
                cin >> c;
                if(c == "Y")
                        st += "1";
                else
                        st += "0";
        }
        cout << st << endl;
        fflush(stdout);
        return 0;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    ll N, A, B; cin >> N >> A >> B;
    if ((B - A - 1) % 2 == 0) {
        ll ans = (1LL << 60);
        ans = min({
            ans,
            N - B + 1 + (N - (A + N - B + 1)) / 2,
            A + (B - A - 1) / 2,
        });
        cout << ans << endl;
    } else {
        cout << (B - A) / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#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 <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  ll n, a, b;
  cin >> n >> a >> b;
  ll c = n / (a + b);
  n -= c * (a + b);
  cout << c * a + min(n, a);
}

Measured memory_bytes: 256
#pragma GCC optimize(3) 
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<set> 
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#define ll long long
#define db long double
#define inf 200001
#define INF (ll)1e15 
#define pi acos(-1)
#define mxbit 30
#define rd(n) {n=0;char ch;int f=0;do{ch=getchar();if(ch=='-'){f=1;}}while(ch<'0'||ch>'9');while('0'<=ch&&ch<='9'){n=(n<<1)+(n<<3)+ch-48;ch=getchar();}if(f)n=-n;}
using namespace std;

char str[inf];
int nxt[inf];
ll sum[26][inf];
int n,lens;

void getnxt(void){
	int k=0;
    nxt[0]=0;
    for (int i=2;i<=n;i++){
        while (k && str[k+1]!=str[i]){
            k=nxt[k];
        }
        if (str[k+1]==str[i]){
            k++;
        }
        nxt[i]=k;
    }
    return;
}

ll query(ll x,int p){
	if (x<n){
		return sum[p][x];
	}
	ll a=sum[p][lens],b=sum[p][n];
	ll l1=lens,l2=n;
    while(l1+l2<x){
    	a+=b;
		swap(a,b);
		l1+=l2;
		swap(l1,l2);
	}
    return b+query(x-l2,p);
}

int main(){
	scanf("%s",str+1);
	n=strlen(str+1)/2;
	getnxt();
	lens=n-nxt[n];
	for (int i=0;i<26;i++){
		for (int j=1;j<=n;j++){
			sum[i][j]=sum[i][j-1]+(str[j]-'a'==i);
		}
	}
	ll l,r;
	rd(l) rd(r)
	for (int i=0;i<26;i++){
		printf("%lld ",query(r,i)-query(l-1,i));
	}
	return 0;
}

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

int main() {
    string S;
    cin >> S;
    int y = stoi(S.substr(0, 4)), m = stoi(S.substr(5, 2)), d = stoi(S.substr(8, 2));
    if (m <= 4) cout << "Heisei" << endl;
    else cout << "TBD" << endl;
    return 0;
}

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

const int mod = 1000000007;
int dp[2010];
int main() {
    int n;
    cin >> n;
    dp[0] = 1;
    rep(i,n) {
        for(int j = 3;i+1-j>=0;j++) {
            dp[i+1] += dp[i+1-j];
            dp[i+1] %= mod;
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll sz=3e5, mx=1e18;

ll a[sz], w[sz];

int main()
{
    ll i,j,n,d,tot=0;
    cin >> n;
    for(i=1; i<=n; i++) scanf("%lld", &a[i]), a[i]-=i, tot+=a[i];
    sort(a+1, a+1+n);
    ll ans=mx;
    for(i=n/2-2; i<n/2+2; i++) {
        tot=0;
        for(j=1; j<=n; j++) {
            tot+=abs(a[j]-a[i]);
        }
        ans=min(ans,tot);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2304
def main():
    N = int(input())
    dp = [[0, 0, 0] for i in range(N)]
    a0, b0, c0 = [int(n) for n in input().split()]
    dp[0] = [a0, b0, c0]
    for i in range(1, N):
        li = [int(n) for n in input().split()]
        for t in range(3):
            dp[i][t] = max(dp[i-1][(t+1)%3], dp[i-1][(t+2)%3]) + li[t]
    print(max(dp[N-1]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 56480
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
  int x, flag, d;
  scanf("%d", &x);
  flag = 0;
  d = x / 100;
  if(d == 7)flag = 1;
  d= (x % 100) / 10;
  if(d == 7)flag = 1;
  d = x % 10;
  if(d == 7)flag = 1;

  if(flag == 1){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e5;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    pair<int,int>p[x];
    for (int i=0;i<x;i++){
        cin>>p[i].first;
        p[i].second=i;
    }
    sort(p,p+x);
    int y[x];
    for (int i=0;i<x;i++){
        if (i<x/2)
            y[p[i].second]=p[x/2].first;
        else
            y[p[i].second]=p[x/2-1].first;
    }
    for (int i=0;i<x;i++)
        cout<<y[i]<<endl;
    return 0;
}


Measured memory_bytes: 4608
#include<stdio.h>
#include<math.h>

int main(){
	double x,h;
	while(~scanf("%lf%lf",&x,&h)){
		if(h==0&&x==0)break;
		printf("%lf\n",x*(x+sqrt(4*h*h+x*x)));
	}
	return 0;
}

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

int rev[3001][3001];
int dp[3001][3001];

char s[3001];
char t[3001];
char ans[3001];
int main()
{
	scanf("%s%s",s,t);
	int n=strlen(s);
	int m=strlen(t);
	for(int i=0;i<3001;i++)
	{
		for(int j=0;j<3001;j++)
			dp[i][j]=-INT_MIN;
	}
	
	dp[0][0]=0;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			if(i+1<=n)
			{
				if(dp[i+1][j]<dp[i][j])
				{
					dp[i+1][j]=dp[i][j];
					rev[i+1][j]=0;
					
				}
			}
			if(j+1<=m)
			{
				if(dp[i][j+1]<dp[i][j])
				{
					dp[i][j+1]=dp[i][j];
					rev[i][j+1]=1;
					
				}
			}
			if(i+1<=n&&j+1<=m&&s[i]==t[j])
			{
				if(dp[i+1][j+1]<dp[i][j]+1){
					dp[i+1][j+1]=dp[i][j]+1;
					rev[i+1][j+1]=2;
				}
			}
		}
	}
	int ns=n;
	int nt=m;
	int at=dp[n][m]-1;
	while(ns|nt){
		if(rev[ns][nt]==0){
			ns--;
		}else if(rev[ns][nt]==1)nt--;
		else{
			ns--;
			nt--;
			ans[at]=s[ns];
			at--;
		}
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 70656
import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()
count = 0

#a<=b<=c とする
#a,b 固定
for i in range(N):
  for j in range(i+1,N):
    a,b = L[i],L[j]
    k = bisect.bisect_left(L,a+b)
    count += k-j-1
 
print(count)

Measured memory_bytes: 45196
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> correct(N, 0);
    for (int i = 0; i < Q; i++){
        int a;
        cin >> a;
        correct[a - 1] += 1;
    }

    for (int j = 0; j < correct.size(); j++){
        if (K + correct[j] - Q > 0){
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    } 
}

Measured memory_bytes: 1024
#include <iostream>

int main(int argc, char const* argv[])
{
    int result = 0;
    int min_val = 124;

    int tmp1, tmp2;

    for(int i=0; i < 5; ++i)
    {
        int n;
        std::cin >> n;
        tmp1 = n / 10;
        tmp2 = n % 10;

        if(tmp2 != 0)
        {
            tmp1++;
            min_val = std::min(min_val, tmp2);
        }
        result += tmp1 * 10;

    }

    if(min_val != 124)
    {
        result -= (10 - min_val);
    }

    std::cout << result << std::endl;

    return 0;
}

Measured memory_bytes: 256
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define pi 3.141592653589793
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll modd = (ll)1e9 + 7;
const int mod = 10000007;
/*#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}*/
void pr (int f)
{
    if(f==1)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}
map<int,int>mp;
//set<int > s;
multiset<string> :: iterator it;

deque <char> q ;
int vis [551000];

int main()
{
    fast;
   ll a,b,c,k,s;
   cin>>a>>b>>c>>k;
   s=min(a,k);
   k-=min(a,k);
   k-=min(b,k);
   
   cout<<s-min(k,c)<<endl;

}





Measured memory_bytes: 3632
from collections import deque
n=int(input())
graph=[list(map(int,input().split())) for _ in range(n-1)]
tree=[[] for _ in range(n)]
for a,b in graph:
    tree[a-1].append(b-1)
color=[0]*n
q=deque([0])
while q:
    c=1
    x=q.popleft()
    for i in tree[x]:
        if c==color[x]:
            c+=1
        color[i]=c
        c+=1
        q.append(i)
print(max(color))
for j in range(n-1):
    print(color[graph[j][1]-1])

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

const int MAX = 3010;

string s, t;
int dp[MAX][MAX] = {0};

int main() {
  cin >> s >> t;

  int s_len = (int)s.length();
  int t_len = (int)t.length();

  for (int i = 0; i < s_len; ++i) {
    for (int j = 0; j < t_len; ++j) {
      if (s[i] == t[j]) {
        dp[i + 1][j + 1] = dp[i][j] + 1;
      }
      if (dp[i + 1][j + 1] < dp[i + 1][j]) {
        dp[i + 1][j + 1] = dp[i + 1][j];
      }
      if (dp[i + 1][j + 1] < dp[i][j + 1]) {
        dp[i + 1][j + 1] = dp[i][j + 1];
      }
    }
  }

  string ans = "";
  int n = s_len;
  int k = t_len;

  while (0 < n && 0 < k) {
    if (dp[n][k] == dp[n - 1][k]) {
      --n;
    } else if (dp[n][k] == dp[n][k - 1]) {
      --k;
    } else {
      ans = s[n - 1] + ans;
      --n;
      --k;
    }
  }

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


Measured memory_bytes: 35584
#include <stdio.h>
 
int main() {
 
  int n,m;
  int i,j;
  int a,b;
  int A[100][100], B[100], c[100];
 
  scanf("%d %d " ,&n,&m);
 
  for(j=0; j<n; j++) {
  for(i=0; i < m; i++) {
    scanf("%d",&A[j][i]);
  }
}
 
  for(j=0; j<m; j++) {
    scanf("%d",&B[j]);
  }
 
  for(j=0;j<n ; j++){ 
  for(i = 0; i<m; i++){
     c[j] = c[j] + A[j][i]*B[i];
    }
  }
 
  for(i=0;i<n;i++) {
    printf("%d\n",c[i]);
  }
  return 0;
}



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

#define int long long 
#define dou double 
#define endl "\n"

const int MOD=1e9+7;

void solve()
{
	char chr;
	cin >> chr;
	if(isupper(chr))
		cout <<"A\n";
	else
		cout <<"a\n";
}

main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
	return 0;
}

Measured memory_bytes: 3580
import java.util.*;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String  S= sc.next();
		String ans="Yes";
		if(N%2==1){
			ans="No";
			System.out.println(ans);
		}
		else{
			for(int i=0;i<=N/2-1;i++){
				if(S.charAt(i)!=S.charAt(i+(N/2))){
					ans="No";
				}
			}
		System.out.println(ans);
		}
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    if (b % a == 0)
    {
        cout << (a + b) << endl;
    }
    else
        cout << (b - a) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.*;

public class Main {
	static FastScanner sc = new FastScanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] ar = new int[n];
		for (int i=0; i<n; i++) {ar[i] = sc.nextInt();}
		Arrays.sort(ar);
		int m = sc.nextInt();
		int total = 0;
		for (int i=0; i<m; i++) {
			if (Arrays.binarySearch(ar,sc.nextInt()) >= 0) {total++;}
		}
		out.println(total);
	}
}



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


Measured memory_bytes: 27404
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class AtCoder {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String str = in.next();
            for (int i = 0; i < str.length(); i++) {
                if (str.charAt(i) != ',') {
                    out.print(str.charAt(i));
                } else {
                    out.print(" ");
                }
            }
            out.println();
        }

    }
}



Measured memory_bytes: 21972
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

struct AC{
        int a;
        int c;
    };


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    string S;
    cin >> S;

    int N = S.size();
    ll ds[N+1][4];
    REP(i, 4) ds[0][i] = 0;
    ds[0][0] = 1;

    REP(i, N) {
        int m = S[i] == '?' ? 3 : 1;

        ds[i+1][0] = m * ds[i][0] % MOD;
        ds[i+1][1] = m * ds[i][1] % MOD;
        ds[i+1][2] = m * ds[i][2] % MOD;
        ds[i+1][3] = m * ds[i][3] % MOD;

        if (S[i] == 'A') (ds[i+1][1] += ds[i][0]) %= MOD;
        if (S[i] == 'B') (ds[i+1][2] += ds[i][1]) %= MOD;
        if (S[i] == 'C') (ds[i+1][3] += ds[i][2]) %= MOD;
        if (S[i] == '?') {
            (ds[i+1][1] += ds[i][0]) %= MOD;
            (ds[i+1][2] += ds[i][1]) %= MOD;
            (ds[i+1][3] += ds[i][2]) %= MOD;
        }
    }

    cout << fixed << setprecision(20);
    cout << ds[N][3] << endl;

}


Measured memory_bytes: 3664