akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

// --------------------------------------------------------------------------------
#define FASTIO	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define fset(arr,n,val) for(int i=0;i<n;++i) arr[i] = val
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------

void solve_main()
{
    int n,m;cin>>n>>m;
    bool done[n+1];
    int wa[n+1];
    mset(wa,0);
    mset(done,0);
    int ac = 0;
    int penalty = 0;
    while(m--)
    {
    	int u;cin>>u;
    	string s;cin>>s;
    	if(done[u])
    		continue;
    	if(s=="AC")
    	{
    		ac++;
    		done[u] = true;
    		continue;
    	}
    	if(s=="WA")
    	{
    		wa[u]++;
    	}
    }
    for(int i=1;i<=n;++i)
    {
    	if(done[i])
    		penalty+=wa[i];
    }
    cout<<ac<<" "<<penalty;
}

int main()
{

	#ifndef ONLINE_JUDGE
		freopen("/home/suryakant/input.txt","r",stdin);
		freopen("/home/suryakant/output.txt","w",stdout);
	#endif

    int t=1;
    // cin>>t;
    while(t--)
    {
        solve_main();
    }
    
}

Measured memory_bytes: 4116
#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}
};
constexpr int N_MAX = 500000;

ll fact[N_MAX+1], rfact[N_MAX+1];

ll perm(ll n, ll k) {
    if(n-k < 0LL) return 0LL;
    return (fact[n] * rfact[n-k]) % MOD;
}

ll comb(ll n, ll k) {
    if(n-k < 0LL) return 0LL;
    return (perm(n, k) * rfact[k]) % MOD;
}

ll modpow(ll a, ll p) {
    ll ret = 1LL;
    while(p) {
        if(p & 1) {
            ret = (ret * a) % MOD;
        }
        a = (a * a) % MOD;
        p >>= 1;
    }
    return ret;
}

void init_fact(ll n) {
    fact[0] = fact[1] = 1;
    rfact[0] = rfact[1] = 1;
    for(ll i=2;i<=n;++i) {
        fact[i] = (fact[i-1] * i) % MOD;
        rfact[i] = modpow(fact[i], MOD-2);
    }
}


int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n, m;
    cin >> n >> m;
    init_fact(max(n, m));

    ll ans = 0LL;
    for(int k=0;k<=n;++k) {
        ll p = perm(m-k, n-k);
        ll tmp = (((comb(n, k) * perm(m, k)) % MOD) * ((p * p) % MOD)) % MOD;
        if(k % 2) {
            ans += MOD - tmp;
        } else {
            ans += tmp;
        }
        ans %= MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 11452
inp = list(input().split())
stk = []
for i in range(len(inp)):
    if inp[i]!='+' and  inp[i]!='-' and inp[i]!='*':
        stk.append(int(inp[i]))
    else:
        if inp[i] == '+':
            up = stk.pop(-1)
            down = stk.pop(-1)
            stk.append(down + up)
        elif inp[i] == '-':
            up = stk.pop(-1)
            down = stk.pop(-1)
            stk.append(down - up)
        else:
            up = stk.pop(-1)
            down = stk.pop(-1)
            stk.append(down * up)
print(stk[0])


Measured memory_bytes: 5604
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;

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

    int n = s.length();

    if(s[n - 1] == 's') cout << s << "es" << endl;
    else cout << s << 's' << endl;
    

    return 0;
}

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

int main() {
int N,K;
cin >> N >> K;
vector<int> vec(N);
for(int i=0; i<N; i++){
    cin >> vec.at(i);
}
sort(vec.begin(),vec.end());
int ans = 0;
for(int j=0; j<K; j++){
ans += vec.at(N - K + j);
}
cout << ans <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vb=vector<bool>;
using pii=pair<int,int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int n; cin>>n;
    vector<pii> t[n];
    rep(i,0,n){
        int u,k;
        cin>>u;
        cin>>k;
        rep(j,0,k){
            int v,c;
            cin>>v>>c;
            pii in=make_pair(v,c);
            t[u].push_back(in);
        }
    }
    set<int> rem,visited;
    visited.insert(0);
    rep(i,1,n)rem.insert(i);
    vector<int> ans(n,-1);
    ans[0]=0;
    while(!rem.empty()){
        int minv=1<<30;
        int mini=-1;
        for(int from:visited){;
            for(pii to:t[from]){
               if(ans[to.first]==-1&&to.second+ans[from]<minv){
                   minv=to.second+ans[from]; mini=to.first;
               }
            }
        }
        if(mini!=-1){
            ans[mini]=minv;
            rem.erase(mini);
            visited.insert(mini);
        }
    }
    rep(i,0,n)cout<<i<<" "<<ans[i]<<endl;
    return 0;
}





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

namespace Search
{
    class Allocation
    {
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var w = new int[nk[0]];
            var W = 0;
            for (int i = 0; i < w.Length; i++)
            {
                w[i] = int.Parse(Console.ReadLine());
                W += w[i];
            }

            var k = nk[1];
            var P = W / k;

