akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int[] A = new int[N + 1];
            for (int i = 1; i <= N; i++) {
                A[i] = sc.nextInt();
            }

            int c1 = 0, c2 = 0, c3 = 0;
            for (int a : A) {
                if (a == 1) {
                    c1++;
                } else if (a == 2) {
                    c2++;
                } else if (a == 3) {
                    c3++;
                }
            }

            double[][][] dp = new double[N + 1][N + 1][N + 1];

            double ans = solve(N, dp, c1, c2, c3);

            System.out.println(ans);
        }
    }

    static double solve(int N, double[][][] dp, int c1, int c2, int c3) {
        if (dp[c1][c2][c3] != 0) {
            return dp[c1][c2][c3];
        }

        if (c1 + c2 + c3 == 0) {
            return 0;
        }

        int c = c1 + c2 + c3;

        dp[c1][c2][c3] = (double) N / c;

        if (c1 > 0) {
            dp[c1][c2][c3] += solve(N, dp, c1 - 1, c2, c3) * c1 / c;
        }

        if (c2 > 0) {
            dp[c1][c2][c3] += solve(N, dp, c1 + 1, c2 - 1, c3) * c2 / c;
        }

        if (c3 > 0) {
            dp[c1][c2][c3] += solve(N, dp, c1, c2 + 1, c3 - 1) * c3 / c;
        }

        return dp[c1][c2][c3];
    }

}


Measured memory_bytes: 309460
////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 300;
int arr[N + 5][N + 5];
int id[N + 5];
int mark[N + 5];
int occ[N + 5];

vector<int> who[N + 5];
priority_queue<pair<int,int> > pq;

void hora(int tc) {
	int n, m;
	cin>>n>>m;
	for(int i = 1;i <= n;i++) {
		for(int j = 1;j <= m;j++) cin>>arr[i][j];
		id[i] = 2;
		occ[arr[i][1]]++;
		who[arr[i][1]].pb(i);
	}
	int result = 0;
	for(int i = 1;i <= m;i++) {
		pq.push({occ[i], i});
		result = max(result, occ[i]);
	}
	while(!pq.empty()) {
		while(!pq.empty() && (mark[pq.top().S ]== 1 || occ[pq.top().S] != pq.top().F)) pq.pop();
		if(!pq.empty()) {
			int idx = pq.top().S;
			pq.pop();
			mark[idx] = 1;
			for(auto x: who[idx]) {
				for( ; id[x] <= m; ) {
					int val = arr[x][id[x]];
					id[x]++;
					if(mark[val] == 1) continue;
					who[val].pb(x);
					occ[val]++;
					pq.push({occ[val], val});
					break;
				}
			}
			while(!pq.empty() && (mark[pq.top().S ]== 1 || occ[pq.top().S] != pq.top().F)) pq.pop();
			if(pq.empty()) break;
			result = min(result, pq.top().F);
		}
	}
	cout<<result<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


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


class Program {


	static void Main(string[] args) {

		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res="";
		//int res = 0; ;
		//int t = int.Parse(Console.ReadLine());
		//string str = Console.ReadLine();
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int n = int.Parse(Console.ReadLine());
		//string res="";
		int n = int.Parse(Console.ReadLine());
		string str = Console.ReadLine();

		int res = str.Length;
		int now=0;

		for ( int i = 0; i < str.Length; i++ ) {
			if ( str[i] == '.' ) { now++; }
		}
		res = now;

		for ( int i = 0; i < str.Length; i++ ) {
			if ( str[i] == '.' ) { now--; }
			if ( str[i] == '#' ) { now++; }
			res = Math.Min(res, now);

		}



			Console.WriteLine(res);


		return;
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}

}

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

const int mod=998244353;
int n,k;
ll dp[(int)1e6+5];

int main()
{
    cin>>n>>k;
    vector<int>l(k),r(k);
    for(int i=0;i<k;i++)
    {
        cin>>l[i]>>r[i];
    }
    vector<ll>ans(n+1);

    dp[0]=1,ans[0]=0;

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<k;j++)
        {
            if(i-r[j]>=0)
                dp[i]+=(ans[i-l[j]+1]-ans[i-r[j]])%mod;
            else if(i-l[j]>=0)
                dp[i]+=(ans[i-l[j]+1]-ans[0])%mod;
        }
        ans[i+1]+=(ans[i]+dp[i])%mod;
    }
    dp[n-1]=dp[n-1]%mod;
    if(dp[n-1]<0)
        dp[n-1]+=mod;

    cout<<dp[n-1]<<"\n";


}


Measured memory_bytes: 6488
import sys
input = lambda: sys.stdin.readline().rstrip() 
def main():
    moji=input()
    cycle=int(input())
    flont_or_back=0
    flont=""
    back=""
    for i in range(cycle):
        line=input()
        if line[0]=="1":
            flont_or_back+=1
        else:
            fi=line[2]
            ci=line[4]
            if flont_or_back%2==0:
                if fi=="1":
                    flont+=ci
                else:
                    back+=ci
            else:
                if fi=="1":
                    back+=ci
                else:
                    flont+=ci
    flont=flont[::-1]
    moji=flont+moji+back
    if flont_or_back%2==0:
        print(moji)
    else:
        print(moji[::-1])
    

if __name__ == '__main__':
    main() 
  


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

