akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
#define pi 3.141592653589
using namespace std;
ll k, t, ans = 0, inf = 1e9 + 7; ll a[114], cnt[114];
signed main() {
	cin >> k >> t;
	rep(i, t)cin >> a[i];
	sort(a, a + t);
	cnt[0] = 0;
	for (int i = 1; i < t; i++)cnt[i] = cnt[i - 1] + a[i - 1];
	rep(i, t)ans += a[i];
	rep(i, t)inf = min(inf, abs(cnt[i] - (ans - cnt[i])));
	cout << max((ll)0, inf - 1) << endl;
	getchar(); getchar(); return 0;
}

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

using namespace std;

vector<int> v;

int main(){
  int N, x, ans;
  ans = 0;
  cin >> N >> x;
  for (int i=0;i<N;i++) {
    int a;
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  for (auto it = v.begin();it != v.end();it++) {
    x -= *it;
    if (x < 0) {
      break;
    }
    ans++;
  }
  if (x > 0) {
    ans--;
  }
  cout << ans << endl;
  return(0);
}


Measured memory_bytes: 888
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#define DEBUG 0
#define dd if (DEBUG)

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, A) for (auto & a : A)
#define all(a) (a).begin (), (a).end ()
#define rall(a) (a).rbegin (), (a).rend ()
#define sz(a) (int) (a).size ()
#define szl(a) (int) (a).length ()
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit);

typedef long long ll;
typedef pair <int, int> pii;
#define f first
#define s second
#define mp(a, b) make_pair((a), (b))
typedef vector <int> vi;
typedef vector <vi> mi;
typedef vector <ll> vll;
typedef vector <vll> mll;
#define pb(a) push_back ((a))

const ll MOD = 1e+9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int INFi = 0x3f3f3f3f;
const ll MAXN = 1e+6+7;

