akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair
 
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
bool solve() {
    int n; cin >> n;
    vector<ll> a(n);
    for (auto &x : a) cin >> x;
    string s; cin >> s;

    reverse(all(a));
    reverse(all(s));
    ll used = 0;
    forn(i,n) {
        auto have = a[i] & ~used;
        if (!have) continue;

        //cerr << n-1-i << ' ' << have << endl;

        if (s[i] == '1') return true;
        int bit = __builtin_ctzll(have);
        forn(j,n) if (j != i && ((a[j]>>bit)&1)) {
            a[j] ^= a[i];
        }
        used |= 1LL<<bit;
    }
    return false;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int T; cin >> T;
    while (T--) {
        cout << solve() << '\n';
    }
    return 0;
}


Measured memory_bytes: 3620
N, Y = map(int, input().split())

x, y, z = -1, -1, -1

for i in range(N+1):
    for j in range(N+1):
        if i+j <= N:
            if 10000*i + 5000*j + 1000*(max(N-i-j, 0)) == Y:
                x = i
                y = j
                z = N - (i+j)
                break

print(x, y, z)

Measured memory_bytes: 3064
import math

if __name__ == '__main__':
    '''
    A: 時針の長さ
    B: 分針の長さ
    H: 何時
    M: 何分
    '''
    A, B, H, M = map(int, input().split())

    deg = (H * 30 + M * 0.5) - (360 / 60 * M)

    if deg <= 180:
        pass
    else:
        deg = 360 - deg

    rad = deg * math.pi / 180

    side = math.sqrt(A ** 2 + B ** 2 -2 * A * B * math.cos(rad))
    print(side)


Measured memory_bytes: 9460
import java.util.Scanner;

public class Main {
	
	public static boolean isPrime(int num){
	    if ( num > 2 && num%2 == 0 ) {
	        return false;
	    }
	    int top = (int)Math.sqrt(num) + 1;
	    for(int i = 3; i < top; i+=2){
	        if(num % i == 0){
	            return false;
	        }
	    }
	    return true; 
	}

	public static void main(String[] args) {
		// scan in the numbers
		Scanner sc = new Scanner(System.in);
		int listSize = sc.nextInt();
		int primeNum = 0;
		if (listSize >= 1 && listSize<= 10000) {
			for(int i = 0; i < listSize; i++) {
				int value = sc.nextInt();
				int exp = (int) Math.pow(10, 8);
				if( value >= 2 && value <= exp && isPrime(value) ) {
					primeNum++;
				}
			}
			// print the number of prime numbers in the given list
			System.out.println(primeNum);
		}
		
	}

}



Measured memory_bytes: 41244
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var N = parseInt(tmp[0], 10);
	var M = parseInt(tmp[1], 10);

    var divisors = divisor(M);
    var max = 0;
            for (var i =0;i < divisors.length;i++) {
                var d = divisors[i];
                if (M / d >= N) {
                    max = Math.max(max, d);
                }
            }

	//出力
	console.log('%d',max);
}
function divisor(n) {
        var res = [];
        for (var i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                res.push(i);
                if (n / i != i) {
                    res.push(n / i);
                }
            }
        }
        return res;
    }

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	char b;
	cin>>b;
	if(b=='A')cout<<"T"<<endl;
	if(b=='T')cout<<"A"<<endl;
	if(b=='G')cout<<"C"<<endl;
	if(b=='C')cout<<"G"<<endl;

	return 0;

}


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

