akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

typedef struct{int to; int cost;} edge;


#define FST first
#define SND second

const int MAX_N = 300;                  // 10^5
// const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 1000000000;              // 10^9
// const ll  MAX_N = 1000000000000000000;     // 10^18
// const int BASE  = 1000000000 + 7;          // 10^9 + 7
// const int INFI  = 1000000000 + 7;          // 10^9 + 7
const ll INFL  = 1000000000000000000 + 7; // 10^18 + 7

ll N, A[MAX_N][MAX_N];

std::vector<edge> G[MAX_N];
ll D[MAX_N];

ll dijkstra(int s, int t) {
  for (int i = 0; i < N; i++) D[i] = (i == s) ? 0: INFL;
  D[s] = 0;
  std::priority_queue<Pi, vector<Pi>, greater<Pi> > pque;
  pque.push(Pi(0, s));
  while(!pque.empty()) {
    Pi p = pque.top(); pque.pop();
    int v = p.second;
    if (D[v] < p.first) continue;
    for (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (D[e.to] > D[v] + e.cost) {
        D[e.to] = D[v] + e.cost;
        pque.push(Pi(D[e.to], e.to));
      }
    }
  }
  return D[t];
}

void solve() {
  std::priority_queue<pair<int, Pi>, vector<pair<int, Pi> >, greater<pair<int, Pi> > > pq;
  for (int i = 0; i < N; i++){
    for (int j = 0; j < i; j++) pq.push(make_pair(A[i][j], Pi(i, j)));
  }

  ll ans = 0;
  while(!pq.empty()) {
    auto p = pq.top(); pq.pop();
    ll c = p.FST, s = p.SND.FST, t = p.SND.SND;
    ll d = dijkstra(s, t);
    if (c < d) {
      edge e, f;
      e.to = t; e.cost = c;
      f.to = s; f.cost = c;
      G[s].push_back(e);
      G[t].push_back(f);
      ans += c;
    } else if (c > d) {
      ans = -1;
      break;
    }
  }

  cout << ans << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,e) for(int i = a;i < e;++i)
using LL = long long;

int main() {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	FOR(i, 0, 3) {
		if (s[i] == t[i])ans++;
	}
	cout << ans << endl;

}




Measured memory_bytes: 256
import java.util.Scanner;
public 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;
	int d = a * 2 + b * 2;
	System.out.println(c+" "+d);
    }
}

Measured memory_bytes: 17164
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 998244353 
#define int long long
#define ll long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000005
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define PI M_PI
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
int add(int a, int b) {a=(a%mod + b%mod)%mod;return a;}
int sub(int a, int b) {a =(a%mod - b%mod + mod)%mod ;return a;}
int mul(int a, int b) {return (a%mod * b%mod) % mod;}


void solve()
{   
   int n,k,s=0;
   cin>>n>>k;
   int A[n+5];
   for(int i=0;i<n;i++)cin >> A[i];
   sort(A,A+n);
   for(int i=0;i<k;i++)s+=A[i];
   cout << s;
}

signed main()
{ boost
  int test=0,t;
    //cin >> t ;
    t=1;
   while(test++ <t){
	  //cout<<"Case #"<<test<<": ";
	   solve();}
  
}

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

