akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main()
{
	int n, m, i, j;
	cin >> n >> m;
	
	int ** A = new int *[n];
	for (i = 0; i < n; i++)
		A[i] = new int[m];

	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++)
			cin >> A[i][j];

	int *B = new int[m];
	for (i = 0; i < m; i++)
		cin >> B[i];

	for (i = 0; i < n; i++)
	{
		int c = 0;
		for (j = 0; j < m; j++)
			c += A[i][j] * B[j];
		cout << c << endl;
	}
	
	delete[] B;

	for (i = 0; i < n; i++)
		delete[] A[i];
	delete[] A;

	return 0;
}

Measured memory_bytes: 1240
import java.util.Scanner;

public class Main {
	public static void selectionSort(int[] array, int n) {
		int tmp, minj, count = 0;
		for (int i = 0; i < n; i++) {
			minj = i;
			for (int j = i; j < n; j++) {
				if (array[j] < array[minj]) minj = j;
			}
			if (minj != i) {
				tmp = array[i]; array[i] = array[minj]; array[minj] = tmp;
				count++;
			}
		}
		for (int i = 0; i < n; i++) {
			System.out.print(array[i]);
			if (i < n - 1) System.out.print(" ");
		}
		System.out.println();
		System.out.println(count);
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		selectionSort(array, n);
	}
}



Measured memory_bytes: 26312
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int mas = in.nextInt();
      	int cost = in.nextInt();
      	int start = in.nextInt();
      	int sum1 = 0;
        int sum2 = 0;
      
      for(int i = 0;i < cost;i++){
        int kane = in.nextInt();
        if(kane<start){
          sum1++;
        }else{
          sum2++;
        }
      }
      System.out.print(Math.min(sum1,sum2));
	}
}

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

const int N = 100005;

using namespace std;