static const int MAX = 20;
int c[MAX], v[MAX];

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }
    int ans = 0;
    for(int i = 0; i < (1 << n); i++){
        int xy = 0;
        for(int j = 0; j < n; j++){
            if(i >> j & 1){
                xy += v[j] - c[j];
            }
        }
        ans = max(ans, xy);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cassert>
#include<map>

using namespace std;

#define fi first
#define se second
#define rep(i,s,t) for(int i=(s),_t=(t);i<_t;++i)
#define per(i,s,t) for(int i=(t)-1,_s=(s);i>=_s;--i)
#define debug(x) cerr<<#x<<" == "<<(x)<<endl
#define bug(x) cerr<<#x<<" == "<<(x)<<" "

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

template<class T>inline void rd(T &x){
	static char c,f;
	x=0;f=1;
	while(c=getchar(),c<48)if(c=='-')f=-1;
	do x=x*10+(c&15);
	while(c=getchar(),c>47);
	x*=f;
}

template<class T>void pf(T x){
	if(x<0)putchar('-'),x=-x;
	else if(!x){putchar('0');return ;}
	static int stk[100],tp;
	for(tp=0;x;x/=10)stk[tp++]=x%10;
	while(tp)putchar(stk[--tp]^48);
}

template<class T>void ptn(T x){pf(x),putchar('\n');}
template<class T>void ptk(T x){pf(x),putchar(' ');}
template<class T>void Min(T &A,T B){if(A>B)A=B;}
template<class T>void Max(T &A,T B){if(A<B)A=B;}

const int N=55;
int cnt[2],n,P;
ll C[N][N];

int main(){
	rd(n),rd(P);
	rep(i,1,n+1){
		int x;
		rd(x);
		++cnt[x&1];
	}
	C[0][0]=1;
	rep(i,1,N){
		C[i][0]=C[i][i]=1;
		rep(j,1,i)C[i][j]=C[i-1][j]+C[i-1][j-1];
	}
	if(P==1){
		if(!cnt[1])ptn(0);
		else {
			ll ans=0,res=0;
			rep(i,0,cnt[0]+1)ans+=C[cnt[0]][i];
			for(int i=1;i<=cnt[1];i+=2)res+=C[cnt[1]][i];
			ptn(ans*res);
		}
	}else {
		ll ans=0,res=0;
		rep(i,0,cnt[0]+1)ans+=C[cnt[0]][i];
		for(int i=0;i<=cnt[1];i+=2)res+=C[cnt[1]][i];
		ptn(ans*res);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 100000

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

int main(){
    int x,t;
    cin >> x >> t;
    cout << max(x - t, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
	v, e, *L = map(int, open(0).read().split())
	g = [[] for _ in range(v)]
	deg = [0] * v
	for s, t in zip(*[iter(L)] * 2):
		g[s - 1].append(t - 1)
		deg[t - 1] += 1
	q = []
	for i, d in enumerate(deg):
		if not d:
			q.append(i)
	ans = [0] * v
	while q:
		c = q.pop(0)
		for n in g[c]:
			deg[n] -= 1
			if not deg[n]:
				q.append(n)
				ans[n] = c + 1
	print("\n".join(map(str, ans)))

if __name__ == "__main__":
	main()

Measured memory_bytes: 37488
from math import ceil, floor

N, K = map(int, input().split())

if K % 2:
    Ms = range(K, N + 1, K)
else:
    Ms = range(K // 2, N + 1, K // 2)

ans = 0
for a in Ms:
    nMin = ceil((1 + a) / K)
    nMax = floor((N + a) / K)
    ans += (nMax - nMin + 1) ** 2

print(ans)


Measured memory_bytes: 3060
#include<cstdio>
#include<stdlib.h>
using namespace std;
long long a,b,c,d;
int tt;
long long gcd(long long x,long long y)
{
	long long z=x%y;
	while (z!=0)
	{
		x=y;
		y=z;
		z=x%y;
	}
	return y;
}
int main()
{
	 scanf("%d",&tt);
	 for (int i=1;i<=tt;i++)
	 {
	 	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	 	if (a<b) printf("%s\n","No");
	 	else
	 	{
	 		if (a>c)
	 		{
	 			a-=(a-c)%b==0?((a-c)/b)*b:((a-c)/b+1)*b;
			 }
			if (a<0) {
				printf("%s\n","No");
				continue;
			}  
			if (d-b<0) printf("%s\n","No");
			else if (d==b) printf("%s\n","Yes");
			else
			{
				d-=b;
				if (b<=c) printf("%s\n","Yes");
				else
				if (b>c+d) printf("%s\n","No");
				else  
				{
					long long t=gcd(d,b);
					if (((c-a)%t==0&&c+t>=b)||(((c-a)%t!=0&&a+((c-a)/t+1)*t>=b))) printf("%s\n","Yes");
					else printf("%s\n","No");
				}
			}
		 }
	 }
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import math

A, B, X = map(int, input().split())

V = A * A * B

H = X / V * B
H2 = A * X / V 

lb = 0
ub = 90

def judge(s):
    global A
    global B
    global H

    if (B - H) * math.cos(s * math.pi/180) - A / 2 * math.sin(s * math.pi/180) >= 0:
        return True
    else:
        return False

def judge2(s):
    global A
    global B
    global H2

    if B/2 * math.cos(s * math.pi/180) - H2 * math.sin(s * math.pi/180) >= 0:
        return True
    else:
        return False

for i in range(100):
    mid = (lb + ub) / 2
    if judge(mid):
        lb = mid
    else:
        ub = mid

if H < B/2:
    print(math.atan(B/2/H2)*180/math.pi)
else:
    print(mid)



Measured memory_bytes: 3064
using System;
using System.Linq;

namespace AtCoder
{
    internal class Program
    {
        private static void Main()
        {
            var n = int.Parse(Console.ReadLine() ?? "");
            var a = (Console.ReadLine() ?? "").Split(' ').Select(long.Parse).OrderByDescending(x => x).ToArray();
            var s = 0L;
            for (var i = 1; i < n; i++) s += a[i / 2];
            Console.WriteLine(s);
        }
    }
}


Measured memory_bytes: 51704
#include <bits/stdc++.h>
using namespace std;
char a[6][6];
int b[6][6];
int main() {
  int h,w,k;
  cin >>h>>w>>k;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
      if(a[i][j]=='#')b[i][j]=1;
    }
  }
  long long kotae=0;
  for(int s=0;s<(1<<h);s++){
    for(int t=0;t<(1<<w);t++){
      int sum=0;
      for(int u=0;u<h;u++){
        for(int v=0;v<w;v++){
          if(s>>u&1 && t>>v&1)sum+=b[u][v];
        }
      }
      if(sum==k)kotae++;
    }
  }
  cout<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 3632
import sys
INPUT = sys.stdin.readline

def SINGLE_INT(): return int(INPUT())
def MULTIPLE_INT_LIST(): return list(map(int, INPUT().split()))
def MULTIPLE_INT_MAP(): return map(int, INPUT().split())
def SINGLE_STRING(): return INPUT()
def MULTIPLE_STRING(): return INPUT().split()

N, A, B , A_goal, B_goal = MULTIPLE_INT_MAP()
S = SINGLE_STRING()

def surpass():

    if '...' in S[B-2:B_goal+1]:
        return 'Yes'
    else:
        return 'No'


if '##' in S[A-1: A_goal+1] or '##' in S[B-1:B_goal+1]:
    print('No')

else:
    if A_goal < B_goal:
        print('Yes')
    else:
        print(surpass())


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  string ans = "NO";
  for (int i = 1; i <= B; i++) {
    if ((A * i) % B == C) {
      ans = "YES";
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#参考
def resolve():
    n=int(input())
    dic={}
    for _ in range(n):
        s=input()
        if not s in dic.keys():
            dic[s]=0
        else:
            dic[s]+=1
    m=max(dic.values())
    ans=[]
    for each in dic.keys():
        if dic[each]==m:
            ans.append(each)
    for each in sorted(ans):
        print(each)
resolve()


Measured memory_bytes: 32984
a, b, c = map(int, input().split())

d = 0
if a > b:
  d = a
  a = b
  b = d
else: pass

d = 0
if b > c:
  d = b
  b = c
  c = d
else: pass

d = 0
if a > b:
  d = a
  a = b
  b = d
else: pass

print(a, b, c)


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

x = 0
for i in range(n):
    x += b[a[i]-1]
    if i > 0 and a[i] == a[i-1] + 1:
        x += c[a[i-1]-1]
print(x)

Measured memory_bytes: 9140
fun main(args: Array<String>) {
    val s = readString()

    val ans = MutableList(s.length) { 0 }

    var i = 0
    while (i <= s.length - 1) {
        var numR = 0
        var numL = 0
        while (s[i] == 'R') {
            numR++
            i++
        }
        var iR = i - 1
        while (s[i] == 'L') {
            i++
            numL++
            if (i > s.length - 1) break
        }
        ans[iR] += (numR / 2 + numR % 2 + numL / 2)
        ans[iR+1] += (numL / 2 + numL % 2 + numR / 2)
    }
    val ansS = StringBuilder()
    ans.forEach { ansS.append("$it ") }
    println(ansS.toString())
}

// Tools
fun readString() = readLine()!!

Measured memory_bytes: 49120
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         String input = infile.readLine();
         int N = input.length();
         int[] arr = new int[N];
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(input.charAt(i)+"");
         long[] resid = new long[2019];
         resid[0]++;
         long temp = 0L;
         for(int i=N-1; i >= 0; i--)
         {
            temp += arr[i]*power(10, N-1-i, 2019);
            temp %= 2019;
            resid[(int)temp]++;
         }
         long res = 0L;
         for(int i=0; i < 2019; i++)
            res += (resid[i]*(resid[i]-1))/2;
         System.out.println(res);
      }
      public static long power(long x, long y, long p) 
      { 
          long res = 1L;      
          x = x % p;  
          while (y > 0) 
          { 
              if((y & 1)==1) 
                  res = (res * x) % p; 
              y = y >> 1;  
              x = (x * x) % p;  
          } 
          return res; 
      }
   }

Measured memory_bytes: 46836
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
ll mod=1e9+7;
int main() {
    /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout << std::fixed;
    cout << std::setprecision(10);
    int n;
    cin>>n;
    ld a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ld dp[n][n+1];
    for(int i=0;i<n;i++){
        for(int j=0;j<=n;j++){
            dp[i][j]=(ld)0;
        }
    }
    dp[0][0]=(ld)1-a[0];
    dp[0][1]=a[0];
    for(int i=1;i<n;i++){
        for(int j=0;j<=i+1;j++){
            if(j-1>=0) dp[i][j]+=a[i]*dp[i-1][j-1];
            dp[i][j]+=((ld)1-a[i])*dp[i-1][j];
        }
    }
    ld ans=0.0;
    for(int j=n/2+1;j<=n;j++){
        ans+=dp[n-1][j];
    }
    cout<<ans;
}

Measured memory_bytes: 140928
N = int(input())
a = [0 for _ in range(N)]
b = [0 for _ in range(N)]
c = [0 for _ in range(N)]
for i in range(N):
  a[i], b[i], c[i] = map(int, input().split(' '))
dp = [[0 for _ in range(3)] for _ in range(N + 1)] 
for i in range(N):
  dp[i][0] = max(dp[i-1][1] + a[i], dp[i-1][2] + a[i], dp[i][0])
  dp[i][1] = max(dp[i-1][0] + b[i], dp[i-1][2] + b[i], dp[i][1])
  dp[i][2] = max(dp[i-1][0] + c[i], dp[i-1][1] + c[i], dp[i][2])
print(max(dp[N-1][0], dp[N-1][1], dp[N-1][2]))

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

#define rep(i, n) for (ll i=0;i<(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(x) (x).begin(),(x).end()
#define Sort(a) sort(ALL(a))
#define Rev(a) reverse(ALL(a))


using namespace std;
//using ll=long long;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;
const long double PI=3.14159265358979323846;


template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}


int main(){

  ll n;
  cin>>n;

  vector<ll> v(n);

  rep(i,n){
    cin>>v[i];
  }

  int ii = max_element(ALL(v))- v.begin();
  ll a = v[ii];
  ll b=0;
  ll d = 10000000000;
  if(a%2==0){
    rep(i, n){
      if(a==v[i]) continue;
      if(abs((a)/2-v[i])<d){
	b=v[i];
	d = abs((a)/2-v[i]);
      }
    }
  }
  else{
    rep(i, n){
      if(a==v[i]) continue;
      if( min(abs(a/2-v[i]), abs(a/2+1-v[i])) <d) {
	b=v[i];
	d = min(abs(a/2-v[i]), abs(a/2+1-v[i]));
      }
    }
  }
  cout<<a<<" "<<b<<endl;
  
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl "\n"
#include "string"


int32_t main(){
	boost;
	int t = 1;
	//cin >> t;
	while(t--) {
		int n, k;
		cin >> n >> k;
		string s;
		cin >> s;
		int cnt = 0;
		for(int i = 0; i < n;) {
			int j = i;
			while(j < n && s[i] == s[j])
				j++;
			cnt++;
			i = j;
		}
		cout <<  min(n - 1, n - cnt + 2*k) << endl;
	}
}


Measured memory_bytes: 3688
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
string t="+-";
int main()
{
	string s,out(9,'a');
	cin>>s;
	rep(i,4) out[i*2]=s[i];out[7]='=';out[8]='7';
	rep(i,8){
		int sum=(s[0]-'0');
		rep(j,3){
			if((i&(1<<j))) sum-=(s[j+1]-'0'),out[j*2+1]='-';
			else sum+=(s[j+1]-'0'),out[j*2+1]='+';
		}
		//cout<<i<<' '<<sum<<endl;
		if(sum==7){
			cout<<out<<endl;return 0;
		}
	}
}


Measured memory_bytes: 256
from collections import deque, defaultdict

N, M = map(int, input().split())
# graph = [[] for _ in range(N + 1)]
graph = defaultdict(list)
for _ in range(M):
    u, v = map(int, input().split())
    graph[u].append(v)
    graph[v].append(u)

dist = [0] * (N + 1)
queue = [1]

while len(queue)>0:
    now = queue.pop(0)
    for v in graph[now]:
        if dist[v] == 0:
            queue.append(v)
            dist[v] = now


print("Yes")
for k in dist[2:]:
    print(k)

Measured memory_bytes: 39300
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <set>
using namespace std;

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    if (n % x == 0) {
        cout << n / x * t << endl;
    }
    else {
        cout << ((n / x) + 1) * t << endl;
    }
}

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

bool check(int *x,int n)
{
  int e=0;
  for(int i=0; i<n; i++)
  {
    if(x[i]%2==0) e++;
  }
  if (e==n) return true;
  else return false;
}

int main()
{
  int n;
  cin >>n;
  int x[n];
  for(int i=0; i<n; i++)
  {
    cin >> x[i];
  }
  int t=0;
  for(int i=0;; i++)
  {
    if(check(x,n)==true) 
    {
      t++;
      for(int j=0; j<n; j++)
      {
        x[j]/=2;
      }
    }
    else break;
  }
  cout << t<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int x,y,z,a,max=0;
	scanf("%d %d %d",&x,&y,&z);
	for(a=1;a<=x;a++)
	{
	if(a*y+(a+1)*z<=x)
		max=a;
		else break;
	}
	printf("%d\n",a-1);
	return 0;
}

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

int main() {
  vector<string> days = {"SUN", "SAT", "FRI", "THU", "WED", "TUE", "MON"};
  string s;cin>>s;
  int count = find(days.begin(), days.end(), s)-days.begin();
  cout<<(count==0?7:count)<<endl;
}


Measured memory_bytes: 256
// 26/05/2018
// Cut and Count
#include<iostream>
#include<cmath>
#include<string>
#include<set>

using namespace std;

int main(){
  int N,maxi=0;
  set<char> res; // characters in both string without repitition
  string S,st1,st2;
  cin >> N;
  cin >> S;
  for(int i=0; i<N-1; i++){
    st1 = S.substr(0,i+1);
    st2 = S.substr(i+1);
    for(int j=0; j <st1.length() ; j++){
      if(st2.find(st1[j]) != string::npos){
        res.insert(st1[j]);
      }
    }
    if(res.size() > maxi )  maxi = res.size();
    res.clear();
  }

  cout << maxi << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int n, m;
	int ans = 0;
	cin >> n >> m;
	int x, y;
	vector<pair<int, bool>> data(n, mp(1, false));
	data[0].S = true;
	rep(i, m) {
		cin >> x >> y;
		x--;
		y--;
		data[y].F++;
		data[y].S |= data[x].S;
		data[x].F--;
		data[x].S &= (data[x].F != 0);
	}
	rep(i, n) { ans += (data[i].S == true); }
	cout << ans << endl;
}

Measured memory_bytes: 3972
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
count = 0
for i in range(n):
  if b[i] >= a[i] + a[i+1]:
        count += (a[i] + a[i+1])
        a[i] = 0
        a[i+1] = 0
  elif b[i] >= a[i]:
    a[i+1] = a[i] + a[i+1] -b[i]
    a[i] = 0
    count += b[i]
  else:
    a[i] -= b[i]
    count += b[i]
print(count)

Measured memory_bytes: 82020
import math
import collections
import sys

input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]

n=I()
V=LI()
C=LI()
ans=0
for i in range(n):
    if V[i]-C[i]>=0:
        ans+=V[i]-C[i]
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

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

// 素因数分解による指数の列挙
vector<int> factor(int n){
    vector<int> res;
    for (int i = 2; i * i <= n; i++){
        int cnt = 0;
        while(n % i == 0){
            cnt++;
            n /= i;
        }
        res.push_back(cnt);
    }
    if (n != 1) res.push_back(1);
    return res;
}

const int MAX = 100100;
ll fact[MAX], finv[MAX], inv[MAX];
void init_combination(int p){
    fact[0] = fact[1] = finv[0] = finv[1] = inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fact[i] = i * fact[i - 1] % p;
        inv[i] = p - inv[p % i] * (p / i) % p;
        finv[i] = inv[i] * finv[i - 1] % p;
    }
}

ll combination(int n, int k, int p){
    if (n < k || n < 0 || k < 0) return 0;
    return fact[n] * (finv[k] * finv[n - k] % p) % p;
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> power = factor(m);
    ll ans = 1;
    init_combination(MOD);
    for (int i = 0; i < (int)power.size(); i++){
        (ans *= combination(power[i] + n - 1, n - 1, MOD)) %= MOD;
    }
    
    cout << ans << endl;

    return 0;
}

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

int eat=0;
bool poison=false;

int cookies(int a, int b, int c){
 	if (poison) {
    	if (b>0) {
          b--;
          eat++;
          poison = false;
          cookies(a, b, c);
        }else if (a>0) {
          a--;
          poison = false;
          cookies(a, b, c);
        }
    } else if(c>0) {
      c--;
      eat++;
      poison = true;
      cookies(a, b, c);
    } else if(b>0) {
      b--;
      eat++;
      cookies(a, b, c);
    }
  }

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  cookies(A, B, C); 
  cout << eat << endl;
}


Measured memory_bytes: 384
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;


fn main() {
    proconio::input! {
        h: usize,
        w: usize,
        m: usize,
        a: [(usize, usize); m]
    };
    let mut vh = vec![0; h];
    let mut vw = vec![0; w];
    for i in &a {
        vh[(i.0)-1] += 1;
        vw[(i.1)-1] += 1;
    }
    let mh = vh.iter().max().unwrap();
    let mw = vw.iter().max().unwrap();
    let mut b = vh.iter().filter(|&x| x == mh).count() * vw.iter().filter(|&x|x == mw).count();
    for i in &a {
        if vh[(i.0)-1] == *mh && vw[(i.1)-1] == *mw { b -= 1; }
    }
    if b==0 {
        println!("{}",mh+mw-1)
    }
    else {
        println!("{}",mh+mw)
    }
}

Measured memory_bytes: 12916
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
int main() {
	int n;
	scanf("%d", &n);
	printf("%d\n", (n - 2) * 180);
}


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

# a*y=b*x+c
# y=(b/a)*x+(c/a)
#  =(b*x+c)/a
flag=0
for i in range(10000):
    if (b*i+c)%a==0:
        print('YES')
        break
else:
    print('NO')




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

const int MAX = 4005;
const int mod = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main(){
    COMinit();
    int i,N,K;
    long long int ans;
    cin >> N >> K;
    for(i=1;i<K+1;i++){
        ans=(COM(K-1,i-1)*COM(N-K+1,i))%mod;
        cout << ans << endl;
    }
}

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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  ll n,k; cin>>n>>k;
  vector<ll> a(n);
  rep(i, n) cin>>a[i];

  vector<ll> cnt(42, 0);
  rep(i, 42) {
    rep(j, n) {
      cnt[i] += (a[j]>>i)&1;
    }
  }
  ll x = 0;
  for (int i=41; i>=0; i--) {
    ll c = cnt[i];
    if (2*c > n) continue;
    ll t = 1LL<<i;
    if (x+t > k) continue;
    x += t;
  }
  ll ans = 0;
  rep(i, n) ans += a[i]^x;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3960
n, m = map(int, input().split())
a = []
b = []
for i in range(m):
  a_, b_ = map(int, input().split())
  a.append(a_)
  b.append(b_)

for i in range(1, n+1):
  c = a.count(i)
  d = b.count(i)
  print(c+d)

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double

void fio() 
{
    std::ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
}

void inputread()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}
bool is7(ll n)
{
    while(n>0)
    {
        if(n%10==7)
        {
            return true;
        }
        else
        {
            n/=10;
        }        
    }
    return false;
}
int32_t main()
{
    fio();
    ll n;
    cin >> n;
    if(is7(n))
    {
        cout <<"Yes";
    }
    else
    {
        cout << "No";
    }
    
    return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i=0; i<n; i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    int a=0;
    int b=0;
    for(int i=0; i<n; i++){
        if(i%2 == 0){
            a += vec.at(i);
        } else {
            b += vec.at(i);
        }
    }
    cout << a - b << endl;
}


Measured memory_bytes: 256
/* All rights reserved.
* Author : yeguosheng
* FileName:
* Date : 2019-09-20-19.19.28
* Description : atcode141a
*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<cstring>
#define lop(i,s,e)  for(int i = s;i <= e;i++)
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define inf 0x7fffffff
#define ll long long
#define esp 1e-9
using namespace std;
string s;

int main()
{
    cin>>s;
    switch(s[0])
    {
    case 'S':
        cout<<"Cloudy"<<endl;
        break;
    case 'C':
        cout<<"Rainy"<<endl;
        break;
    case'R':
        cout<<"Sunny"<<endl;
        break;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, h, w; cin >> n >> h >> w;
    cout << (n-h+1) * (n-w+1) << endl;
}


Measured memory_bytes: 3608
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
ITP1_6-D

Array - Matrix Vector Multiplication
????????¶??? : 1 sec, ?????¢?????¶??? : 65536 KB
??????????????¨????????????

n??m
????????? A ??¨???m??1 ??????????????????b ??????????????????A ??¨ b

?????????????????????????????°????????????????????????????????????

?¬????????????? m
????????°??????????????????????????? m??1

????????????????????¨???????????????
b=???????????????b1b2:bm???????????????

?¬????????????? n
????????°??????????????????????????? m ????¨?????????????????????? n??m

???????????¨???????????????
A=???????????????a11a21:an1a12a22:an2......:...a1ma2m:anm???????????????

??????????????????????????????????????????????????°????????¨???????´???¨?????????m??1
?????????????????? b ???????????? i ?????????????´???? bi(i=1,2,...,m)???n??m ????????? A ?????? n??m ??????????´????????????????i ??? j ?????????????´???? aij(i=1,2,...,n,j=1,2,...,m)

??§??????????????????

n??m
????????? A ??¨m??1?????????????????? b ????????????n??1?????????????????? c ??¨?????????c ??? i ?????????????´? ci

????¬?????????§??????????????????
ci=???j=1maijbj=ai1b1+ai2b2+...+aimbm
Input

???????????? n
??¨ m ????????????????????§??????????????????????¶???? n ???????????? A ???????´? aij ????????????????????§??????????????????????¶???? m ?????????????????? b ???????´? bi

?????????????????????????????????????????????
Output

????????? n
???????????????????????????????????? c ???????´? ci

???????????????????????????????????????????????????
Constraints

    1???n,m???100

0???bi,aij???1000

Sample Input

3 4
1 2 0 1
0 3 0 1
4 1 1 0
1
2
3
0

Sample Output

5
6
9

=end
f=STDIN.gets.chomp.split.map{|x| x.to_i}
n=f[0]
m=f[1]
a = Array.new(n+1).map{ Array.new(m+1) }
b = Array.new(m+1)
c = Array.new(n+1)
(1..n).each {|i|
  (1..m).each {|j| a[i][j] = 0}
}
(1..m).each {|j| b[j] = 0 }
(1..n).each {|i| c[i] = 0 }

(1..n).each {|i|
  f = STDIN.gets.chomp.split
  (1..m).each {|j| a[i][j] = f[j-1].to_i}
}

(1..m).each {|j|
  b[j] = STDIN.gets.chomp.to_i
}

(1..n).each {|i|
  (1..m).each {|j| c[i] += a[i][j] * b[j]
    }
  }

(1..n).each {|i|
  puts c[i]
}

Measured memory_bytes: 8896
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        string S;
        cin >> S;
        map<char, ll> mp;
        rep(i, 0, len(S)) mp[S[i]]++;

        bool f1 = mp['N'] > 0 and mp['S'] == 0;
        bool f2 = mp['S'] > 0 and mp['N'] == 0;
        bool f3 = mp['E'] > 0 and mp['W'] == 0;
        bool f4 = mp['W'] > 0 and mp['E'] == 0;
        if (f1 or f2 or f3 or f4) {
                cout << "No" << endl;
        } else {
                cout << "Yes" << endl;
        }
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0); 
string n;
ll s;
ll ns;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n;
    ns = n.size();
    rep1(i,0,ns) s += n[i] - '0';
    if(s % 9 == 0) cout << "Yes";
    else cout << "No";
    
    return 0;  
}


Measured memory_bytes: 3748
#include <iostream>
#include <stdio.h>
using namespace std;

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

	int m = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 2 == 1)
			m++;
	}
	printf("%.8lf\n", (double)m / n);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int MO,n;
LL ans,f[6010][8010],fac[2000010],inv[2000010];
LL pw(LL x,LL y){
	LL t=1;
	for (;y;y>>=1){
		if (y&1) t=t*x%MO;
		x=x*x%MO;
	}
	return t;
}
LL C(int x,int y){
	return fac[x]*inv[y]%MO*inv[x-y]%MO;
}
int main(){
	cin>>n>>MO;
	fac[0]=1;
	FOR(i,1,2000000) fac[i]=fac[i-1]*i%MO;
	inv[2000000]=pw(fac[2000000],MO-2);
	FORD(i,1999999,0) inv[i]=inv[i+1]*(i+1)%MO;
	f[0][n]=1;
	FOR(i,1,n*3)
		FOR(j,0,n*4){
			if (i>=3){
				(f[i][j]+=f[i-3][j]*(i-1)%MO*(i-2))%=MO;
			}
			if (i>=2){
				(f[i][j]+=f[i-2][j+1]*(i-1))%=MO;
			}
			if (i>=1){
				if (j>=1) (f[i][j]+=f[i-1][j-1])%=MO;
			}
		}
	FOR(j,n,n*4) (ans+=f[n*3][j])%=MO;
	ans=(ans%MO+MO)%MO;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 407040
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdint>
#include <unordered_set>
#include <string>


std::vector<int> make_vector(const std::string& str) {
    std::vector<int> result(26, 0); 
    for (auto& ch : str) {
        result[ch - 'a']++;
    }
    return result;
}

void intercept (std::vector<int>& cur, const std::string& word) {
    auto vc = make_vector(word);
    for (int i = 0; i < vc.size(); ++i) {
        cur[i] = std::min(cur[i], vc[i]);
    }
}

int main() {
    int n;
    std::cin >> n;
    std::string first, word;
    std::cin >> first;
    std::vector<int> cur = make_vector(first);

    for (int i = 1; i < n; ++i) {
        std::cin >> word;
        intercept(cur, word);
    }

    for (int i = 0; i < cur.size(); ++i) {
        for (int j = 0; j < cur[i]; ++j) {
            std::cout << (char)('a' + i);
        }
    }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        //        int a = sc.nextInt();
        //        int b = sc.nextInt();

        String b = sc.next();

        sc.close();

        //        boolean ans = false;
        //
        //        for (int i = 0; i < a; i++) {
        //
        //        }

        //        System.out.println(ans ? "YES" : "NO");
        if (b.equals("A")) {
            System.out.println("T");
        } else if (b.equals("T")) {
            System.out.println("A");
        } else if (b.equals("C")) {
            System.out.println("G");
        } else {
            System.out.println("C");
        }
    }
}

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

int main(){
  int i,j,cnt;
  int n;
  cin>>n;
  int a[n],b[n];
  for(i=0;i<n;i++)cin>>a[i];
  for(i=0;i<n;i++)b[i]=i+1;
  vector<pair<int,int>> v;
  for(i=0;i<n;i++){
    v.push_back({a[i],b[i]});
  }
  sort(v.begin(),v.end());
  for(i=0;i<n;i++){
    cout<<v[i].second<<endl;
  }
}

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

using namespace std;

int main(){
    int a, b, c; cin >> a >> b >> c;
    int cnt_5 = 0, cnt_7=0;
    if(a == 5) cnt_5++;
    if(b == 5) cnt_5++;
    if(c == 5) cnt_5++;
    if(a == 7) cnt_7++;
    if(b == 7) cnt_7++;
    if(c == 7) cnt_7++;
    if(cnt_5 == 2 && cnt_7 == 1)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>

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

using namespace std;
typedef long long ll;

bool prime[10000000];
void Eratosthenes(int n) {
    rep(i,n) prime[i] = true;
    prime[1] = false;

    REP(i,2,(int)sqrt(n)) {
        if(prime[i]) {
            for(int j=0;i*(j+2)<n;j++) {
                prime[i*(j+2)] = 0;
            }
        }
    }
}

int main()
{
    Eratosthenes(10000000);

    int a,d,n;
    while(cin >> a >> d >> n ) {
        if(a == 0 && d == 0 &&  n == 0) break;

        vector<int> v;
        for(int i=a;i<1000005;i+=d) {
            if(prime[i]) v.push_back(i);
        }

        cout << v[n-1] << endl;
    }

    return 0;
}

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

void solve(){
	int n;
	cin >> n;
	
	double a[n]={};
	
	for(int i=0; i<n; i++)
		cin >> a[i];
	
	double dp[n+1][n+1]={};
	memset(dp, 0, sizeof dp);
	
	// dp[i][j] -> first i coins choose and j of them is heads.
	// not coin drawn so probability 1.
	dp[0][0]=1.0;
	
	// ith coin first i drawn
	for(int i=1; i<=n; i++){
		// j of them is heads it may be 0 or all i so, 0 to i
		for(int j=0; j<=i; j++){
			// current coin drawn head
			// so mult a[i] and recurse next i-1, j-1 beause current heads
			if(j>0)
				dp[i][j]+=dp[i-1][j-1]*a[i-1];
				
			// if current not head then i-1, j because not head
			dp[i][j]+=dp[i-1][j]*(1-a[i-1]);
		}
	}
	
	// we need to sum all prob.
	// mans we drawns all n coins where >=n/2 is head sum all that
	double ans=0.0;
	
	for(int i=0; i<=n; i++){
		if(i > n-i)
			ans+=dp[n][i];
	}
	
	cout << setprecision(12) << fixed << ans << "\n";
}

int main(){
	solve();
}


Measured memory_bytes: 74048
k,n = (int(x) for x in input().split())
a = [int(x) for x in input().split()]

diff = 0
largest_diff = 0
sumNum = 0 

for x in range(n-1):
	diff = a[x+1]-a[x]
	sumNum += diff
	if largest_diff < diff:
		 largest_diff = diff

last_diff = k-a[n-1]+a[0]
sumNum += last_diff
if largest_diff < last_diff:
	largest_diff = last_diff

print(sumNum-largest_diff)

Measured memory_bytes: 77388
/*
AtCoder Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

int dist(int x1, int y1, int x2, int y2){
    return abs(x1 - x2) + abs(y1 - y2);
}

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

    int N;
    cin >> N;

    int t1 = 0, x1 = 0, y1 = 0;
    int t2, x2, y2;
    int diff;
    bool valid = true;
    bool thisgood = false;
    for(int i = 0; i < N; i++){
        cin >> t2 >> x2 >> y2;
        diff = t2 - t1;
        thisgood = false;
        while(diff >= 0){
            if(diff == dist(x1, y1, x2, y2)){
                thisgood = true;
                break;
            }
            diff -= 2;
        }

        if(thisgood != true){
            valid = false;
            break;
        }
        x1 = x2; y1 = y2; t1 = t2;
    }

    if(valid) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String X = in.next();
		int sCount = 0;
		int xCount = X.length();
		for (int i = 0; i < X.length(); i++) {
			char c = X.charAt(i);
			if (c == 'S') {
				sCount++;
			} else {
				int delete = sCount > 0 ? 1 : 0;
				sCount -= delete;
				xCount -= delete == 1 ? 2 : 0;
			}
		}
		System.out.println(xCount);
		in.close();
	}
}

Measured memory_bytes: 26660
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#define IL inline
#define reg register
#define LL long long
#define N 500010
#define EPS 1e-5
using namespace std;

LL T,n,i,j,k,x,y,z;
LL a[N],b[N];

LL l,r,mid,ans;

IL bool Check(LL x){
	reg LL i=0,s=0,p=0;
	for (i=1;i<=n;i++){
		if (a[i]<=x)	continue;
		p=(LL)(a[i]/x);
		if (a[i]>p*x)	s+=p;
		else s+=p-1;
	}
	if (s<=k)	return 1;
	else return 0;
}

int main(){
	#ifdef __Marvolo
	freopen("zht.in","r",stdin);
	freopen("zht.out","w",stdout);
	#endif
	scanf("%lld%lld",&n,&k);
	for (i=1;i<=n;i++)	scanf("%lld",&a[i]);
	for (i=1;i<=n;i++)	a[i]*=2;
	sort(a+1,a+1+n);
	a[0]=0;
	for (i=1;i<=n;i++)	a[0]+=a[i];
/*	if (a[0]<=k){
		cout<<"0"<<endl;
		return 0;
	}
	if (a[0]-n <=k ){
		cout<<"1"<<endl;
		return 0;
	}*/
	if (!k){
		printf("%lld\n",a[n]/2);
		return 0;
	}
	l=1;	r=a[n]*2;
	while (l<=r){
		mid=(l+r)>>1;
		if (Check(mid))	ans=mid,r=mid-1;
		else l=mid+1;
	}
	while (ans>1 && Check(ans-1))	ans--;
	while (!Check(ans))	ans++;
	if (ans&1)	cout<<(ans+1)/2<<endl;
	else cout<<ans/2<<endl;
	return 0;
}

Measured memory_bytes: 5272
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 重さの検索
    def weighting(self, x):
        self.find(x)
        return self.weight[x]

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]


N, M = map(int, input().split())
wuf = WeightedUnionFind(N)
for i in range(M):
    l, r, d = map(int, input().split())
    if wuf.same(l, r):
        if wuf.diff(l, r) != d:
            print("No")
            break
    else:
        wuf.union(l, r, d)
else:
    print("Yes")

Measured memory_bytes: 10236
#include <stdio.h>
#include <stdlib.h>

int main() {
	long long a, v, b, w, t;
	scanf("%lld%lld%lld%lld%lld", &a, &v, &b, &w, &t);
	if (a < b) {
		if ((v - w) * t >= b - a)printf("YES");
		else printf("NO");
	}
	else {
		if ((v - w) * t >= a- b)printf("YES");
		else printf("NO");
	}
	return  0;
}

Measured memory_bytes: 1708