akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
    
using namespace std;
    
#define int long long
#define endl "\n"

template<typename RandomIt>
void ruffleSort(RandomIt first, RandomIt last)
{
    random_device rd;
    mt19937 g(rd());
    shuffle(first, last, g);
    sort(first, last);
}

template<typename Container>
auto outputContainer(const Container & con) 
{
    for(int i = 0; i < con.size(); ++i)
        cout << con[i] << " \n"[i+1==con.size()];
}

template<typename T = int>
auto readVector(const int N) 
{
    vector<T> v(N);
    for(auto & e : v) cin >> e;
    return v;
}


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

    if(s.back() == 's') {
        cout << s << "es" << endl;
    } else {
        cout << s << "s" << endl;
    }

    return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
 
int c, p, l, lp;
long long r;
int main() {
  for(; (c = getchar_unlocked()) != EOF && c > ' '; r += ++l) {
    if(c != p) { 
      if(c == '<')
        r -= l < lp ? l : lp;
      p = c, lp = l, l = 0;
    }
  }
  if(p == '>')
    r -= l < lp ? l : lp;
  printf("%lld\n", r);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a==1 && b!=1)
    {
        cout<<"Alice"<<endl;
    }
    else if(b==1 && a!=1)
    {
        cout<<"Bob"<<endl;
    }
    else if(a!=1 && b!=1 && a>b)
    {
        cout<<"Alice"<<endl;
    }
    else if(a!=1 && b!=1 && b>a)
    {
        cout<<"Bob"<<endl;
    }
    else if(a==b)
    {
        cout<<"Draw";
    }
    return 0;

}

Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0031
{
    class Program
    {
        static void Main(string[] args)
        {
            string input;
            while ((input = Console.ReadLine()) != null)
            {
                input = Convert.ToString(int.Parse(input), 2);
                char[] zeroIchi = input.ToCharArray();
                Array.Reverse(zeroIchi);
                List<double> answer = new List<double>();
                for (int i = 0; i < zeroIchi.Length; ++i)
                {
                    if (ToInt(zeroIchi[i]) == 1)
                    {
                        answer.Add(Math.Pow(2, i));
                    }
                }
                Console.WriteLine(string.Join(" ", answer));
            }
        }
        public static int ToInt(char self)
        {
            return self - '0';
        }
    }
}



Measured memory_bytes: 15972
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

n=int(input())
k=int(input())
keta=len(str(n))
sn=str(n)
dp=[[[0]*(k+1) for j in range(keta)] for i in range(2)]

for i in range(keta):
    if i==0:
        dp[0][0][0]=1
        dp[0][0][1]=int(sn[i])-1
        dp[1][0][1]=1
    else:
        for j in range(k+1):
            if j!=k:
                dp[0][i][j]+=dp[0][i-1][j]
                dp[0][i][j+1]+=dp[0][i-1][j]*9
                if int(sn[i])==0:
                    dp[1][i][j]+=dp[1][i-1][j]
                else:
                    dp[1][i][j+1]+=dp[1][i-1][j]
                    dp[0][i][j]+=dp[1][i-1][j]
                    dp[0][i][j+1]+=dp[1][i-1][j]*(int(sn[i])-1)
            else:
                dp[0][i][j]+=dp[0][i-1][j]
                if int(sn[i])==0:
                    dp[1][i][j]+=dp[1][i-1][j]
                else:
                    dp[0][i][j]+=dp[1][i-1][j]

print(dp[0][-1][-1]+dp[1][-1][-1])

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