int main(){
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif

	int s,w;
	cin >> s >> w;
	if(w>=s){
		cout << "unsafe";
	}
	else{
		cout << "safe";
	}
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 2e5 +5;
const LL mm =  998244353;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

LL po(LL a, LL n){
	if(n==0) return 1;
	LL an = po(a,n/2);
	an = (an*an)%mm;
	if(n&1) an = (an*a)%mm;
	return an;
}

LL f[MAXN], fi[MAXN];

LL ncr(LL n, LL m){
	LL aa =  (f[n]*fi[n-m])%mm;
	aa = (aa*fi[m])%mm;
	return aa;
}

int main(){
  fio();
  LL n,m; cin>>n>>m;
  LL k; cin>>k;
  f[0] = 1;
  fi[0] = 1;
  for1(i,n+10){
  	f[i] = (i*f[i-1])%mm;
  	fi[i] = po(f[i],mm-2);
  }
  LL an = 0;
  for(LL x = 0; x<=k; x++){
  	LL aa = po(m-1, n-1-x);
  	aa = (ncr(n-1,x)*aa)%mm;
  	an = (an + aa)%mm;
  }
  an = (an*m)%mm;
  cout<<an<<endl;
  return 0;
}

Measured memory_bytes: 6780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
bool win[maxn];
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, k; cin >> n >> k;
    int r, s, p; cin >> r >> s >> p;
    string t; cin >> t;
    int res = 0;
    for (int i = 0; i < k; ++i) {
        win[i] = 1;
        if (t[i] == 'r') res += p;
        else if (t[i] == 's') res += r;
        else res += s;
    }
    for (int i = k; i < n; ++i)
        if (!win[i - k] || (win[i - k] && t[i - k] != t[i])) {
            win[i] = 1;
            res += (t[i] == 'r'? p: t[i] == 's'? r: s);
        }
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define VI vector<int>
#define VII vector<vector<int>>
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)


