akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll div_ceil(ll, ll);

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

int main() {
  int N, K;
  cin >> N >> K;
  cout << N - K + 1 << endl;
}

ll div_ceil(ll a, ll b) {
  ll quotient = a / b;
  ll remainder = a % b;
  if (remainder == 0) {
    return quotient;
  } else {
    return quotient + 1;
  }
}


Measured memory_bytes: 256
a = {'S': [0 for i in range(13)],'H': [0 for i in range(13)],'C': [0 for i in range(13)],'D': [0 for i in range(13)]}



n = int(input())
for i in range(n):
    (s, r) = input().split()
    a[s][int(r)-1] = 1
 
for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if a[s][r] == 0:
            print(s, r+1)


Measured memory_bytes: 5600
import sys

n, k = map(int, input().split())
a = list(map(int, input().split()))
a = [0] + a

visited = set([])
hist = [-1 for _ in range(n+1)]
cur = 1
cnt = 0
d = 0

while True:
    if cnt == k:
        print(cur)
        sys.exit()
    if hist[cur] != -1:
        d = cnt - hist[cur]
        break
    hist[cur] = cnt
    cur = a[cur]
    cnt += 1

k -= hist[cur]
index = hist[cur] + k % d
# print(hist)

for i, histi in enumerate(hist):
    if index == histi:
        print(i)
        sys.exit()


Measured memory_bytes: 32272
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	//Lを3等分した時が最大の体積
	fmt.Printf("%.12f\n", math.Pow(float64(nextInt())/3, 3))
}

Measured memory_bytes: 640
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = max(a*c, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);
    print(ans);

}

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

Measured memory_bytes: 3644
def main():
    N = int(input())
    cnt = 0
    flag = False
    for _ in range(N):
        D1, D2 = map(int, input().split())
        if D1 == D2:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            flag = True
    if flag:
        print('Yes')
    else:
        print('No')



if __name__ == "__main__":
    main()

Measured memory_bytes: 62316
n = int(raw_input())
a = map(int, raw_input().split())

def gcd(p,q):
    if q == 0:
    	return p
    return gcd(q, p % q)


if n == 1:
    print a[0]
else:
    element = gcd(a[0], a[1])
    if n == 2:
    	print element
    else:
        for i in range(2, n):
            element = gcd(element, a[i])
        print element

Measured memory_bytes: 11320
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

ll d[1111111],c[1111111];
void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) {
    R a[i];
    d[a[i]]++;
  }
  int ans=0;
  REP(i,1,1111111) {
    if(d[i]) {
      for(ll j=i*2; j<=1111111; j+=i) c[j]=1;
    }
  }
  rep(i,n) {
    if(d[a[i]]==1&&!c[a[i]]) ans++;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main(void){
    string s;
    cin >> s;
    bool check = false;
    for(int i = 0;i < s.size() - (s.size()-7);i++){
        string t,t1,t2;
        t1 = s.substr(0,i);
        t2 = s.substr(i+s.size()-7);
        t = t1 + t2;
        if(t == "keyence")check = true;
    }
    if(check == true)cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=[0 for i in range(N+1)]
C=[0 for i in range(N+1)]
D=[0 for i in range(N+1)]
for i in range(N):
    B[A[i]]+=1
for i in range(1,N+1):
    C[i]=B[i]*(B[i]-1)//2
sum_=sum(C)
for i in range(1,N+1):
    print(sum_-B[A[i-1]]*(B[A[i-1]]-1)//2+(B[A[i-1]]-2)*(B[A[i-1]]-1)//2)

Measured memory_bytes: 128912
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stack>
#include<string.h>
#include<string>
using namespace std;
int main()
{
    int n,a[100];
    while(cin>>n)
    {
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a,a+n);
        cout<<a[n-1]-a[0]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long t = sc.nextLong();
        long a = sc.nextLong();
        
        for (int i=1; i<n; i++){
            long tt = sc.nextLong();
            long aa = sc.nextLong();
            long c = Math.max(t/tt,a/aa);
            while (tt*c < t || aa*c < a)
                c++;
            t = tt*c;
            a = aa*c;
        }
        System.out.println(t+a);
            
    }

}


Measured memory_bytes: 24820
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin>>n;
    string s[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    int sum[n]={};
    int mi[n]={};
    int pos=0;
    array<int,2> p[n]={};
    for(int i=0;i<n;i++){
        for(int j=0;j<s[i].size();j++){
            if(s[i][j]=='(')sum[i]++;
            else sum[i]--;
            chmin(mi[i],sum[i]);
        }
        pos += sum[i];
        p[i] = {mi[i],sum[i]};
    }
    sort(p,p+n);
    if(pos){
        cout << "No\n";
        return 0;
    }
    int now = 0;
    for(int i=0;i<n;i++){
        if(sum[i]>=0 && mi[i]>=0)now += sum[i];
    }
    bool ok = 1;
    for(int i=n-1;i>=0;i--){
        if(p[i][0] < 0 && p[i][1] >= 0){
            if(now+p[i][0] < 0)ok=false;
            now += p[i][1];
        }
    }

    
    // second
    for(int i=0;i<n;i++){
        reverse(s[i].begin(),s[i].end());
        sum[i]=0;
        mi[i]=0;
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<s[i].size();j++){
            if(s[i][j]==')')sum[i]++;
            else sum[i]--;
            chmin(mi[i],sum[i]);
        }
        p[i] = {mi[i],sum[i]};
    }
    sort(p,p+n);
    now = 0;
    for(int i=0;i<n;i++){
        if(sum[i]>=0 && mi[i]>=0)now += sum[i];
    }
    for(int i=n-1;i>=0;i--){
        if(p[i][0] < 0 && p[i][1] >= 0){
            if(now+p[i][0] < 0)ok=false;
            now += p[i][1];
        }
    }

    if(!ok)cout << "No\n";
    else cout << "Yes\n";
}

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

typedef long long int lli;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int x;
    cin >> x;

    if(x >= 30)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}



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