            while (true)
            {
                var X = 0;
                var c = 1;
                int i;
                for (i = 0; i < w.Length; i++)
                {
                    if ((X += w[i]) <= P) continue;
                    else
                    {
                        i--;
                        c++;
                        X = 0;
                    }
                    if (c > k) break;
                }
                if (i == w.Length) break;
                P++;
            }
            Console.WriteLine(P);
        }
    }
}

Measured memory_bytes: 10312
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while(A>0 || C>0){
        /* 高橋 */
        C = C-B;
        if(C<=0){
            cout << "Yes" << endl;
            break;
        }
        /* 青木 */
        A = A-D;
        if(A<=0){
            cout << "No" << endl;
            break;
        }

    };
}

Measured memory_bytes: 3132
class BallGame
  attr_accessor :left, :right

  def initialize(left = [], right = [])
    @left = left
    @right = right
  end

  def insertable(balls)
    if balls.length() == 0
      return true
    end
    if balls[0] > (@left[-1].nil? ? 0 : @left[-1])
      new_ball_game = BallGame.new(@left + [balls[0]], @right)
      if new_ball_game.insertable(balls[1..-1])
        return true
      end
    end
    if balls[0] > (@right[-1].nil? ? 0 : @right[-1])
      new_ball_game = BallGame.new(@left, @right + [balls[0]])
      if new_ball_game.insertable(balls[1..-1])
        return true
      else
        return false
      end
    end
    return false
  end
end

if __FILE__ == $0
  n = gets.to_i
  n.times do 
    balls = gets.split().map{|i| i.to_i}
    ballGame = BallGame.new()
    if ballGame.insertable(balls)
      puts "YES"
    else
      puts "NO"
    end
  end
end

Measured memory_bytes: 6116
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int A[200001],dp[200001];
int main(){
    int n,k;
    cin>>n>>k;
    for(int i=0; i<n; i++) cin>>A[i];
    for(int i=0;i<=k;i++){
        dp[i]=0;
        for(int j=0; j<n;j++) if(i-A[j]>=0&&!dp[i-A[j]]) dp[i]=1;
    }
    if(dp[k]) cout<<"First"<<"\n";
    else cout<<"Second"<<"\n";
}


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

bool IsPrime(int num)
{
	if (num < 2)
	{
		return false;
	}
	else if (num == 2)
	{
		return true;
	}
	else if (num % 2 == 0)
	{
		return false;
	}
	
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}
	
	return true;
}

int main()
{
	long long int x, i;
	cin >> x;
	
	i = 0;
	while(1)
	{
		if (IsPrime(x+i))
		{
			cout << x+i << endl;
			break;
		}
		i++;
	}
	
	return 0;
}


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

public class Main {

	static long count = 0;
	
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		String[] strArray = reader.readLine().split(" ");
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = Integer.parseInt(strArray[i]);
		}
		mergeSort(arr, 0, arr.length);
		System.out.println(count);
	}

	private static void mergeSort(int[] arr, int left, int right) {
		if (left + 1 < right) {
			int mid = left + (right - left) / 2;
			mergeSort(arr, left, mid);
			mergeSort(arr, mid, right);
			merge(arr, left, mid, right);
		}
	}
 
	private static void merge(int[] arr, int left, int mid, int right) {
		
		int n1 = mid - left;
		int n2 = right - mid;
		
		int[] L = new int[n1 + 1];
		int[] R = new int[n2 + 1];
		for (int i = 0; i < n1; i++) {
			L[i] = arr[left + i];
		}
		for (int i = 0; i < n2; i++) {
			R[i] = arr[mid + i];
		}
		L[n1] = Integer.MAX_VALUE;
		R[n2] = Integer.MAX_VALUE;
		int i = 0;
		int j = 0;
		for (int k = left; k < right; k++) {
			if (L[i] <= R[j]) {
				arr[k] = L[i];
				i++;
			} else {
				if (L[i] != Integer.MAX_VALUE) {
					count += n1 - i;
				}
				arr[k] = R[j];
				j++;
			}
		}
	}
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(n);
	for(auto&i:a)cin>>i;
	sort(a.begin(),a.end());
	int ans=0;
	for(int i=0;i<n;){
		int b=a.at(i),cnt=0;
		while(i<n&&a.at(i)==b)++i,++cnt;
		if(cnt>b)ans+=cnt-b;
		else if(cnt<b)ans+=cnt;
	}
	cout<<ans<<"\n"s;
}

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

int main() {
	string s;
	cin >> s;
	
	sort(s.begin(), s.end());
	
	if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]){
		cout << "Yes" << '\n';
	}
	else{
		cout << "No" << '\n';
	}
}

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

int main() {
  int N,K;
  int min;
  int bufA,bufB;
  cin >> N >> K;

  min = 0;
  bufA = 1;
  for (int i=0;i<N;i++) {
    //操作A
    bufA *=2;
    bufB = bufA;
    for (int j=i+1;j<N;j++) {
      //操作B
      bufB += K;
    }
    //1回目の処理
    if (min==0) min = bufB;
    //結果が最小であるか比較
    if (bufB<min) min = bufB;
  }
  cout << min << endl;
}


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