int main(void) {
  int N;
  int ans = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    ans += a - 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;


int main(){
    int n;
    scanf("%d",&n);
    int C[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            C[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        int u,k;
        scanf("%d %d",&u,&k);
        vector<int> v(k);
        for(auto&e:v){
            scanf("%d",&e);
        }
        for(int i=0;i<k;i++){
            C[u-1][v[i]-1]=1;
        }
    }

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

    return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <set>
#include <fstream>
#define N 205
#define inf 2000483640
using namespace std;
int h[30], d[10], c[10010], a[10];
char s[110][110];
int main()
{
    int n, m, i, j, now, t;
    scanf("%d%d", &n, &m);
    for(i = 0; i < n; ++i) scanf("%s", s[i]);
    for(i = 0; i < n; ++i)
    {
        for(j = 0; j < m; ++j)
            h[s[i][j] - 'a']++;
    }
    for(i = 0; i < 26; ++i)
        c[h[i]]++;
    for(i = 0; i <= (n - 1) / 2; ++i)
    {
        for(j = 0; j <= (m - 1) / 2; ++j)
        {
            t = 4;
            if(n - 1 - i == i)
                t /= 2;
            if(m - 1 - j == j)
                t /= 2;
            a[t]++;
        }
    }
    now = m * n;
    bool ok = 1;
    for(i = 4; i >= 1; --i)
    {
        while(a[i])
        {
            if(now < i || now <= 0)
            {
                ok = 0;
                goto c;
            }
            if(c[now])
            {
                c[now]--;
                a[i]--;
                c[now - i]++;
            }else
            {
                now--;
            }
        }
    }
    c:;
    if(ok)
        puts("Yes");
    else
        puts("No");
    return 0;
}
/*
1
10
*/


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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S)
{
    map<char, ll> mp;
    rep(i, S.size())
        mp[S[i]]++;

    if (mp.size() == 2)
        cout << YES << endl;
    else
        cout << NO << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

int main() {
    int A,B,M;
    cin >> A >> B >> M;
    vector<int>a(A);
    vector<int>b(B);
    int X = 100001;
    int Y = 100001;
    for(int i = 0; i < A; i++) {
        cin >> a[i];
        X = min(X,a[i]);
    }
    for(int i = 0; i < B; i++) {
        cin >> b[i];
        Y = min(Y,b[i]);
    }
    int ans = X+Y;
    for(int i = 0; i < M; i++) {
        int x,y,c;
        cin >> x >> y >> c;
        ans = min(ans,a[x-1]+b[y-1]-c);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
def main():
    N = int(input())
    A = list(map(int,input().split()))
    B = [A[i-1] - i for i in range(1,N+1)]
    B.sort()
    b = B[N // 2] if N%2 == 1 else round((B[N // 2 - 1] + B[N // 2]) / 2)
    print(sum([abs(bb -b) for bb in B]))
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 27412
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if ((a % 2 == 0) || (b % 2 == 0)) {
  	cout << "Even" << endl;
  }
  else {
  	cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true){
			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();
			if(op.equals("?")) break;
			if(op.equals("+")){
				System.out.println(a+b);
			}else if(op.equals("-")){
				System.out.println(a-b);
			}else if(op.equals("*")){
				System.out.println(a*b);
			}else if(op.equals("/")){
				System.out.println(a/b);
			}
		}
	}

}

Measured memory_bytes: 26272
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

x = ir()
if 400<=x<=599:
    print(8)
elif 600<=x<=799:
    print(7)
elif 800<=x<=999:
    print(6)
elif 1000<=x<=1199:
    print(5)
elif 1200<=x<=1399:
    print(4)
elif 1400<=x<=1599:
    print(3)
elif 1600<=x<=1799:
    print(2)
elif 1800<=x<=1999:
    print(1)

Measured memory_bytes: 72672
n,k=map(int,input().split())
a=list(map(int,input().split()))
d={}
cnt=[]
m=0
ans=0
for i in range(2*n):
  if a[m] in d:
    ans+=1
    cnt.append(a[m])
    if ans==k:
      print(a[m])
    break
  else:
    d[a[m]]=0
    cnt.append(a[m])
    ans+=1
    if ans==k:
      print(a[m])
      break
    m=a[m]-1
if ans!=k:
  if cnt[-1]==cnt[-2]:
    print(cnt[-1])
  else:
    cnt=cnt[cnt.index(cnt[-1]):-1]
    print(cnt[(k-ans)%len(cnt)])

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

int main(){
    int n;cin>>n;
    int count=0;
    for(int i=0;i<n;i++){
        int a;cin>>a;
        while(a%2==0){
            a=a/2;
            count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N,K; cin>>N>>K;
	int A[N];
	rep(i,0,N) cin>>A[i];
	int dp[K+1];
	rep(i,0,K+1) dp[i] = 1;
	rep(i,1,K+1){
		rep(j,0,N){
			if(i < A[j]) continue;
			if(dp[i - A[j]] == 1) dp[i] = 0;
		}
	}cout<<(dp[K] == 0 ? "First" : "Second")<<endl;
}

Measured memory_bytes: 768
#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include <queue>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
const ll MOD = 1000000007;

    ll N,C,K,temp,ans=0;
    vector<ll> T;
    bool fir=true,go=false;

int main() {
    scanf("%lld%lld%lld",&N,&C,&K);
    REP(i,N){
        scanf("%lld",&temp);
        T.push_back(temp);
    }
    sort(T.begin(),T.end());
        T.push_back(MOD);
    ll count=0;
    temp=T[0]+K;
    REP(i,N+1){
        count++;
        //cout<<"Ti"<<T[i]<<":"<<temp<<endl;
        if(count>C || T[i]>temp){
            //cout<<"OK"<<endl;
            temp=T[i]+K;
            ans++;
            count=1;
        }else  if(i==N){ans++;}
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1400
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[][] a = new long[n][2];
		for (int i = 0; i < n; ++i) {
			a[i][0] = sc.nextLong();
			a[i][1] = sc.nextLong();
		}
		Arrays.sort(a, new Comparator<long[]>() {
			@Override
			public int compare(long[] arg0, long[] arg1) {
				return -Long.compare(arg0[0] + arg0[1], arg1[0] + arg1[1]);
			}
		});
		long ans = Long.MAX_VALUE / 3;
		long[][][] g = new long[2][n / 2 + 10][n / 2 + 10];
		for (int i = 0; i < g.length; ++i)
			for (int j = 0; j < g[i].length; ++j)
				for (int k = 0; k < g[i][j].length; ++k)
					g[i][j][k] = Long.MAX_VALUE / 10;
		g[0][0][0] = 0;
		for (int i = 0; i < n; ++i) {
			for (int k = 0; k <= 1; ++k) {
				for (int j = Math.max(0, -n / 2 - k + i); j <= i - k && j <= n / 2; ++j) {
					g[k][i - j - k][j + 1] = Math.min(g[k][i - j - k][j + 1],
							g[k][i - j][j] + a[i][0] + j * (a[i][0] + a[i][1]));
					g[k][i - j - k + 1][j] = Math.min(g[k][i - j - k + 1][j],
							g[k][i - j - k][j] + a[i][1] + (i - j - k) * (a[i][0] + a[i][1]));
				}
			}
			if (n % 2 == 1) {
				for (int j = Math.max(0, -n / 2 + i); j <= Math.min(n / 2, i); ++j) {
					g[1][i - j][j] = Math.min(g[1][i - j][j],
							g[0][i - j][j] + (n - 1) / 2 * (a[i][0] + a[i][1]));
				}
			}
		}
		for (int i = 0; i < g.length; ++i)
			for (int j = 0; j < g[i].length; ++j)
				for (int k = 0; k < g[i][j].length; ++k) {
					if (i + j + k == n) {
						ans = Math.min(ans, g[i][j][k]);
					}
				}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}
}


Measured memory_bytes: 161140
#include<iostream>
#include<ctype.h>
using namespace std;
int main()
{
    char ch;
    cin>>ch;
    if(isupper(ch))
    {
        cout<<"A"<<endl;
    }
    else if(islower(ch))
    {
        cout<<"a"<<endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

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

int main() {
    ll n;
    ll mod = 1e9 + 7;
    ll res = 1;

    cin >> n;
    FOR(i, 1, n) {
        if (res > mod) {
            res = (i * (res % mod));
        } else {
            res = i * res;
        }
    }
    cout << res % mod << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using ll = long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
using namespace std;

ll n;
ll f(ll x, ll th, ll fi, ll se){
  if (x > n) return 0;
  ll ret = 0;
  if (th > 0 && fi > 0 && se > 0) ret++;
  ret += f(x*10+3, th+1, fi, se);
  ret += f(x*10+5, th, fi+1, se);
  ret += f(x*10+7, th, fi, se+1);
  return ret;
}

int main(){
  cin >> n;
  cout << f(0, 0, 0, 0) << endl;
  
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main(){
    char ch[]={'A','T','G','C'};
    string s; cin>>s;
    int ans=0,cnt=0;
    for(char c:s){
        bool flg=1;
        for(char cc:ch){
            if(c==cc){
                cnt++;
                flg=0;
            }
        }
        if(flg){
            cnt=0;
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
map <string, int> f;
int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		string s;
		cin >> s;
		f[s]++;
	}
	int mx = 0;
	for(const auto &x : f) 
		if(x.second > mx) mx = x.second;
	for(auto it = f.begin(); it != f.end(); ++it)
		if(it -> second == mx)
			cout << it->first << endl;
	return 0;
}

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

#define MAXN 10005
#define MAXH 105

int a[MAXN] , result[MAXH][MAXH] ; 

int main() {
	int h,w,n; cin>>h>>w>>n ; 
	for(int i=1;i<n+1;i++){
		cin>>a[i] ; 		
	}
	
	int current = 1 ; 
	for(int i=1 ; i<h+1 ; i++){
		if(i%2 == 1){
			for(int j=1;j<w+1;j++){
				result[i][j] = current ;  
				a[current]-- ; 
				if(a[current] == 0){
					current++ ; 
				}
			}
		}
		else{
			for(int j=w ; j>=1 ;j--){
				result[i][j] = current ; 
				a[current]-- ; 
				if(a[current] == 0){
					current++ ; 
				}
			}
		}
	}
	
	for(int i=1;i<h+1;i++){
		for(int j=1;j<w+1;j++){
			cout<<result[i][j]<<" " ; 
		}
		cout<<endl ; 
	}
	
	return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val m = sc.nextInt()
    val a = Array(m) { sc.nextInt() }
    val r = n - a.sum()
    println(if (r < 0) -1 else r)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 40824
import { readFileSync } from 'fs'

const getNeedsCount = (base: number, K: number) => {
  let count = 0
  let point = base
  while (true) {
    if (point >= K) return count
    point *= 2
    count += 1
  }
}

function main(input: string) {
  const [N, K] = input.split(' ').map(Number)

  const list = Array(N).fill(null).map((_, i) => i + 1)
    .map(point => getNeedsCount(point, K))
    .map((v) => 1 / (N * 2 ** v))

  const result = list.reduce((acc, v) => acc + v, 0)

  console.log(result)
}

main(readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 15008
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
using namespace std;

#define INF 1e18
#define int long long

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

    cout << c - min(a - b, c) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int 
#define pb push_back
#define vv vector<ll>
#define fr(i,x) for(int i=0;i<x;i++)
int dx[4] = {-1,0,0,1};
int dy[4] = {0,-1,1,0};

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    
    if(a.first == b.first) return a.second<b.second;
    return (a.first < b.first); 
}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
    

    ll n,x,m,r,cnt = 0,k,y;
    
    cin >> n >> m >> k;
    vector<ll>a,b;a.push_back(0);b.push_back(0);
    for (ll i = 1; i <= n; i++)
    {
        cin >> x;
        a.push_back(x+a[i-1]);
    }
    for (int i = 1; i <= m; i++)
    {
        cin >> x;
        b.push_back(x+b[i-1]);
    }ll res = 0;
    for (int i = 0; i <= n; i++)
    {
        ll t = 0;
        auto it = a.begin();
        if(a[i] <= k) {
           it = upper_bound(b.begin(),b.end(),k-a[i]);
           t += (i+(it-b.begin()-1));
           //t = max(t,(i+(it-b.begin()-1)));
       }
       res = max(t,res);
       
    }
    cout << res << endl;
    
    
    
    
    
    
    
}

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

int main() {
	string s, u;
	int k;
	cin >> s >> k;
	long d[3] = {};
	for (int j = 0; j < 3; j++) {
		auto t = u += s;
		for (int i = 1; i < t.length(); i++)
			if (t[i - 1] == t[i])
				t[i] = '!', d[j]++;
	}
	if (k < 2) cout << d[0] << endl;
	else cout << (k % 2 ? d[2] : d[1]) + (d[2] - d[0])*(k / 2 - 1) << endl;
	return 0;
}


Measured memory_bytes: 256
// template version 1.7

// varibable settings {{{
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define int long long
#define INF 1e18
// #define INF 2147483647
#define MOD 1e9+7
#define infile "../test/sample-1.in"
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
// }}}

int solve(){
  int a[5];
  int res=0;
  int m=INF;
  rep(i,5){
    cin>>a[i];
    res+=(a[i]/10)*10;

    if (a[i]%10>0){
      res += 10;
      chmin(m, a[i]%10);
    }
  }
  dump(m);
  if (m<INF) cout << res-(10-m)<< endl;
  else{
    cout << res << endl;
  }
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    string s, ans = "";
    int n;
    cin >> s >> n;
    for (int i = 0; i < s.length(); i += n)
    {
        ans += s[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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;
}
//union_find(親par,深さrnk)
const int MXV=100000;
int par[MXV],rnk[MXV],siz[MXV];
void union_init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        rnk[i]=0;
        siz[i]=1;
    }
}
//根を探す
int find(int x){
    if(par[x]==x){
        return x;
    }
    else{
        return par[x]=find(par[x]);
    }
}

void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y){
        return;
    }
    if(rnk[x]<rnk[y]){
        par[x]=y;
        siz[y]+=siz[x];
        siz[x]=0;
    }
    else{
        par[y]=x;
        siz[x]+=siz[y];
        siz[y]=0;
        if(rnk[x]==rnk[y]){
            rnk[x]++;
        }
    }
}
//集合が同じか
bool same(int x,int y){
    return find(x)==find(y);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N,M;
    cin >> N >> M;
    union_init(N);
    vl A(M),B(M);
    rep(i,M){
        cin >> A[i] >> B[i];A[i]--;B[i]--;
    }
    reverse(A.begin(),A.end());
    reverse(B.begin(),B.end());
    vl ans;
    ll now=N*(N-1)/2;
    rep(i,M){
        ans.pb(now);
        if(same(A[i],B[i])){
            continue;
        }
        else{
            ll sa=siz[find(A[i])],sb=siz[find(B[i])];
            now+=(sa*(sa-1)/2+sb*(sb-1)/2);
            unite(A[i],B[i]);
            ll sn=siz[find(A[i])];
            now-=sn*(sn-1)/2;
        }
    }
    reverse(ans.begin(),ans.end());
    rep(i,M){
        cout << ans[i] << endl;
    }
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/


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

void fnInput(vector<int> &rvnElm, vector<int> &rvnTrg)
{
  int nElmCnt, nTrgCnt;
  cin >> nElmCnt;

  rvnElm.resize(nElmCnt);
  for (int i = 0; i < nElmCnt; i++)
    cin >> rvnElm[i];

  cin >> nTrgCnt;

  rvnTrg.resize(nTrgCnt);
  for (int i = 0; i < nTrgCnt; i++)
    cin >> rvnTrg[i];
}

int fnRcsSch(int nPos, int nTrg, const vector<int> &cnrvnElm, vector<vector<int>> &rvvnDP)
{
  if (!nTrg)                    return 1;
  if (nTrg < 0)                 return 0;
  if (nPos == cnrvnElm.size())  return 0;
  if (rvvnDP[nPos][nTrg] != -1) return rvvnDP[nPos][nTrg];

  if (fnRcsSch(nPos + 1, nTrg, cnrvnElm, rvvnDP))
    return (rvvnDP[nPos][nTrg] = 1);
  else if (fnRcsSch(nPos + 1, nTrg - cnrvnElm[nPos], cnrvnElm, rvvnDP))
    return (rvvnDP[nPos][nTrg] = 1);
  else
    return (rvvnDP[nPos][nTrg] = 0);
}

void fnExhSch(const vector<int> &cnrvnElm, const vector<int> &cnrvnTrg)
{
  vector<vector<int>> vvnDP(21, vector<int>(2001, -1));
  
  for (int i = 0; i < cnrvnTrg.size(); i++)
  {
    int nTrg = cnrvnTrg[i];
    int nRtn;

    if (nRtn = fnRcsSch(0, nTrg, cnrvnElm, vvnDP))
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnElm, vnTrg;

  fnInput(vnElm, vnTrg);
  fnExhSch(vnElm, vnTrg);

  return 0;
}

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

struct Process
{
    char name[11];
    int time;
};

int main()
{
    int n = 0;
    int q = 0;
    cin >> n >> q;
    queue<Process> que;
    for (int i = 0; i != n; ++i){
        Process prc;
        cin >> prc.name >> prc.time;
        que.push(prc);
    }
    int t = 0;
    while (!que.empty()){
        auto prc = que.front();
        que.pop();
        if (prc.time <= q){
            t += prc.time;
            cout << prc.name << ' ' << t << endl;
        }else{
            t += q;
            prc.time -= q;
            que.push(prc);
        }
    }
    return 0;
}

Measured memory_bytes: 3684
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <queue>

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using usize = std::size_t;

auto main() -> i32 {
	char s[21];
	scanf("%s", s);
	printf("%.3s\n", s);
	return 0;
}


Measured memory_bytes: 1728
a,b,c,k = map(int,input().split())
cnt = 0

if a>= k:
    print(k)
    exit()
else:
    k = k-a
    cnt +=a
if k >=b:
    k = k-b
if c >=k:
    cnt -=k
else:
    cnt -=c
print(cnt)

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  for (int i = 0; i < 19; i++) {
    cout << ((i == 5 || i == 13) ? ' ' : s[i]);
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int Height, Width;
	
	while(1) {
	    scanf("%d%d", &Height, &Width);
	    
	    //どちらも0の場合、処理を終了する
	    if((Height == 0) && (Width == 0)) {
	        break;
	    }
	    //枠を描く処理
	    for(int i = 0; i < Height; i++) {
	        for(int j = 0; j < Width; j++) {
	            //端になる部分には、"#"を描く
	            if((i == 0) || (j == 0) || (i == Height - 1) || (j == Width - 1)) {
	                printf("#");
	            }
	            //内部には、"."を描く
	            else {
	                printf(".");
	            }
	        }
	        printf("\n");
	    }
	    printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	int n,a,b;
	cin >> n >> a >> b;
	const int cmax = min(a,b);
	const int cmin = max(a + b - n,0);
	cout << cmax << " " << cmin << endl;
	return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())

ppp = []
mpp = []
pmp = []
ppm = []
pmm = []
mpm = []
mmp = []
mmm = []

for i in range(N):
    x,y,z = map(int,input().split())
    ppp.append(x+y+z)
    mpp.append(-x+y+z)
    pmp.append(x-y+z)
    ppm.append(x+y-z)
    pmm.append(x-y-z)
    mpm.append(-x+y-z)
    mmp.append(-x-y+z)
    mmm.append(-x-y-z)

ans = []
ppp.sort(reverse=True)
ans.append(sum(ppp[:M]))
mpp.sort(reverse=True)
ans.append(sum(mpp[:M]))
pmp.sort(reverse=True)
ans.append(sum(pmp[:M]))
ppm.sort(reverse=True)
ans.append(sum(ppm[:M]))
pmm.sort(reverse=True)
ans.append(sum(pmm[:M]))
mpm.sort(reverse=True)
ans.append(sum(mpm[:M]))
mmp.sort(reverse=True)
ans.append(sum(mmp[:M]))
mmm.sort(reverse=True)
ans.append(sum(mmm[:M]))

print(max(ans))

Measured memory_bytes: 3440
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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

int N, W;
vector<ll> weight, value;

// i番目の品物までを使って合計の重さをjにするときの価値の最大値
ll dp[110][100100];

int main() {
	cin >> N >> W;
	rep(i, N) {
		int x, y;
		cin >> x >> y;
		weight.push_back(x); value.push_back(y);
	}
	rep(i, 110) {
		rep(j, 100100) {
			dp[i][j] = LINF;
		}
	}
	
	dp[0][0] = 0;
	for (int i = 0; i < N; ++i) {
		for (int sum_v = 0; sum_v <= 100100; ++sum_v) {

			// i 番目の品物を選ぶ場合
			if (sum_v - value[i] >= 0) {
				chmin(dp[i + 1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
			}

			// i 番目の品物を選ばない場合
			chmin(dp[i + 1][sum_v], dp[i][sum_v]);

		}
	}

	ll res = 0;
	for (int sum_v = 0; sum_v < 100100; ++sum_v) {
		if (dp[N][sum_v] <= W) res = sum_v;
	}
	cout << res << endl;

	return 0;
}


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

int main() {
  string s,t;
  cin >> s >> t;
  vector<char>datas(26,'A');
  vector<char>datat(26,'A');
  for(int i = 0;i < s.size();i++){
    if(datas[s[i]-'a'] == 'A') datas[s[i]-'a'] = t[i];
    else if(datas[s[i]-'a'] != t[i]){
      cout << "No" << endl;
      return 0;
    }
    if(datat[t[i]-'a'] == 'A') datat[t[i]-'a'] = s[i];
    else if(datat[t[i]-'a'] != s[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--)
#define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--)

#define each(it, c) \
    for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(obj) (obj).begin(), (obj).end()

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x) cerr << #x << " = " << (x) << endl;

#define endl "\n"

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;
}

typedef long long lint;

using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d, t, s;
    cin >> d >> t >> s;
    cout << (t * s >= d ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	long long  A, B;
	int K;
	scanf("%lld%lld%d", &A, &B, &K);
	for (long long i = A; i <= min(B, A + K - 1); i++) {
		printf("%lld\n", i);
	}
	for (long long i = max(B - K + 1, A + K); i <= B; i++) {
		printf("%lld\n", i);
	}
	return 0;
}

Measured memory_bytes: 128
program main
 implicit none
 integer*16 L,R,i,j,m,v,ans
 data m /2019D0/
 read(*,*) L,R
 if(R - L > m)then
  R = mod(R,m) + m
 else
  R = mod(R,m)
 end if
 L = mod(L,m)
 ans = 4000
 do i=L,R-1
  do j=i+1,R
   v = mod(i*j,m)
   if(ans >= v) then
    ans = v
   end if
   if(v == 0) then 
    exit
   end if
  end do
 end do
 write(*,*) ans
end program main

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
  cin >> n;
  bool ok = false;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      if(4*i + 7*j == n) ok = true;
    }
  }
  if(ok == false) cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 256
n = int(input())
x = 'abcdefghijklmnopqrstuvwxyz'
ans = ''
while True:
    ans = x[(n - 1) % 26] + ans
    n -= 1
    n //= 26
    if n == 0:
        break
    elif n < 26:
        ans = x[n - 1] + ans
        break
print(ans)


Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

int main(){
  int n;cin>>n;
  int ans = 0;
  for(int i=n;i<1000;i++){
    string t=to_string(i);
    if(t[0]==t[1]&&t[1]==t[2]){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<set>
using namespace std;
int H,W;
char ch[105][105];
bool tf;
set <int> S;
int main()
{
	scanf("%d %d",&H,&W);
	for(int i=1;i<=H;i++)
	{
		tf=true;
		for(int j=1;j<=W;j++)
		{
			scanf(" %c",&ch[i][j]);
			if(ch[i][j]=='#')
			tf=false;
		}
		if(tf)
		{
			H--;
			i--;
		}
	}
	for(int i=1;i<=W;i++)
	{
		tf=true;
		for(int j=1;j<=H;j++)
		if(ch[j][i]=='#')
		{
			tf=false;
			break;
		}
		if(tf)
		S.insert(i);
	}
	for(int i=1;i<=H;i++)
	{
		for(int j=1;j<=W;j++)
		{
			if(S.find(j)==S.end())
			printf("%c",ch[i][j]);
		}
		printf("\n");
	}
	return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(long long &a, long long b) { if (a > b) a = b; }

int main(){
  ll i , j;
  ll n;
  string a, b, c;
  cin >> n >> a >> b >> c;
  ll result = 0;
  ll buf;
  for(i = 0; i < n; i++){
    buf = (a[i] == b[i]) + (b[i] == c[i]) + (c[i] == a[i]);
    if(buf == 1)
      result++;
    else if(buf == 0)
      result += 2;
  }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <cassert>
#include <queue>
//#include "optimization.h"

using namespace std;

const int mod = 1000000007;

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    #else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // LOCAL
    string s;
    int n, a, m, b;
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; i++){
        cin >> a;
        mp[a]++;
    }
    cin >> m;
    for (int i = 0; i < m; i++){
        cin >> a;
        if (mp.count(a) == 0 || mp[a] == 0){
            cout << "NO";
            return 0;
        }
        mp[a]--;
    }
    cout << "YES";
    #ifdef LOCAL
    cout.flush();
    _Exit(0); //GLIBCXX_DEBUG not working without it
    #endif // local
    return 0;
}



Measured memory_bytes: 9600
import java.util.*;

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

    int n = N/15;
    int ans = n*(15*800-200)+(N-n*15)*800;   

    System.out.println(ans);
    }
}


Measured memory_bytes: 35636
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN 100
int num[MAXN+5];
int main() {
	int a,b;
	cin>>a>>b;
	if(a<=0&&b>=0){
		cout<<"Zero";
		return 0;
	}
	if(a>0&&b>0){
		cout<<"Positive";
		return 0;
	}
	int k=b-a+1;
	if(k%2==0) cout<<"Positive";
	else cout<<"Negative";
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    ll a, b;
    cin >> a >> b;
    if(b%a == 0){
        cout << -1 << endl;
        return 0;
    }
    for(ll add = 0; add <= a; add++){
        ll c = b + add;
        ll greed = c/b + c%b/a + c%b%a, susp = c/a + c%a;
        if(susp < greed){
            cout << b+add << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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

main(){
    long long int N, M, m = 1000000007, a[64], k = 1, l = 0, c = 0, i, o = 1;
    scanf("%lld", &N);
    M = ((++N)^(N/2));
    for(i = 64; i; ++c){
        if(M & (o << --i)){
            swap(k, l);
            l += k * c;
            l %= m;
            c = 0;
        }
        a[i] = (N & (o << i))?l:(-l);
    }
    i = 0;
    for(k = 0, l = 1; i < 64 - __builtin_clzll(M); ++i){
        k += a[i] * l;
        l *= 3;
        k %= m;
        l %= m;
    }
    cout << (k + m) % m << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(void)
{
    char s;
    cin >> s;
    char ans = s + 1;
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int x = scanner.nextInt(), max = 1;
			for (int i = 2; i <= (int) Math.sqrt(x); i++) {
				int pow = i * i;
				while (pow <= x) {
					max = Math.max(pow, max);
					pow *= i;
				}
			}
			System.out.println(max);
		}
	}
}


Measured memory_bytes: 35768
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int mod=1e9+7;

int fact(int N){
    int res=1;
    for(int i=1;i<=N;i++) res=res*i%mod;
    return res;
}

signed main()
{
    int N,M; cin>>N>>M;
    int ans;
    if(abs(N-M)<=1) ans=fact(N)*fact(M)%mod;
    if(N==M) ans=ans*2%mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int x,a,b;
  bool ok = false;
  cin >> x;
  for(a=0;a<=1000;a++){
    for(b=-1000;b<=1000;b++){
      if(a*a*a*a*a-b*b*b*b*b==x){
        ok = true;
        break;
      }
    }
    if(ok){
      break;
    }
  }
  cout << a << " " << b;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    ll K;
    Scd(N);
    Scll(K);
    vi a(N);
    Rep(i,N){
        Scd(a[i]);
        a[i]--;
    }

    vi di(N,-1);
    di[0] = 0;
    stack<int> s;
    s.push(0);

    int ans = 0;

    while( K ){
        int from = s.top();
        s.pop();
        int to = a[from];
        ans = to;
        s.push(to);
        if( di[to] < 0 || K < N ){
            K--;
        }else{
            K--;
            K %= ( di[from]+1 - di[to] );
        }
        di[to] = di[from]+1;
    }

    printf ("%d\n", ans+1 );

    return 0;
}



Measured memory_bytes: 4864
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, a, b) for(int i = a; i < b; i++)

long gcd(long a, long b) {
    if (a < b) {
        swap(a, b);
    }

    while (b != 0) {
        a = a % b;
        swap(a, b);
    }

    return a;
}

long lcm(long a, long b) {
    return a * b / gcd(a, b);
}

// x \in [a,b]において x % div == 0を満たすものの数
long calc_div_num(long a, long b, long div) {
    if (a > b) {
        swap(a, b);
    }

    return b / div - (a - 1) / div;
}

int main() {
    long a, b, c, d;
    cin >> a >> b >> c >> d;
    long cd_lcm = lcm(c, d);

    long div_num = calc_div_num(a, b, c) + calc_div_num(a, b, d) - calc_div_num(a, b, cd_lcm);

    cout << (b - a + 1 - div_num) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	int K, N;
	cin >> K >> N;
	int  *A = new int[N];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int maxSub = 0;
	for (int i = 1; i < N; i++) {
		if (A[i] - A[i - 1] > maxSub)
			maxSub = A[i] - A[i - 1];
	}
	if (K - A[N - 1] + A[0] > maxSub)
		maxSub = K - A[N - 1] + A[0];
	cout << K - maxSub << endl;
	
	return 0;
}

Measured memory_bytes: 1152
program main
	implicit none
	integer N, ans, i, amin, amax
	integer, allocatable :: a(:), b(:)
	read(*, *) N
	allocate(a(1:N))
	read(*, *) a(1:N)
	amax = maxval(a)
	amin = minval(a)
	allocate(b(amin-1:amax+1))
	b(amin-1:amax+1) = 0
	do i = 1, N
		b(a(i)) = b(a(i)) + 1
	end do
	ans = 0
	do i = amin, amax
		ans = max(ans,b(i-1)+b(i)+b(i+1))
	end do
	write(*, *) ans
end program main

Measured memory_bytes: 1536
abc = []
n = int(input())
for i in range(n):
  abc.append([int(s) for s in input().split()])

dp = [[0, 0, 0]for i in range(n)]
dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]
for i in range(1, n):
  dp[i][0] = max(dp[i-1][1]+abc[i][0], dp[i-1][2]+abc[i][0])
  dp[i][1] = max(dp[i-1][0]+abc[i][1], dp[i-1][2]+abc[i][1])
  dp[i][2] = max(dp[i-1][0]+abc[i][2], dp[i-1][1]+abc[i][2])
print(max(dp[n-1]))

Measured memory_bytes: 44108