int main(){
    int N; cin>>N;
    int ans = 111;
    for(int i=222;i<N+111;i+=111) ans = i;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
//coded b vishal mourya - the legendary coder
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define f(a,b) for(ll i = a ; i < b ; i++ )
#define fj(a,b) for(ll j = a ; j < b ; j++ )
#define fk(a,b) for(ll k = a ; k < b ; k++ )
#define fasthoja ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(void){
    fasthoja;
    ll t; cin >> t;
    ll cnt = 0;
    // ll kit = 0;
    while(t--) {
        // if(  )
        ll a,b; cin >> a >> b;
        
        if( a == b ) {
            cnt++;
            // kit++;
        }
        else {
            if( cnt >= 3 )
                break;
            cnt = 0;
        }
            
    }
    
    if( cnt >= 3 ) cout << "Yes\n";
    else cout << "No\n";

 return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007, INF = 1111111111;
const double EPS = 1e-9;


int main() {

	cin.tie(0);

	int n;
	cin >> n;

	vector<lint> a(n);
	FOR(i, 0, n) cin >> a[i];
	FOR(i, 1, n) a[i] = a[i - 1] + a[i];

	for (const auto &ele : a) DMP(ele);

	lint tmp1 = 0, tmp2 = 0, ans1 = 0, ans2 = 0;

	FOR(i, 0, n) {

		if (i % 2 == 0) {
			if (a[i] + tmp1 >= 0) {
				ans1 += a[i] + tmp1 + 1;
				tmp1 -= a[i] + tmp1 + 1;
			}
			if (a[i] + tmp2 <= 0) {
				ans2 -= a[i] + tmp2 - 1;
				tmp2 -= a[i] + tmp2 - 1;
			}
		}
		else {
			if (a[i] + tmp1 <= 0) {
				ans1 -= a[i] + tmp1 - 1;
				tmp1 -= a[i] + tmp1 - 1;
			}
			if (a[i] + tmp2 >= 0) {
				ans2 += a[i] + tmp2 + 1;
				tmp2 -= a[i] + tmp2 + 1;
			}
		}
	}

	cout << min(ans1,ans2);

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int N, A, B, D, judge = 0, a[100005], M, i;
long long Ans;
string S;


int main() {
	int K;
	cin >> N >> K;

	A = N - K;

	Ans = A;

	if (K > 1)
		cout << Ans << endl;
	else
		cout << 0 << endl;

	return 0;
}


Measured memory_bytes: 256
function Main(input){
  input = input.trim().split(' ').map(x=>parseInt(x));
  for (let i=0;i<5;i++){
    if (input[i] === 0){
      var ans = i+1;
      break;
    }
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <sys/mman.h>
#include <unistd.h>
typedef long long lint;
const int N=1e5+5;
const int mod=1e9+7;
int m,n,q;

namespace IO{
	char *ibuf;
	struct _Init{
		_Init(){ibuf=(char*)mmap(0,lseek(0,0,SEEK_END),PROT_READ,MAP_PRIVATE,0,0);}
	}_init;
	inline int nxi(){
		int x=0;
		char c;
		while((c=*ibuf++)>'9'||c<'0');
		while(x=x*10-48+c,(c=*ibuf++)>='0'&&c<='9');
		return x;
	}
}
using IO::nxi;

struct mtrx{
	int n[3][3];

	friend inline mtrx operator * (const mtrx &a,const mtrx &b){
		mtrx c;
		for(int i=0; i<3; ++i){
			for(int j=0; j<3; ++j){
				lint tmp=0;
				for(int k=0; k<3; ++k){
					tmp+=(lint)a.n[i][k]*b.n[k][j];
				}
				c.n[i][j]=tmp%mod;
			}
		}
		return c;
	}
}nxt_0[30],nxt_1;

struct vec{
	int n[3];

	vec operator * (const mtrx &b) const{
		vec c;
		c.n[0]=((lint)n[0]*b.n[0][0]+(lint)n[1]*b.n[1][0]+(lint)n[2]*b.n[2][0])%mod;
		c.n[1]=((lint)n[0]*b.n[0][1]+(lint)n[1]*b.n[1][1]+(lint)n[2]*b.n[2][1])%mod;
		c.n[2]=((lint)n[0]*b.n[0][2]+(lint)n[1]*b.n[1][2]+(lint)n[2]*b.n[2][2])%mod;
		return c;
	}
};

inline int hbit(int x){
	int ans=0;
	for(int i=16; i; i>>=1){
		if(x>>i) x>>=i,ans+=i;
	}
	return ans;
}

void build_mtrx(){
	nxt_0[0].n[0][0]=1,nxt_0[0].n[0][1]=2,nxt_0[0].n[0][2]=1;
	nxt_0[0].n[1][0]=0,nxt_0[0].n[1][1]=1,nxt_0[0].n[1][2]=1;
	nxt_0[0].n[2][0]=1,nxt_0[0].n[2][1]=2,nxt_0[0].n[2][2]=2;
	nxt_1.n[0][0]=1,nxt_1.n[0][1]=2,nxt_1.n[0][2]=1;
	nxt_1.n[1][0]=0,nxt_1.n[1][1]=1,nxt_1.n[1][2]=1;
	nxt_1.n[2][0]=0,nxt_1.n[2][1]=0,nxt_1.n[2][2]=1;
	for(int i=1; i<30; ++i){
		nxt_0[i]=nxt_0[i-1]*nxt_0[i-1];
	}
}

inline void jmp(vec &dp,int len){
	for(int i=hbit(len); ~i; --i){
		if(len>>i&1) dp=dp*nxt_0[i];
	}
}

int main(){
	m=nxi(),n=nxi();
	build_mtrx();
	vec dp=(vec){{1,0,0}};
	for(int lst=-1,i=1; i<=n; ++i){
		int x=nxi();
		jmp(dp,x-lst-1);
		dp=dp*nxt_1;
		if(i==n) jmp(dp,m-x-1);
		lst=x;
	}
	if(!n) jmp(dp,m);
	printf("%d\n",dp.n[2]);
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
C - Flip,Flip, and Flip......
https://beta.atcoder.jp/contests/abc090/tasks/arc091_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(N, M):
    if N == 1:
        if M == 1:
            return 1
        else:
            return M - 2
    if M == 1:
        return N - 2

    return (M - 2) * (N - 2)



def main(args):
    N, M = map(int, input().split())
    ans = solve(N, M)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

int main(){
    int A, B, C;
    int X, Y, money, money2;

    cin >> A >> B >> C >> X >> Y;

    if((A + B) > C*2){
        if(X < Y){
            money = X*C*2 + (Y - X)*B;
            money2 = Y*C*2;
        }else{
            money = Y*C*2 + (X - Y)*A;
            money2 = X*C*2;
        }
    }else{
        money = A*X + B*Y;
        money2 = money;
    }
    if(money < money2){
        cout << money << endl;
    }else{
        cout << money2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
s = list(input())
l = len(s)
s.append("?")
ans = 0
w = "!"
x = 0
for i in range(l):
    if x == 1:
        x = 0
    elif s[i] == w:
        ans += 1
        x = 1
        w = s[i] + s[i + 1]
        if i == l - 1:
            ans -= 1
    else:
        ans += 1
        w = s[i]
print(ans)

Measured memory_bytes: 10600
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
xyc = [list(map(int,input().split())) for nesya in range(m)]
cheap = min(a)+min(b)
for hoge in xyc:
  ch = a[hoge[0]-1]+b[hoge[1]-1]-hoge[2]
  cheap = min(ch,cheap)
print(cheap)

Measured memory_bytes: 38444
#include"bits/stdc++.h"
using namespace std;

void Main() {
  string s;
  cin >> s;
  vector<char> a, b;
  int now = 0;
  for (int i = 0; i < s.size(); i++) {
    a.push_back(now);
    b.push_back(1 - now);
    now = 1 - now;
  }

  int aa = 0, bb = 0;
  for (int i = 0; i < s.size(); i++) {
    if (a[i] != s[i] - '0') aa++;
    if (b[i] != s[i] - '0') bb++;
  }

  cout << min(aa, bb) << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define   PI    acos(-1)
int fx[]= {0,1,0,-1};
int fy[]= {-1,0,1,0};
#define mx 100005
ll dp[mx];
int main()
{
    ll n,i,j,k;
    cin>>n>>k;
    ll a[n];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(i=1;i<=mx;i++)dp[i]=INT_MAX;
    for(i=0; i<n; i++)
    {
        for( j=i+1;j<=i+k;j++){
            if(j<n){
                dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
            }
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}




Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n;
  string s;
  cin>>n>>s;
  long long int rightw=0;
  long long int rightr=0;
  bool w=false;
  long long int ans=0;
  for(long long int i=0; i<n; i++){
    if(s[i]=='R'){
      rightr++;
    }else{
      rightw++;
    }
  }
  for(long long int i=0; i<n; i++){
    if(s[i]=='W'){
      if(rightr>0){
        ans++;
        rightr--;
      }
    }else{
      rightr--;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3676
// https://beta.atcoder.jp/contests/abc077
// status:
// tag:

#define SUBMIT
//#define DEBUG

#include <utility>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <queue>
#include <numeric>
#include <limits>
#include <cmath>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

int N;

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    auto program_input = std::string(R"(eye
eel
)");
    stringstream stream(program_input);
#endif
    string s1, s2;
    stream >> s1 >> s2;

    reverse(s1.begin(), s1.end());
    if (s1 == s2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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


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

    for (int i = 0; i < n; i++) {
        if (a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0) {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
hl = list(map(int, input().split()))
maximum = 0
count = 0
for i in range(n-1):
    if hl[i] >= hl[i + 1]:
        count += 1
    else:
        if count > maximum:
            maximum = count
        count = 0
    if i == n-2 and count > maximum:
        maximum = count
print(maximum)

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	string s, t;
	cin>>s>>t;
	for (int i = 0; i < s.size(); i++)
		cout<<s[i]<<t[i];
}


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

cnt=0
for i in range(n):
  x=a[i]
  y=b[i]
  if x>y:
    cnt-=x-y
  elif x<y:
    cnt+=(y-x)//2

print('Yes' if cnt>=0 else 'No')

Measured memory_bytes: 4596
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

int main(){
    lli ans=0,n,a,b;
    string s;
    lli i,j;
    cin>>n>>a>>b;
    if((n==0)||(a>b)){
        ans=0;
    }
    else{
        if(n==1){
            if(a==b){
                ans+=1;
            }
        }
        else{
            ans=(a+(n-1)*b)-(a*(n-1)+b)+1;
        }
    }
    cout<<ans<<endl;
}


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

int main()
{
	string S;

	cin >> S;

	long long int ans = 0,s = S.size();

	ans += (s-1) * 9;

	if (s > 1) {
		ans += S[0] - '0';
		for (int i = 1; i < s; i++) {
			if (S[i] != '9') {
				ans--;
				break;
			}
		}
	}

	if (s == 1)ans = S[0] - '0';

	cout << ans << endl;


	return 0;
}

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

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

int dfs(vector<vector<int>> &_tree, vector<long long> &_count, int _node, int _parent){

    vector<int> _nodes = _tree.at(_node);
    for (auto next_v : _nodes){
        if(next_v == _parent){
            continue;
        }
        _count.at(next_v) += _count.at(_node);
        dfs(_tree, _count, next_v, _node);
    }
    return 0;
}


int main()
{
    int N, Q;
    cin >> N >> Q;
    vector<vector<int>> tree(N + 1);
    rep(i, N-1){
        int a, b;
        cin >> a >> b;
        tree.at(a).push_back(b);
        tree.at(b).push_back(a);
    }

    vector<long long> count;
    count.resize(N + 1);
    rep(i, Q){
        int p, x;
        cin >> p >> x;
        count.at(p) += x;
    }

    dfs(tree, count, 1, 0);
    for (int i = 1; i < N + 1;i++){
        cout << count.at(i) << endl;
    }
}



Measured memory_bytes: 39976
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>

using namespace std;

int main(void) {
	string S;
	int w;
	cin >> S >> w;
	for (int i = 0; i < S.length(); i += w) cout << S[i];
	cout << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
int N;
vector<int> G[100005];
int color[100005];
unordered_map<string, int> M;
int color_count;

void dfs(int now, int c)  {
  int n_color = 0;
  rep(j, G[now].size()) {
    int next = G[now][j];
    int a = now, b =next;
    if (now > next) swap(a, b);
    string t = to_string(a)+'-'+to_string(b);
    int idx = M[t];
    if (color[idx] >= 0) continue;
    if (n_color==c) n_color++;
    if (n_color>=color_count) n_color=0;
    color[idx] =n_color;
    dfs(next, n_color);
    n_color++;
  }
}

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

  cin >> N;
  int a,b;
  rep(i, N-1) {
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
    string t = to_string(a)+'-'+to_string(b);
    M[t]=i;
  }

  rep(i, N) {
    int d = G[i].size();
    color_count = max(color_count, d);
  }
  fill(color, color+N, -1);
  dfs(0, 0);
  cout << color_count << "\n";
  rep(i, N-1) cout << color[i]+1 << "\n";
  return 0;
}


Measured memory_bytes: 24332
#include<stdio.h>
int main()
{
    int a,i,count=0;
    float n;
    scanf("%d",&a);
    for(i=1; i<=a; i++)
    {
        if(i%2!=0)
        {
            count++;
        }

    }
    n=count/(float)a;
    printf("%.9f\n",n);


    return 0;
}



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

int main(){
  int n;
  cin>>n;
  vector<int> A(n);
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  int sum=0;
  for(int i=0;i<n;i++){
    int kk=A[n-1-i];
    if(i%2==0){sum+=kk;}
    else{sum-=kk;}
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n],b[n+1];
    memset(b,0,sizeof(b));
    for(int i=0;i<n;i++){
    	cin>>a[i];
    	b[a[i]]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
    	ans+=(b[i]-1)*b[i]/2;
    }
    for(int i=0;i<n;i++){
    	cout << ans+1-b[a[i]]<<endl;
    }
    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h> 
using namespace std; 
#include <stack>
#define ll long long 
const ll INF=1000000007;
#define vecpair vector<pair <ll,ll> >
#define pb push_back
#define mp make_pair
#define vel vector<ll>
bool prime[100001];
void SieveOfEratosthenes() 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true.  
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=100000; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=100000; i += p) 
                prime[i] = false; 
        } 
    } 
  
    
} 
ll bs(vel a,ll s,ll e,ll x){
	int l=s;
	int h=e;
	int m;
	while(l<=h){
		m=(l+h)/2;
		if(a[m]>x) h=m-1;
		else if(a[m]<x) l=m+1;
		else return m;
		}
		return -1;
	}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
SieveOfEratosthenes();
ll test;
test=1;
while(test--){
ll n,d;
cin>>n>>d;
ll a[n][2];
for(ll i=0;i<n;i++){
	cin>>a[i][0]>>a[i][1];
	}
	ll ans=0;
	for(ll i=0;i<n;i++){
		if(a[i][0]*a[i][0]+a[i][1]*a[i][1]<=d*d) ans++;
		}
		cout<<ans;
}
}


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

int main() {
    string S;
    cin >> S;
    REP(i,S.size()){
        if (i%2==0) {
            cout << S[i];
        }
    }
    cout << endl;
    return 0;
}


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

typedef long long ll;

int main()
{
    int n, k;
    cin >> n >> k;

    for (int i = 1; i <= n; i++) {
        int tmp;
        cin >> tmp;
    }

    n--, k--;
    cout << (n + k-1) / k; // n/k  re ceil() korlam
}


Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let (n, m) = i.read2::<usize, usize>();
    let mut xyz = Vec::new();
    for _ in 0..n {
        xyz.push(i.read3::<i64, i64, i64>());
    }
    writeln!(o, "{}", solve(&xyz, m)).unwrap();
}
fn solve(xyz: &[(i64, i64, i64)], m: usize) -> i64 {
    let mut result = 0;
    let mut rs = Vec::new();
    for &s0 in &[1, -1] {
        for &s1 in &[1, -1] {
            for &s2 in &[1, -1] {
                rs.clear();
                for &xyz in xyz {
                    rs.push(xyz.0 * s0 + xyz.1 * s1 + xyz.2 * s2);
                }
                rs.sort();
                rs.reverse();
                result = max(result, rs.iter().take(m).sum());
            }
        }
    }
    result
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        {$f:ident($($v:ident: $t:ident),*)} => {
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                $(
                    let $v = i.next().unwrap().parse().ok().unwrap();
                )*
                ($($v),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(v1: T1, v2: T2) }
        fn_read! { read3(v1: T1, v2: T2, v3: T3) }
    }
}


Measured memory_bytes: 4352
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    a, b, c = list(map(int, readline().split()))
    if a == b != c or a == c != b or b == c != a:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

L_max = 0
R_min = N
for L, R in LR:
    L_max = max(L_max, L)
    R_min = min(R_min, R)

ans = 0
if L_max <= R_min:
    ans = R_min - L_max + 1

print(ans)

Measured memory_bytes: 27396
e=enumerate
(n,t),*g=[list(map(int,t.split()))for t in open(0)]
d=[0]
g.sort()
dp=[]
d=[0]*t
for a,b in g:
  p=d[:]
  for i in range(a,t):
    v=d[i-a]+b
    if v>p[i]:p[i]=v
  dp+=p,
  d=p
a=m=0
for(*_,v),(_,w)in zip(dp[-2::-1],g[::-1]):
  if w>m:m=w
  if v+m>a:a=v+m
print(a)

Measured memory_bytes: 121052
// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	int n;
	cin>>n;
	int h[n+1];
	for(int i=1;i<=n;i++){
		cin>>h[i];
	}
	int dp[n+1];
	dp[n]=0;
	int mx=0;
	for(int i=n;i>=1;i--){
		if(h[i-1]>=h[i]){
			dp[i-1]=dp[i]+1;
		}
		else {
			dp[i-1]=0;
		}
		mx = max(mx,dp[i]);
	}
	/*for(int i=0;i<=n;i++){
		cout<<dp[i]<<" ";
	}*/
	//cout<<endl;
	cout<<mx<<endl;
	
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
   int ac =0 ,wa =0 ,tle =0,re =0;
    while(n--){
        string s;
        cin>>s;
        if(s=="AC")ac++;
        else if(s=="TLE")tle++;
        else if(s=="WA")wa++;
        else re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
}

Measured memory_bytes: 3600
fn main() {
    let mut input = String::new();
    let _ = std::io::stdin().read_line(&mut input).unwrap();
    let input = input
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<u32>().unwrap())
        .collect::<Vec<_>>();

    let k = input[0] + 1;
    let s = input[1];
    let mut count = 0;

    for x in 0..k {
        for y in 0..k {
            let t = x + y;
            if t > s {
                break;
            }
            if (s - t) < k {
                count += 1;
            }
        }
    }

    println!("{}", count);
}

Measured memory_bytes: 4352
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<stdio.h>

int main(){
    int L;
    int R;
    int d;
    int ans=0;

    scanf("%d %d %d",&L,&R,&d);

    for(int i = L; i <= R; i++)
    {
        if(i%d == 0)
            ans++;
    }

    printf("%d",ans);
    
}

Measured memory_bytes: 1728
n = int(input())
kane = [input().split() for i in range(n)]
sum = 0
for i in range(n):
    if kane[i][1] == "JPY":
        tmp = float(kane[i][0])
        sum += tmp
    else:
        tmp = float(kane[i][0])
        sum += tmp * 380000.0
print(sum)

Measured memory_bytes: 3060
/*
 * @Filename: 
 * @Author: shifaqiang
 * @Email: 14061115@buaa.edu.cn
 * @Github: https://github.com/luoboganer
 * @Date: 2020-07-12 00:38:24
 * @LastEditors: shifaqiang
 * @LastEditTime: 2020-07-12 00:42:03
 * @Software: Visual Studio Code
 * @Description: 
 */

#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
    int n;
    cin >> n;
    vector<int> heights(n), dp(n, 0);
    for (auto i = 0; i < n; i++)
    {
        cin >> heights[i];
    }
    dp[1] = abs(heights[0] - heights[1]);
    for (auto i = 2; i < n; i++)
    {
        dp[i] = min(abs(heights[i] - heights[i - 1]) + dp[i - 1], abs(heights[i] - heights[i - 2]) + dp[i - 2]);
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 4004
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int main() {
  int n;cin >> n;
  vector<int> a(n),b(n),c(n);
  for(int i=0; i<n; ++i) cin >> a[i];
  for(int i=0; i<n; ++i) cin >> b[i];
  for(int i=0; i<n-1; ++i) cin >> c[i];
  int prev = -10;
  int satis = 0;
  for(int i=0; i<n; ++i){
    satis += b[a[i]-1];
    if(a[i] ==prev+1){
      satis += c[prev-1];
    }
    prev = a[i];
  }
  cout << satis << endl;
  return 0;
}


Measured memory_bytes: 256
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

#setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')
MOD = 10**9 + 7

def main():
	n = int(rl())
	A = list(rli())
	psums = [A[0]]
	ans = 0
	for i in range(1, n):
		psums.append(psums[-1] + A[i])
	for j in range(1, n):
		ans += psums[j-1] * A[j]
		ans %= MOD 
	print(ans)
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 112632
#include<bits/stdc++.h>
using namespace std;
int main () {
  int K, N;
  cin >> K >> N;
  vector<int>A(N);
  for (int i = 0; i < N; i ++) cin >> A[i];
  int ans = A[N - 1] - A[0];
  for (int i = 0; i < N - 1; i ++) {
    int b = A[i + 1] - A[i];
    b = K - b;
    if (ans > b) ans = b;
  }
  cout << ans << endl;
}


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

int main()
{
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> req(M);
  for (int i = 0; i < M; i++)
  {
    int a, b;
    cin >> a >> b;
    req[i].first = b;
    req[i].second = a;
  }
  sort(req.begin(), req.end());

  int ans = 1;
  int t = req[0].first; 
  for (int i = 1; i < M; i++)
  {
    if (t <= req[i].second)
    {
      ans++;
      t = req[i].first;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define vi vector<int>
#define rep(i, xtz, n) for(int i=xtz; i<n; i++)

using namespace std;

vector<int> dp(1e5+1, 1e9+9);

int main(){
    //freopen("i.in", "r", stdin);
    int n; cin>>n;
    int k; cin>>k;
    vector<int> h(n);
    rep(i, 0, n) cin>>h[i];
    dp[0]=0;
    rep(i, 0, n){
        rep(j, 1, k+1){
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define C(n,m) ((LL)fac[n]*ifac[m]%mo*ifac[(n)-(m)]%mo)

const int maxn=3010;
const int mo=1e9+7;

int n,m,m0,l[maxn],r[maxn];
int fac[6010],ifac[6010],dp[maxn][maxn];
bool s[maxn];

int power(int x,int k)
{
	int res=1;
	while (k)
	{
		if (k&1) res=(LL)res*x%mo;
		x=(LL)x*x%mo;
		k>>=1;
	}
	return res;
}

int main()
{
#ifdef h10
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
	int i,j;
	char c;

	fac[0]=1;
	for (i=1;i<=6000;i++)
		fac[i]=(LL)fac[i-1]*i%mo;
	ifac[6000]=power(fac[6000],mo-2);
	for (i=6000;i>=1;i--)
		ifac[i-1]=(LL)ifac[i]*i%mo;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++)
	{
		c=getchar();
		while (c!='0'&&c!='1') c=getchar();
		s[i]=c=='1';
	}
	for (i=1;i<=m;i++)
	{
		scanf("%d%d",&l[i],&r[i]);
		if (r[i]>r[m0])
			m0++,l[m0]=l[i],r[m0]=r[i];
	}
	m=m0;
	l[m+1]=r[m+1]=2333333;

	int p=1;
	dp[1][0]=1;
	for (i=1;i<=m;i++)
	{
//		printf("i=%d\n",i);
		int cnt=0;
		p=max(p,l[i]);
		while (p<=r[i]) cnt+=s[p++];
		for (j=0;j<=n;j++) if (dp[i][j])
		{
			int R=max(0,r[i]-l[i+1]+1);
			int L=r[i]-l[i]+1-R;
			for (int k=max(0,cnt+j-L);k<=R&&k<=cnt+j;k++)
				(dp[i+1][k]+=(LL)dp[i][j]*C(L,cnt+j-k)%mo)%=mo;
		}
//		puts(""); puts("");
	}
	printf("%d\n",dp[m+1][0]);
}


Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
void exgcd(ll a,ll b,ll &x,ll &y){
    if(b==0){x=1;y=0;return;}
    exgcd(b,a%b,y,x);y-=a/b*x;
}
int main(){
	ll n;cin>>n;n*=2;
    ll ans=n-1;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0&&__gcd(i,n/i)==1){
			ll x,y;
			exgcd(i,n/i,x,y);
			if(x>0&&i*x-1>0)
				ans=min(ans,i*x-1);
			if(x<0&&i*(-x)>0)
				ans=min(ans,i*(-x)); 
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 3728
//author: Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main()
{
    fastio;
    ll a=0,b=0,c=0;
    cin>>a>>b>>c;
    if(a+b+c>=22) cout<<"bust";
    else cout<<"win";
    return 0;
}


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

using namespace std;

int main(){
  while(true){
    int x,y,s;
    cin>>x>>y>>s;
    int ans=0;
    if(x==0) break;
    for(int i=1;i*(100+x)/100<s;i++){
      for(int j=1;i*(100+x)/100+j*(100+x)/100<=s;j++){
        if (i*(100+x)/100+j*(100+x)/100==s){
          ans=max(i*(100+y)/100+j*(100+y)/100,ans);
            }
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int k, a, b;
    cin >> k >> a >> b;
    for(int i=a;i<=b;++i) {
        if(i % k == 0) {
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";
    return 0;
}


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

int main() {
  int n;
  string s;
  cin >> n;

  int p = 0, w = 0, g = 0, y = 0, c = 0;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s == "P") {
      if (++p == 1) {
        c++;
      }
    } if (s == "W") {
      if (++w == 1) {
        c++;
      }
    } if (s == "G") {
      if (++g == 1) {
        c++;
      }
    } if (s == "Y") {
      if (++y == 1) {
        c++;
      }
    }
  }
  
  if (c == 3) {
    cout << "Three" << endl;
  } else if (c == 4) {
    cout << "Four" << endl;
  }
}

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

using ll = long long;
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	vector<ll> a(n);
	ll tot = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		tot += a[i];
	}
	ll best = 1e18;
	ll cur = 0;
	for(int i = 0; i < n; i++){
		cur += a[i];
		best = min(best, max(tot-cur, cur) - min(tot-cur, cur));
	}
	cout << best << '\n';
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int d[] = {5, 2};
bool msN[300000];

bool checkMSN(int x) {
	int k = 0;
	for (int i = 6; i < x; k = (k + 1) % 2, i += d[k]) {
		if (x % i == 0) {
			return false;
		}
	}
	msN[x] = true;
	return true;
}

int main() {
	int n;
	fill(msN, msN + 300000, false);
	while (cin >> n, n != 1) {
		cout << n << ":";
		int k = 0;
		int outCount = 0;
		for (int i = 6; i <= n; k = (k + 1) % 2, i += d[k]) {
			if (n % i == 0 && (msN[i] || checkMSN(i))) {
				cout << " " << i;
				outCount++;
			}
		}
		if (outCount == 0) cout << " " << n << endl;
		else cout << endl;
	}
}

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

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

#define F first
#define S second
#define PB push_back
#define MP make_pair

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

int main(){
	int n,w;
	cin >> n >> w;
	int weight[n];
	ll value[n];
	FOR(i,n) cin >> weight[i] >> value[i];
	ll sol[n][w+1];// sol[i][j] = value can be taken with first i+1 objects with weight condition j+1
	//sol[i][j]= v[i]+sol[i-1][j-w[i]] , sol[i-1][j]
	//sol[0][k]=if first object has weight <=k+1 then v[0]
	FOR(i,n) sol[i][0]=0;
	for(int i=1;i <= w;i++) sol[0][i]=(int) ((weight[0]<=i))?value[0] : 0;
	for(int i=1; i < n; i++){
		for(int j=1;j <= w;j++){
			if(j >=weight[i]) sol[i][j]=max(value[i]+sol[i-1][j-weight[i]] , sol[i-1][j]);
			else sol[i][j]=sol[i-1][j];
		}
	}
	cout << sol[n-1][w];
	return 0;
}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define ll long long int
using namespace std;
int main()
{
    ll tc;

    ll a=0,b=0,c=0,n,x,y,z,cnt=0,sum=0;
    string str;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if(s=="AC")a++;
        else if(s=="WA")b++;
        else if(s=="TLE")c++;
        else if(s=="RE")cnt++;
    }
    cout<<"AC x "<<a<<endl;
cout<<"WA x "<<b<<endl;
cout<<"TLE x "<<c<<endl;
cout<<"RE x "<<cnt<<endl;



}




Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pe;
int main(void)
{
	int i,j,k,n;

	while(1) {
		cin>>n;	
		vector<pair<int,int> > pp(n);
		if(n==0) break;
		for(i=0;i<n;i++) {
			int a,b;
			cin>>pp[i].second>>a>>b;
			pp[i].first=a+b;
		}
		sort(pp.begin(),pp.end());
		cout<<pp[n-1].second<<" "<<pp[n-1].first<<endl;
	}
}

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

int main(){
    int n;
    cin>>n;
    int r[200010];
    for(int i=0;i<n;i++)cin>>r[i];
    int maxv=1e9*(-1);
    int minv=r[0];
    for(int i=1;i<n;i++){
        maxv=max(maxv,r[i]-minv);
        minv=min(minv,r[i]);
    }
    cout<<maxv<<endl;
    return 0;
}


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

using namespace std;

int main()
{
    char str[106];

    cin>>str;

    int n = strlen(str) , i;

    int cnt[26] = {0} ;

    for(i = 0 ; i < n ; i++){
        cnt[str[i]-'a']++;
    }

    bool ok = 1;

    for(i = 0 ; i < 26 ; i++){
        if(cnt[i]%2 != 0){
            ok = 0;
            break;
        }
    }

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

    return 0;

}


Measured memory_bytes: 3632
N = int(input())
li = []
for i in range(N):
    si, pi = input().split()
    pi = int(pi)
    li +=[ [i+1, si, pi]]
li.sort(key=lambda x:x[2], reverse=True)
li.sort(key=lambda x:x[1], reverse=False)
for j in li:
    print(j[0])

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

#define ll long long
#define endl "\n"

const ll lmt=1e5+5;
vector<pair<ll,bool>>adj[lmt];
ll dis[lmt],k;

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

	cin>>k;
	for(ll i=0;i<lmt;i++){
		dis[i]=1e9;
	}
	dis[1]=0;
	for(ll i=1;i<k;i++){
		ll plus=(i+1)%k, mul=(i*10)%k;
		//cout<<i<<" "<<plus<<" "<<mul<<endl;
		if(i!=plus){
			adj[i].push_back(make_pair(plus,1));
			//adj[plus].push_back(make_pair(i,1));
		}
		if(i!=mul){
			adj[i].push_back(make_pair(mul,0));
			//adj[mul].push_back(make_pair(i,0));
		}
	}
	deque<ll>q;
	q.push_back(1);
	while(!q.empty()){
		ll u=q.back();
		q.pop_back();
		for(pair<ll,ll>v:adj[u]){
			if(dis[v.first]>dis[u]+v.second){
				dis[v.first]=dis[u]+v.second;
				if(v.second==0){
					q.push_front(v.first);
				}else{
					q.push_back(v.first);
				}
			}
		}
	}
	cout<<dis[0]+1<<endl;
}

Measured memory_bytes: 11832
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll N,T;
    cin>>N>>T;
    v c(N),t(N);
    rep(i,0,N){
        cin>>c[i]>>t[i];
    }

    ll mincost = INF;
    rep(i,0,N){
        if(t[i] <= T){
            mincost = min(mincost, c[i]);
        }
    }
    if(mincost == INF)cout<<"TLE";
    else cout<< mincost;
    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    
    l, r = map(int, input().split())
    if r - l >= 2019:
        ans = 0
    else:
        ans = 100000
        for i in range(l, r):
            for j in range(i + 1, r + 1):
                ans = min(ans, i * j % 2019)
    
    print(ans)
    
    return 0

main()

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for(int i=0; i<n; i++) {
            list.add(sc.nextInt());
        }
        for(int i=0; i<n; i++) {
            h -= list.get(i);
        }
        if(h <= 0) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 59752
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
const double pi = acos(-1);
using namespace std;

int main() {
    IOS
    int n;
    cin >> n;
    cout << (n-2)*180 << endl;
    return 0;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

type Status struct {
	val string
	len int
}

func main() {
	n := SingleInt()
	k := SingleInt()
	s := SingleStr()
	ss := make([]int, 0, n)

	now := "1"
	cnt := 0
	for i := 0; i < n; i++ {
		if string(s[i]) == now {
			cnt++
		} else {
			ss = append(ss, cnt)
			now = reverse(now)
			cnt = 1
		}
	}
	if cnt != 0 {
		ss = append(ss, cnt)
	}
	if len(ss)%2 == 0 {
		ss = append(ss, 0)
	}

	add := 2*k + 1
	ans := 0

	left := 0
	right := 0 // [left, right) leftは含むがrightは含まない
	tmp := 0   // [left, right)のsum

	sslen := len(ss)
	for i := 0; i < sslen; i += 2 {
		next_left := i
		next_right := Min(i+add, sslen)

		// 左端を移動する
		for next_left > left {
			tmp -= ss[left]
			left++
		}

		// 右端を移動する
		for next_right > right {
			tmp += ss[right]
			right++
		}

		ans = Max(tmp, ans)
	}
	fmt.Printf("%#v\n", ans)
}

func Max(nums ...int) int {
	if len(nums) == 0 {
		panic("function max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func Min(nums ...int) int {
	if len(nums) == 0 {
		panic("function min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func reverse(v string) string {
	if v == "0" {
		return "1"
	}
	return "0"
}

func SingleStr() string {
	var s string
	fmt.Scan(&s)
	return s
}

func SingleInt() int {
	var n int
	fmt.Scan(&n)
	return n
}


Measured memory_bytes: 2048
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]

place = [None]*(H*W+1)
for h in range(H):
    for w in range(W):
        place[A[h][w]] = (h, w)
place[0] = (0, 0)
dis = [[0 for _ in range((H*W)//D+1)] for _ in range(D)]
for i, (x, y) in enumerate(place):
    if i <= D:
        continue
    bx, by = place[i-D]
    dis[i%D][i//D] = dis[i%D][i//D-1] + abs(x-bx) + abs(y-by)


for l, r in LR:
    ans = dis[r%D][r//D] - dis[l%D][l//D]
    print(ans)

Measured memory_bytes: 45112