#define int long long
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    flash
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		if(n>=1800)
		{
			cout<<1;
		}
		else if(n>=1600)
		{
			cout<<2;
		}
		else if(n>=1400)
		cout<<3;
		else if(n>=1200)
		cout<<4;
		else if(n>=1000)
		cout<<5;
		else if(n>=800)
		cout<<6;
		else if(n>=600)
		cout<<7;
		else if(n>=400)
		cout<<8;		
    }
    return 0;
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int A, B;
  cin >> A >> B;
  if (A >= 13) {
    cout << B << endl;
  } else if (A >= 6) {
    cout << B / 2 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
setか
Tちょうどの時間は注文不可
3000
DPかな
とるとらないの2^3000はむり
一番ポイントの高いものは確実に最後にとれる
最後とも限らないのか

T-1までのとりかた
3000^2でDPか
DP[0]=0
3000*3000でとる？
最後、時間外にとるやつをどうするか
配列自体は6000まで、更新するのはT-1まで
上からみてく？
1個目をとるかとらないか、0とA0が更新？
最後にとる場合のパターンが漏れる
選択した箇所だけ加算するようにしないと

最初に時間がでかいのきたらばぐる
3 11
100 100
10 30
10 30
*/
int main(){
  ll N,T,oo=1e9; cin>>N>>T;
  vector<ll> DP(6050,-oo);
  DP[0]=0;
  vector<vector<ll>> Z(N,vector<ll>(2,0));
  ll high=0;
  for(ll i=0; i<N; i++){
    ll a,b; cin>>a>>b;
    Z[i][0]=a;
    Z[i][1]=b;
  }
  sort(Z.begin(), Z.end(), [](auto& x, auto& y){return x[0] < y[0];});
  for(ll j=0; j<N; j++){
    ll t=Z[j][0], d=Z[j][1];
    for(ll i=T-1; i>=0; i--){
      if(DP[i]==-oo) continue;
      DP[i+t]=max(DP[i+t],DP[i]+d);
    }
  }
  ll ans=0;
  for(ll i=0; i<=6000; i++) ans=max(ans,DP[i]);
  cout<<ans<<endl;
}

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

#define INF 1000000000000000
#define fi first
#define se second
#define mk(a,b) make_pair(a,b)

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

ll N,M,N_;
ll A[5010];
pii seg[20020][210];
ll fid[5010][5010] = {0};
ll ans = 0;

void init()
{
    N_ = 1;
    while(N_ <= N)N_ *= 2;
    for(int i = 0; i < N_ * 2 - 1; i++)
        for(int j = 0; j < M; j++)seg[i][j] = mk(0,0);
    return;
}

void up_date(ll k,ll x,ll p,int m)
{
    pii data = mk(x,p);
    k += N_ - 1;
    seg[k][m] = data;
    while(k > 0)
    {
        k = (k - 1) / 2;
        seg[k][m] = max(seg[k * 2 + 1][m],seg[k * 2 + 2][m]);
    }
    return;
}

pii get_min(int a,int b,int m,int k = 0,int l = 0,int r = N_)
{
    if(b <= l || r <= a)return mk(-1,0);

    if(a <= l && r <= b)return seg[k][m];

    pii res1,res2;
    res1 = get_min(a,b,m,k * 2 + 1,l,(l + r) / 2);
    res2 = get_min(a,b,m,k * 2 + 2,(l + r) / 2,r);

    return max(res1,res2);
}

void con(ll l,ll r,int m)
{
    if(l >= r)return;
    pii now = get_min(l,r,m);
    fid[now.se + 1][l + 1] += now.fi;
    fid[r + 1][l + 1] -= now.fi;
    fid[now.se + 1][now.se + 2] -= now.fi;
    fid[r + 1][now.se + 2] += now.fi;
    con(now.se + 1,r,m);
    con(l,now.se,m);
    return;
}

int main()
{
    scanf("%lld%lld",&N,&M);
    init();
    for(int i = 2; i <= N; i++)scanf("%lld",A + i);
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < M; j++)
        {
            int a;
            scanf("%lld",&a);
            up_date(i,a,i,j);
        }
    }

    for(int i = 0; i < M; i++)con(0,N,i);

    for(int i = 3; i <= N; i++)A[i] += A[i - 1];
    for(int i = 1; i <= N; i++)
        for(int j = 1; j <= N; j++)
            fid[i][j] += fid[i - 1][j];

    for(int i = 1; i <= N; i++)
        for(int j = 1; j <= N; j++)
            fid[i][j] += fid[i][j - 1];

    for(int i = 1; i <= N; i++)
    {
        for(int j = 1; j <= i; j++)ans = max(ans,fid[i][j] - A[i] + A[j]);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 252160
#include <iostream>
#include <cstring>
#include <cmath>
#include <iomanip>
using namespace std;
int count(int k,int i)
{
	
	int answer=0;
	

	while(i<k)
	{
		i*=2;
		answer++;
	}
	return answer;
}

int main()
{
  double n,k;
  cin>>n>>k;
  
  double probab=0.0;
  
  
  for(int i=1;i<=n;i++)
  {
   	int no_of_times=count((int)k,i); ;
    
    probab+=(1/pow(2,no_of_times));
  }
  probab=probab/n;
  cout<<setprecision(12)<<probab;
  
  
  return 0;
}

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

#define ll long long
#define sq(a) (a)*(a)
#define caset int t; cin >> t; cin.ignore(numeric_limits<streamsize>::max(),'\n'); while(t--)
#define get1(a) ll int a; cin>>a;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define line '\n'

#define vi(v)	vector < int > v;
#define	all(v)	v.begin(), v.end()


#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
//#ifndef ONLINE_JUDGE   freopen("input.txt","r",stdin);		freopen("output.txt","w",stdout); 	#endif

void solve()
{
	

	
}

int main() {
	// fast;
	int a=0, w=0, tt=0, r=0;
	caset{
		int n;
		string s;
		getline(cin, s);

		if(s=="AC")
			a++;
		else if (s=="WA")
		{
			/* code */w++;
		}
		else if (s=="TLE")
		{
			/* code */tt++;
		}
		else
			r++;

		
	
	}
	cout<<"AC x "<<a<<endl;
		cout<<"WA x "<<w<<endl;
		cout<<"TLE x "<<tt<<endl;
		cout<<"RE x "<<r<<endl;
return 0;
}
// 11 10 1 9 2
// 8 3 7 4 6 5


Measured memory_bytes: 3632
#include<stdio.h>
int f[30];
int n;

int main(){
	for(int i=0;i<30;i++)f[i]=0;
	for(int i=0;i<28;i++){
		scanf("%d",&n);
		f[n-1]=1;
	}
	for(int i=0;i<30;i++){
		if(f[i]==0)printf("%d\n",i+1);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int N;
    int T, A;

    std::cin >> N;
    std::cin >> T >> A;

    int min = 1<<30;
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        int H = 0;
        std::cin >> H;
        int d = std::abs((T*1000 - H*6) - A*1000);
        if (min > d) {
            min = d;
            ans = i;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i=0; i<N; i++)
			A[i] = sc.nextInt();
		
		System.out.println(win(A) ? "First" : "Second");
		
		sc.close();
	}
	
	static boolean win(int[] A) {
		int N = A.length;
		int even = 0;
		for(int i=0; i<N; i++)
			if(A[i]%2==0)
				even++;
		if(even%2==1) {
			return true;
		} else {
			if(even==N-1) {
				for(int i=0; i<N; i++) {
					if(A[i]%2==1) {
						if(A[i]==1)
							return false;
						A[i]--;
						break;
					}
				}
				int gcd = A[0];
				for(int i=1; i<N; i++)
					gcd = gcd(gcd, A[i]);
				for(int i=0; i<N; i++)
					A[i] /= gcd;
				return !win(A);
				
			} else {
				return false;
			}
		}
	}
	
	static int gcd(int a, int b) {
		return a%b==0 ? b : gcd(b, a%b);
	}
}


Measured memory_bytes: 34360
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 2000000;

// unsolved

int main() {
  /* code */
  int R[MAX], n;

  cin >> n;
  for (int i = 0; i < n; i++) {
    /* code */
    cin >> R[i];
  }
  int maxv = R[1] - R[0];
  int minv = R[0];

  for (int i = 1; i < n; i++) {
    /* code */
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;

  return 0;
}

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

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


int main()
{
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    REP(i, N){
        cin >> C[i];
        REP(j, M) cin >> A[i][j];
    }

    int ans = 1e+9;
    // 全探索 by bit
    for(int i = 0; i < (1 << N); ++i){
        int cost = 0;
        vector<int> understand(M, 0);
        for(int j = 0; j < N; ++j){
            if(i & (1<<j)){
                cost += C[j];
                REP(k, M) understand[k] += A[j][k];
            }
        }
        bool is_understand = true;
        REP(k, M){
            if(understand[k] < X){
                is_understand = false;
                break;
            }
        }
        if(is_understand) ans = min(ans, cost);
    }
    if(ans == 1e+9) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}

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

const int Maxn = 505;
const int Maxm = 255;
const int Maxd = 4;
const int dy[Maxd] = {-1, 0, 1, 0};
const int dx[Maxd] = {0, -1, 0, 1};

int dp[Maxn][Maxn];
int n;
bool fr[Maxn][Maxn];
int a[Maxn * Maxn];
int res;

void Traverse(int r, int c, int bef)
{
    if (r < 0 || r >= n || c < 0 || c >= n) return;
    if (!fr[r][c]) bef++;
    if (bef >= dp[r][c]) return;
    dp[r][c] = bef;
    for (int d = 0; d < Maxd; d++)
        Traverse(r + dy[d], c + dx[d], bef);
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n * n; i++) {
        scanf("%d", &a[i]); a[i]--;
    }
    fill((int*)dp, (int*)dp + Maxn * Maxn, Maxm);
    for (int i = 0; i < n; i++) {
        Traverse(i, 0, 0);
        Traverse(i, n - 1, 0);
        Traverse(0, i, 0);
        Traverse(n - 1, i, 0);
    }
    for (int i = 0; i < n * n; i++) {
        int r = a[i] / n, c = a[i] % n;
        int my = dp[r][c] - 1;
        fr[r][c] = true;
        res += my;
        Traverse(r, c, my);
    }
    cout << res << endl;
    return 0;
}


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

int main() {
    ll r,c,n;
    std::cin >> r>>c>>n;
    set<pair<ll,ll>> ux,ry,dx,ly;
    for (int i = 0; i < n; i++) {
        ll x1,y1,x2,y2;
        std::cin >> x1>>y1>>x2>>y2;
        if((x1==0||y1==0||x1==r||y1==c)&&(x2==0||y2==0||x2==r||y2==c)){
            if(x1==0){
                ly.insert({-y1,i});
            }else if(x1==r){
                ry.insert({y1,i});
            }else if(y1==0){
                ux.insert({x1,i});
            }else{
                dx.insert({-x1,i});
            }
            
            if(x2==0){
                ly.insert({-y2,i});
            }else if(x2==r){
                ry.insert({y2,i});
            }else if(y2==0){
                ux.insert({x2,i});
            }else{
                dx.insert({-x2,i});
            }
        }else{
            continue;
        }
    }
    stack<ll> st;

    for (auto e : ux) {
        if(st.size()==0){
            st.push(e.second);
        }else{
            if(st.top()==e.second){
                st.pop();
            }else{
                st.push(e.second);
            }
        }
    }
    
    for (auto e : ry) {
        if(st.size()==0){
            st.push(e.second);
        }else{
            if(st.top()==e.second){
                st.pop();
            }else{
                st.push(e.second);
            }
        }
    }
    
    for (auto e : dx) {
        if(st.size()==0){
            st.push(e.second);
        }else{
            if(st.top()==e.second){
                st.pop();
            }else{
                st.push(e.second);
            }
        }
    }
    for (auto e : ly) {
        if(st.size()==0){
            st.push(e.second);
        }else{
            if(st.top()==e.second){
                st.pop();
            }else{
                st.push(e.second);
            }
        }
    }
    if(st.size()==0){
        std::cout << "YES" << std::endl;    
    }else{
        std::cout << "NO" << std::endl;
    }
    
}

Measured memory_bytes: 16860
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

bool hasline(char c, char bd[3][3]) {
    if (bd[0][0] == c && bd[0][1] == c && bd[0][2] == c) return true;
    if (bd[1][0] == c && bd[1][1] == c && bd[1][2] == c) return true;
    if (bd[2][0] == c && bd[2][1] == c && bd[2][2] == c) return true;
    if (bd[0][0] == c && bd[1][0] == c && bd[2][0] == c) return true;
    if (bd[0][1] == c && bd[1][1] == c && bd[2][1] == c) return true;
    if (bd[0][2] == c && bd[1][2] == c && bd[2][2] == c) return true;
    if (bd[0][0] == c && bd[1][1] == c && bd[2][2] == c) return true;
    if (bd[0][2] == c && bd[1][1] == c && bd[2][0] == c) return true;
    return false;
}

void solve67(string s) {
    char bd[3][3];
    REP(i,3) REP(j,3) bd[i][j] = s[3*i+j];
    if (hasline('o', bd)) {
        cout << "o" << endl;
    }else if (hasline('x', bd)) {
        cout << "x" << endl;
    }else {
        cout << "d" << endl;
    }
}

int main() {
    string s;
    while(cin >> s) {
        solve67(s);
    }
    return 0;
}

Measured memory_bytes: 1180
// Depth First Search
#include <stdio.h>

#define MAX 101

// 頂点の訪問状態をcolorで表す //
#define BLACK  2
#define GRAY 1
#define WHITE 0

// タイムスタンプd[v]: v を最初に発見した発見時刻を記録する
// タイムスタンプf[v]: v の隣接リストを調べ終えた完了時刻を記録する
// 隣接行列M:頂点iから頂点jまで辺があるとき1
int time, n, d[MAX], f[MAX], color[MAX], M[MAX][MAX];

// 再帰による深さ優先探索
void visit(int u){
  int i;
  
  color[u] = GRAY; // 頂点uを訪問
  time++;
  d[u] = time;   // 訪問した発見時刻を記録
  
  for(i=0; i < n; i++){
    if(M[u][i] == 0) continue;
    if(color[i] == WHITE) visit(i);
  }
  color[u] = BLACK; // 頂点uの隣接リストの調査終了
  time++;
  f[u] = time;    // 調べ終えた完了時刻を記録
  // time++;
}

void dfs(){
  int u;

  // すべての頂点のcolorをwhiteにする //
  for(u=0; u < n; u++){
    color[u] = WHITE; // 初期化
  }
  time = 0; // 初期化
  
  for(u=0; u < n; u++){
    if(color[u] == WHITE)visit(u);
  }
  for(u=0; u < n; u++){
    printf("%d %d %d\n", u+1, d[u], f[u]);
  }
}

int main(){
  int i, j, k, row, col;
  scanf("%d", &n);

  // 隣接行列Mを初期化
  for(i=0; i < n; i++){
    for(j=0; j < n; j++){
      M[i][j] = 0;
    }
  }
  
  for(i=0; i < n; i++){
    scanf("%d%d", &row, &k);
    for(j=0; j < k; j++){
      scanf("%d", &col);
      M[row-1][col-1] = 1;
    }
  }

  dfs();

  return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
 
int main() {
    fast();
   /* ll t;
    cin>>t;
    while(t--)
    {
       
    }*/
    ll n,m;
    cin>>n>>m;
    if(n==m)
    cout<<"Yes";
    else
    cout<<"No";
}


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

int main() {
  string str;
  cin >> str;
  int count = 0;
  int answer = 0;
  
  for (int i = 0; i < str.size(); i++) {
  
    if (str.at(i) == 'A' ||str.at(i) == 'T' ||str.at(i) == 'C' ||str.at(i) == 'G') {
      count++;
    }
    else{
      count = 0;
    }
    if(count > answer){
      answer = count;
      
    }
  }

  cout << answer << endl;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  if (c >= a && c <= b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;

#define MAX 100000
int n, k;
ll w[MAX];

int check(ll P) {
    int i = 0;
    rep(j, k) {
        ll sum = 0;
        while(sum + w[i] <= P) {
            sum += w[i];
            i++;
            if (i == n) {
                return n;
            }
        }
    }
    return i;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    rep(i, n) { cin >> w[i]; }
    ll left = 0, right = MAX * 10000, mid;
    while(right - left > 1) {
        mid = (left + right) / 2;
        int v = check(mid);
        if (v >= n) {
            right = mid;
        } else {
            left = mid;
        }
    }
    cout << right << endl;
    return 0;
}


Measured memory_bytes: 3936
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC120C
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            int N = S.Length;

            Stack<char> stack = new Stack<char>();

            int count = 0;
            for (int i = 0; i < N; i++)
            {
                if (stack.Count == 0 || stack.Peek() == S[i]) stack.Push(S[i]);
                else
                {
                    stack.Pop();
                    count += 2;
                }
            }

            Console.WriteLine(count);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13664
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Ord

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    getLine
    as <- getIntList
    bs <- getIntList
    let ds = sortOn Down $ zipWith (-) as bs
        mds = filter (< 0) ds
        m = length mds
        p = length . takeWhile (< abs (sum mds)) $ scanl (+) 0 ds
    print $ if sum ds < 0 then -1 else m + p

Measured memory_bytes: 25980
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  s=S()
  l=[1]*len(s)

  ans=[0]*len(s)

  c1=c2=0
  f=inf
  for i in range(len(s)-1):
    # print(ans)
    if s[i]=='R':
      if c1!=0 and c2!=0:
        if (max(c1,c2)-1)%2==1:
          if c1>=c2:
            ans[f+1]=-(-(c1+c2)//2)
            ans[f]=(c1+c2)//2
          else:
            ans[f]=-(-(c1+c2)//2)
            ans[f+1]=(c1+c2)//2
        else:
          if c1>=c2:
            ans[f]=-(-(c1+c2)//2)
            ans[f+1]=(c1+c2)//2
          else:
            ans[f+1]=-(-(c1+c2)//2)
            ans[f]=(c1+c2)//2
        f=inf
        c1=0
        c2=0
      c1+=1

      if s[i+1]=='R':
        ans[i]=0
      else:
        # ここはOK
        f=i
    else:
      c2+=1
      if s[i-1]=='L':
        ans[i]=0

  # print(c1,c2)
  c2+=1
  # if s[-2]=='L':
  # if (max(c1,c2)-1)%2==1:
  #   ans[f+1]=-(-(c1+c2)//2)
  #   ans[f]=(c1+c2)//2
  # else:
  #   ans[f]=-(-(c1+c2)//2)
  #   ans[f+1]=(c1+c2)//2
    
  if (max(c1,c2)-1)%2==1:
    if c1>=c2:
      ans[f+1]=-(-(c1+c2)//2)
      ans[f]=(c1+c2)//2
    else:
      ans[f]=-(-(c1+c2)//2)
      ans[f+1]=(c1+c2)//2
  else:
    if c1>=c2:
      ans[f]=-(-(c1+c2)//2)
      ans[f+1]=(c1+c2)//2
    else:
      ans[f+1]=-(-(c1+c2)//2)
      ans[f]=(c1+c2)//2

  # else:
    # print(c1,c2,f)

  return ' '.join([str(x) for x in ans])

# main()
print(main())


Measured memory_bytes: 13656
// abc179_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int idx=0;idx<(n-1);idx++) cout << (vec)[idx] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << "\n";}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    int ans = 0;
    REPN(a, 1, N+1){
        int x = N/a;
        REPN(b, 1, x+1){

            int c = N - a * b;
            if (c > 0){
                ans++;
            }
        }
    }

    print(ans);


    return 0;
}


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

int main()
{
    int n;cin>>n;
    vector<int> v(n);
    int i;
    vector<int> count(1e5+1,0);
    vector<int> count2(1e5+1,0);
    for(i=0;i<n;i++)cin>>v.at(i);
    for(i=0;i<n;i++)
    {
        if(i%2==0)count.at(v.at(i))++;
        else count2.at(v.at(i))++;
    }
    int mx1count,mx1num,mx2count,mx2num;
    mx1count=0;
    mx1num=1;
    mx2count=0;
    mx2num=1;
    for(i=1;i<=1e5;i++)
    {
        if(count.at(i)>mx1count)
        {
            mx1count=count.at(i);
            mx1num=i;
        }
        if(count2.at(i)>mx2count)
        {
            mx2count=count2.at(i);
            mx2num=i;
        }
    }
    int ans=0;
    if(mx1num!=mx2num)ans=n-mx1count-mx2count;
    else
    {
        count.at(mx1num)=-1;
        count2.at(mx2num)=-1;
        int mx1count2=0;
        mx1num=1;
        int mx2count2=0;
        mx2num=1;
        for(i=1;i<=1e5;i++)
        {
            if(count.at(i)>mx1count2)
            {
                mx1count2=count.at(i);
                mx1num=i;
            }
            if(count2.at(i)>mx2count2)
            {
                mx2count2=count2.at(i);
                mx2num=i;
            }
        }
        ans=n-max(mx1count+mx2count2,mx2count+mx1count2);
    }
    cout<<ans<<endl;
}


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

int main(){
  int c[3][3];
  for(int i = 0;i < 3;i++)
    for(int j = 0;j < 3;j++)cin >> c[i][j];

  int d[2][3];
  for(int i = 0;i < 2;i++){
    for(int j = 0;j < 3;j++){
      d[i][j] = c[i+1][j] - c[i][j];
    }
  }

  int e[3][2];
  for(int i = 0;i < 3;i++){
    for(int j = 0;j < 2;j++){
      e[i][j] = c[i][j+1] - c[i][j];
    }
  }



  bool flag = true;

  for(int i = 0;i < 2;i++){
    if(!(d[i][0] == d[i][1] && d[i][1] == d[i][2]))flag = false;
  }

  for(int i = 0;i < 2;i++){
    if(!(e[0][i] == e[1][i] && e[1][i] == e[2][i]))flag = false;
  }

  if(!(flag))cout << "No" << endl;
  else cout << "Yes" << endl;


}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

using namespace std;

#define int long long

vector<int> tmp;

signed main() {
	string S;
	int s;
	cin >> s;
	cin >> S;
	int m = 0;
	int x=0;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] == 'I')x++;
		else x--;

		m = max(x,m);
	}
	cout << m << endl;
}



Measured memory_bytes: 764
n, k = map(int, input().split())
h = [int(input()) for _ in range(n)]
h.sort()
min = h[k-1] - h[0]
for i in range(len(h)-k+1):
    dif = h[i+k-1] - h[i]
    if dif < min:
        min = dif
print(min)


Measured memory_bytes: 7384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll N,M;
    cin >> N >> M;
    map<ll,ll> mp;
    for (ll i = 0;i<M;i++) {
        ll a,b;
        cin >> a >> b;
        mp[a]++;
        mp[b]++;
    }
    for (ll i = 1;i<=N;i++) {
        cout << mp[i] << endl;
    }
}

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

public class Hello
{
    public const long INF = 999999999999999;
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = long.Parse(line[0]);
        var x = long.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, long.Parse);
        var ans = getAns(a, x);
        Console.WriteLine(ans);
    }
    public static long getAns(long[] a, long x)
    {
        var n = a.Length;
        var mina = new long[n];
        for (int i = 0; i < n; i++) mina[i] = a[i];
        var finret = mina.Sum();
        for (int i = 1; i < n; i++)
        {
            var ret = 0L;
            for (int j = 0; j < n; j++)
            {
                var ni = (j - i + n) % n;
                mina[j] = Math.Min(mina[j], a[ni]);
                ret += mina[j];
            }
            ret += i * x;
            finret = Math.Min(ret, finret);
        }
        return finret;
    }
}

Measured memory_bytes: 13292
#include <iostream>
 using namespace std;
 int main(){
 int N,K;
 cin>>N>>K;

 int cnt=0;
 for(int i=0;i<N;i++){
 int h;
 cin>>h;
 if(h>=K) cnt++;
 }

 cout<<cnt<<endl;
 return 0;
 }

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
    if (i+1) % 15 == 0:
        a.insert(i+1,"FizzBuzz") 
    elif (i+1) % 3 == 0:
        a.insert(i+1,"Fizz") 
    elif (i+1)% 5 == 0:
        a.insert(i+1,"Buzz") 
    else:
        a.append(i+1)
        
b = [num for num in a if isinstance(num, int)]
print(sum(b))

Measured memory_bytes: 37940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
typedef long long ll;
using namespace std;

int main(){
    char b, ans;
    cin >> b;
    if(b == 'A') ans = 'T';
    else if(b == 'T') ans = 'A';
    else if(b == 'G') ans = 'C';
    else ans = 'G';
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 256
<?php
$n = intval(fgets(STDIN));
$array = array_map("intval", explode(" ", trim(fgets(STDIN))));
$min = 10**10;
for($i = -100; $i <= 100; $i++){
    $sum = 0;
    foreach($array as $a){
        $sum+=($a-$i)**2;
    }
    $min = min($min, $sum);
}
echo $min;


Measured memory_bytes: 4732
#include<stdio.h>

int main (void)
{
  int A , B , K;
  scanf("%d %d %d", &A , &B , &K);
  int keep[50];

  int count = 0;
  for(int i = 1 ; i <= 100 ; i++){
    if(A % i == 0 && B % i == 0){
      keep[count] = i;
      count++;
    }
  }

  printf("%d",keep[count - K]);

return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3

N, A, B = list(map(int, input().split()))
S = input()
k = 0
ans = ""
b_i = 0
for i, ch in enumerate(S):

    if ch == "b":
        b_i += 1
    r = "No"
    if ch == "a" and k < A + B:
        r = "Yes"
        k += 1
    elif ch == "b" and k < A + B and b_i <= B:
        r = "Yes"
        k += 1
    ans += r + "\n"

print(ans)


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

int main(){
    int n,q,a,ans=0;
    cin>>n>>q;
    queue<pair<string,int> > s;
    pair<string,int> t;
    for(int i=0;i<n;i++){
        cin>>t.first>>t.second;
        s.push(t);
    }
    while(! s.empty()){
        t=s.front();
        s.pop();
        t.second-=q;
        ans+=q;
        if(t.second<=0){
            ans+=t.second;
            cout<<t.first<<' '<<ans<<endl;
            continue;
        }
        s.push(t);
    }
}


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

using namespace std;
using ll = long long;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    swap(a, b);
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

void solve(long long A, long long B){
  auto v = prime_factorize(gcd(A, B));
  std::cout << v.size()+1 << std::endl;
}

int main(){
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  solve(A, B);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define INF 99999999

void enter(int);
int out(void);
void bfs(int);

int n;
int G[100][100],d[100],judge[100];
int head=0,tail=0,que[100];

void enter(int x)
{
  que[tail] = x;
  tail = (tail + 1) % 100;
}

int out(void)
{
  int x;
  x = que[head];
  head = (head +1) % 100;
  return x;
}


void bfs(int x)
{
  int i,u;

  for(i=0;i<n;i++) {
    judge[i] = 0;
    d[i] = INF;
  }

  judge[x] = 1;
  d[x] = 0;
  enter(x);

  while(head != tail) {
    u = out();
    for(i=0;i<n;i++) {
      if(G[u][i] == 1 &&judge[i] == 0) {
	judge[i] = 1;
	d[i] = d[u] + 1;
	enter(i);
      }
    }
    judge[u] = 2;
  }

  for(i=0;i<n;i++) {
    printf("%d ",i+1);
    if(d[i] == INF)
      printf("-1\n");
    else
      printf("%d\n",d[i]);
  }
}
 
    
int main()
{
  int x,y,z,i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++) {
    for(j=0;j<n;j++) {
      G[i][j] = 0;
    }
  }

  for(i=0;i<n;i++) {
    scanf("%d%d",&x,&y);
    x--; /* 行列用に-1 */
    for(j=0;j<y;j++) {
      scanf("%d",&z);
      z--; /* 行列用に-1 */
      G[x][z] = 1;
    }
  }

  bfs(0);
  
  return 0; 
}



Measured memory_bytes: 2072
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    string s, t;
    cin >> s >> t;
    ll n = s.size();
    ll m = t.size();

    vvl dp(n+1, vl(m+1));  // dp[i][j] : sのi文字目までとtのj文字目までのLCSの長さ
    rep(i, n) {
        rep(j, m) {
            if(s[i] != t[j]) {
                chmax(dp[i+1][j+1], max(dp[i+1][j], dp[i][j+1]));
            }
            else {
                chmax(dp[i+1][j+1], dp[i][j] + 1);
            }
        }
    }

    string ans = "";
    ll i = n-1, j = m-1;
    while(i >= 0 && j >= 0) {
        if(dp[i+1][j+1] == dp[i][j+1]) {
            i--;
        }
        else if(dp[i+1][j+1] == dp[i+1][j]) {
            j--;
        }
        else if(dp[i+1][j+1] == dp[i][j] + 1) {
            ans = s[i] + ans;
            i--;  j--;
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 74160
while True:
    h, w = map(int,input().split())
    if h == 0 and w == 0:
        break
    else:
        for i in range(h):
            if i % 2 == 0:
                for j in range(w):
                    if j % 2 == 0:
                        print('#', end = '')
                    else:
                        print('.', end = '')
            else:
                for j in range(w):
                    if j % 2 == 0:
                        print('.', end = '')
                    else:
                        print('#', end = '')
            print('')
    print('')


Measured memory_bytes: 7008