const int N = 200005;
int a[N], b[N], aa[N], bb[N], n;

int low_binary(int pos, int value){
	int lo = 0, hi = n - 1, mid, res = -1;
	while(lo <= hi){
		mid = (lo + hi) >> 1;
		if(aa[pos] + bb[mid] >= value){
			res = mid;
			hi = mid - 1;
		}
		else{
			lo = mid + 1;
		}
	}
	return res;
}

int high_binary(int pos, int value){
	int lo = 0, hi = n - 1, mid, res = -1;
	while(lo <= hi){
		mid = (lo + hi) >> 1;
		if(aa[pos] + bb[mid] >= value){
			hi = mid - 1;
		}
		else{
			res = mid;
			lo = mid + 1;
		}
	}
	return res;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  	int i, bit;
	int ans = 0;
	cin >> n;
	for(i = 0; i < n; ++i)cin >> a[i];
	for(i = 0; i < n; ++i)cin >> b[i];
	for(bit = 0; bit < 30; ++bit){
		int T = (1 << bit);
		for(i = 0; i < n; ++i){
			aa[i] = a[i] % (2*T);
			bb[i] = b[i] % (2*T);
		}

		sort(bb, bb + n);

		int ct = 0, lower_bound, upper_bound;

		for(i = 0; i < n; ++i){
			lower_bound = low_binary(i, T);
			upper_bound = high_binary(i, 2*T);
			if(lower_bound != -1)
				ct = ct + (upper_bound - lower_bound + 1);
			lower_bound = low_binary(i, 3*T);
			upper_bound = high_binary(i, 4*T);
			if(lower_bound != -1)
				ct = ct + (upper_bound - lower_bound + 1);	
		}


		if(ct & 1)
			ans = ans + T;
	}
	cout << ans << endl;
	return 0;
}

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

int main(void){
   int N;
   cin>>N;
   vector<char> S(N);
   for(int i=0;i<N;i++){
       cin>>S[i];
   }
   set<char> result;
   for(int i=0;i<N;i++){
       result.insert(S[i]);
   }
   if(result.size()==3) cout<<"Three"<<endl;
   if(result.size()==4) cout<<"Four"<<endl;
   return 0;
}



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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N,M;
vint v[100010];
int p[100010],y[100010];
int pprint[6];

void print(int x){
    rep(i,0,6){
        pprint[i]=x%10;
        x/=10;
    }
    rrep(i,0,6){
        cout<<pprint[i];
    }
}

signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>N>>M;
    rep(i,0,M){
        cin>>p[i]>>y[i];
        v[p[i]].pb(y[i]);
    }
    
    rep(i,0,100010){
        if(v[i].size()==0)continue;
        sort(all(v[i]));
    }
    rep(i,0,M){
        print(p[i]);
        print(lower_bound(all(v[p[i]]),y[i])-v[p[i]].begin()+1);
        cout<<endl;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 8576
//  problem
//  Created by 聂小楠 on 2017/8/12.
//  All rights reserved.

#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#define endl '\n'
#define ll long long
#define pii pair<int,int>
#define MAX_N 1000
#define Mem(a,b) memset(a,b,sizeof(a))
#define FREI freopen("in.txt","r",stdin)
#define FREO freopen("out.txt","w",stdout)
#define INF  2147483647
using namespace std;
const ll mod =1e9+7;
int a[105];
int ans[105][105];
ll lcm(ll a,ll b)
{
    return a/__gcd(a,b)*b;
}
int main()
{
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    ll tmp;
    ll ans=1;
    for(int i=0;i<n;i++)
    {
        cin>>tmp;
        ans=lcm(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
s = deque(input())
q = int(input())
rev = 0

for i in range(q):
    t = input()
    if rev == 0:
        if len(t) == 1:
            rev = 1
        else:
            if t[2] == "1":
                s.appendleft(t[4])
            else:
                s.append(t[4])
    else:
        if len(t) == 1:
            rev = 0
        else:
            if t[2] == "1":
                s.append(t[4])
            else:
                s.appendleft(t[4])

if rev == 1:
    s.reverse()
print(*s, sep="")



Measured memory_bytes: 12272
#include<iostream>
#include<string>

using namespace std;

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

int main(){
    int A, B, m;
    cin >> A >> B >> m;
    int a[A], b[B];
    int amin = 1000000, bmin = 1000000;
    rep(i, A) {
        cin >> a[i];
        amin = min(amin, a[i]);
    }
    rep(i, B) {
        cin >> b[i];
        bmin = min(bmin, b[i]);
    }
    int x[m], y[m], c[m];
    rep(i, m){
        cin >> x[i] >> y[i] >> c[i];
        x[i]--;
        y[i]--;
    }
    int ans = amin + bmin;
    rep(i, m){
        ans = min(ans, a[x[i]] + b[y[i]] - c[i]);
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string s, t; cin >> s >> t;
    int n = s.size();
    int ans = 1e9;
    for (int i = 0; i + t.size() <= n; ++i) {
        int cnt = 0;
        for (int j = 0; j < t.size(); ++j) {
            if (s[i + j] != t[j]) {
                cnt++;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3624
n = int(input())
t, a = map(int, input().split())
l = list(map(int, input().split()))
ans = 0
minNum = float('inf')

for i in range(len(l)):
    num = t - l[i] * 0.006
    if abs(num - a) < minNum:
        minNum = abs(num -a)
        ans = i + 1
print(ans)

Measured memory_bytes: 9272
N, A, B = map(int, input().split())
if (A == 0):
    print('0')
elif (B == 0):
    print(N)
else:
    sum = A + B
    div = N // sum
    mod = N % sum
    plus = mod - A
    if (plus > 0):
        ans = div*A + A
        print(ans)
    else:
        ans = div*A + mod
        print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int N;
long long A[55];

int main()
{
	scanf ("%d",&N);
	for (int i=0;i<N;i++) scanf ("%lld",&A[i]);
	long long ans = 0;
	while (1){
		bool ch = 0;
		for (int i=0;i<N;i++) if (A[i] >= N){
			long long down = A[i] / N; A[i] %= N;
			if (down){
				ch = 1;
				for (int j=0;j<N;j++) if (i != j) A[j] += down;
				ans += down;
			}
		}
		if (!ch) break;
	}
	printf ("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Bus Line
 */
public class Main {

	// 15 stations
	final static int[] stations = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1 };

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n = Integer.parseInt(line);
			int s, g;

			for (int i = 0; i < n; ++i) {
				line = br.readLine();
				s = Integer.parseInt(line.substring(0, line.indexOf(' ')));
				g = Integer.parseInt(line.substring(line.indexOf(' ') + 1));

				if (s <= 5 && g < s) {
					s = 15 - s;
				}

				StringBuilder sb = new StringBuilder();
				for (int j = s;; j++) {
					if (j > 14) {
						j -= 15;
					}
					sb.append(stations[j] + " ");
					if (stations[j] == g) {
						break;
					}
				}
				System.out.println(sb.substring(0, sb.length() - 1).toString());
			}
		}

	}
}

Measured memory_bytes: 17024
#include<bits/stdc++.h>
#define ll long long
#define forn(i,n) for(ll i=0;i<(n);i++)
#define maxx ((ll)1e6+5)
using namespace std;
int main()
{
  ll n;
  cin>>n;
  cout<<(1000*(n/500))+(5*((n%500)/5));
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(s[i] != '?') continue;
        s[i] = 'D';
    }
    cout << s << endl;
}

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

int main() {
  int n, d, x, a;
  cin >> n >> d >> x;
  int i;
  for (i = 0; i < n; i++) {
    cin >> a;
    x += (d % a == 0 ? d / a : d / a + 1);
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int n,m,i,j,sum,x,y;
    char a[52][52];
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        memset(a,0,sizeof(a));
        getchar();
        for(i=1;i<=n;i++)
            {
                for(j=1;j<=m;j++)
                    scanf("%c",&a[i][j]);
                getchar();
            }
        for(i=1;i<=n;i++)
            for(j=1;j<=m;j++)
            {
                sum=0;
                if(a[i][j]=='#')
                    continue;
                for(x=-1;x<2;x++)
                    for(y=-1;y<2;y++)
                    {
                        if(a[i+x][j+y]=='#')
                            sum++;
                    }
                a[i][j]=sum;
            }
            for(i=1;i<=n;i++)
                {
                    for(j=1;j<=m;j++)
                        if(a[i][j]=='#')
                        printf("#");
                        else
                            printf("%d",a[i][j]);
                    printf("\n");
                }
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 1e5+5;

void solve()
{
    string s, t;
    cin >> s >> t;

    ll h = sz(s), w = sz(t);

    vector<vector<ll>> dp(h+1, vector<ll>(w+1, 0));

    for(ll i=0; i<=h; i++)
    {
        dp[i][0] = 0;
    }

    for(ll j=0; j<=w; j++)
    {
        dp[0][j] = 0;
    }

    for(ll i=1; i<=h; i++)
    {
        for(ll j=1; j<=w; j++)
        {
            if(s[i-1] == t[j-1])
            {
                dp[i][j] = dp[i-1][j-1] + 1;
            }

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

    // cout << dp[h][w] << endl;

    string ans = "";

    ll i=h, j=w;

    while(i > 0 || j > 0)
    {
        if(i > 0 && j > 0 && dp[i][j] == dp[i-1][j-1] + 1 && s[i-1] == t[j-1])
        {
            i--, j--;
            ans += s[i];
        }

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

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

    reverse(all(ans));
    cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 70784
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  var list = List.fill(n)(sc.nextInt)

  var aliceSum = 0
  var bobSum = 0
  list.sorted.reverse.zipWithIndex.foreach{
    v =>
      if(v._2 % 2 == 0) aliceSum += v._1
      else bobSum += v._1
  }

  println(aliceSum - bobSum)
}

Measured memory_bytes: 25792
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        while(true)
        {   
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();

            if(op.equals("+"))
            {
                System.out.printf("%d\n",a+b);
            }
            else if(op.equals("-"))
            {
                System.out.printf("%d\n",a-b);
            }
            else if(op.equals("*"))
            {
                System.out.printf("%d\n",a*b);
            }
            else if(op.equals("/"))
            {
                System.out.printf("%d\n",(int)a/b);
            }
            else if(op.equals("?"))
            {
                break;
            }
        }

        sc.close();
    }
}


Measured memory_bytes: 26496
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

int main() {
    cin>>S;
    rep(i,19) {
        if(i != 5 && i != 13) cout<<S[i];
        else cout<<' ';
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define rn return
#define fi first
#define se second
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;



int main(){
    const int inf = 100000000;
    int n,m; cin >> n >> m;
    int a[1000],b[1000],c[1000],dist[100][100];
    
    rep(i,m){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
    }
    rep(i,n){
        rep(j,n){
            if (i==j) dist[i][j] = 0;
            else dist[i][j] = inf;
        }
    }
    
    rep(i,m){
        dist[a[i]][b[i]] = min(dist[a[i]][b[i]],c[i]);
        dist[b[i]][a[i]] = min(dist[b[i]][a[i]],c[i]);
    }
    
    rep(k,n){
        rep(i,n){
            rep(j,n){
                dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j]);
            }
        }
    }
    
    int ans = m;
    rep(i,m){
        bool shortest = false;
        rep(j,n) if(dist[j][a[i]]+c[i] == dist[j][b[i]]) shortest = true;
        if (shortest == true){
            ans--;
        }
    }
    cout << ans;
    rn 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,d;
    cin >> n >> d;
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        long long int a,b;
        cin >> a >> b;
        if((a*a)+(b*b)<=d*d)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    
}

Measured memory_bytes: 3636
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] read = ReadLine().Split(' ');
//        int read_leng = read.Length;
//        int[] readR = new int[mochinum];
        int tate = int.Parse(read[0]);
        int yoko = int.Parse(read[1]);
        
        char[,] map = new char[tate+2,yoko+2];
        
        for(int i=0;i<tate;i++){
            string gyou = ReadLine();
            for(int j=0;j<yoko;j++){
                map[i+1,j+1] = gyou[j];
            }
        }
        string[,] ans = new string[tate,yoko];
        for(int i=0;i<tate;i++){
            for(int j=0;j<yoko;j++){
                if(map[i+1,j+1] == '.'){
                    int count = 0;
                    for(int k=0;k<=2;k++){
                        for(int l=0;l<=2;l++){
                            if(k==1&&l==1){ continue; }
                            if(map[i+k,j+l] == '#'){ count++; }
                        }
                    }
                    ans[i,j] = count.ToString();
                }else{
                    ans[i,j] = "#";
                }
                Write(ans[i,j]);
            }
            WriteLine();
        }
    }
}


Measured memory_bytes: 11220
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
border_x = max(x)
border_y = min(y)
if border_x >= border_y:
    print("War")
elif border_x<= X or border_y>= Y:
    print("War")
else:
    print("No War")

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

int main()
{
    int N,D;
    cin >> N >> D;
    if(N%(2*D+1) == 0){
        cout << N/(2*D+1) <<endl;
    }else{
         cout << N/(2*D+1)+1 <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

sat = 0
ai_prev = None
for ai in a:
    sat += b[ai - 1]
    if ai_prev == ai - 1:
        sat += c[ai_prev - 1]
    ai_prev = ai
print(sat)


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

int main()
{
	int n, y, a = 0, b = 0, c = 0;
	int ac, bc, cc;
	bool f = false;
	cin >> n >> y;
	a = y / 10000;
	b = (y - a * 10000) / 5000;
	c = (y - a * 10000 - b * 5000) / 1000;
	ac = a;
	if (a + b + c == n) {
		cout << a << " " << b << " " << c << endl;
		f = true;
	}
	else {
		for (int i = 0; i < ac; i++) {
			a--;
			b += 2;
			if ((a + b + c) == n) {
				cout << a << " " << b << " " << c << endl;
				f = true;
				break;
			}
			bc = b;
			cc = c;
			for (int j = 0; j < b; j++) {
				bc--;
				cc += 5;
				if ((a + bc + cc) == n) {
					cout << a << " " << bc << " " << cc << endl;
					f = true;
					return 0;
				}
			}
		}
	}
	if (!f) cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 256
inputs = gets.strip().split(" ")
a  = inputs[0].to_i
op = inputs[1]
b  = inputs[2].to_i

until op == "?"
	case op
	when '+'
		puts a + b
	when "-"
		puts a - b
	when "*"
		puts a * b
	when '/'
		puts a / b
	end

	inputs = gets.strip().split(" ")
	a  = inputs[0].to_i
	op = inputs[1]
	b  = inputs[2].to_i
end


Measured memory_bytes: 6872
import sys
input = sys.stdin.readline

n = int(input())
T = [[] for _ in range(n)]
for _ in range(n-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  T[a].append(b)
  T[b].append(a)
def dfs(v):
  dist = [-1]*n
  dist[v] = 0
  stack = [v]
  while stack:
    nv = stack.pop()
    for i in T[nv]:
      if dist[i] == -1:
        dist[i] = dist[nv] + 1
        stack.append(i)
  return dist
B = dfs(0)
W = dfs(n-1)
cnt_b, cnt_w = 0, 0
for i in range(n):
  if B[i] <= W[i]:
    cnt_b += 1
  else:
    cnt_w += 1
if cnt_b > cnt_w:
  print("Fennec")
else:
  print("Snuke")

Measured memory_bytes: 28976
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){

int A, B, C;
cin >> A >> B >> C;
string ans;

if(A == 7 && B == 5 && C == 5){
	ans = "YES";
}
else if(A == 5 && B == 7 && C == 5){
	ans = "YES";
}
else if(A == 5 && B == 5 && C == 7){
	ans = "YES";
}
else{
	ans = "NO";
}

cout << ans << endl;

return 0;
}

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

using namespace std;


string s;

int main() {

        cin >> s;

        int qtd = 0;
        int maior = -1;
        for (int i = 0; i < s.size();i++) {
                if (s[i] == 'R') {
                        qtd++;
                } if (s[i] != 'R') {
                        qtd = 0;
                }

                if (maior < qtd) {
                        maior = qtd;
                }

        }

        cout << maior << endl;

        return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  int A;
  int p[N];
  rep(i, N){
    p[i] = K;
  }
  
  rep(i, Q){
    cin >> A;
    p[A-1]++;
  }
   rep(j, N) p[j] -= Q;
  
  rep(i, N){
    if(p[i] > 0){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1024
s, = (int(x) for x in input().split())

if s == 1 or s == 2 or s == 4:
    print("4")
    exit()

ncount = 1
while s != 1:
    ncount += 1
    if s%2 == 0:
        s = s//2
    else:
        s = 3*s+1

print(ncount+1)


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < M; i++) {
    cin >> A.at(i);
  }
  int ans = 0;
  for (int j = 0; j < M; j++) {
    ans+=A.at(j);
  }
  if(ans > N) {
    cout << "-1" <<endl;
  }
  else {
    cout << N-ans <<endl;
  }
}


Measured memory_bytes: 7220
#include <bits/stdc++.h>
using namespace std;
    int mod = 1e9 + 7;
    long long int count = 0;
   
   long long int dp[1000][1000];
    long long  int maxPath(vector<vector<char>>& grid,int i,int j,int n,int m)
    {
      
        if(i>=n || j>=m)
            return 0;
        
           if(grid[i][j]=='#')
           return 0;
        
        if(i==n-1 && j==m-1)
        {
            
            return 1;
        }
        if(dp[i][j] != -1)
        {
            return dp[i][j];
        }
    
        
   dp[i][j] =  maxPath(grid,i+1,j,n,m) +  maxPath(grid,i,j+1,n,m);
   dp[i][j] = dp[i][j] % mod; 
        
       return dp[i][j];
      
     
        
    }
    
    int uniquePathsWithObstacles(vector<vector<char>>& grid) {
        int n = grid.size();
        int m = grid[0].size();
        if(n==1 && m==1)
        {
            if(grid[0][0]=='.')
                return 1;
            else
                return 0;
            
        }
        memset(dp,-1,sizeof dp);
       return  maxPath(grid,0,0,n,m);
       

    }
int main() {
int n,m;
cin>>n>>m;
 vector<vector<char> > vec( n , vector<char> (m, '.'));  
 for(int i = 0;i<n;i++)
 {
     for(int j = 0;j<m;j++)
     {
         cin>>vec[i][j];
     }
 }

 cout<<uniquePathsWithObstacles(vec)%mod;
}


Measured memory_bytes: 9216
#include "bits/stdc++.h"
using namespace std;
int main(){
    int a,b,c,d,e,f,g,h;
    cin>>a>>b>>c>>d>>e>>f>>g>>h;
    int a1=a*e+b*f+a/10*g+b/20*h;
    int a2=c*e+d*f+c/10*g+d/20*h;
    if(a1>a2){
        cout<<"hiroshi"<<endl;
    }else if(a1<a2){
        cout<<"kenjiro"<<endl;
    }else{
        cout<<"even"<<endl;
    }
    
}

Measured memory_bytes: 3108
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
 
Node root;
 
Node minimum(Node x){
  while(x->left!=NIL)
    x=x->left;
  return x;
}
 
Node find(Node u,int k){
  if(u==NIL||u->key==k)
    return u;
  if(u->key > k)
    return find(u->left,k);
  else
    return find(u->right,k);
}
Node successor(Node x){
  if(x->right!=NIL)
    return minimum(x->right);
  Node y =x->parent;
  while(y!=NIL&&x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}
 
void insert(int k){
   Node y = NIL;
   Node x = root;
   Node z;
    
   z =malloc(sizeof(struct node));
   z->key = k;
   z->left = NIL;
   z->right = NIL;
   while(x!=NIL){
     y=x;
     if(z->key < x->key)x=x->left;
     else x=x->right;
   }
   z->parent=y;
   if(y==NIL)root=z;
   else if(z->key <y->key)
   y->left=z;
   else
     y->right=z;
}
void delete(Node z){
  Node y; 
  Node x;
  if(z->left==NIL||z->right==NIL)
    y=z;
  else y=successor(z);
  if(y->left!=NIL){
    x=y->left;
  }
  else
    x=y->right;
  if(x!=NIL)
    x->parent=y->parent;
  if(y->parent==NIL)
    root=x;
  else{
    if(y==y->parent->left)
      y->parent->left=x;
    else
      y->parent->right=x;
  }
  if(y!=z)
    z->key=y->key;
  free(y);
}
 
void inorder(Node u){
  if(u->left!=NIL)
    inorder(u->left);
  printf(" %d",u->key);
  if(u->right!=NIL)
    inorder(u->right);
}
 
void preorder(Node u){
  if(u!=NIL)
    printf(" %d",u->key);
  if(u->left!=NIL)
    preorder(u->left);
  if(u->right!=NIL)
    preorder(u->right);
}
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
     Node t = find(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if ( com[0] == 'd' ){
      scanf("%d", &x);
      delete(find(root, x));
    }
  }
  return 0;
}

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

const int maxn = 2e5 + 10;
long long a[maxn], b[maxn];

int main()
{
    int n, m, ans = 0;
    long long k;
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= m; i++) cin >> b[i];
    for (int i = 1; i <= n; i++) a[i] += a[i - 1];
    for (int i = 1; i <= m; i++) b[i] += b[i - 1];
    // here
    for (int i = 0; i <= n; i++) {
        if (k < a[i]) break;
        int j = upper_bound(b, b + m + 1, k - a[i]) - b - 1;
        ans = max(ans, i + j);
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

//#define int long long
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int n, T;
int t[200000 + 5];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> T;
    rep(i, n) cin >> t[i];
    ll ans = 0;
    rep(i, n - 1) {
        if (t[i + 1] - t[i] >= T) ans += T;
        else ans += t[i + 1] - t[i];
    }
    cout << ans + T << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

ll contest = 26;

int main(){
    ll d; cin >> d;
    vector<ll> c(contest), t(d);
    vector<vector<ll>> s(d, vector<ll>(contest));
    rep(i, contest) cin >> c[i];
    rep(i, d) rep(j, contest) cin >> s[i][j];
    rep(i, d) cin >> t[i];
    ll v = 0;
    vector<ll> last(contest, 0);
    rep(i, d){
        v += s[i][t[i]-1];
        last[t[i]-1] = i+1;
        rep(j, contest){
            if(t[i]-1 == j) continue;
            v -= c[j]*((i+1)-last[j]);
        }
        cout << v << endl;
    }
    return 0;
}

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

int main() {
    double r;
    const double PI=3.141592653589;
    cin >> r;
    cout << r*2*PI << endl;
    return 0;
}

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

#include <iostream>
#include <algorithm>

#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>

#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>


using namespace std;
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false

int n, z, w;
int a[2000 + 5], dp[2000 + 5][2000 + 5][2];

int dfs(int now, int pl, int card1, int card2) {
    if (now == n) {
        if (card2 == 0) return abs(a[card1] - w);
        return abs(a[card1] - a[card2]);
    }
    if (pl == 0) {
        if (dp[now][card2][pl] != -1) return dp[now][card2][pl];
        rep2(nx, now, n) {
            dp[now][card2][pl] = max(dp[now][card2][pl], dfs(nx + 1, pl^1, nx, card2));
        }
        return dp[now][card2][pl];
    }
    else {
        if (dp[now][card1][pl] != INF) return dp[now][card1][pl];
        rep2(nx, now, n) {
            dp[now][card1][pl] = min(dp[now][card1][pl], dfs(nx + 1,  pl^1, card1, nx));
        }
        return dp[now][card1][pl];
    }
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> z >> w;
    rep(i, n) cin >> a[i];
    rep(i, n)rep(j, n)rep(k, 2) {
        if (k == 0) {
            dp[i][j][k] = -1;
        }
        else {
            dp[i][j][k] =  INF;
        }
    }
    cout << dfs(0, 0, 0, 0) << endl;
}

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

int main() {
  int k,t,amax=0;cin>>k>>t;
  vector<int> a(t);
  for(int i=0;i<t;i++){
    cin>>a[i];
    amax=max(a[i],amax);
  }
  cout<<((2*amax-1-k)<0?0:(2*amax-1-k))<<endl;
}

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

#define   ll     long long int

int main( )
{
    int a, b, c;
    cin >> a >> b >> c;
    if (c % __gcd(a, b) == 0) {
        cout << "YES\n";
    }
    else {
        cout << "NO\n";
    }
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

string s;

int main() {
    cin >> s;

    if (s.front() == s.back()) {
        if (s.length() & 1) {
            cout << "Second" << endl;
        }
        else {
            cout << "First" << endl;
        }
    }
    else {
        if (s.length() & 1) {
            cout << "First" << endl;
        }
        else {
            cout << "Second" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long LL;
const int MAXN=10000 +10;

int a[MAXN], b[MAXN],n; 
int main(){
	scanf("%d",&n);
	for (int i=0; i<n; i++)scanf("%d", &a[i]);
	LL minu1=0, minu2=0, plus=0;
	for (int i=0; i<n; i++){
		scanf("%d", &b[i]);
		LL delt= a[i]-b[i];
		if ( delt>0) plus+= delt;
		if ( delt<0){
			delt= abs(delt);
			minu1 += delt%2;
			minu2 += delt/2;
		}
	}
	if ( plus<=minu2){
		printf("Yes\n");
	}	else{
		plus-= minu2;
		if ( plus) printf("No\n");
			else printf("Yes\n");
	}
	return 0;
}


Measured memory_bytes: 384
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a, b, c, k = nm()

    if k <= a + b:
        ans = min(a, k)
    else:
        ans = a - (k - (a + b))
    
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9728
#include <iostream>
using namespace std;
int main(void){
    int n;
  	cin>>n;
  	string str;
  	int ac=0,wa=0,tle=0,re=0;
  	while(cin>>str){
      	if(str=="AC"){
            ac++;
        }else if(str=="WA"){
            wa++;
        }else if(str=="TLE"){
            tle++;
        }else if(str=="RE"){
            re++;
        }
    }
  	cout<<"AC x "<<ac<<endl;
  	cout<<"WA x "<<wa<<endl;
  	cout<<"TLE x "<<tle<<endl;
  	cout<<"RE x "<<re<<endl;
  	return 0;
}

Measured memory_bytes: 3624
import math
n = int(input())

ans = n/1.080
ans = int(ans)

#print(ans,math.floor(ans * 1.08))

if math.floor(ans * 1.08) == n:
    print(ans)
    exit()
else:
    for i in range(50000):
        if math.floor((ans+i) * 1.08) == n:
            print(int(ans+i))
            exit()
        if math.floor((ans+i) * 1.08) > n:
            print(':(')
            exit()
            
print(':(')

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

int n, a[100005], ans;
map<int, int> memo;

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    memo[a[i]]++;
  }

  for (auto i = memo.begin(); i != memo.end(); i++) {
    int f = (*i).first;
    int s = (*i).second;
    if (f < s) {
      ans += s - f;
    }
    if (f > s) {
      ans += s;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 8300
#pragma GCC optimize(2)
#include<bits/stdc++.h>
constexpr int MAXN = 1e5 + 5;
constexpr long long M = 998244353;
constexpr double EPS = 1e-7;
using namespace std;
template <typename T> inline void read(T &x) {
    int f = 1; x = 0;
    char ch = getchar();
    while (!isdigit(ch)) ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}
struct segTree {
    using Node = segTree *;
    Node lson, rson;
    int l, r;
    long long mul;
}Tree[MAXN << 1];
using LL = long long;
int n;
inline void search(string s, int mx) {
    if (s.size () == n) {
        cout << s << endl;
        return;
    }
    for (char c = 'a'; c <= mx; c++)
        search(s + c, c == mx ? mx + 1 : mx);
}
int main() {
    //freopen("test.out", "w", stdout);
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    //sort (vec.begin(), vec.end());
    cin >> n;
    search("", 'a');
    return 0;
}

Measured memory_bytes: 1536
import heapq
from collections import namedtuple

edge = namedtuple("edge","to cost")

def dijkstra(G, s):
    que = [[0, s]]
    V = len(G)
    d = [float("inf")] * V
    d[s] = 0
    while que:
        c, v = heapq.heappop(que)
        if d[v] > c: continue
        for e in G[v]:
            if d[e.to] > d[v] + e.cost:
                d[e.to] = d[v] + e.cost
                heapq.heappush(que, [d[e.to], e.to])

    return d

V, E, r = map(int, raw_input().split())
G = [[] for i in xrange(V)]
for i in xrange(E):
    s, t, d = map(int, raw_input().split())
    G[s].append(edge(t, d))

d = dijkstra(G, r)
for i in d:
    if i < float("inf"):
        print i
    else:
        print "INF"

Measured memory_bytes: 93256
def main():
    from collections import Counter
    n, *a = map(int, open(0).read().split())
    b = Counter(a)
    c = [(k, v) for k, v in b.items()]
    c.sort(key=lambda x: x[0])
    ans = 0
    c = [c[0]] + c + [c[-1]]
    for x, y, z in zip(c, c[1:], c[2:]):
        v = y[0]
        tmp = y[1]
        if v - x[0] == 1:
            tmp += x[1]
        if v - z[0] == -1:
            tmp += z[1]
        ans = max(ans, tmp)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15832
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <functional>
#include <cassert>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define ALL(a) (a).begin(),(a).end()

#define pb push_back
#define mp make_pair

using namespace std;
typedef unsigned long ul;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;

int main() {
    ll h, w, n;
    cin >> h >> w >> n;
    map<pair<int, int>, int> m;
    int D[3]={-2,-1,0};
    ll hb = h-2;
    ll wb = w-2;
    REP(i,n){
        ll a,b;
        cin >> a >> b;
        a--; b--;
        REP(j,3){
            REP(k,3){
                ll c = a + D[j];
                ll d = b + D[k];

                if (c >= 0 && d >= 0 && c < hb && d < wb && a-c<3 && b-d<3) {
                    m[mp(c,d)]++;
                }
            }
        }
    }
    vector<long long> res = vector<long long>(10, 0);
    ll sum = 0;
    for (auto mm : m){
        res[mm.second]++;
        sum++;
    }
    res[0] = (hb*wb)-sum;

    for (auto a : res){
        cout << a << endl;
    }
}


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

int dp[200010][3];

int main(void){
    string s;
    cin >> s;
    int n = s.size();
    s += "_";
    rep(i,n){
        rep1(d,2){
            if (i >= d) {
                if (s.substr(i-d, d) != s.substr(i, d)) {
                    dp[i+d][d] = max(dp[i+d][d], dp[i][d]+1);
                }
            }    
        }
        dp[i+1][1] = max(dp[i+1][1], dp[i][2]+1);
        dp[i+2][2] = max(dp[i+2][2], dp[i][1]+1);
    }
    cout << max(dp[n][1], dp[n][2]) << endl;
    return 0;
}


Measured memory_bytes: 2948