string s;
int n, l[N], r[N], x[N], root[N], summ[N], sz[N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    if (s.size() == 1)
    {
        cout << "YES";
        return 0;
    }
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> l[i] >> r[i];
        l[i]--, r[i]--;
    }
    if (s.size() % 2 == 1)
    {
        int pos = s.size() / 2;
        for (int i = 0; i < n; i++)
        {
            if (l[i] == pos && r[i] == pos)
            {
                n--;
                swap(l[i], l[n]);
                swap(r[i], r[n]);
                i--;
                continue;
            }
            if (l[i] > pos) l[i]--;
            if (r[i] >= pos) r[i]--;
        }
        string t = "";
        for (int i = 0; i < s.size(); i++) if (i != pos) t += s[i];
        s = t;
    }
    int len = s.size() / 2;
    for (int i = 0; i < n; i++)
    {
        if (l[i] < len && r[i] >= len)
        {
            int p1 = len - l[i], p2 = r[i] - len + 1;
            if (p1 == p2) l[i] = -1, r[i] = -1;
            if (p1 < p2)
            {
                l[i] += 2 * p1;
            }
            if (p1 > p2)
            {
                r[i] -= 2 * p2;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (l[i] >= len)
        {
            int rr = s.size() - 1 - l[i];
            int ll = s.size() - 1 - r[i];
            l[i] = ll, r[i] = rr;
        }
    }
    string a = "", b = "";
    for (int i = 0; i < len; i++) a += s[i];
    for (int i = len; i < s.size(); i++) b += s[i];
    reverse(b.begin(), b.end());
    for (int i = 0; i < len; i++)
    {
        x[i + 1] = (b[i] + 26 - a[i]) % 26;
    }
    //for (int i = 0; i <= len; i++)
    //{
    //    cout << x[i] << " ";
    //}
    //cout << endl;
    for (int i = len + 1; i > 0; i--)
    {
        x[i] = (x[i] - x[i - 1] + 26) % 26;
    }
    for (int i = 0; i < n; i++)
    {
        l[i]++, r[i]++, r[i]++;
    }
    iota(root, root + len + 2, 0);
    fill(sz, sz + len + 2, 1);
    for (int i = 0; i < n; i++)
    {
        int a = l[i], b = r[i];
        while (a != root[a]) a = root[a];
        while (b != root[b]) b = root[b];
        if (a == b) continue;
        if (sz[a] < sz[b])
        {
            sz[b] += sz[a];
            root[a] = b;
        }
        else
        {
            sz[a] += sz[b];
            root[b] = a;
        }
    }
    for (int i = 1; i < len + 2; i++)
    {
        int j = i;
        while (j != root[j]) j = root[j];
        summ[j] += x[i];
    }
    int t = -1;
    for (int i = 0; i < len + 2; i++)
    {
        if (summ[i] % 26 != 0)
        {
            if (t == -1) t = i;
            else cout << "NO", exit(0);
        }
    }
    if (t == -1) cout << "YES", exit(0);
    cout << "YES";
}


Measured memory_bytes: 2156
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int K, S;
    cin >> K >> S;
    
    int ans = 0;
    for(int x=0;x<=K;x++){
        for(int y=x;y<=K;y++){
            for(int z=y;z<=K;z++){
                if(x + y + z == S){
                    if(x==y && y==z)
                        ans++;
                    else if(x==y || y==z || z==x)
                        ans += 3;
                    else
                        ans += 6;
                }
                    
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "E"
const ll base=1000000007;
ll f[1001][1001];
ll h[1001][1001];
ll nt[1001][1001];
ll fact[1001];
bool done[1001][1001];
bool doneh[1001][1001];
ll F(int, int);
ll power(ll a, int x){
    if(x==0) return 1;
    ll t=power(a, x/2);
    t=(t*t)%base;
    if(x%2) t=(t*a)%base;
    return t;
}
int n, a, b, c, d;
ll H(int u, int v){
    if(doneh[u][v]) return h[u][v];
    doneh[u][v]=1;
    return h[u][v]=(fact[u*v]*power((fact[v]*power(fact[u], v))%base, base-2))%base;
}
//ll G(int u, int v){
//    if(u<0) return 0;
//    if(doneg[u][v]) return g[u][v];
//    doneg[u][v]=1;
//    return g[u][v]=(F(u, v)+G(u-v-1, v))%base;
//}
ll F(int u, int v){
//    write(u);
//    putchar(' ');
//    write(v);
    if(done[u][v]) return f[u][v];
    done[u][v]=1;
    if(u==0) return f[u][v]=1;
    if(v<a) return f[u][v]=0;
    f[u][v]=F(u, v-1);
    FOR(i, c, d) if(i*v<=u) f[u][v]=((F(u-i*v, v-1)*((nt[u][i*v]*H(v, i))%base))%base+f[u][v])%base;
    else break;
    f[u][v]%=base;
    return f[u][v];
}
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    fact[0]=1;
    FOR(i, 1, 1000) fact[i]=(fact[i-1]*i)%base;
    nt[0][0]=1;
    FOR(i, 1, 1000){
        nt[i][0]=nt[i][i]=1;
        FFOR(j, 1, i) nt[i][j]=(nt[i-1][j]+nt[i-1][j-1])%base;
    }
    read(n);
    read(a);
    read(b);
    read(c);
    read(d);
    writeln(F(n, b));
    FOR(i, 1, n) FOR(j, 1, n) if(f[i][j]<0) bug(f[i][j]);
}

Measured memory_bytes: 25344
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+5  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
//ll const mod=998244353;
ll const mod=1e9+7;
const ll MAX=1000005;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


//////////////////////////////////////

int main(){
    int n,k;
    cin>>n>>k;
    int mx=(n-2)*(n-1)/2;
    if(k>mx){
        cout<<-1<<endl;
        return 0;
    }
    mx-=k;
    vector<P> ans;
    rep(i,n-1)ans.push_back(P(1,i+2));
    for(int i=n;i>1&&mx>0;i--){
        arep(j,2,i){
            ans.push_back(P(j,i));
            if(--mx==0)break;
        }
    }
    cout<<ans.size()<<endl;
    for(auto x:ans){
        cout<<x.first<<" "<<x.second<<endl;
    }
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<vector>

int main(){
	int n;
	std::cin>>n;
	for(int i=0;i<n;i++){
		std::vector<int>v(3,0);		
		for(int j=0;j<3;j++)std::cin>>v[j];
		for(int j=0;j<3;j++){
			for(int k=0;k<2;k++){
				if(v[k]<v[k+1]){
					v[k]^=v[k+1];
					v[k+1]^=v[k];
					v[k]^=v[k+1];
				}
			}
		}
		if(v[0]*v[0]==v[1]*v[1]+v[2]*v[2])std::cout<<"YES"<<std::endl;
		else std::cout<<"NO"<<std::endl;
	}
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	int i = 0;
	char input;
	int count = 0;
	while (i < N) {
		cin >> input;
		if (input == 'Y') {
			count++;
		}
		i++;
	}
	if (count > 0) {
		cout << "Four" << endl;
	}else {
		cout << "Three" << endl;
	}
}

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

using namespace std;

const int N = 1e6+5;

const int mod = 1e9+7;

int n;
int cnt[N];
bool did[N];

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

int main(){
    scanf("%d " , &n);
    int totG = 0;
    for(int i = 1; i <= n; i++){
       int x;
       scanf("%d" , &x);
       cnt[x]++;
       totG = __gcd(x , totG);
    }
    bool exit = 0;
    for(long long i = 2; i < N; i++){
        if(did[i])
            continue;
        int found = 0;
        for(long long j = i; j < N; j += i){
            found += cnt[j];
            did[j] = 1;
        }
        if(found > 1)
            exit = 1;
        if(exit)
            break;
    }
    //cout << exit << "\n" ;
    if(!exit){
        puts("pairwise coprime");
    } else if(exit && totG == 1){
        puts("setwise coprime");
    } else {
        puts("not coprime");
    }
}


Measured memory_bytes: 8596
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int M = Integer.parseInt(st.nextToken());
         int K = Integer.parseInt(st.nextToken());
         int[][] grid = new int[N][M];
         for(int i=0; i < N; i++)
         {
            String input = infile.readLine();
            for(int a=0; a < M; a++)
               if(input.charAt(a) == '1')
                  grid[i][a] = 1;
         }
         int res = Integer.MAX_VALUE;
         outer:for(int mask=0; mask < (1<<(N-1)); mask++)
         {
            ArrayList<Integer>[] cake = new ArrayList[Integer.bitCount(mask)+1];
            for(int i=0; i < cake.length; i++)
               cake[i] = new ArrayList<Integer>();
            int dex = 0;
            for(int i=0; i < N; i++)
            {
               cake[dex].add(i);
               if((mask&(1<<i)) > 0)
                  dex++;
            }
            int temp = Integer.bitCount(mask);
            int[] cnt = new int[cake.length];
            for(int i=0; i < M; i++)
            {
               int max = 0;
               for(int a=0; a < cake.length; a++)
                  for(int x: cake[a])
                  {
                     cnt[a] += grid[x][i];
                     max = Math.max(max, cnt[a]);
                  }
               if(max > K)
               {
                  //cut
                  int[] next = new int[cake.length];
                  for(int a=0; a < cake.length; a++)
                     for(int x: cake[a])
                        next[a] += grid[x][i];
                  cnt = next;
                  max = 0;
                  for(int x: next)
                     max = Math.max(max, x);
                  if(max > K)
                     continue outer;
                  temp++;
               }
            }
            res = Math.min(res, temp);
         }
         System.out.println(res);
      }
   }

Measured memory_bytes: 53584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    int n,k,x,y;
    cin >> n >> k >> x >> y;
    int ans=0;
    rep(i,n){
        if(i+1>k) ans+= y;
        else ans+= x;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
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 INF = 1e9;

//入力
ll d,g;
vector<ll>p,c;

int main(){
    cin >> d >> g;
    p.resize(d);
    c.resize(d);
    rep(i,d)cin>>p[i]>>c[i];
    ll ans = INF;
    for(int bit=0;bit<(1<<d);bit++){
        ll solved = 0;
        ll score = 0;
        priority_queue<ll>pq;
        rep(i,d){
            if((bit>>i)&1){
                solved+=p[i];
                score += 100*(i+1)*p[i]+c[i];
            }
            else{
                rep(j,p[i]){
                    pq.push(100*(i+1));
                }
            }
        }
        while(score<g){
            score+=pq.top();pq.pop();
            solved++;
        }
        chmin(ans,solved);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>

using namespace std;

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

	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		int l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>

int main()
{
	int n;
	int i,j,count=0;
	scanf("%d",&n);
	int a[n];
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		for(j=2;j<sqrt(a[i])+1;j++){
			if(a[i]==2){
				break;
			}
			if(a[i]%j==0){
				count++;
				break;
			}
		}
	}
	
	printf("%d\n",n-count);
	
	return 0;
	
}

Measured memory_bytes: 1816
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main(void)
{
    string S;
    cin >> S;
    int ans = 10000;
    for (int i = S.size()-1; i >= 2; i--) ans = min(ans, abs(753 - 100*(S[i-2]-'0') - 10*(S[i-1]-'0') - (S[i]-'0')));
    cout << ans << endl;
    return 0;
}

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

int main(){
#ifdef _DEBUG
	//freopen("_in" , "r", stdin );
	//freopen("_out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	string s; cin >> s;
	map<char, int> m;
	for (int i = 0; i < (int) s.size(); i++) {
		m[s[i]]++;
	}
	for (auto i : m) {
		if (i.second % 2) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}


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

struct Node {int key;
    Node *parent,*left,*right;};

Node *root,*nil;

void insert(int k){
    Node *x = root;
    Node *y = nil;
    Node *z = new Node;
    z -> key = k;
    z -> left = nil;
    z -> right = nil;
    while( x != nil ){
        y = x;
        if(z -> key < x -> key){
            x = x -> left;
        }else{
            x = x -> right;
        }
    }
    z -> parent = y;
    if(y == nil){
        root = z;
    }else if(z -> key < y -> key){
        y -> left = z;
    }else{
        y -> right = z;
    }
}

void inorder(Node* n){
    if(n == nil) return;
    inorder(n -> left);
    cout << " " << n -> key;
    inorder(n -> right);
}

void preorder(Node* n){
    if(n == nil) return;
    cout << " " << n -> key;
    preorder(n -> left);
    preorder(n -> right);
}

void print(Node *root){
    inorder(root);
    cout << endl;
    preorder(root);
    cout << endl;
}

void find(int num){
    Node *x = root;
    while( x != nil){
        if( x -> key == num){
            cout << "yes" << endl;
            return ;
        }else if(x -> key < num){
            x = x -> right;
        }else{
            x = x -> left;
        }
    }
    cout << "no" << endl;
}

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string order;
        cin >> order;
        if(order == "insert"){
            int num;
            cin >> num;
            insert(num);
        }else if(order == "find"){
            int num;
            cin >> num;
            find(num);
        }else{
            print(root);
        }
    }
}




Measured memory_bytes: 21912
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
int main() {
  int N, W;
  cin >> N >> W;
  int n[N], w[N], dp[N + 10][W + 10] = {0};
  rep(i, N) cin >> n[i] >> w[i];
  rep(i, N) rep(j, W + 1) dp[i][j] = -1;
  dp[0][0] = 0;
  rep(i, N) rep(j, W + 1) {
    if (dp[i][j] >= 0) {
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
      if (w[i] + j <= W)
        dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + n[i]);
    }
  }
  int ans = 0;
  rep(j, W + 1) {
    ans = max(ans, dp[N][j]);
  }
  cout << ans << endl;
  return 0;
}

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

int pnjgeven, pnjgodd, total, itungeven, itungodd;
string odd, even, akhir;

int main (){
	cin>>odd>>even;
	pnjgodd=odd.length();
	pnjgeven=even.length();
	total=pnjgodd+pnjgeven;
	for (int i=0; i<=total-1; i++){
		if (i%2==0){
			akhir+=odd [itungodd];
			itungodd++;
		}else {
			akhir+=even [itungeven];
			itungeven++;
		}
	}
	cout<<akhir<<endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using P = pair<int, int>;

int main(){
  int n;
  cin >> n;
  vector<vector<P>> human(n);
  rep(i, n){
    int a; cin >> a;
    rep(j, a){
      int x, y;
      cin >> x >> y;
      x--;
      human[i].push_back(P(x, y));
    }
  }
  
  int ans = 0;
  rep(i, 1<<n){
    bool flag = true;
    int now = 0;
    rep(j, n){
      if ((i>>j)&1){
        now++;
        for(P xy : human[j]){
          if (((i>>xy.first)&1) != xy.second){
            flag = false;
            break;
          }
        }
      }
      if (!flag) break;
    }
    if (flag) ans = max(ans, now);
  }
  cout << ans << endl;
  
  return 0;
}

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

string Sum(string& FirstInteger, string& SecondInteger)
{
	int Degit;
	string AddedZero;
	if(FirstInteger.size() < SecondInteger.size()){
		Degit = SecondInteger.size();
		for(int i = 0; i < Degit - FirstInteger.size(); i++){
			AddedZero.push_back('0');
		}
		FirstInteger = AddedZero + FirstInteger;
	}else{
		Degit = FirstInteger.size();
		for(int i = 0; i < Degit - SecondInteger.size(); i++){
			AddedZero.push_back('0');
		}
		SecondInteger = AddedZero + SecondInteger;
	}
//	cout << FirstInteger << '+' << endl << SecondInteger << endl;
	string SumInteger;
	SumInteger.resize(Degit);
	bool IsMoveUp  = false;
	bool WasMoveUp = false;
	for(int i = 0; i < Degit; i++){
		WasMoveUp = IsMoveUp;
		int Sum = WasMoveUp + FirstInteger[Degit-1-i] - '0' + SecondInteger[Degit-1-i] - '0';
		if(Sum >= 10){
			IsMoveUp = true;
			Sum -= 10;
		}else{
			IsMoveUp = false;
		}
		SumInteger[Degit-1-i] = Sum + '0';
	}
	if(IsMoveUp == true){
	    return '1' + SumInteger;
	}else{
	    return SumInteger;
	}
}

int main()
{
	int N;
	cin >> N;
	for(int i = 0; i < N; i++){
		string FirstInteger, SecondInteger;
		cin >> FirstInteger >> SecondInteger;
//		cout << FirstInteger << '+' << SecondInteger << endl;
		string SumInteger = Sum(FirstInteger, SecondInteger);
//		cout << SumInteger.size() << "keta" << endl;
		if(SumInteger.size() <= 80){
//		    cout << "c" << endl;
		    cout << SumInteger.c_str() << endl;
//			cout << "b" << endl;
		}else{
			cout << "overflow" << endl;
		}
//		cout << "a" << endl;
	}
	return 0;
}

Measured memory_bytes: 3152
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	long long int n,i;
	cin>>n;
	i=n%10;
	if(i==2 || i==4 || i==5 || i==7 || i==9){
		cout<<"hon"<<endl;
	}
	else if(i==0 || i==1 || i==6 || i==8){
		cout<<"pon"<<endl;
	}
	else if(i==3){
		cout<<"bon"<<endl;

	}

	return 0;
}

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

int main() {
    int n;
    cin>>n;
    int mx=0,mn=1e9,a;
    for (int i=0;i<n;i++) {
        cin>>a;
        mx=max(mx,a);
        mn=min(mn,a);
    }
    cout<<mx-mn<<endl;
    return 0;
}

Measured memory_bytes: 256
import heapq

n = int(input())
l = list(map(float,input().split()))

heapq.heapify(l)

while len(l) > 1:
  a = heapq.heappop(l)
  b = heapq.heappop(l)
  heapq.heappush(l,(a+b)/2)

print(heapq.heappop(l))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define MEM(x) memset(x,0,sizeof(x))
#define vc vector<int>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define inf 0x3f3f3f3f
#define t_case int tt; cin>>tt; while (tt--)
#define lnginf 9223372036854775807
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define For(i,j,k) for (int i=(int)(j);i<(int)(k);i++)
#define ins insert
#define in(x); { for (auto &i : x) cin >> i; }
#define out(x); { for (auto i : x) cout<<i<<' ' ; }
#define PI 3.14159265359
const long long LL_INF = (long long) 2e18 + 5;
using namespace std;
//const int N = 1e5 + 1;
void solve() {
	int n, m, k; cin >> n >> m >> k;
	vector<int> a(n), b(m);
	int sum = 0;
	For(i, 0, n) {cin >> a[i], sum += a[i];}
	in(b)
	int ans = 0, j = 0, bs = 0;
	for (int i = n; i >= 0; i--) {
		if (i < n)sum -= a[i];
		if (sum <= k) {
			while (j < m and sum + bs + b[j] <= k )bs += b[j], j++;
			ans = max(ans, i + j );
		}
	}
	cout << ans << '\n';

}
int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif


	fastio   solve();


}

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

int main(){
    int A, B; cin >> A >> B;
    
    if(A == 1) A += 13;
    if(B == 1) B += 13;

    if(A > B) cout << "Alice" << endl;
    else if(A < B) cout << "Bob" << endl;
    else cout << "Draw" << endl;
}

Measured memory_bytes: 256
n, total = gets.split.map(&:to_i)
ans_x, anx_y, ans_z = -1, -1, -1

(0..n).each do |x|
  (0..n-x).each do |y|
    z = n - x - y
    if 10000*x + 5000*y + 1000*z == total
      ans_x, anx_y, ans_z = x, y, z
    end
  end
end

puts "#{ans_x} #{anx_y} #{ans_z}"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
using namespace std;


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

/* vector<int> A(N); 
　xの二乗:  pow(x, 2.0) 
    小さい順: sort(v.begin(), v.end());
*/
 
int main() {
  
  int A,B;
  string C,D,E;
  cin >> C >> D >> A >> B >> E;
  
  if(C==E) cout << (A-1) << " " << B << endl;
  if(D==E) cout << A << " " << (B-1) << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
	int A,B;
  	char op[5];
  	scanf("%d %s %d",&A,op,&B);
  	if(strcmp(op,"+")==0){
    	printf("%d",A+B);
    }else if(strcmp(op,"-")==0){
    	printf("%d",A-B);
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

using namespace std;
using ll = long long;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}

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


//////////////////////////////////////////////////

ll gcd (ll a, ll b) { return b?gcd(b,a%b): a;}

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i], a[i] /= 2;
    
    auto func = [&](int x) -> int {
        int res = 0;
        while (x%2 == 0) {
            x/=2;
            res++;
        }
        return res;
    };

    int t = func(a[0]);
    rep(i, n) {
        if (func(a[i]) != t) {
            cout << 0 << endl;
            return 0;
        }
        a[i] >>= t;
    }
    m >>= t;

    ll lc = 1;
    rep(i, n) {
        lc = lc*a[i]/gcd(lc, a[i]);
        if (lc > m) {
            cout << 0 << endl;
            return 0;
        }
    }

    int ans = ((m/lc)+1)/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
/* 
 * Project: AtCoder Beginners Contest 163 
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/04/19
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cmath>
using namespace std;

float r;

void solve() {
    float length;
    length = 2 * 3.14159265 * r;
    printf("%f\n", length);
}

int main() {

    scanf("%f", &r);

    solve();

}

Measured memory_bytes: 3232
import java.util.Scanner;

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

    double pp = 0;

    for(int i=1; i<=n; i++){
      int count = 0;
      int m = i;
      while(m<k){
        m = m * 2;
        count +=1;
      }
      pp += 1/Math.pow(2, count);
    }

    System.out.println(pp*1/n);
  }
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  ll n; cin >> n;
  ll x = 0;
  for(ll i = 1; i*i <= n; ++i){
    if(n % i == 0)x = i;
  }
  cout << max(to_string(x).size(),to_string(n/x).size()) << endl;
}



Measured memory_bytes: 3668
#include <iostream>
using namespace std;
int main(){
    int A,B,C,D,e,f,g;
    cin >> A >> B >> C >> D;
    if(A>B){
        e=B;
        }
    else if(B>A){
        e=A;
        }
    if(C>D){
        f=D;
        }
    else if(D>C){
        f=C;
        }
    g=e+f;
    cout << g;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  ci(n)
  vll A(n);
  vll B(n-1);
  ci(A[0])
  ll s=A[0];
  FOR(i,1,n){
    ll a;
    ci(a)
      s+=a;
    A[i]+=s;
  }
  
  FOR(i,0,n-1){
    B[i]=abs(s-A[i]-A[i]);
  }
  SORT(B);
  co(B[0])
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define INF 1e9

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

  int unwanted;
  vector<int> c(n + 1);
  cin >> c[0] >> c[1];
  for(int i = 2; i <= n; i++){ cin >> unwanted >> c[i]; }

  vector<vector<int> > dp(n, vector<int>(n + 1, INF));
  for(int i = 0; i < n; i++){ dp[i][i + 1] = 0; }

  for(int k = 2; k <= n; k++){
    for(int i = 0; i < n; i++){
      for(int j = 1; j < k; j++){
        if(i + k <= n){
          dp[i][i + k] = min(dp[i][i + k], dp[i][i + j] + dp[i + j][i + k] + c[i] * c[i + j] * c[i + k]);
        }
      }
    }
  }


  // ??????
  cout << dp[0][n] << endl;


  return 0;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  string prev = {s[0]};
  for (int i = 1; i < s.size(); i++) {
    string curr = {s[i]};
    if (prev == curr) {
      n--;
      prev = curr + s[++i];
    } else {
      prev = curr;
    }
  }
  cout << n << endl;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  char c = s[0];
  vector<int> a;
  a.push_back(0);
  for(int i = 1; i < n; i++) {
    if(s[i] != c) {
      a.push_back(i);
      c = s[i];
    }
  }
  a.push_back(n);
  int ans = 0;
  int l = a.size();
  int f = s[0] - '0';
  for(int i = 1; i < l; i++) {
    if((f + i) % 2) {
      int m = min(i+2*k-1,l-1);
      ans = max(ans,a[m]-a[i-1]);
    } else {
      int m = min(i+2*k,l-1);
      ans = max(ans,a[m]-a[i-1]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1020
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

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

using namespace std;

typedef pair<int,int> pii;

int getMid(int a[]){
  sort(a, a + 3);
  return a[1];
}

int main(){

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

  int num[100001] = {};
  list<int> l;
  REP(i,n){
    int t;
    scanf("%d", &t);
    l.push_back(t);
    num[t]++;
  }

  int ans = 0;
  REP(i,100001){
    if(num[i] >= 2){
      ans += num[i] - 1;
    }
  }

  printf("%d\n", n - ans - ans % 2);

  

  return 0;
}



Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    const int mod = 1e9 + 7;
    int n, k;
    cin >> n >> k;
    vector<int> dp(k + 2);
    dp[0] = 1;
    rep(i, n) {
        vector<int> add_dp(k + 2);
        int x;
        cin >> x;
        for (int j = k; j >= 0; j--) {
            (add_dp[min(j + x + 1, k + 1)] += mod - dp[j]) %= mod;
            (add_dp[j] += dp[j]) %= mod;
        }
        for (int j = 1; j <= k; j++) {
            (add_dp[j] += add_dp[j - 1]) %= mod;
        }
        dp.swap(add_dp);
    }
    cout << dp[k] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <stack>
#include <vector>

using namespace std;

typedef pair<int, int> seg;

int R, C, N;
vector<seg> edges;
stack<int> st;

int Convert(int x, int y)
{
	if (y == 0) return x;
	if (x == R) return R + y;
	if (y == C) return R + C + R - x;
	if (x == 0) return R + C + R + C - y;
	return -1;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin >> R >> C >> N;
	for (int i = 1; i <= N; i++)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int p = Convert(a, b), q = Convert(c, d);
		if (p >= 0 && q >= 0)
			edges.emplace_back(make_pair(min(p, q), max(p, q)));
	}
	sort(edges.begin(), edges.end());
	bool flag = true;
	for (auto k : edges)
	{
		while (!st.empty() && k.first >= st.top())
			st.pop();
		if (!st.empty() && k.second > st.top())
		{
			flag = false;
			break;
		}
		st.push(k.second);
	}
	cout << (flag ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define int long long
//#define double long double
#define endre getchar();getchar();return 0
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

int n, c, k;
int a[114514];
int ans = 1;
signed main() {
	cin >> n >> c >> k;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	int p = a[0], q = 0;
	rep(i, n) {
		if (p + k < a[i] || q + c <= i) {
			ans++;
			p = a[i];
			q = i;
		}
	}
	cout << ans << endl;
	endre;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

int main()
{
  string s;
  cin >> s;
  string scopy = s;
  /*
  sort(scopy.begin(), scopy.end());
  int count = 0;
  int max_count = 0;
  char maxc = 'N';
  for(int i=0; i < scopy.size()-1; i++){
    if(scopy[i] == scopy[i+1]){
      count++;
    }else{
      if(count > max_count){
	max_count = count;
	maxc = scopy[i];
      }
      count = 0;
    }
  }
  */
  char a[30];
  int j=0;
  for(int i='a'; i <= 'z'; i++){
    a[j] = i;
    j++;
  }
  vector<vector<int> >H(30);
  for(int i=0; i < 26; i++){
    for(int j=0; j < s.size(); j++){
      if(s[j] == a[i])
	H[i].push_back(j);
    }
  }
  int min_count = 1000;
  for(int i=0; i < 26; i++){
    int left = 0;
    int right = 0;
    int count = 0;
    if(H[i].size() > 0){
      left = H[i][0];
      for(int j=1; j < H[i].size(); j++){
	if(H[i][j] - H[i][j-1] - 1 > left)
	  left = H[i][j] - H[i][j-1] - 1;
      }
      right = s.size()-1 - H[i][H[i].size()-1];
      if(left > right)
	count = left;
      else
	count = right;
    if(count < min_count)
      min_count = count;
    }
  }

  cout << min_count << endl;
  /*
  int ans = 0;
  //cout << maxc << endl;
  if(maxc == 'N' && count == 0){
    if(s.size() % 2 == 0)
      cout << (s.size()-2) / 2 + 1 << endl;
    else
      cout << (s.size()-1) / 2 << endl;
  }else{
    for(int k=s.size()-1; k > 0; k--){
      bool end = true;
      for(int i=0; i < k; i++){
	if(s[i] != s[i+1])
	  end = false;
      }
      //cout << s << endl;
      if(end){
	cout << s.size()-1 - k << endl;
	//cout << s << endl;
	break;
      }
      for(int i=0; i < k; i++){
	if(s[i] == maxc || s[i+1] == maxc)
	  s[i] = maxc;
      }
    }
  }
*/
  return 0;
}


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