typedef long long ll;
ll n, s, x, a[105];
int main()
{
	ll i;
	cin >> n >> x;
	for (i = 0; i < n; i++) {
		scanf ("%lld", &a[i]);
	}
	sort(a, a + n);
	for (i = 0; i < n; i++) {
		s += a[i];
		if (s > x) break;
	}
	if (i == n) {
		if (s == x) cout << n;
		else cout << n - 1;
	} else {
		cout << i;
	}
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/rope>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define mst(a,b) memset(a,b,sizeof(a))
#define ALL(x) x.begin(),x.end()
#define pii pair<int,int>
#define mp make_pair
#define lowbit(x) (x&(-x))
#define X first
#define Y second
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;
typedef long long ll;
typedef long long LL;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<ll, ll> pll;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const long double eps = 1e-8;
const long double pi = acos(-1.0);
const int N = 1e6 + 5;
const int mod = 1e9 + 21;
const int maxn = 1e7 + 5;
int e[5][5];
int main() {
#ifdef local
    freopen("input", "r", stdin);
//    freopen("out.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    for(int i = 1; i <= 3; i++){
        int u,v;
        cin>>u>>v;
        e[u][v] = 1;
        e[v][u] = 1;
    }
    int a[4] = {1,2,3,4};
    do{
        int b = 1;
        for(int i = 1; i <= 3; i++){
            if(!e[a[i]][a[i - 1]])b = 0;
        }
        if(b){
            cout<<"YES"<<endl;
            return 0;
        }
    }while(next_permutation(a,a + 4));
    cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, m, a;
  in2(n, m);
  rep2(i, 1, 185000000){
    if(m % i == 0){
      if(n * i <= m)
        a = max(a, i);
      if(n * (m / i) <= m)
        a = max(a, (m / i));
    }
  }
  out(a);
  memi;
}

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

using namespace std;



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

	vector<string> s{ "dream", "dreamer", "erase", "eraser" };

	reverse(a.begin(), a.end());
	for (int i = 0; i < 4; i++) {
		reverse(s.at(i).begin(), s.at(i).end());
	}

	string n;
	bool flag = true;

	for (int i = 0; i < a.size();) {
		bool flag2 = false;
		for (int j = 0; j < 4; j++) {
			n = s.at(j);
			if (a.substr(i, n.size()) == n) {
				i += n.size();
				flag2 = true;
			}
		}
		if (!flag2) {
			flag = false;
			break;
		}
	}

	if (flag) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 3720
using System;
using System.Collections.Generic;
using System.Linq;

public class AtCoder_161_D
{
    public static void Main()
    {
        int k = int.Parse(Console.ReadLine());

        List<List<long>> ans = new List<List<long>>();
        ans.Add(new List<long>
        {
            1, 2, 3, 4, 5, 6, 7, 8, 9
        });

        if (k <= 9)
        {
            Console.WriteLine(ans[0][k - 1]);
            return;
        }

        k -= 9;

        int keta = 0;
        long current = 0;

        while (k > 0)
        {
            keta++;
            ans.Add(new List<long>());
            for (int i = 0; i < ans[keta - 1].Count; i++)
            {
                long left = ans[keta - 1][i];
                long last = ans[keta - 1][i] % 10;
                if (last > 0)
                {
                    current = left * 10 + last - 1;
                    ans[keta].Add(current);
                    k--;
                    if (k <= 0) break;
                }

                current = left * 10 + last;
                ans[keta].Add(current);
                k--;
                if (k <= 0) break;

                if (last < 9)
                {
                    current = left * 10 + last + 1;
                    ans[keta].Add(current);
                    k--;
                    if (k <= 0) break;
                }
            }
        }

        Console.WriteLine(current);
    }
}


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

const long long MOD = (long long) 1e9 + 7;

vector<long long> fact;

long long modpow(long long b, long long p) {
  if (p == 0) {
    return 1;
  }
  long long ans = modpow((b * b) % MOD, p / 2);
  if (p % 2 == 1) {
    ans = (ans * b) % MOD;
  }
  return ans;
}

long long inv(long long x) {
  return modpow(x, MOD - 2);
}

long long C(int n, int k) {
  return ((fact[n] * inv(fact[k])) % MOD * inv(fact[n - k])) % MOD;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  fact.resize((int) 2e6 + 1);
  fact[0] = 1;
  for (int i = 1; i <= (int) 2e6; i++) {
    fact[i] = (fact[i - 1] * i) % MOD;
  }
  int k;
  cin >> k;
  string s;
  cin >> s;
  int n = (int) s.length();
  long long ans = 0;
  for (int i = 0; i <= k; i++) {
    long long add = (modpow(26, i) * modpow(25, k - i)) % MOD;
    add = (add * C(n + k - i - 1, n - 1)) % MOD;
    ans = (ans + add) % MOD;
  }
  cout << ans << '\n';
  return 0;
}

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

const int N = 1e5 + 10;

vector <int> tr[N];
int p[N], SG[N];

void dfs(int x, int f){
	p[x] = f;
	for (int i = 0; i < (int)tr[x].size(); i++){
		if (tr[x][i] == f) continue;
		dfs(tr[x][i], x);
		SG[x] ^= SG[tr[x][i]] + 1;
	}
}