int main ()
{
    FASTIO;
    int i, j, n;
    string s, abc = "abc";
    cin >> n >> s;
    trav (a, s)
        if (a <= 'Z')
            a += 'a' - 'A';
    dd cout << s << endl;
    for (i = j = n = 0; i < szl (s); i++)
    {
        if (s[i] == abc[j])
            ++j;
        else if (s[i] == 'a')
            j = 1;
        else
            j = 0;
        if (szl (abc) <= j)
        {
            j = 0;
            ++n;
        }
    }
    cout << n << '\n';


    return 0;
}



Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/submissions/me
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
typedef long long ll;

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 dp[3100][3100] = {};

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

    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < t.size(); j++) {
            if (s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j] + 1);
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }

    string res = "";

    int i = (int)s.size(), j = (int)t.size();
    while(i > 0 && j > 0) {
        if (dp[i][j] == dp[i-1][j]) {
            i--;
        }

        else if (dp[i][j] == dp[i][j-1]) {
            j--;
        }

        else {
            res = s[i-1] + res;
            i--, j--;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 37120
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main() {
    double n, s, m, sum = 0;
    while(1) {
        sum = 0;
        cin >> n;
        if(n == 0) break;
        double s[1000] = {};
        for(int i = 0; i < n; i++) {
            cin >> s[i];
        }
        for(int i = 0; i < n; i++) {
            sum += s[i];
        }
        m = sum/n;
        sum = 0;
        for(int i = 0; i < n; i++) {
            sum += (s[i] -m)*(s[i] -m);
        }
        printf("%.10lf\n", sqrt(sum/n));
    }
    return 0;
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

ll func(ll n) {
    if (n % 2 == 0) {
        return ((n / 2) % 2) ^ n;
    } else {
        return ((n + 1) / 2) % 2;
    }
}

void solve() {
    ll A, B;
    cin >> A >> B;
    
    ll ans = func(A-1) ^ func(B);
    cout << ans << endl;
}

signed main() {
    solve();
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.OutputStream;
import java.util.*;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class Main{
	//WRWWRWRR     wwwrrrrwwwwrrr
	public void solve(int testNumber, InputReader in, PrintWriter out) {
		int n = in.nextInt();
		int k = in.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++){
			arr[i] = in.nextInt();
		}
		Arrays.sort(arr);
		long l = 1;
		long r = arr[n-1];
		long res = -1;
		while(l<=r){
			long mid = (r+l)/2;
			long tot =0;
			boolean can = true;
			for(int i=0;i<n;i++){
				if(arr[i]>mid){
					tot += arr[i]/mid;
				}
				if(tot>k){
					can = false;
					break;
				}
			}
			if(can){
				res = mid;
				r = mid-1;
			}else{
				l = mid+1;
			}
		}
		out.println(res);
	}
//	public static void main(String[] args){
//		Scanner scanner = new Scanner(new InputStreamReader(System.in));
//		int n  = Integer.parseInt(scanner.nextLine());
//		String s = scanner.nextLine();
//		LinkedList<Integer> q = new LinkedList<>();
//		for(int i=0;i<n;i++){
//			if(s.charAt(i)=='W'){
//				q.add(i);
//			}
//		}
//		int res = 0;
//		for(int i=n-1;i>=0;i--){
//			if(q.size()==0) break;
//			if(s.charAt(i)=='R'){
//				int v = q.poll();
//				if(v>i) break;
//				res++;
//			}
//		}
//		System.out.println(res);
//
//	}
	public static void main(String[] args){
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Main solver = new Main();
//        int num = in.nextInt();
//        while(num-->0){
//            solver.solve(1, in, out);
//        }
        solver.solve(1, in, out);
        out.close();
    }
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

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

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

	}
}


Measured memory_bytes: 57968
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define pow10(n) stoll("1"+string(n,'0'))
//fill(all(arr),1)
//if(map.count(key)){}
//bitset<20>(n);
//int mini=min({a,b,c,d,e});
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;
ld angle(double h,double m)
{
	if(h==12)h=0;
	if(m==60)m=0;
	long double hour=0.5*(h*60+m);
	long double min=6*m;
	long double	 ans=abs(hour-min);
	//ans = min(360 - ans, ans); 
	if((360-ans)<ans)ans=360-ans; 
	return ans;

}
const ld pi = 2 * acos(0);

int32_t main(){
	FIO
	int a,b,h,m;
	cin>>a>>b>>h>>m;
	long double deg=angle(h,m);
	//deg=min(deg,360-deg);
	//cout<<deg;
	deg*=pi/180.0;
	ld ans=a*a+b*b-2*a*b*cos(deg);
	ans=sqrt(ans);
	//	cout<<ans<<endl;

	cout<<fixed<<setprecision(20)<<ans;

	
	
	return 0;
}

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

using namespace std;
typedef long long LL;

int main()
{
	vector<LL> v(4);
	for (int i = 0; i < 4; i++) {
		cin >> v[i];
	}
	LL N;
	cin >> N;

	LL M = (N/2)*2;

	LL cost = 1LL<<60;
	vector<double> d = {4,2,1,0.5};
	for (int i = 0; i < 4; i++) {
		LL c = LL(M*d[i])*v[i];
		cost = min(cost, c);
	}
	N -= M;
	if (N > 0) {
		LL cost2 = 1LL<<60;
		for (int i = 0; i < 3; i++) {
			LL c = 1*d[i]*v[i];
			cost2 = min(cost2, c);
		}
		cost += cost2;
	}
	cout << cost << endl;
	exit(0);
}



Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def inv(x):
    return pow(x, mod - 2, mod)

cms = 10**4
cm = [0] * cms

def comb_init():
    cm[0] = 1
    for i in range(1, cms):
        cm[i] = cm[i-1] * i % mod

def comb(a, b):
    if b < 0 or a < b or a < 0:
        return 0
    return (cm[a] * inv(cm[a-b]) % mod) * inv(cm[b]) % mod

def main():
    n,k = LI()
    l = n - k

    comb_init()
    rr = []
    for i in range(1,k+1):
        t = comb(k-1, i-1)

        u = comb(l+1, i)
        rr.append(t * u % mod)

    return JA(rr, '\n')


print(main())



Measured memory_bytes: 5656
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int now=1;
    int ans=0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(now==a){
            now++;
        }else{
            ans++;
        }
    }
    if(now==1)ans=-1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pii;
///-------------------------

/// problem's variable---------------



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


int main()
{
    Phuong_;
    string s;
    cin >> s;
    int a=0;
    int b=0;
    for(int i=0;i<3; ++i)
    {
        if (s[i]=='A') a++; else b++;
    }
    if (a==2 || b==2) cout << "Yes"; else cout << "No";
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> X(N);
    for (auto& x : X) {
        cin >> x;
    }
    int ans = 1 << 30;
    rep(p, 1, 101) {
        int now_ans = 0;
        for (auto& x : X) {
            now_ans += (x - p) * (x - p);
        }
        chmin(ans, now_ans);
    }
    cout << ans << endl;
    return 0;
}

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

const int N = 100000+9;

int n,x[N];
LL a,b,vout;

inline int read() {
	char c=getchar(); int f=1,ret=0;
	while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
	while (c<='9'&&c>='0') {ret=ret*10+c-'0';c=getchar();}
	return ret * f;
}

int main() {
	n = read(); a = read(); b = read();
	for (int i=1;i<=n;i++) 
		x[i] = read();
	for (int i=1;i<n;i++) {
		LL c = (x[i+1] - x[i]) * a;
		vout += min(c, b);
	}
	printf("%lld\n",vout);
	return 0;
}


Measured memory_bytes: 640
N, M = map(int, input().split())
AB = [ [ int(i) for i in input().split()]  for _ in range(N)]
CD = [ [ int(i) for i in input().split()]  for _ in range(M)]

for n in range(N):
    closest = 1
    dist = abs(CD[0][0] - AB[n][0]) + abs(CD[0][1] - AB[n][1])
    for m in range(1, M):
        tmp_dist = abs(CD[m][0] - AB[n][0]) + abs(CD[m][1] - AB[n][1])
        if tmp_dist < dist:
            dist = tmp_dist
            closest = m+1
    print(closest)

Measured memory_bytes: 3064
import java.util.*;

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

		if (D==25) {System.out.println("Christmas");}
		if (D==24) {System.out.println("Christmas Eve");}
		if (D==23) {System.out.println("Christmas Eve Eve");}
		if (D==22) {System.out.println("Christmas Eve Eve Eve");}
	}
}

