akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
    _typer init = 0;
    char ch = getchar(), k = 0;
    for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
    for ( ; isdigit(ch); ch = getchar())
        init = (init << 3) + (init << 1) + (ch ^ 48);
    return k ? -init : init;
}
const ll N = 505, INF = 1e9;

/*******************************************************************************
 *
 *
 *
 ******************************************************************************/

int n, A[N], k, S, tmp[N];

bool Check(int x) {
    int cnt = 0, d;
    rep (i, 1, n) tmp[i] = x - A[i] % x, cnt += A[i] % x;
    d = cnt / x;
    sort(tmp + 1, tmp + n + 1);
    cnt = 0;
    rep (i, 1, d) cnt += tmp[i];
    return cnt <= k;
}

int main() {
    n = read<int>(), k = read<int>();
    rep (i, 1, n) A[i] = read<int>(), S += A[i];
    int Ans = 0;
    rep (i, 1, sqrt(S)) if (S % i == 0) {
        if (Check(i)) Ans = max((int) i, Ans);
        if (Check(S / i)) Ans = max(Ans, S / i);
    }
    cout << Ans << endl;
    return 0;
}



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

Measured memory_bytes: 3548
#include <stdio.h>

int main()
{
	int a, b;
	
	scanf("%d %d", &a, &b);
    if (a < b)
    {
    	printf("a < b\n");
    }
	else if (a > b)
	{
		printf("a > b\n");
	}
	else if (a == b)
	{
		printf("a == b\n");
	}
		
	return 0;
	
} 


Measured memory_bytes: 2620
#include<bits/stdc++.h>
using namespace std ;
typedef long long LL;
const int MAXN = 1 + 1e5;
typedef pair <int,int> II;

int n,a[MAXN],l[MAXN],r[MAXN];



int main(){
                            #define NAME "ABC"
                    //    freopen(NAME".inp","r",stdin);
                //        freopen(NAME".out","w",stdout);
                        ios_base::sync_with_stdio(0);
                        cin.tie();

                        cin >> n;
                        for (int i = 1; i <= n; i++)
                            cin >> a[i];
                        l[1] = a[1];
                        r[n] = a[n];
                        for (int i = 2; i <= n; i++)
                            l[i] = __gcd(l[i-1] , a[i]);
                        for (int i = n - 1; i >= 1; i--)
                            r[i] = __gcd(r[i+1] , a[i]);
                        int ans = max (l[n-1] , r[2]);
                        for (int i = 2; i < n; i++){
                            ans = max (ans , __gcd(l[i-1] , r[i+1]));
                        }
                        cout << ans;








return 0;
}


Measured memory_bytes: 1408
#define rep(i,n) for (int i = 0; i < n; i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


int main() {
	int n, m; cin >> n >> m;
	vector<int> a(n),b(n+1,0);
	rep(i, n) cin >> a[i];
	rep(i, n) b[i + 1] = (b[i] + a[i]) % m;
	sort(b.begin(), b.end());
	ll ans = 0,cnt=0;
	rep(i, n) {
		if (b[i] == b[i + 1]) {
			cnt++;
		}
		else {
			ans += cnt * (cnt + 1) / 2;
			cnt = 0;
		}
	}
	ans += cnt * (cnt + 1) / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
    int n, m;
    int i;
    int s;
    
    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }
        
        s = 0;
        for (i = 0; i < n / 4; i++){
            scanf("%d", &m);
            s += m;
        }
        printf("%d\n", s);
    }
    return (0);
}

Measured memory_bytes: 600
def main():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    cnt=0
    b=[1]
    res=[-1]*n
    res[0]=0
    flg=0
    now=1
    start=0
    t=1
    while flg==0:
        cnt+=1
        if res[a[now-1]-1]==-1:
            res[a[now-1]-1]=cnt
            b.append(a[now-1])
            now=a[now-1]
        else:
            start=res[a[now-1]-1]
            t=cnt-start
            if cnt<=k:
                flg=1
                k-=start
            else:
                flg=2
    if flg==1:
        print(b[start+(k%t)])
    else:
        print(b[k])
if __name__=="__main__":
    main()

Measured memory_bytes: 32380
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){
    
    int A,B,C,d;

    cin>>A>>B>>C;

    d=A-B;

    if(d>=C){
        cout << 0 <<endl;
    }else{
        cout << C-d<<endl;
    }
    

    return 0;
}

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