int main(){
	int n, u, v;
	scanf("%d",&n);
	for (int i = 1; i <= n - 1; i++){
		scanf("%d %d",&u,&v);
		tr[u].push_back(v);
		tr[v].push_back(u);
	}
	memset(SG, 0, sizeof(SG));
	dfs(1, 0);
	if (SG[1]) printf("Alice\n");
	else printf("Bob\n");
	return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
template<class T> inline void chmax(T& a, T b){if(a<b)a=b;}
template<class T> inline void chmin(T& a, T b){if(a>b)a=b;}
const long long INF = 1LL << 60;

int N,M;
vector<vector<int> > G;
vector<int> bfs;
int dp[110000];

int main(){
  cin >> N >> M;
  G.assign(N,vector<int>());
  
  bfs.assign(N,0);
  for(int i=0;i<M;++i){
    int v,e;
    cin >> v >> e;
    v--;e--;
    G[v].push_back(e);
    bfs[e]++;
  }
  // 現在根にあたる頂点を保持(トポロジカルソート用)
  queue<int> q;
  for(int i=0;i<N;++i){
    if(bfs[i]==0) q.push(i);
  }
  while(!q.empty()){
    int v = q.front();q.pop();
    for(auto nv : G[v]){
      bfs[nv]--;
      if(bfs[nv]==0){
        q.push(nv);
        chmax(dp[nv],dp[v]+1);
      }
    }
  }
  int ans = 0;
  for(int i=0;i<N;++i){
    chmax(ans,dp[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
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;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j]
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
int main(){
    int n,u,v; cin >> n >> u >> v;
    u--; v--;
    vector<vector<int>> to(n);
    rep(i,n-1){
        int a,b; cin >> a >> b;
        a--; b--;
        to[a].pb(b);
        to[b].pb(a);
    }
    int rank[n];
    rank[v]=0;
    bool vis[n];
    rep(i,n) vis[i]=0;
    queue<int> q;
    q.push(v); vis[v]=1;
    while(!q.empty()){
        int d=q.front(); q.pop();
        for(auto p:to[d]){
            if(!vis[p]){
                vis[p]=1;
                q.push(p);
                rank[p]=rank[d]+1;
            }
        }
    }
    int dist[n];
    dist[u]=0;
    rep(i,n) vis[i]=0;
    q.push(u); vis[u]=1;
    while(!q.empty()){
        int d=q.front(); q.pop();
        for(auto p:to[d]){
            if(!vis[p]){
                vis[p]=1;
                q.push(p);
                dist[p]=dist[d]+1;
            }
        }
    }
    int ans=0;
    rep(i,n){
        if(dist[i]<rank[i]) ans=max(ans,rank[i]-1);
    }
    cout << ans << endl;
}



Measured memory_bytes: 6784
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c=a*b;
		if (c%2==0){
        	System.out.print("Even");
        }else{
			System.out.print("Odd");
        }
		
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,sum,sub,mul;
    cin>>a>>b;
    sum=a+b;
    sub=a-b;
    mul=a*b;
    if(sum>=mul&&sum>=sub)
    {
        cout<<sum<<endl;
    }
    else if(sub>=mul&&sub>=sum)
    {
        cout<<sub<<endl;
    }
    else if(mul>=sum&&mul>=sub)
    {
        cout<<mul<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
def solve():
    
    A, B, C, D, E, F = map(int, input().split())
    memo = []
    
    for a in range(31):
        for b in range(31):
            for c in range(101):
                for d in range(101):
                    w = (100*A)*a + (100*B)*b
                    s = C*c + D*d
                    if w+s > F:
                        break
                    else:
                        if w/100 * E >= s:
                            memo.append([w+s,s])
    
    print(*sorted(memo, key=lambda x: (100*x[1] / x[0] if x[0] else 0))[-1])

if __name__ == '__main__':
    solve()

Measured memory_bytes: 45312
//c++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define len(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
const ll MOD = 1000000007;
//const ll MOD = 998244353;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.9lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}


ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}

void solve(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a <= b * c){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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


Measured memory_bytes: 3644
from itertools import accumulate
n, *A = map(int, open(0).read().split())
B = list(accumulate(A))
p0 = n0 = p1 = n1 = 0
for i, b in enumerate(B):
    if i % 2 == 0:
        if b+p0-n0 <= 0:
            p0 += abs(b+p0-n0)+1
        if b+p1-n1 >= 0:
            n1 += abs(b+p1-n1)+1
    else:
        if b+p0-n0 >= 0:
            n0 += abs(b+p0-n0)+1
        if b+p1-n1 <= 0:
            p1 += abs(b+p1-n1)+1
print(min(p0+n0, p1+n1))


Measured memory_bytes: 20048
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn =new Scanner(System.in);
		int a = scn.nextInt();
		int b= scn.nextInt();
		int m = scn.nextInt();
		int [] arr1=new int[a];
		int [] arr2 =new int[b];
		 int[][] arr3 =new int[m][3];
		 for(int i=0;i<a;i++){
			 arr1[i]=scn.nextInt();
			 
		 }
		 for(int i=0;i<b;i++){
			 arr2[i]=scn.nextInt();
		 }
         for(int i=0;i<m;i++){
        	 for(int j=0;j<3;j++){
        		 
        		 arr3[i][j]=scn.nextInt();
        		 if(j!=2)
        		 arr3[i][j]--;
        	 }
         }
         int min = Integer.MAX_VALUE;
         for(int i=0;i<m;i++){
        	 int val =arr1[arr3[i][0]];
        	 int val2  =arr2[arr3[i][1]];
        	 min =Math.min(min, val+val2-arr3[i][2]);
         }
         Arrays.sort(arr1);
         Arrays.sort(arr2);
         min =Math.min(min, arr1[0]+arr2[0]);
         System.out.println(min);
	}

}

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

int solve(int N, int M)
{
  vector<int> group(M+1, 0);
  group[0] = N;
  int ans = 0;
  for (; group[M] == 0; ++ans) {
    vector<int> next(M+1, 0);
    for (int i = 0; i <= M; i++) {
      const int x = group[i] / 2;
      next[i+1] += x;
      next[0] += x;
      next[i] += group[i] - 2*x;
    }
    group.swap(next);
  }
  return ans;
}

int main()
{
  int T = 0;
  int N, M;
  while (cin >> N >> M && N != 0) {
    cout << "Case " << ++T << ": " << solve(N, M) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    string S;
    cin >> S;
    int r = 0;
    int ans = 0;
    rep(i,3) {
        S[i] == 'R' ? r++ : r = 0;
        chmax(ans,r);
    }
    cout << ans << endl;
    
    
    
    

    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5010;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

char c[2010][2010];
bool flag[2010][2010];
ll cnt[2010][2010];

//long longしか使わない
//素数は1より大きい
int main() {
	ll n, m;
	cin >> n >> m;
	vector<ll>p(m), y(m);
	vector<vector<ll>>arr(n + 1);
	vector<ll>city(m), id(m);
	rep(i, m) {
		cin >> p[i] >> y[i];
		city[i] = p[i];
		id[i] = y[i];
		arr[p[i]].push_back(y[i]);
	}
	for (ll i = 1;i <= n;++i) {
		sort(arr[i].begin(), arr[i].end());
	}
	rep(i, m) {
		printf("%06d", city[i]);
		printf("%06d\n", 1 + lower_bound(arr[city[i]].begin(), arr[city[i]].end(), id[i]) - arr[city[i]].begin());
	}
}

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

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

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

	vector<long long int> B(N);
	for (int i = 0; i < N; i++) {
		B[i] = abs(A[i]);
	}
	sort(B.begin(), B.end());

	long long int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] < 0) {
			cnt++;
		}
	}

	long long int ans = 0;
	for (int i = 0; i < N; i++) {
		ans += B[i];
	}

	if (cnt % 2 == 0) {
		cout << ans << endl;
	}
	else {
		cout << ans - 2 * B[0] << endl;
	}
}

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

using namespace std;

int main()
{
    char a;
    cin>>a;
    if(a=='A') cout<<"T"<<endl;
    else if(a=='T') cout<<"A"<<endl;
    else if(a=='G') cout<<"C"<<endl;
    else if(a=='C') cout <<"G"<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict
input = lambda: sys.stdin.readline().rstrip()

n = int(input())
a = list(map(int, input().split()))
q = int(input())
bc = [list(map(int, input().split())) for _ in range(q)]

d = defaultdict(lambda: 0)
ans = 0
for v in a:
   d[v] += 1
   ans += v
for i in range(q):
   b, c = bc[i]
   if b > c:
      ans -= (b - c) * d[b]
   else:
      ans += (c - b) * d[b]
   d[c] += d[b]
   d[b] = 0
   print(ans)


Measured memory_bytes: 104348
//*e**** ********e* *e****e* ****e**
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(int argc, char const *argv[])
{
	int n,k;
	string s;
	cin >> n >> s >> k;

	char c = s[k-1];

	for (string::iterator i = s.begin(); i != s.end(); ++i)
	{
		if(*i != c){
			*i = '*';
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

int main() {
	makei(N);
	makei(C);
	vvi d(C);
	vvi ans(3);
	vvi c(3);
	For(i, 3)For(j, C)ans[i].push_back(0);
	For(i, C) {
		For(j, C) {
			makei(D);
			d[i].push_back(D);
		}
	}
	For(i, N) {
		For(j, N) {
			makei(D);
			c[(i + j) % 3].push_back(D - 1);
		}
	}
	For(i, 3) {
		For(j, C) {
			for (int k : c[i]) {
				ans[i][j] += d[k][j];
			}
		}
	}
	int Ans = INT32_MAX;
	For(i, C) {
		For(j, C) {
			For(k, C) {
				if (i == j || j == k || k == i)continue;
				mini(Ans, ans[0][i] + ans[1][j] + ans[2][k]);
			}
		}
	}
	say(Ans);
}

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

#define MAX 200002

int n;
int m;

vector<int> v[MAX];

int main(){
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for (int i = 0; i < v[0].size(); i++){
		int go = v[0][i];
		for (int j = 0; j < v[go].size(); j++){
			int go2 = v[go][j];
			if (go2 == n - 1){
				puts("POSSIBLE");
				return 0;
			}
		}
	}
	puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 12016
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(const auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) {cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl;}

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>&m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}
template<typename S,typename T,typename U>
struct TRI{S fi;T se;U th;TRI(){}TRI(S f,T s,U t):fi(f),se(s),th(t){}
bool operator<(const TRI&_)const{return(fi==_.fi)?((se==_.se)?(th<_.th):(se<_.se)):(fi<_.fi);}};
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,TRI<S,T,U>&t){return o<<"{"<<t.fi<<","<<t.se<<","<<t.th<<"}";}

typedef pair<int, int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int dfs1(int& pos, const string& s);
int dfs2(int& pos, const string& s);

int dfs3(int& pos, const string& s){
    if(isdigit(s[pos])){
        int res = 0;
        while(isdigit(s[pos])){
            res = res * 10 + (s[pos++] - '0');
        }
        return res;
    }
    pos++;
    const int res = dfs1(pos, s);
    pos++;
    return res;
}

// m, d
int dfs2(int& pos, const string& s){
    int res = dfs3(pos, s);
    while(pos < (int)s.size()){
        if(s[pos] == '*'){
            ++pos, res *= dfs3(pos, s);
        }else if(s[pos] == '/'){
            ++pos, res /= dfs3(pos, s);
        }else break;
    }
    return res;
}

// a, s
int dfs1(int& pos, const string& s){
    int res = dfs2(pos, s);
    while(pos < (int)s.size()){
        if(s[pos] == '+'){
            ++pos, res += dfs2(pos, s);
        }else if(s[pos] == '-'){
            ++pos, res -= dfs2(pos, s);
        }else break;
    }
    return res;
}

int parse(const string& s){
    int pos = 0;
    return dfs1(pos, s);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t;
    cin >> t;
    string s;
    rep(i,t){
        cin >> s;
        cout << parse(s) << "\n";
    }
    return  0;
}


Measured memory_bytes: 3144
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		for(int i=0;i<H;i++){
			for(int j=0;j<S[i].Length;j++){
				if(S[i][j] == "snuke"){
					Console.WriteLine("{0}{1}",(char)('A'+j),i+1);
				}
			}
		}
		
		
		
	}
	int H,W;
	String[][] S;
	public Sol(){
		var d = ria();
		H = d[0]; W = d[1];
		S = new String[H][];
		for(int i=0;i<H;i++) S[i] = rsa();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 2904
import java.util.Scanner



object Main extends App {

  def read(): Array[Int] = {
    val sc: Scanner = new Scanner(System.in)
    val n = sc.nextInt
    val arr = Array.fill(n)(sc.nextInt)
    sc.close()
    arr
  }

  def solve()  = {
    val arr = read()
    var max = Long.MinValue
    var min = arr.head
    for(i <- 1 until arr.length) {
      max = Math.max(max, arr(i)-min)
      min = Math.min(min, arr(i))
    }
    max
  }
  println(solve)

}



Measured memory_bytes: 205564
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n) 
{ v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i]; }
template<class T, class U> void read_n(vector<pair<T, U>>& v, size_t n)
{ v = vector<pair<T, U>>(n); 
  for (lli i=0; i<n; ++i) cin >> v[i].first >> v[i].second; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli a, b, c;
int main() {
  cin >> a >> b >> c;
  cout << (a*b/2) << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ0576().doIt();
	}
	
	class AOJ0576{
		String kan;
		void doIt(){
			int n = in.nextInt();
			kan = in.next();
			int cnt = 0;
			for(int i=0;i<n;i++){
				cnt+=get_Kanban(in.next());
			}
			System.out.println(cnt);
		}
		
		int get_Kanban(String input){
			int n = input.length();
			for(int i=0;i<n;i++){// 何文字目から始めるか
				for(int s=1;s<n;s++){// 間隔
					String a = "";
					for(int k=i;k<n;k+=s){// 文字場所
						if(a.length()==kan.length())break;
						a+=input.charAt(k);
					}
					if(a.equals(kan))return 1;
				}
			}
			return 0;
		}
	}
}

Measured memory_bytes: 90708
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>

struct Vector {
    double x = 0, y = 0;
    Vector(int _x, int _y) : x(_x), y(_y) {}
    Vector(double _x, double _y) : x(_x), y(_y) {}

    double dot(const Vector &r) const {
        return x * r.x + y * r.y;
    }
    
    double cross(const Vector &r) const {
        return x * r.y - y * r.x;
    }

    double length() const {
        return sqrt(x * x + y * y);
    }

    Vector  operator +  (const Vector &r) const {
        return Vector(x + r.x, y + r.y);
    }
    Vector& operator += (const Vector &r) {
        x += r.x, y += r.y;
        return *this;
    }

    Vector  operator -  () const {
        return Vector(-x, -y);
    }

    Vector  operator -  (const Vector &r) const {
        return *this + -r;
    }
    Vector& operator -= (const Vector &r) {
        x -= r.x, y -= r.y;
        return *this;
    }

    Vector  operator *  (double k) const {
        Vector tmp = *this;
        tmp.x *= k, tmp.y *= k;
        return tmp;
    }

    Vector& operator *= (double k) {
        x *= k, y *= k;
        return *this;
    }

    // 单位化
    void unitise() {
        double len = length();
        x /= len, y /= len;
    }
};
typedef Vector Point;
struct Line {
    Point p;
    // 规定方向向量取单位向量
    Vector dir;

    Line(Point _p, Vector _dir) : p(_p), dir(_dir) {
        dir.unitise();
    }

};

// 向量数乘
Vector operator * (double k, const Vector & r) {
    return r * k;
}

// 点到直线的投影点
Point projection(const Point &p, const Line &l) {
    double d = Vector(p - l.p).dot(l.dir);
    return l.p + d * l.dir;
}
using namespace std;


int main() {
    // freopen("in", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int xp1, yp1, xp2, yp2, q, xp, yp;
    cin >> xp1 >> yp1 >> xp2 >> yp2 >> q;
    Line L(Point(xp1, yp1), Vector(xp2 - xp1, yp2 - yp1));
    while (q--) {
        cin >> xp >> yp;
        Point p(xp, yp);
        Point pro = projection(p, L);
        Point ans = p + 2 * (pro - p);
        cout << fixed << setprecision(8) << ans.x << ' ' << ans.y << '\n';
    }
    return 0;
}


Measured memory_bytes: 3300
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n;
    cin >> n;
    ll b=26;
    ll ctr=1;
    Vi bs;
    bs.pb(1);
    bs.pb(26);
    while(n-b>0){
        n-=b;
        b*=26;
        bs.pb(b);
        ctr++;
    }
    string ans="";
    rp(i,ctr){
        ll num=(n-1)/bs[ctr-i-1];
        char ch='a'+num;
        ans+=ch;
        n-=num*bs[ctr-i-1];
    }
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3652
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 m = sc.nextInt();
		int[][] d = new int[n][2];
		for(int i = 0; i < n; i++){
		    d[i][0] = sc.nextInt();
		    d[i][1] = sc.nextInt();
		}
		
		// 計算
		long result = 0;
		Arrays.sort(d, (a,b) -> Integer.compare(a[0], b[0]));
		for(int i = 0; i < n; i++){
		    if(m == 0) break;
		    result += (long)d[i][0] * min(m, d[i][1]);
		    m = max(0, m - d[i][1]);
		}
		
		// 出力
		System.out.println(result);
        
	}
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1e9  //
#define LINF 1e18  //
#define MOD (1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

//------------------------------------------------------

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

    ll sum = 0;

    repll2(i, n) {
        string s = to_string(i);
        ll digits = 0;

        rep(j, s.length()) {
            digits += (ll) (s[j] - '0');
        }
        if (a <= digits && digits <= b) sum += i;
    }

    cout << sum << endl;

    return 0;
}



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