Measured memory_bytes: 22868
#include <stdio.h>

int main(void){

  long n,k,r,s,p;
  scanf("%ld %ld %ld %ld %ld", &n, &k, &r, &s, &p);
  char t[n+1];
  scanf("%s", t);
  int win[n];
  for (long i = 0; i < n; i++) {
    win[i] = 1;
  }
  for (long i = k; i < n; i++) {
    if (win[i-k] == 1 && t[i-k] == t[i]) {
      win[i] = 0;
    }
  }
  long score = 0;
  for (long i = 0; i < n; i++) {
    if (win[i] == 1) {
      if (t[i] == 'r') {
        score += p;
      }
      if (t[i] == 's') {
        score += r;
      }
      if (t[i] == 'p') {
        score += s;
      }
    }
  }
  printf("%ld\n", score);

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll , ll> lli;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
typedef vector<lli> vlli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<=(b);i++)
#define f22(a,b) for(int j=(a);j<=(b);j++)
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld", &a , &b)
#define pf(a) printf("%lld\n",a)
#define pff(a,b) printf("%lld %lld\n", a , b)
#define PI 3.14159265359
#define bug printf("**!\n")
#define mem(a , b) memset(a, b ,sizeof(a))
#define front_zero(n) __builtin_clzll(n)
#define back_zero(n) __builtin_ctzll(n)
#define total_one(n) __builtin_popcountll(n)

const ll mod = (ll)998244353;
const ll maxn = (ll)1e5+5;
const int nnn = 1048590;
const int inf = numeric_limits<int>::max()-1;
//const ll INF = numeric_limits<ll>::max()-1;
const ll INF = 1e18;

ll dx[]={0,1,0,-1};
ll dy[]={1,0,-1,0};
ll dxx[]={0,1,0,-1,1,1,-1,-1};
ll dyy[]={1,0,-1,0,1,-1,1,-1};

ll n , m , k,cnt,ok;
ll num[maxn] , cal[maxn];
vector < ll > v[maxn] , bad[maxn];

void dfs(ll s){
	if(num[s]!=-1) return;
	ok++;
	num[s] = cnt;
	for(auto u : v[s]){
		dfs(u);
	}
	return;
}

void solve(){
 	
 	mem(num,-1);
 	mem(cal,0);
 	
 	cin >> n >> m >> k;
 	ll x,y;
 	f0(m) cin >> x >> y , v[x].pb(y) , v[y].pb(x);
 	f0(k) cin >> x >> y , bad[x].pb(y) , bad[y].pb(x);
 	cnt = 1;
 	f1(n){
	   if(num[i] != -1) continue;
	   ok = 0;
	   dfs(i);
	   cal[cnt] = ok;
	   cnt++;
	}
	f1(n){
	   ll id = num[i];
	   ll kk = cal[id] - v[i].size();
	   for(auto u : bad[i]){
	   	if(num[u] == id) kk--;
	   }	
	   cout << kk-1 << ' ';
	}
	return;
}


int main() {
   
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll T;
    T=1;
    //cin >> T;
    //scanf("%lld",&T);
    ll CT = 0;
    //work();
    while(T--){
    	//cout << "Case " << ++CT <<": " ;
    	//printf("Case %lld: ",++CT);
		solve();
	}
    
    return 0;
}


Measured memory_bytes: 14720
#include<bits/stdc++.h>
typedef  long long int ll;
typedef long double ld;
#define pb  push_back
#define vll vector<ll>
#define mll map<ll,ll>
const double PI = 2*acos(0.0);
#define gcd(a,b)   __gcd((a),(b))
#define lcm(a,b)   ((a)/(__gcd((a),(b)))*(b))
#define INF         LLONG_MAX
#define ln  INT_MAX
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;
int main() {
ll n;
cin>>n;
ll a[n],s=0,p;
for(int i=0; i<n; i++){cin>>a[i];}
for(int i=1; i<n; i++){
    if(a[i-1]>a[i]){
            p=a[i-1]-a[i]; s=s+p;
        a[i]=a[i-1];

    }
}
cout<<s;

return 0;
}


Measured memory_bytes: 5164
def readinput():
    n,k=list(map(int,input().split()))
    abList=[]
    for _ in range(n):
        a,b=list(map(int,input().split()))
        abList.append((a,b))
    return n,k,abList

def main(n,k,abList):
    hist=[0]*(10**5+1)
    for a,b in abList:
        hist[a]+=b
    sum=0
    for i in range(1,10**5+1):
        sum+=hist[i]
        if sum>=k:
            return i
    else:
        return 0