int main()
{
    vector<long long int> A;
    vector<long long int> B;
    vector<long long int> :: iterator it;
    long long int N, M, K, i, a, temp, len, ans=0;
    cin>>N>>M>>K;
    A.push_back(0);
    for(i=1;i<=N;i+=1)
    {
        cin>>a;
        A.push_back(A[i-1] + a);
    }
    B.push_back(0);
    for(i=1;i<=M;i+=1)
    {
        cin>>a;
        B.push_back(B[i-1] + a);
    }
    for(i=0;i<=N;i+=1)
    {
        if(A[i]>K)
        {
            break;
        }
        temp = K - A[i];
        it = lower_bound(B.begin(), B.end(), temp);
        if(it==B.end())
        {
            len = M;
        }
        len = it - B.begin();
        if(*(it)!=temp)
        {
            len-=1;
        }
        ans = max(ans, i+len);
    }
    cout<<ans<<endl;
}

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

int main(void) {
    int64_t N;
    string S,T;
    
    cin >> N >> S >> T;

    for(int i=0;i<N;i++) {
        cout << S[i] << T[i];
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 256
N = int(input())
G = [[] for k in range(N)]
for k in range(N-1):
    u, v, w = map(int,input().split())
    u-=1
    v-=1
    G[u].append([v,w])
    G[v].append([u,w])

D = [-1 for k in range(N)]
D[G[0][0][0]] = 0
Q = [G[0][0]]

while len(Q) > 0:
    now = Q.pop()
    ima = now[0]
    for tsugi in G[ima]:
        if D[tsugi[0]] == -1:
            D[tsugi[0]] = tsugi[1] + D[ima]
            Q.append(tsugi)

for d in D:
    if d%2 == 0:
        print(0)
    else:
        print(1)


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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a > b) {
        swap(a,b);
    }
    if(a <= c && c <= b) {
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 256
import Data.List

solve :: Int -> Int -> [Int] -> Int
solve _ count [] = count
solve 0 count (x:xs) = solve x count xs
solve status count (x:xs)
  | status == x = solve status count xs
  | status /= x = solve 0 (count+1) xs

check :: [Int] -> [Int]
check [x] = []
check (x:y:xs)
  | y-x > 0 = 1 : check	(y:xs)
  | y-x < 0 = -1 : check (y:xs)
  | otherwise = check (y:xs)

main = getContents >>= print . solve 0 1 . check . map read . tail . words

Measured memory_bytes: 2428
import sys
from bisect import bisect_right as bsr
from collections import Counter as cnt
from collections import defaultdict as dd
from collections import deque
from fractions import gcd
from itertools import permutations as perm
from math import ceil, factorial, floor
from operator import itemgetter as ig

sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    S = input(str)
    print({"SUN": 7, "MON": 6, "TUE": 5, "WED": 4, "THU": 3, "FRI": 2, "SAT": 1}[S])


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 5048
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

char solve(string s)
{
	for(int i=0;i<3;i++){
		if(s[i]!='s' && s[i]==s[i+3] && s[i+3]==s[i+6])
			return s[i];
		if(s[i*3]!='s' && s[i*3]==s[i*3+1] && s[i*3+1]==s[i*3+2])
			return s[i*3];
	}
	if(s[0]!='s' && s[0]==s[4] && s[4]==s[8])
		return s[0];
	if(s[2]!='s' && s[2]==s[4] && s[4]==s[6])
		return s[2];
	return 'd';
}

int main()
{
	for(string s;getline(cin,s);){
		cout<<solve(s)<<endl;
	}
	
	return 0;
}

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

const ll maxs = 2e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){
    
}

void solve(){
    ll n;
    cin >> n;
    vector<ll> A(3,0);
    cin >> A[0] >> A[1] >> A[2];
    string ans(n,'.');
    string s[n];
    for(ll i=0;i<n;i++){
        cin >> s[i];
    }
    for(ll i=0;i<n;i++){
        ll a = s[i][0] - 'A';
        ll b = s[i][1] - 'A';

        if(A[a] == 0 and A[b] == 0 ){
            cout << "No";
            return;
        }else if( A[a] > A[b] ){
            ans[i] = 'A' + b;
            A[a]--;A[b]++;
        }else if( A[b] > A[a] ){
            ans[i] = 'A' + a;
            A[a]++;A[b]--;
        }else{
            if(i==n-1 || s[i] == s[i+1]){
                ans[i] = 'A' + a;
                A[a]++;A[b]--;
            }else{
                ll c = s[i+1][0] - 'A';
                ll d = s[i+1][1] - 'A';
                
                if(a == c || a == d){
                    ans[i] = 'A' + a;
                    A[b]--;A[a]++;
                }else{
                    ans[i] = 'A'+ b;
                    A[a]--;A[b]++;
                }

            }
        }
    }

    cout << "Yes\n";
    for(ll i=0;i<n;i++)
        cout << ans[i] << endl;

}

int main(){
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

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

using namespace std;

const int MOD = 1e9 + 7;

int main()
{
  long long n, m;
	cin >> n >> m;
	cout << min(n, m / 2) + (n < m / 2 ? (m - 2 * n) / 4 : 0) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		String A = scan.next();
		String B = scan.next();
		String C = scan.next();
		int count = 0;
		for(int i=0;i<N;i++) {
			if (A.charAt(i)==B.charAt(i) && B.charAt(i)==C.charAt(i)) continue;
			else if (A.charAt(i)==B.charAt(i) || A.charAt(i)==C.charAt(i) || B.charAt(i)==C.charAt(i)) count++;
			else count +=2;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23252
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int N;
vector<ll> B;

ll convert(string a) {
	ll res = 0;
	bool seen = false;
	int cnt = 0;
	for (int i = 0; i < a.length(); ++i) {
		if (a[i] == '.') {
			seen = true;
		}
		else {
			res = res * 10 + ((ll)a[i] - (ll)'0');
			if (seen) ++cnt;
		}
	}
	while (cnt++ < 9)
		res *= 10;
	return res;
}

void input(void) {
	cin >> N;
	B.resize(N);
	for (auto& bi : B) {
		string ai; cin >> ai;
		bi = convert(ai);
	}
}

int points[51][51];
vector<int> t, f;

pair<int, int> prime_factor(ll b) {
	pair<int, int> res{ 0, 0 };
	int& t = res.first;
	int& f = res.second;
	while (b % 5 == 0) {
		++f;
		b /= 5;
	}
	while (b % 2 == 0) {
		++t;
		b /= 2;
	}
	return res;
}

void build(void) {
	t.resize(N); f.resize(N);
	for (int i = 0; i < N; ++i) {
		ll bi = B[i];
		pair<int, int> tf = prime_factor(bi);
		++points[tf.first][tf.second];
		t[i] = tf.first, f[i] = tf.second;
	}
	for (int i = 49; i >= 0; --i) {
		for (int j = 49; j >= 0; --j) {
			points[i][j] += points[i + 1][j] + points[i][j + 1]
				- points[i + 1][j + 1];
		}
	}
}

void show(void) {
	cout << "B : ";
	for (auto bi : B)
		cout << bi << " ";
	cout << endl;
	cout << "t : ";
	for (auto ti : t)
		cout << ti << " ";
	cout << endl;
	cout << "f : ";
	for (auto fi : f)
		cout << fi << " ";
	cout << endl;

}

ll solve(void) {
	ll res = 0;
	for (int i = 0; i < N; ++i) {
		int ti = t[i], fi = f[i];
		res += points[max(18 - ti, 0)][max(18 - fi, 0)];
		if (2 * ti >= 18 && 2 * fi >= 18)
			--res;
	}
	return res / 2;
}

int main(void) {
	input();
	build();
	// show();
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 6408
import java.io.*;
import java.util.*;

class Main {
    static Scanner scanner = new Scanner();

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int[] a = new int[n];
        int highest = 0;
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
            highest = Math.max(highest, Integer.toBinaryString(a[i]).length());
        }
        int[][] b = new int[n + 1][highest];
        int[][] c = new int[n + 1][highest];
        for (int i = 0; i < highest; i++) {
            b[0][i] = 0;
            for (int j = 0; j < n; j++) {
                if (((a[j] >> i) & 1) == 1) {
                    b[j + 1][i] = 0;
                } else {
                    b[j + 1][i] = b[j][i] + 1;
                }
            }
            c[n][i] = b[n][i];
            for (int j = n; j > 0; j--) {
                if (b[j][i] > b[j - 1][i]) {
                    if (j - b[j][i] == 0) {
                        c[j][i] = j;
                    } else {
                        c[j][i] = b[j][i] + b[j - b[j][i] - 1][i] + 1;
                    }
                } else {
                    c[j][i] = b[j - 1][i] + 1;
                }
            }
        }
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            ans += Arrays.stream(c[i]).min().getAsInt();
        }
        System.out.println(ans);
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 113368
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

int a[55];

signed main()
{
	IO_OP;
	
	int n, s = 0;
	cin >> n;
	for(int i=0;i<n;i++) cin >> a[i];
	for(int i=0;i<n;i++)
		for(int j=0;j<i;j++)
			s += a[i] * a[j];
	cout << s << endl;
	
}






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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int H, A;
  cin >> H >> A;
  cout << (H/A) + (H%A > 0 ? 1 : 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,ans=0;
    cin>>n;
    while(n>0)
    {
        ans=n%10;
        if(ans==7)
    {
        cout<<"Yes";
        return 0;
    }
    n=n/10;

    }
    cout<<"No";
}

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

int main()
{
	string s;
	cin >> s;
	int ans0 = 0, ans1 = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s.at(i) != ('0' + i % 2))
		{
			ans0++;
		}
		if (s.at(i) != ('0' + (i + 1) % 2))
		{
			ans1++;
		}
	}
	if (ans0 < ans1)
		cout << ans0 << endl;
	else
		cout << ans1 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ssd ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug_x(x) cout<< #x <<"---> : "<<x<<endl;
#define debug_ve(x) for(auto it: x) cout<<it<<" ";
#define rep(i,a,n) for (int i=a;i<n;i++)
#define _rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef double db;
//std::mt19937 mrand(random_device{}());
//int rnd(int x) { return mrand() % x ; }
const ll mod=1e7;
ll ksm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

/***********************/

int main(){
    ssd;
    int n ;cin>>n;
    int sum =0;
    sum += (n/500)*1000;
  //  debug_x(sum);
    n -= (n/500)*500;
 //   debug_x(n);
    sum += (n/5) *5;
    n -= n/5;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
def read_values():
    return map(int, input().split())


def read_list():
    return list(map(int, input().split()))


def main():
    N = int(input())
    A = read_list()

    S = [0] * (N + 1)
    for i, a in enumerate(A):
        S[i + 1] = S[i] + a
    
    D = {}
    for s in S:
        D[s] = D.setdefault(s, 0) + 1

    res = 0
    for v in D.values():
        res += v * (v - 1) // 2

    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 41352
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int A,B;
  cin >> A >> B;
  srep(i,1,4) {
    if(i!= A && i != B) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner


import scala.io.StdIn._

object Main extends App {

  val Array(n,m) = readLine().split(" ").map(_.toInt)


  def solve() = {
    f(n) + f(m)
  }

  def f(x: Int): Int = x * (x-1) / 2

  println(solve())

}



Measured memory_bytes: 54868
#include<bits/stdc++.h>
using namespace std;
int a[100005][4];
int dp[100005][4];
int n;

int func(int ind, int flag) {

	if (ind == n) return 0;

	if (dp[ind][flag] != -1) return dp[ind][flag];

	int maxi = 0;
	if (flag == 0) {
		maxi = max(maxi, a[ind][1] + func(ind + 1, 1));
		maxi = max(maxi, a[ind][2] + func(ind + 1, 2));
		maxi = max(maxi, a[ind][3] + func(ind + 1, 3));
	}
	else if (flag == 1) {
		maxi = max(maxi, a[ind][2] + func(ind + 1, 2));
		maxi = max(maxi, a[ind][3] + func(ind + 1, 3));
	}
	else if (flag == 2) {
		maxi = max(maxi, a[ind][1] + func(ind + 1, 1));
		maxi = max(maxi, a[ind][3] + func(ind + 1, 3));
	}
	else {
		maxi = max(maxi, a[ind][1] + func(ind + 1, 1));
		maxi = max(maxi, a[ind][2] + func(ind + 1, 2));
	}

	return dp[ind][flag] = maxi;
}

int main() {

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

	memset(dp, -1, sizeof dp);

	cout << func(0, 0);

	return 0;
}

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

using namespace std;

// find divisors efficiently
vector<int> findDivisors(int number) {
    vector<int> divisors;
    for (int i = 1; i <= sqrt(number); i++) {
        if (number % i == 0) {
            divisors.push_back(i);
            if (i != number / i) divisors.push_back(number / i);
        }
    }
    return divisors;
}

int main() {
    // 考え方メモ
    // cの約数を列挙した配列を作り、a~bの範囲でfor文を回し、iとcの約数を比較する
    // 2重ループ O(N^2) -> 10,000 * 10,000 -> 10^8

    int a, b, c;
    cin >> a >> b >> c;

    // cの約数の配列作成する
    vector<int> divisors = findDivisors(c);

    int sumOfDivisors = 0;
    for (int i = a; i <= b; i++) {
        for (int j = 0; j < divisors.size(); j++) {
            if (i == divisors.at(j)) {
                sumOfDivisors++;
            }
        }
    }

    cout << sumOfDivisors << endl;

    return 0;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
bool ck(long long n,long long b,long long s)
{
	long long sum=0;
	while(n)
	{
		sum+=n%b;
		n/=b;
	}
	if(sum==s)
	{
		return true;
	}
	else
	{
		return false;
	}
}
long long n,s;
int main()
{
	cin>>n>>s;
	if(s==n)
	{
		cout<<n+1<<endl;
		return 0;
	}
	else if(s>n)
	{
		cout<<-1<<endl;
		return 0;
	}
	for(long long i=2;i*i<=n;i++)
	{
		if(ck(n,i,s))
		{
			cout<<i<<endl;
			return 0;
		}
	}
	long long cha=n-s,ans=0;
	for(long long i=1;i*i<=n;i++)
	{
		if(cha%i==0)
		{
			long long b=(cha/i)+1;
			if(ck(n,b,s))
			{
				if(ans)
				{
					ans=min(ans,b);
				}
				else
				{
					ans=b;
				}
			}
		}
	}
	if(ans)
	{
		cout<<ans<<endl;
	}
	else
	{
		cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion

signed main() {
    string S; cin >> S;
    int MAX = MINF;
    rep(i, S.size()) {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
            int cnt = 1;
            for (int j = i; j < S.size()-1 ; j++) {
                if (S[j + 1] == 'A' || S[j + 1] == 'C' || S[j + 1] == 'G' || S[j + 1] == 'T') {
                    cnt++;
                }
                else {
                    break;
                }
            }
            MAX = max(MAX, cnt);
        }
    }
    if (MAX == MINF)MAX = 0;
    cout << MAX << endl;
    
}



Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<set>
using lint=long long;
using namespace std;

int main()
{
	lint N,K;
	pair<lint,lint> dt[100010]={};

	lint fdsum[100010]={};
	lint sdsum[100010]={};
	
	cin >> N >> K;
	for(lint i=0;i<N;i++)
		cin >> dt[i].second >> dt[i].first;

	sort(dt,dt+N,greater<pair<lint,lint>>());
	
	lint fdi=1;
	lint sdi=1;
	set<lint> s;
	for(lint i=0;i<N;i++)
	{
		auto itr=s.find(dt[i].second);
		if(itr==s.end())
		{
			s.insert(dt[i].second);
			fdsum[fdi]=dt[i].first;
			fdsum[fdi]+=fdsum[fdi-1];
			fdi++;
		}
		else
		{
			sdsum[sdi]=dt[i].first;
			sdsum[sdi]+=sdsum[sdi-1];
			sdi++;
		}
	}

	lint ans=0;
	for(lint i=1;i<=min(fdi-1,K);i++)
	{
		lint tmp=fdsum[i]+sdsum[K-i];
		tmp+=(i*i);
		ans=max(ans,tmp);
	}

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


Measured memory_bytes: 8064
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <tuple>
template <typename T> constexpr T my_abs(const T &x) { return x < 0 ? -x : x; }
using ll = long long;
constexpr int MOD = 998244353;
char str[4005];
int dp[4005][4005];
int main()
{
	// freopen("yahoo2019-F.in", "r", stdin);
	scanf("%s", str);
	int n = strlen(str), ans = 0;
	dp[0][0] = 1;
	for (int i = 0; i < n * 2; i++)
	{
		int sum = 0;
		for (int j = 0; j <= i && j < n; j++)
			sum += str[j] - '0';
		for (int j = 0; j <= i; j++)
		{
			if (!dp[i][j])
				continue;
			if (j < sum)
				(dp[i + 1][j + 1] += dp[i][j]) %= MOD;
			if (i - j < std::min(n, i + 1) * 2 - sum)
				(dp[i + 1][j] += dp[i][j]) %= MOD;
		}
	}
	for (int i = 0; i <= n * 2; i++)
		(ans += dp[n * 2][i]) %= MOD;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 60416
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
const int d = 365;
//const int d = 5;
int c[26];
int s[d][26];
int last[26] = {0};
bool llast[d][26] = {false};
vector<int> solution(d,-1);
int myscore = 0;

random_device seed_gen;
mt19937 mt(seed_gen());
uniform_int_distribution<int> con(0,26-1);
uniform_int_distribution<int> day(0,365-1);
uniform_real_distribution<double> pro(0.0,1.0);


int score(vector<int> t){
    vector<int> last(26,0);
    int ans = 0;
    rep(i,d){
        ans += s[i][t[i]];
        last[t[i]] = i+1;
        rep(j,26) ans -= c[j] * (i+1-last[j]);
        //cout << ans << endl;
    }
    return ans;
}

// p day contest changes q
void better(int p,int q,clock_t start,clock_t end){
    //cout << myscore << endl;
    int origin = solution[p];
    int newscore = myscore - s[p][origin] + s[p][q];
    int before_origin = 0,before_q = 0;
    int res = 0;
    for(int i=0;i<d;i++){
        if(llast[i][origin]) before_origin = i+1;
        if(llast[i][q]) before_q = i+1;
        res += (c[origin] * (i+1-before_origin) + c[q] * (i+1-before_q));
    }

    llast[p][q] = true;
    llast[p][origin] = false;
    before_origin = 0;
    before_q = 0;

    for(int i=0;i<d;i++){
        if(llast[i][origin]) before_origin = i+1;
        if(llast[i][q]) before_q = i+1;
        res -= (c[origin] * (i+1-before_origin) + c[q] * (i+1-before_q));
    }

    //cout << res << endl;

    double t = 1 - ((double)(end - start)/CLOCKS_PER_SEC)/1.87;
    //cout << t << endl;

   
    newscore += res;
    if(newscore - myscore > 0 || (exp((double)(newscore - myscore)/t) > pro(mt))){
        myscore = newscore;
        solution[p] = q;
    }else{
        llast[p][q] = false;
        llast[p][origin] = true;
    }
}


//day 1-index i_day 's contest is k
int nowscore(int i,int k){
    int res = s[i][k];
    int before = last[k];
    last[k] = i+1;
    rep(j,26) res -= c[j] * (i+1-last[j]);
    last[k] = before;
    return res;
}

int main(){
    clock_t start = clock();

    int tmp;
    cin >> tmp;
    rep(i,26) cin >> c[i];
    rep(i,d)rep(j,26) cin >> s[i][j];

    for(int i=0;i<d;i++){
        int id = -1;
        int mx = -INF;
        for(int j=0;j<26;j++){
            int res = nowscore(i,j);
            if(mx < res){
                id = j;
                mx = res;
            }
        }
        solution[i] = id;
        last[id] = i+1; 
        llast[i][id] = true;
        myscore += mx;
    }

    clock_t end = clock();

    while(((double)(end - start)/CLOCKS_PER_SEC) < 1.87){
        better(day(mt),con(mt),start,end);
        end = clock();
    }



    rep(i,d) cout << solution[i]+1 << endl;
    /*
    cout << myscore << endl;
    cout << (score(solution) + 1e6) << endl;
    cout << (myscore + 1e6) << endl;
    */
    


    return 0;
}


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

typedef long long ll;


int main(){
    ll N;
    cin >> N;
    vector<ll> ans;
    
    while(1){
        if(N%2==0){
            ans.push_back(0);
            N /= -2;
        }
        else {
            N--;
            ans.push_back(1);
            N /= -2;
        }
        if(N==0){
            break;
        }
    }
    
    for(ll i=ans.size()-1; i>=0; i--){
        cout << ans[i];
    }
    cout << endl;
}


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

int32_t main()
{
    int n;
    cin >> n;
    string s1="AC";
    string s2="TLE";
    string s3="WA";
    string s4="RE";

    int cnt1=0;
    int cnt2=0;
    int cnt3=0;
    int cnt4=0;
    for(int i=0; i<n; i++)
    {
        string s;
        cin >> s;
        if(s==s1)
        {
            cnt1++;


        }
        if(s==s2)
        {
            cnt2++;


        }
        if(s==s3)
        {
            cnt3++;


        }
        if(s==s4)
        {
            cnt4++;


        }


    }

    cout << s1 << " " << 'x' << " " << cnt1 << endl;
        cout << s3 << " " <<  'x' << " " << cnt3 << endl;
            cout << s2 << " " <<  'x' << " " <<  cnt2 << endl;
                cout << s4<< " " <<  'x' << " " <<  cnt4 << endl;}























Measured memory_bytes: 3624
N,M = gets.chomp.split.map(&:to_i)
H = gets.chomp.split.map(&:to_i)
A = []
B = []

(1..M).each do |i|
  A[i],B[i] = gets.chomp.split.map(&:to_i)
end

ans = [1] * N

(1..M).each do |j|
  if H[A[j]-1] > H[B[j]-1]
    ans[B[j]-1] = 0
  elsif H[A[j]-1] < H[B[j]-1]
    ans[A[j]-1] = 0
  else
    ans[A[j]-1] = 0
    ans[B[j]-1] = 0
  end
end

puts ans.count(1)

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define ld long double
#define mem(x,y) memset(x,y,sizeof x)

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
/*
 * Be careful of overflow
 * Array bounds
 * Assert a!=0 when performing x/a
 * Check base condition for recursion
 * Iterator -> O(1), Element -> O(log n) while using erase
 * 1LL<<x when x>32
 * Be sure of what you are going to code (exception dp)
 * Don't try fancy tricks during contest
 * You can always make a bad round to a good enough round
 */ 

void solve()
{
	int n,x,t;
	cin>>n>>x>>t;
	cout<< (n+x-1)/x*t<<'\n';
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3584
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll a, b;
  cin >> a >> b;
  dll x = (dll)(0.08), y = (dll)(0.10);
  for(ll i = 1; i <= 2000; i++) {
  	ll v1 = (ll)((dll)(i) * x), v2 = (ll)((dll)(i) * y); 
  	if(v1 == a and v2 == b) {
  		cout << i << endl;
  		return 0;
  	}
  }
  cout << -1 << endl;
  return 0;
} //good night.

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

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pi;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin >> n;
    if(n==2) {
        cout << 1;
        return 0;
    }
    ll cnt=1;
    for(ll i=2; i*i<=n; i++) {
        if(n%i==0) {
            ll b=n/i;
            while(b%i==0)
                b/=i;
            if(b%i==1)
                cnt++;
        }
    }
    n--;
    cnt++;
    for(ll i=2; i*i<=n; i++) {
        if(n%i==0) {
            if(i!=n/i)
                cnt+=2;
            else
                cnt++;
        }
    }
    cout << cnt;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define ff first
#define ss second
int main() {
	ios::sync_with_stdio(0);
	int N; 
	cin >> N;
	long long swim[N], bugs[N], homework[N];
	cin >> swim[0] >> bugs[0] >> homework[0]; 
	for (int i = 1; i < N; i++) {
		cin >> swim[i] >> bugs[i] >> homework[i]; 
		swim[i] += max(bugs[i - 1], homework[i - 1]);
		bugs[i] += max(swim[i - 1], homework[i - 1]);
		homework[i] += max(bugs[i - 1], swim[i - 1]);
	}
	long long answer = max(homework[N - 1], swim[N - 1]); 

	cout << max(answer, bugs[N - 1]) << endl; 
	
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d[10000],e,i,m;
int main() {cin>>a>>b>>c;for(;e<b;e++)cin>>d[e];sort(d,d+b);int m=d[b-1]-d[0]+min({abs(d[b-1]-c),abs(c-d[0]),abs(a-(d[b-1]-c)),abs(a-(c-d[0]))});for(;i<b-1;i++){m=min(m,a-(d[i+1]-d[i])+min({abs(d[i]-c),abs(d[i+1]-c),a-(abs(d[i] - c)),a-(abs(d[i + 1] - c))}));}cout << m*100<< endl;}

Measured memory_bytes: 3132
n,k=map(int,input().split())
a=[int(i) for i in input().split()]

def gcd(x,y):
    if x<y:
        x,y=y,x
    if x%y==0:
        return y
    while x%y!=0:
        x,y=y,x%y
    return y
    
d=a[0]
for i in range(1,n):
    d=gcd(a[i],d)

j=0 if k%d==0 and k<=max(a) else 1
ans=['POSSIBLE','IMPOSSIBLE']
print(ans[j])

Measured memory_bytes: 62832
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using llong = long long;

const int INF = 100100100;
const int MOD = 1e9 + 7;

long long gcd(long long a, long long b) {
    // O(log min(a,b))
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

    llong N;
    cin >> N;
    vector<llong> abs;
    bool parity = true;
    llong sum = 0;

    for (int i = 0; i < N; i++) {
        llong tmp;
        cin >> tmp;
        if (tmp >= 0) {
            abs.push_back(tmp);
            sum += tmp;
        } else {
            abs.push_back(-tmp);
            parity = !parity;
            sum += -tmp;
        }
    }

    if (parity) {
        cout << sum << endl;
    } else {
        auto iter = min_element(abs.begin(), abs.end());
        cout << sum - *iter * 2 << endl;
    }

    return 0;
}


Measured memory_bytes: 1400
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int count(int N)
{
        int cnt = 0;
        while (N)
        {
                cnt += N % 10;
                N /= 10;
        }
        return cnt;
}

int main()
{
        int N;
        cin >> N;
        int ans = 1000000000;
        for (int i = 1; i < N; i++)
        {
                int A = count(i);
                int B = count(N - i);
                ans = min(ans, A + B);
        }
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
  cerr << ' ' << head;
  debug_cerr(tail...);
}
void chmax(lint &a, lint b) { if (a < b) a = b; }
void chmin(lint &a, lint b) { if (a > b) a = b; }
struct IoSetup{
    IoSetup(){
      ios::sync_with_stdio(false);
      cin.tie(nullptr);
      cout << fixed << setprecision(20);
      cerr << fixed << setprecision(20);
    }
} iosetup;

int main() {
  lint x,y;
  cin >> x >> y;
  lint ans = 0;
  if (x <= 3) ans += -100000LL * (x - 4);
  if (y <= 3) ans += -100000LL * (y - 4);
  if (x == y && x == 1) ans += 400000LL;
  cout << ans << '\n';
}


Measured memory_bytes: 256
import heapq
import sys
input=sys.stdin.readline

def dijkstra(s,edge):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

n,m=map(int,input().split())
edge=[[] for _ in range(n)]
for i in range(n-1):
  edge[i+1].append([0,i])
for _ in range(m):
  u,v,w=map(int,input().split())
  edge[u-1].append([w,v-1])
  edge[v-1].append([w,u-1])
d=dijkstra(0,edge)
if d[n-1]==float('inf'):
  print(-1)
else:
  print(d[n-1])

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

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

    static class ABC148_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            String A = in.next();
            String B = in.next();
            String[] aA = A.split("");
            String[] aB = B.split("");
            for (int i = 0; i < N; i++) {
                out.print(aA[i]);
                out.print(aB[i]);
            }
            out.println();
        }

    }
}



Measured memory_bytes: 23632
n = int(input())
a = [int(input()) for i in range(n)]
b = a[:]
b.sort()

if b[n-1] == b[n-2]:
    for _ in range(n): 
        print(b[n-1])
else:
    for j in a:
        if j >= b[n-1]:
            print(b[n-2])
        else:
            print(b[n-1])

Measured memory_bytes: 14112
#include <iostream>
#include <cstdio>
using namespace std;
int n, m, mn=1e9, a[35][35], b, c[5][35];

int f(int p, int q, int r) {
	int i, re = 0;
	for (i = 1; i <= m; i++) re += c[0][i] * a[i][p] + c[1][i] * a[i][q] + c[2][i] * a[i][r];
	return re;
}

int main() {
	int i, j, k, t;
	scanf("%d%d", &n, &m);
	for(i=1; i<=m; i++) for(j=1; j<=m; j++) scanf("%d", &a[i][j]);
	for(i=1; i<=n; i++) for(j=1; j<=n; j++) {
		scanf("%d", &t);
		c[(i+j) % 3][t]++;
	}
	for(i=1; i<=m; i++)
		for(j=1; j<=m; j++)
			for(k=1; k<=m; k++)
				if (i != j && i != k && j != k)
					mn = min(mn, f(i, j, k));
	printf("%d", mn);
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

def main():
    N = int(input())
    S = tuple(map(int, input().split()))
    Q = int(input())
    T = tuple(map(int, input().split()))

    counter = Counter(S)
    cnt = 0
    for i in T:
        cnt += any([counter[i]])
    print(cnt)

main()



Measured memory_bytes: 16784
get_string(String) :-
  current_input(Input),
  read_string(Input, ' \n', '', _, String).
 
get_number(Number) :-
  get_string(String),
  number_string(Number, String).

solve(N,Ans) :- 
  nth1(N,[1,
  9,
  30,
  76,
  141,
  267,
  400,
  624,
  885,
  1249,
  1590,
  2208,
  2689,
  3411,
  4248,
  5248,
  6081,
  7485,
  8530,
  10248,
  11889,
  13687,
  15228,
  17988,
  20053,
  22569,
  25242,
  28588,
  31053,
  35463,
  38284,
  42540,
  46581,
  50893,
  55362,
  61824,
  65857,
  71247,
  76884,
  84388,
  89349,
  97881,
  103342,
  111528,
  120141,
  128047,
  134580,
  146316,
  154177,
  164817,
  174438,
  185836,
  194157,
  207927,
  218812,
  233268,
  245277,
  257857,
  268182,
  288216,
  299257,
  313635,
  330204,
  347836,
  362973,
  383709,
  397042,
  416448,
  434025,
  456967,
  471948,
  499740,
  515581,
  536073,
  559758,
  583960,
  604833,
  633651,
  652216,
  683712,
  709065,
  734233,
  754734,
  793188,
  818917,
  846603,
  874512,
  909496,
  933081,
  977145,
  1006126,
  1041504,
  1073385,
  1106467,
  1138536,
  1187112,
  1215145,
  1255101,
  1295142,
  1342852,
  1373253,
  1422195,
  1453816,
  1502376,
  1553361,
  1595437,
  1629570,
  1691292,
  1726717,
  1782111,
  1827492,
  1887772,
  1925853,
  1986837,
  2033674,
  2089776,
  2145333,
  2197483,
  2246640,
  2332104,
  2379085,
  2434833,
  2490534,
  2554600,
  2609625,
  2693919,
  2742052,
  2813988,
  2875245,
  2952085,
  3003306,
  3096024,
  3157249,
  3224511,
  3306240,
  3388576,
  3444609,
  3533637,
  3591322,
  3693924,
  3767085,
  3842623,
  3912324,
  4027884,
  4102093,
  4181949,
  4270422,
  4361548,
  4427853,
  4548003,
  4616104,
  4718640,
  4812789,
  4918561,
  5003286,
  5131848,
  5205481,
  5299011,
  5392008,
  5521384,
  5610705,
  5739009,
  5818390,
  5930196,
  6052893,
  6156139,
  6239472,
  6402720,
  6493681,
  6623853,
  6741078,
  6864016,
  6953457,
  7094451,
  7215016,
  7359936,
  7475145,
  7593865,
  7689630,
  7886244,
  7984165,
  8130747,
  8253888,
  8403448,
  8523897,
  8684853,
  8802826,
  8949612,
  9105537,
  9267595,
  9376656,
  9574704,
  9686065,
  9827097,
  9997134,
  10174780,
  10290813,
  10493367,
  10611772,
  10813692],Ans).

main :-
  get_number(N),
  solve(N,Ans),
  writeln(Ans).

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

int N,A[100001],lmin,lmax,temp,prof,profcount,T;

int main(void){
    cin>>N>>T;
    cin>>lmin;
    lmax=lmin;
    for(int i=1;i<N;i++){
        cin>>temp;
        if(temp<lmin){
            lmin=temp;
            lmax=temp;
        }
        if(temp>lmax){
            lmax=temp;
            if(prof==lmax-lmin)profcount++;
            else if(prof < lmax-lmin){
                profcount=1;
                prof=lmax-lmin;
            }
        }
        
    }
    cout<<profcount<<endl;
    return 0;
}


Measured memory_bytes: 256