int dp[10000000][2];

signed main(){
	string S; cin>>S;
	int ans=0,N=S.size();
	dp[1][0]=S[0]-'0';
	dp[1][1]=10-(S[0]-'0');
	for(int i=1;i<N;i++){
		int t=S[i]-'0';
		dp[i+1][0]=min(dp[i][0]+t , dp[i][1]+t+1);
		dp[i+1][1]=min(dp[i][0]+10-t , dp[i][1]+10-(t+1));
	}
	cout<<min(dp[N][0],dp[N][1]+1)<<endl;

}

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

int N, M;
long long K;
vector<int> x;
vector<int> a;

vector<int> permmul(const vector<int> &P1, const vector<int> &P2){
    vector<int> ret(N);
    for(int i=0; i<N; i++)
        ret[i] = P2[P1[i]];
    return ret;
}

vector<int> permpow(const vector<int> &P, long long K){
    if(K == 1) return P;
    if(K % 2 == 0){
        auto tmp = permpow(P, K/2);
        return permmul(tmp, tmp);
    }
    else return permmul(P, permpow(P, K-1));
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    cin >> N;
    x.resize(N);
    for(int i=0; i<N; i++) cin >> x[i];
    cin >> M >> K;
    a.resize(M);
    for(int i=0; i<M; i++){
        cin >> a[i];
        a[i]--;
    }

    vector<int> P(N);
    for(int i=0; i<N; i++) P[i] = i;
    for(int i=0; i<M; i++) swap(P[a[i]], P[a[i]-1]);
    P = permpow(P, K);

    vector<long long> y(N);
    for(int i=0; i<N-1; i++) y[i] = x[i+1]-x[i];

    vector<long long> yy(N);
    for(int i=0; i<N; i++) yy[i] = y[P[i]];
    vector<long long> xx(N);
    xx[0] = x[0];
    for(int i=1; i<N; i++) xx[i] = xx[i-1] + yy[i-1];
    for(int i=0; i<N; i++) cout << xx[i] << endl;

	return 0;
}

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