result =[]

for i in range(N):
    left = []
    right= []
    for l in range(0,i):
        if S[l] not in left:
            left.append(S[l])
        else:
            continue

    
     
    for r in range(i,N):
        if S[r] not in right:
             right.append(S[r])
        else:
            continue


    count =0
    for i in left:
        for  s in right:
            if i == s :
                count +=1
    result.append(count)
    

print(max(result))


Measured memory_bytes: 9104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define se set<ll>
#define vec vector<ll>
#define inf 10000000000000000
bool mark[100005];
vec adj[100005];
ll counter;

	




int main()
{    
 

	#ifdef APNA_IO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 

ll n;
cin>>n;
ll a[n+1];
ll b[n];
ll ans=0;

for(ll i=0;i<n+1;i++)
{
	cin>>a[i];
}

for(ll i=0;i<n;i++)
{
	cin>>b[i];
}

for(ll i=0;i<n;i++)
{
	if(b[i]>a[i])
	{	
		ans+=a[i];
		if(b[i]-a[i]>a[i+1])
			{	
				ans+=a[i+1];
				a[i+1]=0;
			}
		else
			{
				ans+=b[i]-a[i];
				a[i+1]-=b[i]-a[i];
			}

		
	}
	else
		ans+=b[i];

}

	

cout<<ans<<"\n";

}		





Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a[3];
  for(int i=0;i<3;i++){
    cin>>a[i];
  }
  sort(a,a+3);
  if(a[0]+a[1]==a[2]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

int main(void) {
    int N;
    cin >> N;

    int C[10][10];
    for(int i=0;i<10;i++) {
        for(int j=0;j<10;j++) {
            C[i][j] = 0;
        }
    }

    int top, bottom;
    for(int i=1;i<=N;i++) {
        bottom = i%10;
        if(i<10) {
            top = bottom;
            C[top][bottom]++;
            //cout << top << " " << bottom << endl;
            continue;
        }

        top = i;
        while(top>=10) {
            top /= 10;
        }
        C[top][bottom]++;
        //cout << top << " " << bottom << endl;
    }

    for(int i=0;i<10;i++) {
        C[0][i] = 0;
        C[i][0] = 0;
    }

    int ans=0;
    for(int i=1;i<=N;i++) {
        bottom = i%10;
        if(i<10) {
            top = bottom;
            ans += C[bottom][top];
            continue;
        }

        top = i;
        while(top>=10) {
            top /= 10;
        }
        ans += C[bottom][top];
    }

    cout << ans << endl;

    return (0);
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    int N, K;
    cin >> N >> K;
    ll cnt1 = 0, cnt2 = 0;
    for (int i = 1; i <= N; i++) {
        if (i % K == 0)
            cnt1++;
        if (K % 2 == 0 && i % K == K / 2)
            cnt2++;
    }

    ll ans = 0;
    if (K % 2 != 0) {
        ans += pow(cnt1, 3);
    } else {
        ans += (cnt1 * cnt1 * cnt1);
        ans += pow(cnt2, 3);
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iomanip>	// fixed setprecision
#include <numeric>	// accumulate
using namespace std;
using ll = long long;
using ld = long double;

int main() {
	cout << fixed << setprecision(10);	// https://qiita.com/a4rcvv/items/05febcf410c51009a29a

	int n; cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++)
	{
		cin >> x[i];
	}

	vector<int> tp(n);
	for (int i = 0; i < n; i++)
	{
		tp[i] = x[i] * x[i];
	}
	int tottp = accumulate(tp.cbegin(), tp.cend(), 0);

	int totx = accumulate(x.cbegin(), x.cend(), 0);
	int premd = totx * -2;

	int totp2;
	int md;
	int ans = INT_MAX;
	for (int p = 1; p <= 100; p++)
	{
		md = premd * p;
		totp2 = (p * p) * n;
		ans = min(ans, tottp + md + totp2);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
N,M,K=map(int,input().split())
A,B=[0],[0]
A+=map(int,input().split())
B+=map(int,input().split())

for i in range(1,N+1):
    A[i]+=A[i-1]
for i in range(1,M+1):
    B[i]+=B[i-1]

ans,j=0,M
for i in range(N+1):
    if A[i]>K:
        break
    while A[i]+B[j]>K:
        j-=1
    ans=max(ans,i+j)

print(ans)


Measured memory_bytes: 40640
n,q=map(int, input().split())
*a,=map(int, input().split())
bit=[0]*(2*n+1)

def add(t,x):
    while t<=n:
        bit[t]+=x
        t+=t&(-t)

def que(t):
    res=0
    while t:
        res+=bit[t]
        t-=t&(-t)
    return res

for i in range(n):
    add(i+1,a[i])


for _ in range(q):
    i,p,x=map(int, input().split())
    if i:
        ans=que(x)-que(p)
        print(ans)
    else:
        add(p+1,x)


Measured memory_bytes: 65032
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main(){
    int Nday ;
    int Nhomework ;
    int total = 0;
    cin >> Nday;
    cin >> Nhomework;
    int DaysToFinish[Nday];

    for (int i = 1; i < Nhomework+1; i++){
        cin >> DaysToFinish[i];
        total += DaysToFinish[i];
    }


    if (total<=Nday)
    {
       cout << Nday - total << endl; 
    }
    else
       cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FL          freopen("in", "r", stdin),freopen("out", "w", stdout);
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
int dx[] = {1, 0}, dy[] = {0, 1};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int n;
ll W;
ll dp[101][100010];
ll w[101];
int  v[101];
ll f(int i, int want){
    if(i == n){
        if(want == 0)
            return 0;
        return 1e12;
    }
    ll &ans = dp[i][want];
    if(ans != -1)return ans;
    ans = 1e12;
    if(want >= v[i])
    ans = min(f(i + 1, want - v[i]) + w[i], ans);
    ans = min(f(i + 1, want), ans);
    return ans;
} 
int main(){
    //FL;
    FIN;
    cin >> n >> W;
    ll sum = 0;
    fore(i, 0, n){
        cin >> w[i] >> v[i];
        sum += v[i];
    }
    cls(dp, -1);
    int ans = 0;
    fore(i, 1, sum + 1){
        ll cur = f(0, i);
        if(cur <= W)
            ans = i;
    }
    cout << ans << '\n';
    EjecuteTime;
    return 0;
}       

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

//a^b % MOD
long long mod_pow(ll a,ll b){
	long long ret = 1;
	long long c = a;
	for(int i = 0;i <= 60;i++){
		if(b & (1LL << i))ret = (ret * c) % MOD;
		c = (c * c) % MOD;
	}
	return ret;
}

//ａをbで割る
long long mod_div(long long a,long long b){
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

#define MAX_K 333333
vector<long long> fact(MAX_K);
long long combination(long long n, long long r){
    if(n < r || n < 0 || r < 0)
        return 0;
	if(fact[0] != 1){
		fact[0] = 1;
		for(long long i = 1;i < MAX_K;i++)fact[i] = (fact[i-1] * i) % MOD;
	}
    long long ret = fact[n];
	long long tmp = (fact[r] * fact[n-r]) % MOD;
    return mod_div(ret,tmp);
}

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

	ll n, k;cin >> n >> k;
	vector<ll> v(n);REP(i, n)cin >> v[i];
	sort(ALL(v));

	ll ans = 0;
	REP(i, n){
		ans += ((v[i] + MOD) % MOD) * combination(i, k-1) % MOD;
		ans %= MOD;
	}
	reverse(ALL(v));
	REP(i, n){
		ans += ((MOD - v[i]) % MOD) * combination(i, k-1) % MOD;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3712
#include <iostream>

bool isTriangle(int a, int b, int c){
	if(a*a == b*b + c*c || b*b == a*a + c*c || c*c == a*a + b*b)	return true;
	else return false;
}

int main(){
	int num_d;
	std::cin >> num_d;
	
	for(int i = 0;i < num_d; ++i){
		int a, b, c;
		std::cin >> a >> b >> c;
		
		if(isTriangle(a, b, c)){
			std::cout << "YES" << std::endl;
		}
		else{
			std::cout << "NO" << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152