if __name__=='__main__':
    n,k,abList=readinput()
    ans=main(n,k,abList)
    print(ans)


Measured memory_bytes: 25204
'use strict';
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim().split(' ');
  var a = Number(inputs[0]);
  var b = Number(inputs[1]);
console.log(a*b,(a+b)*2);
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15404
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i=0;i<n;i++)
    cin >> d.at(i);
  
  sort(d.begin(),d.end(),greater<int>());
  int cnt = 1;
  for(int i=0;i<n-1;i++){
    if(d.at(i) != d.at(i+1))
      cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    A, P = map(int, readline().split())

    print((A * 3 + P) // 2)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <deque>
#include <climits>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<long long int>
#define vc vector<char>
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(i = (a); i < (n); i++)
#define fi(i,a,n) for(i = (a); i <= (n); i++)
#define F first
#define S second
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;

    int x = n/100;
    int y = n%100;

    //cout<<x<<" "<<y<<endl;


    if(x>12 && y>12){
        cout<<"NA"<<endl;
    }
    else if(x==0 && y==0){
        cout<<"NA"<<endl;
    }
    else if(x>12 && y==0){
        cout<<"NA"<<endl;
    }
    else if(y>12 && x==0){
        cout<<"NA"<<endl;
    }
    else if(x!=0 && x<=12 && (y>12 || y==0)){
        cout<<"MMYY"<<endl;
    }
    else if((x>12 || x==0) && y!=0 && y<=12){
        cout<<"YYMM"<<endl;
    }
    else if(x<=12 && x && y<=12 && y){
        cout<<"AMBIGUOUS"<<endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int k,m,n,x,y,z;
bool b=false;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>s;
for(int i=0;i<s.size();i++){
        if(s[i]=='C'){
                k++;m=i;
 
}}
y=s.size();
if(k==1 && s[0]=='A'&& m>=2 && m<=y-2){
    for(int i=1;i<y;i++){
        if(islower(s[i])){
            x++;
    }}
    y-=2;
    if(x==y)cout<<"AC";
    else cout<<"WA";
 
}
else cout<<"WA";
return 0;
}

Measured memory_bytes: 3656
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var NK = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var (N, K) = (NK[0], NK[1]);
            var dict = new Dictionary<long, long>();
            for (var i = 0; i < N; i++)
            {
                var ab = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
                var (a, b) = (ab[0], ab[1]);
                if (dict.ContainsKey(a)) dict[a] += b;
                else dict[a] = b;
            }
            var count = 0L;
            foreach (var val in dict.Keys.OrderBy(x => x).ToArray())
            {
                count += dict[val];
                if (count >= K)
                {
                    Console.WriteLine(val);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 50260
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;
bool flag;
string a1;
int a[71720],n,i,sumend,dp[811][811],m,la,j,k,x,y,z,b,c;
long long int sum;
bool cmp(int a,int b)
{
    return a>b;
}
int gcd(int a,int b)
{
    if(!b)
        return a;
    return gcd(b,a%b);
}
int maxx(short int a,short int b)
{
    if(a>b)
        return a;
    return b;
}
int gqt(int n)
{
    if(!n||n)
        return 1;
    if(n==2)
        return 0;
    for(i=3;i<=sqrt(n);i++)
        if(n%i==0)
            return 1;
    return 0;
}
int main()
{
    cin>>a1;
    la=a1.size();
    cout<<a1[0]<<la-2<<a1[la-1];
    /*while(y!=0)//数字反转模板
    {;
        sum=y%10;
        sumend*=10;
        sumend+=sum;
        y/=10;
    }
    sumend+=x;
    cout<<sumend<<endl;
    return 0;*/
   
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<vector<int>> a(2, vector<int>(n));
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < n; j++) cin >> a[i][j];
    }
    int ans = 0;
    vector<int> memo(n);
    memo[0] = a[0][0];
    for(int i = 1; i < n; i++){
        memo[i] = memo[i-1]+a[0][i];
    }
    for(int i = 0; i < n; i++){
        int coans = memo[i];
        for(int j = i; j < n; j++) coans += a[1][j];
        if(ans < coans) ans = coans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
struct Edge {
    int to,next,val;
    bool operator < (const Edge& rhs)const{
        return val>rhs.val;
    }
} edge[N*2];
int tot, head[N];
void addEdge(int from,int to,int val) {
    edge[tot].next=head[from];
    edge[tot].to=to;
    edge[tot].val=val;
    head[from]=tot++;
}
bool vis[N];
int dis[N];
void SPFA(int s,int e) {
    priority_queue<Edge> Q;
    memset(dis,INF,sizeof(dis));
    memset(vis,false,sizeof(vis));
    dis[s]=0;

    Q.push(Edge{s, 0, 0});
    while (!Q.empty()) {
        Edge temp=Q.top();
        Q.pop();
        if(vis[temp.to])
            continue;
        vis[temp.to]=true;

//        for (int i = head[u.to]; ~i; i = edge[i].next) {
//            int to = edge[i].to;
//            if (dis[to] > dis[u.to] + edge[i].val) {
//                dis[to] = dis[u.to] + edge[i].val;
//                Q.push(Edge{to, 0, dis[to]});
//            }
//        }

        for(int i=head[temp.to]; i!=-1; i=edge[i].next) {
            if(dis[edge[i].to]>dis[temp.to]+edge[i].val) {
                dis[edge[i].to]=dis[temp.to]+edge[i].val;
                Q.push(Edge{edge[i].to,0,dis[edge[i].to]});
            }
        }

    }
    printf("%d\n", dis[e]==INF?-1:dis[e]/2);
}

map<int,int> mp[N];
int allPoint;
int getPoint(int x,int y) {
    if (!mp[x][y])
        mp[x][y]=++allPoint;
    return mp[x][y];
}
int main() {
    int n,m;
    scanf("%d%d",&n,&m);
    memset(head,-1,sizeof(head));
    allPoint=n;
    for (int i=1; i<=m; i++) {
        int x,y,w;
        scanf("%d%d%d",&x,&y,&w);

        int newX=getPoint(x,w);
        int newY=getPoint(y,w);
        addEdge(x,newX,1);
        addEdge(newX,x,1);
        addEdge(newX,newY,0);
        addEdge(newY,newX,0);
        addEdge(y,newY,1);
        addEdge(newY,y,1);
    }
    SPFA(1,n);

    return 0;
}


Measured memory_bytes: 93812
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    char X, Y;
    cin >> X >> Y;
    if (X > Y) cout << ">" << endl;
    if (X == Y) cout << "=" << endl;
    if (X < Y) cout << "<" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<stack> 
#include<queue>
#include<cmath>
#include<map>
#include<bitset>
#define LL long long
#define N 100100
#define M 1010
#define MOD 1000000007
#define FOR(i,l,r) for (int i = (l); i <= (r); i ++)
#define CLR(a,x) memset(a,x,sizeof(a))
#define INF 0x3f3f3f3f
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define X first
#define Y second
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int d1 = n / 100,d2 = n % 10;
	if (d1 == d2) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        int N, p[50], i, k;

        scanf("%d", &N);
        for(i=0;i<N;i++) {
                scanf("%d", &p[i]);
        }

        for(i=0;i<N;i++) {
                if(p[i] != i+1) k++;
        }

        if(k<3) printf("YES\n");
        else printf("NO\n");

        return 0;
}


Measured memory_bytes: 128
def main():
    import sys
    import numpy as np
    input = sys.stdin.readline
    n,m = map(int,input().split())
    A = list(list(input().rstrip()) for i in range(n))
    B = list(list(input().rstrip()) for i in range(m))
    A = np.array(A)
    B = np.array(B)
    
    for i in range(n-m+1):
        for j in range(n-m+1):
            a_b = A[i:i+m,j:j+m]
            if (a_b==B).all():
                print('Yes');exit()
    print('No')
    
if __name__=='__main__':
    main()

Measured memory_bytes: 27136
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

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

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int MAX = 110000;
	
	int N;
	int ans = 0, sum = 0;
	vector<int> A, con(MAX);
	
	cin>>N;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		
		con[A[i]]++;
	}
	
	for(int i = 0; i < con.size(); i++){
		if(con[i])sum += con[i]-1;
	}
	
	// cout<<sum<<endl;
	
	if(sum % 2 == 0) {
		ans = N - sum;
	} else {
		ans = N - sum - 1;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
//#ifndef ONLINE_JUDGE
//#  define LOG(x) (cerr << #x << " = " << (x) << endl)
//#else
//#  define LOG(x) 0
//#endif
#define pb push_back
#define mod 1000000007
#define endl '\n'
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

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

const integer NN = 200005;
int ar[NN];
int n, m, k;
vector<int> adj[NN];


integer main() {
    ios_base::sync_with_stdio(false);

    int t = 1;
//    cin >> t;
    while (t--) {
        double r;
        cin >> r;
        cout << fixed << setprecision(4) << 2 * 2 * acos(0.0) * r << endl;

    }

}



Measured memory_bytes: 8484
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;
ll a,b,c,ans;
ll A[100005];
bool flag = false;

int main(void) {
	cin >> a;
	A[0] = a;
	ans++;
	while (1) {
		ans++;
		if (a % 2 == 0) {
			a /= 2;
		}
		else {
			a = 3 * a + 1;
		}
		FOR(i, 0, ans) {
			if (A[i] == a) { flag = true; break; }
		}
		if (flag)break;
		A[ans] = a;
	}
	ct(ans);
	return 0;
}


Measured memory_bytes: 256
N = int(input())
P = [int(i) for i in input().split()]

ans = 0
flag = 0
for i in range(N):
    if i+1 == P[i]:
        ans += 1
        if flag:
            ans -= 1
            flag = 0
        else:
            flag = 1

    else:
        flag = 0
print(ans)


Measured memory_bytes: 52908
#include <stdio.h>

int main(void){
  long int a,b,c,d,max;
  scanf("%ld",&a);
  scanf("%ld",&b);
  scanf("%ld",&c);
  scanf("%ld",&d);
  max = a*c;
  max = max > a*d ? max: a*d;
  max = max > b * c ? max : b*c;
  max = max > b * d ? max : b * d;
  printf("%ld",max);
  return 0;
}

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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    string s;
    cin >> s;
    bool f = true;
    for (int i = 0; i < s.size(); ++i) {
        if (i % 2 == 0 && s[i] == 'L') {
            f = false;
        }
        if (i % 2 == 1 && s[i] == 'R') {
            f = false;
        }
    }
    cout << (f ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define  pii pair<int,int>
ull N,M;
ull Xor(ull x){ 
  if(x%4==1) return(1);
  else if(x%4==2) return(x+1);
  else if(x%4==3) return(0);
  return(x);
}
int main(){
  cin>>N>>M;
  ull a=Xor(N-1),b=Xor(M);
  if(N<=1) cout<<b;
  else cout<< (a ^ b)<<endl;
}

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

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 200005
#define FH 400005
#define inf INT32_MAX
#define MOD 1000000007LL

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pr;

vector<vector<pr>> g;
vector<int> used;

void dfs(int v)
{
	if (used[v])
		return;
	used[v] = 1;
	for (pr x : g[v])
		dfs(x.first);
}


inline void solve()
{
	int n, m;
	cin >> n >> m;
	g.resize(n + 1);
	used.assign(n + 1, 0);
	int t1, t2, t3;
	fore(i, 0, m)
	{
		cin >> t1 >> t2 >> t3;
		g[t1].push_back({ t2,t3 });
		g[t2].push_back({ t1,t3 });
	}
	int c = 0;
	fore(i, 1, n + 1)
	{
		if (!used[i])
		{
			dfs(i);
			c++;
		}
	}
	cout << c;
}



int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
}

Measured memory_bytes: 11392
#include<stdio.h>
#include <sstream>
#include <iostream>
#include <cstdlib>
 
using namespace std;
 
#define BUF_SIZE 1024
#define ARRAY_SIZE 100
 
int main(){
 
    char buf[BUF_SIZE];
    int n = atoi(fgets(buf,BUF_SIZE,stdin));
    int array[ARRAY_SIZE];
    int change_count = 0;
 
    for(int i = 0; i < n; i++){
        cin >> array[i];
    }
 
    int tmp = 0;
    for(int i = n-1;i > 0;i--){
        for(int j = 0; j < i;j++){
            if(array[j] > array[j+1]){
                tmp = array[j+1];
                array[j+1] = array[j];
                array[j] = tmp;
                change_count++;
            }
        }
    }
 
    for(int i = 0; i < n; i++){
        if(i != n-1){
            printf("%d ",array[i]);
        }else{
            printf("%d\n",array[i]);
        }
    }
    printf("%d\n",change_count);
}


Measured memory_bytes: 3216
#include <stdio.h>
#include <stdlib.h>
 
int main(){
  int i;
  int num[100];
  char s[100];
 
  int head=0;
 
  for(i=0;i<100;i++){
    num[i]=0;
  }
 
  while (scanf(" %s",s)!=EOF){
    if (s[0] == '+'){
      num[head-2]=num[head-2]+num[head-1];
      head=head-1;
    }else if(s[0] == '*'){
     num[head-2]=num[head-2]*num[head-1];
      head=head-1;
    }else if(s[0] == '-'){
      num[head-2]=num[head-2]-num[head-1];
      head=head-1;
    }else{
      num[head]=atoi(s);
      head++;
    }
  }
  printf("%d\n",num[head-1]);
 
  return 0;
}

Measured memory_bytes: 548
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<vector<ll>> vec(M);
    vector<ll> p(M);
    rep(i, M) {
        ll k;
        cin >> k;
        vector<ll> tmp(k);
        rep(j, tmp.size()) {
            cin >> tmp[j];
        }
        vec[i] = tmp;
    }
    rep(i, M) cin >> p[i];
    ll cnt = 0;
    for(ll i = 0; i < (ll)pow(2,N); i++) {
        vector<ll> on(N,0);
        rep(j, N) {
            if (i >> j & 1) {
                on[j] = 1;
            }
        }
        bool flag = true;
        rep(i, M) {
            ll sum = 0;
            rep(j, vec[i].size()) {
                if (on[vec[i][j]-1] == 1) sum++;
            }
            if (sum % 2 != p[i]) flag = false;
        }
        if (flag) cnt++;
    }
    print(cnt);
    return 0;
}

Measured memory_bytes: 512
local S, T = io.read("*l", "*l")

local count = 0
---[[ パターン1
for i = 1, S:len() do
	if S:sub(i, i) ~= T:sub(i, i) then
		count = count + 1
	end
end
--]]
--[[ パターン2
local S_byte_s, T_byte_s = {S:byte(1, -1)}, {T:byte(1, -1)}
for i = 1, S:len() do
	if S_byte_s[i] ~= T_byte_s[i] then
		count = count + 1
	end
end
--]]
print(count)


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

int main(){

    int n;  cin >> n;
    int m = 1;
    int r = sqrt(n);
    for(int i = 2; i <= r; i++){
        int tmp = 1;
        while(tmp*i <= n){
            tmp *= i;
        }
        m = max(m, tmp);
    }

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <queue>
using namespace std;
int main() {
	int k, s;
    cin >> k >> s;
    int counter = 0;
    for(int x = 0; x <= k; x++){
        for(int y = 0; y <= k; y++){
            //for(int z = 0; z <= k; z++){
                //if(x + y + z == s) counter++;
            //}
            int z = s - x - y;
            if(0 <= z and z <= k) counter++;
        }
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vi TIME(n);
  VIN(TIME)
  IN(m);
  Vi pv(m);
  Vi X(m);
  REP(i,m){
    IN2(pv[i],X[i]);
  }
  int sum = VSUM(TIME);
  REP(i,m){
    OUT(sum - TIME[pv[i]-1] + X[i]);
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll =  long long;
int main()
{
    int n;
    cin >> n;
    string s, t, ans;
    cin >> s >> t;
    for (int i = 0; i < n; ++i)
    {
        ans+=s[i];
        ans+=t[i];
    }
    cout << ans  << endl;
}


Measured memory_bytes: 3576
from copy import deepcopy

n, m = [int(i) for i in input().split()]
es = [[int(j) for j in input().split()] for i in range(m)]

x = [float('-inf')] * (n+1)
x[1] = 0

for i in range(n):
    for a, b, c in es:
        x[b] = max(x[b], x[a]+c)

xcp = [i for i in x]
prevxn = x[n]
for a, b, c in es:
        x[b] = max(x[b], x[a]+c)

if prevxn != x[n]:
    print('inf')
else:
    print(x[n])

Measured memory_bytes: 3956
import java.util.Iterator;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;

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

        String s = scan.next();
        int N = s.length();
        int K = scan.nextInt();
        TreeSet<String> ts = new TreeSet<>();
        for(int i=0;i<N;++i){
            for(int j=i+1;j<=Math.min(N, i+5);++j)ts.add(s.substring(i, j));
        }
        Iterator itr = ts.iterator();
        while(--K>0)itr.next();
        System.out.println(itr.next());
    }
}

Measured memory_bytes: 25300
import fractions
A, B, C, D = list(map(int, input().split()))

E = (C * D) // fractions.gcd(C, D)
number = B - A + 1 - (B // C - (A - 1) // C + B // D - (A - 1) // D - B // E + (A - 1) // E)
    
print(number)

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

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;
 
struct Problem{
    string s;
    int q;
 
    void solve(){
        cin >> s >> q;
        int l=(int)s.size();
        vector<vector<int>> dp (l,vector<int>(27,INF)), emp (l,vector<int>(20,INF));
        for(int i=l-1; i>=0; --i){
            dp[i][s[i]-'a']=i+1;
            for(int j=s[i]-'a'+1; j<27; ++j){
                if(dp[i][j-1]<l)dp[i][j]=dp[dp[i][j-1]][j-1];
            }
            for(int j=0; j<s[i]-'a'; ++j){
                if(dp[i][26]<l)dp[i][j]=dp[dp[i][26]][j];
            }
        }
        for(int i=0; i<l; ++i){
            emp[i][0]=dp[i][26];
        }
        for(int i=1; i<20; ++i){
            for(int j=0; j<l; ++j){
                if(emp[j][i-1]<l)emp[j][i]=emp[emp[j][i-1]][i-1];
            }
        }
        for(int i=0; i<q; ++i){
            int ql,qr;
            cin >> ql >> qr;
            ql--;
            int ans =ql;
            for(int j=19; j>=0; --j){
                if(ans<qr && emp[ans][j]<=qr){
                    ans=emp[ans][j];
                }
            }
            if(ans==qr)cout << "Yes" <<"\n";
            else cout << "No" << "\n";
        }
    }
};
 
 
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0;
 
    Problem p;
    p.solve();
    return 0;
}


Measured memory_bytes: 133916
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

const int N = 205;

int n;
int f[N];
char G[N][N];

int bfs(int rt) {
	queue<int> Q;
	memset(f, 0, sizeof(f));
	f[rt] = 1;
	Q.push(rt);
	int ret = 1;
	while (!Q.empty()) {
		int p = Q.front();
		Q.pop();
		ret = max(ret, f[p]);
		for (int e = 1; e <= n; e++) {
			if (G[p][e] == '1') {
				if (f[e]) {
					if (f[e] == f[p])
						return -1;
				} else {
					f[e] = f[p] + 1;
					Q.push(e);
				}
			}
		}
	}
	return ret;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%s", G[i] + 1);
	}
	int ans = bfs(1);
	if (ans == -1) {
		puts("-1");
		return 0;
	}
	for (int i = 2; i <= n; i++) {
		ans = max(ans, bfs(i));
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
a=int(input())
b = 0
if(a >= 10):
    b += 9
    if(a >= 1000):
        b += 900
        if(a >= 100000):
            b += 90000
        elif(a >= 10000):
            b += (a - 10000 + 1)
    elif(a >= 100):
        b += (a - 100 + 1)    
else:
    b += a 
print(b)

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

int main() {
  string s;
  cin >> s;
  int a = 0, n = s.length();
  long long ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    if (s[i] == 'A')
      ++a;
    else if (s[i] == 'B' && s[i + 1] == 'C')
      ans += a, ++i;
    else
      a = 0;
  }
  printf("%lld\n", ans);
  return 0;
}

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

typedef long long ll;
const int N = 100010;

int a[N];
int n;

ll calc(ll x){
	for (int i = 0; i < n; ++ i){
		x = x / a[i] * a[i];
	}
	return x;
}

int main(){
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i){
		scanf("%d", &a[i]);
	}
	ll left = 1, right = 1e15;
	while (left < right){
		ll mid = left + right + 1 >> 1;
		ll x = calc(mid);
		if (x < 2){
			left = mid;
		}
		else{
			right = mid - 1;
		}
	}
	if (calc(left + 1) != 2){
		puts("-1");
		return 0;
	}
	printf("%lld ", left + 1);
	left = 1, right = 1e15;
	while (left < right){
		ll mid = left + right >> 1;
		ll x = calc(mid);
		if (x > 2){
			right = mid;
		}
		else{
			left = mid + 1;
		}
	}
	printf("%lld\n", left - 1);
	return 0;
}

Measured memory_bytes: 640
N,K = map(int,input().split())
AB = [tuple(map(int,input().split())) for _ in range(N)]
AB.sort(key=lambda x:(x[0],x[1]))
#print(AB)

for a,b in AB:
  if K <= b:
    print(a)
    exit()
  else:
    K -= b

Measured memory_bytes: 64344
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

struct person {
	string name;
	long long int a;
	person(string name_, long long int a_) :name(name_), a(a_) {

	}
	
};
bool operator<(const person&l, const person&r) {
	return l.a>r.a;
}
int main() {
	int N; cin >> N;
	vector<person>vs;
	map<string, long long int>memo;
	for (int i = 0; i < N; ++i) {
		string st; long long int a; cin >> st >> a;
		a = 1e8*a + i;
		memo[st] = a;
		vs.emplace_back(st, a);
	}
	sort(vs.begin(), vs.end());
	map<person, int>mp;
	for (int i = 0; i < N; ++i) {
		if (i < N / 5)mp[vs[i]] = true;
		else mp[vs[i]] = false;
	}
	int M; cin >> M;
	for (int i = 0; i < M; ++i) {
		map<person, int>nextmp;
		char c; cin >> c;
		string st;  cin >> st;
		person p("", 0);
		if (c == '+') {
			long long int a; cin >> a;
			a = (1e8)*a + (N + i);
			p=person(st, a);
			memo[st] = a;
			mp[p] = -1;
			auto in = lower_bound(vs.begin(), vs.end(), p);
			vs.insert(in, p);

			auto lineit = vs.begin() + (int(vs.size()) / 5);
			if (lineit != vs.begin()) {
				nextmp[p] = prev(lineit)->a <= p.a;
			}
			else {
				nextmp[p] = false;
			}
		}
		else {
			p=person(st, memo[st]);



			memo.erase(st);
			auto out = lower_bound(vs.begin(), vs.end(), p);
			out = vs.erase(out);

			
		}
		auto lineit = vs.begin() + (int(vs.size()) / 5);
		{
			int num = 3;
			auto it = lineit;
			while (num--) {
				if (it == vs.end())break;
				nextmp[*it] = false;
				it++;
			}
		}
		{
			int num = 3;
			auto it = lineit;
			while (num--) {
				if (it == vs.begin())break;
				it--;
				nextmp[*it] = true;
			}
		}


		vector<pair<string, bool>>anss;
		for (auto m : nextmp) {
			auto aa = mp.find(m.first);
			if ((mp.find(m.first)!=mp.end()&& mp[m.first] != m.second)) {
				{
					anss.push_back(make_pair(m.first.name, nextmp[m.first]));
					
				}
			}
			
		}
		if (anss.size() == 2)if (anss[1].first == st)swap(anss[0], anss[1]);
		for (int i = 0; i < anss.size(); ++i) {
			cout << anss[i].first;
			if (!anss[i].second) {
				cout << " is not working now." << endl;
			}
			else {
				cout << " is working hard now." << endl;
			}
		}
		mp = nextmp;
	}
	return 0;
}

Measured memory_bytes: 12440