int main(void)
{
    int n, m; cin >> n >> m;
    int a;
    int sum = 0;
    for (int i = 0; i < m; i++)
    {
        cin >> a;
        sum += a;
    }
    int ans = max(-1, n-sum);
    cout << ans << endl;
}

Measured memory_bytes: 3608
N = int(input())
A = list(map(int, input().split()))

ct = {}
s = 0
for i in range(N):
  s += A[i]
  ct[s] = ct.get(s, 0) + 1

ans = 0
s = 0
for a in A:
  ans += ct.get(s, 0)
  s += a
  ct[s] -= 1

print(ans)

Measured memory_bytes: 39512
h,w,k = gets.split.map(&:to_i)
dp = Array.new(h+1){Array.new(w+2,0)}
mod = 10**9+7
c = Array.new(w+1,0)
d = 0
(2**(w-1)).times do |i|
    f = true
    (w-2).times do |j|
        f = false if (i[j]&i[j+1]) == 1
    end
    if f
        (w-1).times do |j|
            c[j+1] += i[j]
        end
        d += 1
    end
end

dp[0][1] = 1
for i in 1..h
    for j in 1..w
        dp[i][j] += c[j-1]*dp[i-1][j-1]+c[j]*dp[i-1][j+1]+(d-c[j-1]-c[j])*dp[i-1][j]
        dp[i][j] %= mod
    end
end
p dp[h][k]

Measured memory_bytes: 1788
n = gets.to_i
as = gets.split.map(&:to_i)

now = -1
cnt = 0
ans = 0
n.times do |i|
    if as[i] != now
        ans += cnt/2 
        cnt = 1
        now = as[i]
    else
        cnt += 1
    end
end
ans += cnt/2

puts ans

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int out01 = Math.Min(x[1], x[3]) - Math.Max(x[0], x[2]);

            if (out01 < 0) out01 = 0;
            
            Console.WriteLine(out01);
        }
    }
}

Measured memory_bytes: 13268
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
x = 0
for i in range(n-1):
    if a[i] + 1 == a[i+1]:
        x += c[a[i]-1]
print(sum(b) + x)

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

int main(){
	int k,t; cin>>k>>t;
	vector<int> v(t);
	rep(i,t) cin>>v[i];
	sort(rall(v));
	int cnt=0;
	for(int i=1; i<t; i++) cnt+=v[i];
	int ans=v[0]-cnt-1;
	if(ans<=0) cout<<0<<endl;
	else cout<<ans<<endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <stdio.h>
#include <algorithm>
//#include <string>
#include <math.h>
//#include <vector>

using namespace std;


int main() {
  long long int N;
  int A[17];
  int i,a=0,b=0;
  int ans;

  
  cin >> N; 

  while(N>0){
    A[b] = N%10;
    N /= 10;
    b++; 
  }


  while(A[a]==9){
    a++;
    if(a==b) break;
  }
  ans = a*9;

  //  printf("a b %d %d\n",a,b);
  
  i=b-1;

  while(A[i]==9){
    i--;
  }

  if(b-a>1 && i!=b-1)
    ans += (A[i+1]-1)+9*(b-a-1);
  else if(b-a==1)
    ans += A[b-1];
  else if(i==b-1)
    ans += (A[i]-1)+9*(b-a-1);
  
  cout << ans;
  
  return 0;
}


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

#define rep(i,b) for(long long i = 0; i < (b); i++)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
using ll = long long;
string s;

ll lcm(ll a,ll b){
	
	return (a*b)/(__gcd(a,b));
}

void solve() 
{ 
int n;
cin>>n;
vector<int> v(n);
rep(i,n){
	cin>>v[i];
}
unordered_map<int,int> vis;
sort(all(v));
int ans=0;

for(auto i:v){
	
	for(int j=1;j*i<=v[n-1];j++)
	{
		vis[j*i]++;
	}
}
for(auto i:v){
	if(vis[i]==1){
		ans++;
	}
}
cout<<ans;
}



int main(){

		solve();
		cout<<endl;


				
}
		

	

		

 



Measured memory_bytes: 43124
n = gets.to_i
a = gets.split.map(&:to_i)

gcdl = Array.new(n)
gcdl[0] = a[0]
gcdr = Array.new(n)
gcdr[n-1] = a[n-1]

for i in 1..(n-1)
  gcdl[i] = gcdl[i-1].gcd(a[i])
  gcdr[n-1-i] = gcdr[n-i].gcd(a[n-1-i])
end

max = 0
for i in 0..(n-1)
  if i == 0
    max = [max, gcdr[i+1]].max
  elsif i == n-1
    max = [max, gcdl[i-1]].max
  else
    cmp = gcdr[i+1].gcd(gcdl[i-1])
    max = [max, cmp].max
  end
end 
puts max

Measured memory_bytes: 12684
#include<iostream>
#include<stdio.h>//printf("%.9f\n",*********);
#include<vector>//文字列.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char(小文字-32=大文字) to_string,string,char
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define str string
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

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

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int SED(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}//stringのほうが効率よくないか？

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	rapid_pleaseAC_fast;

  int k,n;
  cin>>k>>n;
  vint a(n);
  vcin(a,n);
  
  int big=k-a[n-1]+a[0];
  
  rop(i,n-1){
    if((a[i]-a[i-1])>big){
      big=a[i]-a[i-1];
    }
  }
  cout<<k-big<<rt;

	please AC;
}

Measured memory_bytes: 1024