akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  string a;
  cin >> a;
  bool ok = 0;
  for (int i = 0; i + 1 < a.size(); i++) {
    if (a[i] == 'A' && a[i + 1] == 'B') {
      ok = 1;
    }
    if (a[i] == 'B' && a[i + 1] == 'A') {
      ok = 1;
    }
  }
  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define il inline
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 1010;
namespace Fast_Input {
    template<class T> il void read(T& res) {
        res = 0;char c;bool sign = 0;
        do { c = getchar(); sign |= c == '-'; } while(!isdigit(c));
        while(isdigit(c)) res = (res << 1) + (res << 3) + (c & 15),c = getchar();
        (sign) && (res = -res);
        return;
    }
}
using Fast_Input::read;
template<class A,class B> il void cmin(A& x,B y) {
    if(x > y) x = y;  return;
}
int n,m,i,j,k,ecnt;
int head[maxn],ver[maxn],nxt[maxn];
int f[maxn],g[2][5010],x[maxn];
il void addedge(int u,int v) {
    ver[++ecnt] = v;
    nxt[ecnt] = head[u];
    head[u] = ecnt;
    return;
}
void dfs(int u) {
    for(int i = head[u];~i;i = nxt[i]) dfs(ver[i]);
    memset(g[0],0x3f,sizeof(g[0]));
    int p = 0;g[p][0] = 0;
    for(int i = head[u];~i;i = nxt[i]) {
        int v = ver[i];p = !p;
        memset(g[p],0x3f,sizeof(g[p]));
        for(int j = 0;j <= x[u];j++) {
            if(j - x[v] >= 0) cmin(g[p][j],g[p ^ 1][j - x[v]] + f[v]);
            if(j - f[v] >= 0) cmin(g[p][j],g[p ^ 1][j - f[v]] + x[v]);
        }
    }
    for(int i = 0;i <= x[u];i++) cmin(f[u],g[p][i]);
    return;
}
int main() {
    read(n);
    memset(head,-1,sizeof(head));
    for(int i = 2,P;i <= n;i++) {
        read(P);
        addedge(P,i);
    }
    for(int i = 1;i <= n;i++) read(x[i]);
    memset(f,0x3f,sizeof(f));
    dfs(1);
    puts(f[1] != inf ? "POSSIBLE" : "IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222





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



  ll a, b;
  cin >> n >> a >> b;

  n++;
  if (n < a) {
    cout << n << endl;
    return 0;
  }
  n -= a;
  ans += a;
  ans += max((b - a)*(n / 2), (n / 2) * 2);
  if (n % 2) ans++;
  cout << ans << endl;





  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define mkp make_pair
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<<endl;}}
#define print1d(mat,n){for(int i=0;i<(int)(n);i++)cout<<mat[i]<<" ";cout<<endl;}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define printpair(v) for(auto val: v){cout<<val.fi<<":"<<val.se<<", ";}cout<<endl;
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<endl;
#define init(v,x) for (auto &itr:v){itr=x;}
#define ln length()
const int mod = 998244353;
#define sz size()
const int inf = 1e18;
int n,arr[100005],barr[100005],carr[100005];
int dp[3][100005];
int f(int i,int prev){
    if(i==n){
        return 0;
    }
    int ans=-inf;
    if(prev!=-1 and dp[prev][i]!=-1){
        return dp[prev][i];
    }
    if(prev!=0){
        ans=max(ans,f(i+1,0)+arr[i]);
    }
    if(prev!=1){
        ans=max(ans,f(i+1,1)+barr[i]);
    }
    if(prev!=2){
        ans=max(ans,f(i+1,2)+carr[i]);
    }
    if(prev!=-1){
        dp[prev][i]=ans;
    }
    return ans;
}
void solve() {
    clr(dp,-1);
    cin>>n;
    rep(i,0,n){
        cin>>arr[i]>>barr[i]>>carr[i];
    }
    cout<<f(0,-1)<<endl;
}

int32_t main(){
    fastIO
#ifndef ONLINE_JUDGE
    freopen(R"(C:\Users\swast\CLionProjects\untitled\input.txt)", "r", stdin);
#endif
    int t=1;
//    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

int main() {
	int N,M;
	cin >> N >> M;

	int n[100];
	int m[100];

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

	for (int k=0; k<M; k++) {

		for (int i=0; i<N-1; i++) {
			if (n[i] % (k+1) > n[i + 1] % (k+1)) {
				int x = n[i];
				int y = n[i + 1];

				n[i] = y;
				n[i + 1] = x;
			}
		}
	}

	for (int i=0; i<N; i++) {
		cout << n[i] << endl;
	}
	return 0;
}



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

struct Team
{
  int num;
  int time;   //sec
};

int main()
{
  while (true)
  {
    int n;
    cin >> n;
    if ( n == 0 ) break;

    Team victory = { 0, INT_MAX, };
    Team second  = { 0, INT_MAX, };
    Team booby   = { 0, 0,       };
    Team lowest  = { 0, 0,       };
    for (int data=0; data<n; data++)
    {
      Team tmp_team;
      cin >> tmp_team.num;
      tmp_team.time = 0;
      for (int i=0; i<4; i++)
      {
        int min,sec;
        cin >> min >> sec;
        tmp_team.time += min*60 + sec;
      }

      if ( tmp_team.time < victory.time )
      {
        second = victory;
        victory = tmp_team;
      }
      else if ( tmp_team.time < second.time )
      {
        second = tmp_team;
      }

      if ( lowest.time < tmp_team.time )
      {
        booby = lowest;
        lowest = tmp_team;
      }
      else if ( booby.time < tmp_team.time )
      {
        booby = tmp_team;
      }
    }
    cout << victory.num << endl
         << second.num  << endl
         << booby.num   << endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define all(a) a.begin(),a.end()
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(auto c:v) cout<<" "<<c; cout<<endl;
int power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
void solve(){
	int n;
	cin>>n;
	int a[n],b[n];
	int cnt[n+1]={0};
	int ca[n+1]={0};
	int ind1[n+1],ind2[n+1];
	memset(ind1,-1,sizeof(ind1));
	memset(ind2,-1,sizeof(ind2));
	for(int i=0;i<n;i++){
		cin>>a[i];
		ca[a[i]]++;
		if(ind1[a[i]]==-1){
			ind1[a[i]]=i;
		}
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
		cnt[b[i]]++;
		ind2[b[i]]=i;
	}
	for(int i=1;i<=n;i++){
		if(cnt[i]+ca[i]>n){
			cout<<"No\n";
			return;
		}
	}
	int mx=0;
	for(int i=1;i<=n;i++){
		if(ind1[i]!=-1&&ind2[i]!=-1&&ind2[i]-ind1[i]>=0)
			mx=max(ind2[i]-ind1[i]+1,mx);
	}
	cout<<"Yes\n";
	vector<int>ans(n);
	for(int i=0;i<n;i++){
		ans[i]=b[(i+mx)%n];
	}
	for(auto x:ans)
		cout<<x<<" ";
	cout<<endl;
}
int main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
}


Measured memory_bytes: 8800
#include <stdio.h>

int main(void){
   int w,h,i,j,jnk;
   scanf("%d%d",&h,&w);

   char str[h][w];
   jnk=getchar();
   for(i=0;i<h;i++){
      for(j=0;j<w;j++)
         str[i][j]=getchar();
      jnk=getchar();
   }
 
for(i=0;i<=w+1;i++)
      printf("#");
   printf("\n");

   for(i=0;i<h;i++){
      printf("#");
      for(j=0;j<w;j++)
         printf("%c",str[i][j]);
      printf("#\n");
   }

   for(i=0;i<=w+1;i++)
      printf("#");
   printf("\n");
   return 0;
}
                            

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

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


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

for(int i=0;i<s.length();i++){
    if(i%2==0)cout << s.at(i);
}
cout << endl;   

    return 0;

}


Measured memory_bytes: 512
n,m=map(int,input().split())
g=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
for i in g[n-1]:
    if g[i].count(0)==1:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Measured memory_bytes: 80716
/*
 
dunjen_master
 
*/
 
 

 
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;
 
const int MAX_N = int(1e6) + 10;
const long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 

inline ll mul(ll a,ll b){

    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}

  

 
#define all(x) (x).begin(),(x).end()




int main(){


   
    ll a,b,c,k;
    cin>>a>>b>>c>>k;

    if(k==0){
        cout<<"0"<<endl;
    }else{
        if(k<=a)cout<<k<<endl;
        else if(k<=a+b)cout<<a<<endl;
        else{
            cout<<a-(k-(a+b))<<endl;
        }
    }
   

    

    
}

    

    
 
    



Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
long long p = 998244353;
//long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}

signed main() {
	int k, n; cin >> n >> k;
	if (2 * k - 1 > n) { cout << -1 << endl; return 0; }
	if (n % 2 == 1) {
		int m = n / 2;
		rep(i, m + 1) { cout << k + 2 * i << " " << k + n + m - i << " " << k + 2 * n + i << endl; }
		rep(i, m) { cout << k + 1 + 2 * i << " " << k + 2 * n - 1 - i << " " << k + 2 * n + m + 1 + i << endl; }
	}
	else {
		int m = n / 2;
		rep(i, m) { cout << k + m - 1 - i << " " << k + n + 2 * i << " " << k + 2 * n + i << endl; }
		rep(i, m) { cout << k + n - 1 - i << " " << k + n + 1 + 2 * i << " " << k + 2 * n + m + i << endl; }
	}
}


Measured memory_bytes: 3456
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int a;
	int counter;
	double sum = 0;
	int kekka;

	cin >> counter;

	for (int i = 0; i < counter; i++) {
		cin >> a;
		sum += ((double)a / (double)counter);
	}

	kekka = (int)sum;

	cout << kekka << endl;
	return 0;
}

Measured memory_bytes: 1160
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static int N,min,cnt;
	static int[] a =new int[180];
	static int[] b =new int[45];
	static int[] alreadyA;
	static int[] alreadyB;
	static{
		int cnt=0;
		for(int i = 1;tetrahedral(i)<=1000000;i++){
			int t = tetrahedral(i);
			a[cnt++]=t;
		}
		for(int i = 0;i<a.length;i++){
			//System.out.println(a[i]);
		}		
		alreadyA=new int[1000000];
		alreadyB=new int[1000000];
		cnt=0;
		for(int i = 1;tetrahedral(i)<=1000000;i++){
			int t = tetrahedral(i);
			if(t%2==1){
				b[cnt++]=t;
			}
		}

	}
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		Arrays.fill(alreadyA, 0);
		Arrays.fill(alreadyB, 0);
		a();
		while(true){
			N =cin.nextInt();
			if(N==0){
				break;
			}
			cnt=0;min=Integer.MAX_VALUE;
			
			System.out.print(alreadyA[N]);
			System.out.println(" "+alreadyB[N]);
		}

	}
	static void a(){
		for(int i= 1;i<1000000;i++){
			int mina=Integer.MAX_VALUE;
			int minb=Integer.MAX_VALUE;
			int x=0,y=0;
			for(int j=0;j<180&&a[j]<=i;j++){
				mina=Math.min(1+alreadyA[i-a[j]],mina);
				if(a[j]%2==1){
					minb=Math.min(1+alreadyB[i-a[j]],minb);
				}
			}
			//System.out.println(i+" " +x+" " +y + " " +min);
			alreadyA[i]=mina;
			alreadyB[i]=minb;
		}
	}
	static int tetrahedral(int a){
		return (a*(a+1)*(a+2))/6;
	}
}

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

int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans;
  ans = a * c;
  if (ans < a*d) ans = a*d;
  if (ans < b*c) ans = b*c;
  if (ans < b*d) ans = b*d;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
//
// Created by kinok on 2020/04/17.
//

#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include<string>

using namespace std;


#define ll long long
#define rep(t) for(int i=0;i<t;i++)
#define deb(a) cout<<#a<<" : "<<a<<endl

	bool kaibun(string s){
        rep(s.length()){
            if(s[i]!=s[s.length()-i-1]){
                return false;
            }
        }
        return true;
    }


    int main(){
        string s;
        cin>>s;
        if(kaibun(s) && kaibun(s.substr(0,((s.length()-1)/2))) && kaibun(s.substr(((s.length()+3)/2)-1,s.length()-1))){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
        return 0;
    }






Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	string s;
	cin >> s;
	
	if (s.size() == 2) {
		if (s[0] == s[1]) {
			cout << "1 2" << endl;
			return 0;
		}
	}

	for (int i = 0; i < s.size()-2; i++) {
		if (s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}

	cout << -1 <<" "<< -1 << endl;

	return 0;
}


Measured memory_bytes: 512
# 2019-11-16 14:51:41(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 
import heapq

def main():
    # 10**5連勤とか超人すぎる
    n, m = [int(x) for x in sys.stdin.readline().split()]

    job_list = dict((i, list()) for i in range(1, m+1))
    for _ in range(n):
        a, b = [int(x) for x in sys.stdin.readline().split()]
        if a <= m:
            job_list[a].append(b)
    
    schedule = [0 for _ in range(m+1)] # 当日は報酬0
    q = []
    for i in range(1, m+1):
        for reward in job_list[i]: # 期限i日前にできる仕事の報酬一覧をheqp queueに入れる
            heapq.heappush(q, -reward) 
            # あとで最大値を取り出すために-1かける(heappop()で取り出せるのは最小値)

        if q: # その日できる仕事が一つでもあれば
            # 報酬の最小値(マイナスなので元々の最大値)を取り出して-1をかけ、scheduleにいれる
            schedule[i] = -heapq.heappop(q) # 戻り値を返すと同時にsheduleにいれた報酬値はqから除いている
        else: # できる仕事がなければ
            pass  # その日の報酬は0のまま

    print(sum(schedule))


if __name__ == "__main__":
    main()


Measured memory_bytes: 29924
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
macro_rules! chmax {
    ($base:expr, $cmp:expr) => {
        if $base < $cmp {
            $base = $cmp;
        }
    };
}

fn main() {
    input! {//
        r:usize,
        c:usize,
        k:usize,
        rcv:[(Usize1,Usize1,usize);k],
    }
    let mut rcvs = vec![vec![0; c]; r];
    for &(r, c, v) in rcv.iter() {
        rcvs[r][c] = v;
    }
    let mut dp = vec![vec![vec![0; 4]; c]; r]; // dp[r][c][k]
    let mut ans = 0;
    for rr in 0..r {
        for cc in 0..c {
            for i in 0..=3 {
                if rr + 1 < r {
                    chmax!(dp[rr + 1][cc][0], dp[rr][cc][i]);
                    if i < 3 {
                        chmax!(dp[rr + 1][cc][0], dp[rr][cc][i] + rcvs[rr][cc]);
                    }
                }
                if cc + 1 < c {
                    chmax!(dp[rr][cc + 1][i], dp[rr][cc][i]);
                    if i < 3 {
                        chmax!(dp[rr][cc + 1][i + 1], dp[rr][cc][i] + rcvs[rr][cc]);
                    }
                }
            }
        }
    }
    let mut ans = dp[r - 1][c - 1][3];
    for i in 0..3 {
        chmax!(ans, dp[r - 1][c - 1][i] + rcvs[r - 1][c - 1]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 713044
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    set<string> st;
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
        st.insert(s[i]);
    }

    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 25168
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define PI 3.14159265359

int main(void){
    double a,b,h,m;
    double rShort,rLong,ang;
    double ans_2,ans;
    cin>>a>>b>>h>>m;
    if(h>=12)h-=12;
    rShort = (h*(360.000000000000000/12.000000000000000))+m/2.000000000000000;
    rLong = m*(360.000000000000000/60.000000000000000);
    ang = abs(rLong-rShort);
    ang = min(ang,(360.000000000000000-ang));
    double ang2 = cos(PI*ang/180.000000000000000);
    
    ans_2 = a*a+b*b-(2*a*b*ang2);
    ans = sqrt(ans_2);
    printf("%.20lf",ans);
    return 0;
}

Measured memory_bytes: 4192
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int A[100];
int main(){
  int res;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY, Q5VJL1cS;
    if(N==0){
      Q5VJL1cS = 0;
    }
    else{
      Q5VJL1cS = A[0];
      for(KL2GvlyY=1;KL2GvlyY<N;KL2GvlyY++){
        Q5VJL1cS = min_L(Q5VJL1cS, A[KL2GvlyY]);
      }
    }
    {
      int cTE1_r3A, e98WHCEY;
      if(N==0){
        cTE1_r3A = 0;
      }
      else{
        cTE1_r3A = A[0];
        for(e98WHCEY=1;e98WHCEY<N;e98WHCEY++){
          cTE1_r3A = max_L(cTE1_r3A, A[e98WHCEY]);
        }
      }
      res =cTE1_r3A-Q5VJL1cS;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int N, A[100];
// {
//   int res;
//   rd(N, A(N));
//   res = max(A(N)) - min(A(N));
//   wt(res);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
int a, b, c;

int main(int argc, char ** argv) {
	scanf("%d%d%d", &a, &b, &c);
	if(b/a > c) printf("%d\n", c);
	else printf("%d\n", b/a);
	return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
#include <utility>
#define INF INT_MAX / 2
using namespace std;

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

int w[21][21];
int main(void) {

	int n,m;
	while(cin >> n,n!=0){
	memset(w,0,sizeof(w));
	for(int i=0;i<n;i++){
		int a,b;
		cin >> a >> b;
		w[b][a] = 1;
	}
	cin >> m;
	int x,y;
	x = y = 10;
	int cnt = 0;
	if(w[y][x] == 1)cnt++;
	w[y][x] =  0;

	for(int i=0;i<m;i++){
		char c;int d;
		cin >> c >> d;
		if(c == 'N'){
			for(int i=0;i<d;i++){
				y++;
				if(w[y][x] == 1)cnt++;
				w[y][x] = 0;
			}
		}else if(c == 'S'){
			for(int i=0;i<d;i++){
				y--;
				if(w[y][x] == 1)cnt++;
				w[y][x] = 0;
			}
		}
		if(c == 'E'){
			for(int i=0;i<d;i++){
				x++;
				if(w[y][x] == 1)cnt++;
				w[y][x] = 0;
			}
		}else if(c == 'W'){
			for(int i=0;i<d;i++){
				x--;
				if(w[y][x] == 1)cnt++;
				w[y][x] = 0;
			}
		}
	}
	if(n == cnt)cout << "Yes" << endl;
	else cout << "No" << endl;
}
}

// command shift d duplicate
// command ctrl 上下
// command D
// command caps G → '' ""
// vector<vector<int>> a(N,vector<int>(M,-1));

Measured memory_bytes: 1152
a,b,c,d=map(int,input().split())
if (a<=0)&(b<=0):
    if (c<=0)&(d<=0):
        print(a*c)
    elif(c>=0)&(d>=0):
        print(b*c)
    else:
        print(a*c)
elif (a>=0)&(b>=0):
    if (c<=0)&(d<=0):
        print(a*d)
    elif(c>=0)&(d>=0):
        print(b*d)
    else:
        print(b*d)
else:
    if(c<=0)&(d<=0):
        print(a*c)
    elif(c>=0)&(d>=0):
        print(b*d)
    else:
        print(max(a*c,b*d))

Measured memory_bytes: 9240
N,A,B=map(int, input().split())
S=input()
cntA=0
cntB=0
for s in S:
  if s == 'c':
    print('No')
    continue
  if s == 'a' and (cntA+cntB) < A+B:
    print('Yes')
    cntA +=1
  elif (s == 'b') and ((cntA+cntB) < A+B) and (cntB < B):
    print('Yes')
    cntB +=1
  else:
    print('No')


Measured memory_bytes: 4016
#include<iostream>
#include<string>
using namespace std;
int main(){
long p,q,i,j,k,d[80];
string s;
while(cin>>p>>q){
i=0;d[i++]=p;s="";
for(p*=10;;p*=10){
j=p/q;p%=q;
d[i]=p;
s+=j+48;
if(p==0)break;
for(k=0;k<i;k++)if(d[k]==p)break;
if(k==i)i++;else break;
}
cout<<s<<endl;
if(p!=0){
for(j=0;j<k;j++)cout<<" ";
for(;j<i;j++)cout<<"^";
cout<<endl;
}
}
return 0;
}

Measured memory_bytes: 1196
category = ['S','H','C','D']
 
table = [[False]*14 for i in range(4)]
 
N = int(input())
 
for loop in range(N):
 
    mark,num = input().split()
    num = int(num)
 
    if mark == 'S':
        table[0][num] = True
    elif mark == 'H':
        table[1][num] = True
    elif mark == 'C':
        table[2][num] = True
    else:
        table[3][num] = True
 
for i in range(4):
    for k in range(1,14):
        if table[i][k] == False:
            print("%s %d"%(category[i],k))


Measured memory_bytes: 5604
#pragma GCC optimize("O3")

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <assert.h>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <random>
#include <cmath>
#include <chrono>
#include <bitset>

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;
const int K = 500;
const int maxN = 2e4 + 1;


void solve() {
	string s;
	cin >> s;
	
	vector<pair<int, int>> a;
	for (int i = 0; i < s.size(); i++) {
		if (!i || s[i] != s[i - 1]) a.pb({ 1, i });
		else a.back().first++;
	}

	vector<int> ans(s.size());
	for (int i = 0; i < a.size(); i += 2) {
		int id = a[i + 1].second;
		int one = a[i].first / 2 + a[i].first % 2 + a[i + 1].first / 2;
		int two = a[i + 1].first / 2 + a[i + 1].first % 2 + a[i].first / 2;
		ans[id - 1] = one;
		ans[id] = two;
	}
	for (int i : ans) cout << i << " ";
}


signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 3524
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  int x , a, b;
  cin >> x >> a >> b;
  int ans1 = abs(x - a);
  int ans2 = abs(x - b);
  if(ans1 < ans2){
    cout << "A" << endl;
  } else {
    cout << "B" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [0] * N
sumA = 0
for i, x in enumerate(input().split()):
  sumA += int(x)
  A[i] = sumA
for i in range(N - 1):
  A[i] = abs(2 * A[i] - A[N - 1])
print(min(A[:-1]))

Measured memory_bytes: 26500
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
	int st[200], top = 0;
	char c[20];

	while(scanf("%s", c) != EOF){
		if (c[0] >= '0' && c[0] <= '9')
		{
			st[top] = atoi(c);
			top++;
		}else if (c[0] == '+')
		{
			top--;
			st[top-1] += st[top];
		}else if (c[0] == '-')
		{
			top--;
			st[top-1] -= st[top];
		}else if (c[0] == '*')
		{
			top--;
			st[top-1] *= st[top];
		}
	}

	printf("%d\n", st[top-1]);

	return 0;
}

Measured memory_bytes: 1828
s = list(map(int, input().split()))
s.sort()
d1 = s[2] - s[0]
d2 = s[2] - s[1]
ans = d1 // 2 + d2 // 2
y = d1 % 2 + d2 % 2
if y == 1:
  ans += 2
if y == 2:
  ans += 1
print(ans)


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

int main() {
	int a[100], n;
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	for (int i = n-1; i >= 0; i--) {
		cout << a[i];
		if (i != 0) {
			cout << " ";
		} else { 
			cout << endl;
		}
	}	
	
	return 0;
}


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

typedef long long ll;
const int maxn = 1e5;
int n, s, x[maxn + 3];
ll p[maxn + 3];

int _abs(int x) {
	return x < 0 ? -x : x;
}

ll solve(int l, int r, int t) {
	if (l > r) {
		return _abs(s - t);
	}
	ll ret = 0;
	if (x[l] > s || (x[r] > s && p[l] >= p[r])) {
		p[l] += p[r];
		ret = solve(l, r - 1, x[r]);
		if (t != -1) ret += _abs(x[r] - t);
	} else {
		p[r] += p[l];
		ret = solve(l + 1, r, x[l]);
		if (t != -1) ret += _abs(x[l] - t);
	}
	return ret;
}

int main() {
	scanf("%d %d", &n, &s);
	for (int i = 1; i <= n; i++) {
		scanf("%d %lld", &x[i], &p[i]);
	}
	printf("%lld\n", solve(1, n, -1));
	return 0;
}

Measured memory_bytes: 4480
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long
#define mo 998244353

_int64 c[400000];

int pow1(int x,int y)
{
  int i;
  _int64 ret;
  ret=1;
  for (i=30;i>=0;i--)
  {
    ret=ret*ret%mo;
    if (((1<<i)&y)!=0)
      ret=ret*x%mo;
  }
  return (int)ret;
}

int inv(int x)
{
  return pow1(x,mo-2);
}

int main()
{
  _int64 i,j,a,b,n,k,ans,tmp;
  scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
  c[0]=1;
  for (i=1;i<=n;i++)
  {
    c[i]=c[i-1];
    c[i]*=(n+1-i);
    c[i]%=mo;
    c[i]*=inv(i);
    c[i]%=mo;
  }
  /*cout<<c[0]<<endl;
  cout<<c[1]<<endl;
  cout<<c[2]<<endl;
  cout<<c[3]<<endl;
  */ans=0;
  for (i=0;i<=n;i++)
  {
    if (i*a>k) break;
    tmp=k-(i*a);
    if (tmp%b!=0) continue;
    j=tmp/b;
    if (j>n) continue;
    ans+=c[i]*c[j]%mo;
    ans%=mo;
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

// typedef
typedef long long ll;
typedef unsigned long ul;
// #define int long long

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // 値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)  // 直後の要素をパディング
#define space_pad(num) setfill(' ') << std::right << setw(num)  // 直後の要素をパディング

// func declaration
template <class T> void print2DVec(vector< vector<T> >&);
template <class T> void calcVec(vector<T>&, int, char);
int char_to_int(const char);

// const
const int INF = 10000000;

/*MEMO
・辞書順
abc < abcd, atcoder < atlas
・イテレータ
std::vector<int>::iterator とタイプするのは面倒なので、
 通常は型推論の auto を使用する。
 auto iter = max_element(ALL(vec));
・2次元配列
vector<vector<int>> vec = {{1, 2, 3}, {4, 5, 6}}
・20×10の配列
vector<vector<int>> vec(20, vector<int>(10, 0));
・(n, m)の多次元配列
vector< vector<int> > vec(n, vector<int>(m, 0))  // 0で初期化
*/

int main() {
    cin.tie();
    ios::sync_with_stdio(false);
    
    // input
    string X, Y;
    cin >> X >> Y;
    reverse(ALL(Y));
    // calculation
    if (X == Y) {
        cout << "YES" << "\n";
    } else {
        cout << "NO" << "\n";
    }
    
    
    
    return 0;
}


// function
template <class T> void print2DVec(vector< vector<T> >& vec) {
    REP(i, vec.size()) {
        REP(j, vec.front().size()) {
            cout << vec.at(i).at(j);
        }
        cout << endl;
    }
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    switch (ch) {
        case '+':
            REP(i, vec.size()) vec.at(i) += num; break;
        case '-':
            REP(i, vec.size()) vec.at(i) -= num; break;
        case '*':
            REP(i, vec.size()) vec.at(i) *= num; break;
        case '/':
            REP(i, vec.size()) vec.at(i) /= num; break;
        case '%':
            REP(i, vec.size()) vec.at(i) %= num; break;
        default:
            cout << "Incorrect Operator" << endl;
    }
}

int char_to_int(const char c) {
    if('0' <= c && c <= '9') return (c - '0');
    return -1;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int num,first,percent,gold[1000],sum,i;
    while (1) {
        scanf("%d %d %d",&num,&first,&percent);
        if (num==0&&first==0&&percent==0) break;
        sum=0;
        for (i=0; i<num; i++) {
            scanf("%d",&gold[i]);
            sum+=gold[i];
        }
        if (gold[first-1]!=0) {
            printf("%d\n",sum*(100-percent)/gold[first-1]);
        } else {
            printf("0\n");
        }
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> B(N-1);
  for(int i=0;i<N-1;i++){
    cin >> B.at(i);
  }
  vector<int> A(N);
  A.at(0) = B.at(0);
  for(int i=1;i<=N-2;i++){
    A.at(i)= min(B.at(i),B.at(i-1));
  }
//  sum += B.at(N-1);

  A.at(N-1) = B.at(N-2);
  int sum=0;
  for(int i=0;i<N;i++){
    sum += A.at(i);
  }
  
   cout << sum << endl;
   return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    int k, n;
    cin >> n >> k;
    vl p(n);
    forn(i, n) cin >> p[i];
    sort(all(p));

    cout << accumulate(p.begin(), p.begin() + k, 0LL) << endl;

    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    string s;cin >> s;
    int size_evod = s.size()%2;
    int is_same = (s[0]==s[s.size()-1]);
    if(size_evod^is_same)cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}

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

int main(){
  int r, D, x_2000;
  cin >> r >> D >> x_2000;
  
  int ans=x_2000;
  for(int i=0; i<10; ++i){
    ans = ans*r-D;
    printf("%d\n",ans);    
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
int ac=0,wa=0,re=0,tle=0,n;
scanf("%d",&n);
while(n--){
    string s;
    cin>>s;
    if(s=="AC"){
        ac++;
    }
    else if(s=="WA"){
        wa++;
    }
    else if(s=="TLE"){
        tle++;
    }
    else if(s=="RE"){
        re++;
    }
}
printf("AC x %d\n",ac);
printf("WA x %d\n",wa);
printf("TLE x %d\n",tle);
printf("RE x %d\n",re);

    return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <utility>
#include <cmath>
#include <string>
#include <bitset>
#include <queue>
#include <cstdio>
#include <cstring>
#include <deque>
#include <unordered_map>
#include <climits>
#include <map>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <ctime>


#define ci(t) cin>>t
#define co(t) cout<<t
#define LL long long
#define fa(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>b;--i)
#define setp pair<pair<int,int>,int>
#define setl pair<LL,LL>
#define micro 0.000001
using namespace std;

int gcd(int a, int b) { return a % b ? gcd(b, a % b) : b; }
pair <int, int> vu[4] = { {0,1}, {0,-1} , {1,0},{-1,0} }; // EWSN

const int max_v = 1e2 + 7;
const int INF = 1e9 + 7;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	LL n, k;
	ci(n >> k);
	if (k >= n)
	{
		co(min(abs(n - k), n));
	}
	else
	{
		n = n % k;
		co(min(abs(n - k), n));
	}
	return 0;
}	

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	    	Scanner sc = new Scanner(System.in);
	    	int x = sc.nextInt();
	    	if (x == 3 || x == 5 || x == 7) {
	    		System.out.println("YES");
	    	} else {
	    		System.out.println("NO");
	    	}
	}
}

Measured memory_bytes: 21844
n, m, x = gets.split.map(&:to_i)

c = Array.new n
a = Array.new(n)

n.times do |i|
  c[i], *a[i] = gets.split.map(&:to_i)
end

books = (0..(n-1)).to_a

result = 10**9

1.upto(n) do |i|
  books.combination(i) do |l|
    sum = Array.new(m){ 0 }
    price = 0
    l.each do |j|
      a[j].each_with_index do |ri, index|
        sum[index] += ri
      end
      price += c[j]
    end
    if sum.all?{|k| k >= x} && price < result
      result = price 
    end
  end
end

if result > 10**8
  puts -1
else
  puts result
end

Measured memory_bytes: 14384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <climits>

using namespace std;

int abs(int x){ return x < 0 ? -x : x; }

int table[101][4];

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0){ break; }
		vector<int> t(n + 1), p(n + 1);
		for(int i = 1; i <= n; ++i){
			cin >> p[i] >> t[i];
		}
		memset(table, -1, sizeof(table));
		table[0][0] = 0;
		for(int i = 1; i <= n; ++i){
			for(int j = 0; j < 4; ++j){
				if(table[i - 1][j] < 0){ continue; }
				int a = (j + 1) * p[i - 1] + p[i];
				if(a <= t[i] - t[i - 1]){
					int s = p[i - 1] + p[i];
					if(table[i][1] < 0 || table[i][1] > table[i - 1][j] + s){
						table[i][1] = table[i - 1][j] + s;
					}
				}
				int b = (j + 1) * abs(p[i] - p[i - 1]);
				if(j < 3 && b <= t[i] - t[i - 1]){
					if(table[i][j + 1] < 0 || table[i][j + 1] > table[i - 1][j] + b){
						table[i][j + 1] = table[i - 1][j] + abs(p[i] - p[i - 1]);
					}
				}
			}
		}
		int answer = INT_MAX;
		for(int i = 0; i < 4; ++i){
			if(table[n][i] >= 0){ answer = min(answer, table[n][i] + p[n]); }
		}
		if(answer == INT_MAX){
			answer = 0;
			for(int i = n; i >= 0; --i){
				bool flag = false;
				for(int j = 0; j < 4; ++j){
					if(table[i][j] >= 0){ flag = true; }
				}
				if(flag){
					answer = i + 1;
					break;
				}
			}
			cout << "NG " << answer << endl;
		}else{
			cout << "OK " << answer << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
n, m = map(int, input().split())
H = list(map(int, input().split()))

edges = [[] for _ in range(n)]

ok = [True] * n

for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    ha = H[a]
    hb = H[b]

    if ha == hb:
        ok[a] = False
        ok[b] = False

    elif ha > hb:
        ok[b] = False

    elif ha < hb:
        ok[a] = False

print(sum(ok))


Measured memory_bytes: 21060
N, X = map(int, input().split())
XL = list(map(int, input().split()))
XL.append(X)
XL.sort()
A = [0 for i in range(N)]
for i in range(N):
  A[i] = XL[i+1] - XL[i]
a = A[0]
for i in range(N - 1):
  b = A[i+1]
  while b != 0:
    a, b = b, a % b
print(a)

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

using namespace std;

struct point{
  double x, y;
};

struct circle{
  point p;
  double r;
};

circle circumscribed_circle(point p, point q, point r){
  double a[2],b[2],c[2];
  circle res;
    
    a[0]=2*(q.x-p.x);
    b[0]=2*(q.y-p.y);
    c[0]=p.x*p.x-q.x*q.x+p.y*p.y-q.y*q.y;
    
    a[1]=2*(r.x-p.x);
    b[1]=2*(r.y-p.y);
    c[1]=p.x*p.x-r.x*r.x+p.y*p.y-r.y*r.y;
    
    res.p.x=(b[0]*c[1]-b[1]*c[0])/(a[0]*b[1]-a[1]*b[0]);
    res.p.y=(c[0]*a[1]-c[1]*a[0])/(a[0]*b[1]-a[1]*b[0]);
 
    res.r=sqrt(pow(fabs(p.x-res.p.x),2)+pow(fabs(p.y-res.p.y),2));
    
    return res;
}

int main(void) {
  
  int n;
  point in[3];
  circle ans;
 
  cin >> n;
  
  while(n--){
    for(int i=0;i<3;i++)
      cin >> in[i].x >> in[i].y;

    ans=circumscribed_circle(in[0], in[1], in[2]);

    printf("%.3f %.3f %.3f\n",ans.p.x,ans.p.y,ans.r);
  }
  
  return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;

int main (){
  int N;
  cin>>N;
  vector<int>A(N);
  rep(i,N)cin>>A[i];
  int ans=0;
  rep(i,N){
    if(i%2==0){
      if(A[i]%2==1){
        ans++;
      }
    }
  }
  cout<<ans;
}


Measured memory_bytes: 3616
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A = np.array(read().split(), np.int64)[1:]

A.sort()
Acum = A.cumsum()

ng = Acum[:-1] * 2 < A[1:]
ng = np.logical_or.accumulate(ng[::-1])[::-1]
x = (~ng).sum() + 1
print(x)

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

int main() {
    int r[MAX], n;

    cin >> n;
    for(int i = 0; i < n; i++) cin >> r[i];

    int maxv = r[1]-r[0];
    int minv = r[0];

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

    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 3896
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		//スキャナークラスを宣言
		Scanner scan = new Scanner(System.in);

		//フォーマットの指定
		DecimalFormat df = new DecimalFormat("#.#");

		//桁数を指定
		df.setMinimumFractionDigits(6);
		df.setMaximumFractionDigits(6);

		//int型の変数を宣言、入力した内容を代入
		int intNum1 = scan.nextInt();
		int intNum2 = scan.nextInt();
		//商
		int intQuotient = intNum1 / intNum2;
		double dbQuotient = (double)intNum1 / intNum2;
		//余り
		int intDiv = intNum1 % intNum2;

		BigDecimal number = new BigDecimal(dbQuotient);

		//商(整数)・余り・浮動点小数を出力
		System.out.println(intQuotient + " " +
							intDiv + " " + df.format(number));
		scan.close();
	}
}


Measured memory_bytes: 26516
#include <bits/stdc++.h>
#define INF 1000000007
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    string table[h];
    for (int i = 0; i < h; i++) {
        cin >> table[i];
    }
    int count[h][w];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            count[i][j] = (table[i][j] == '#') ? 0 : INF;
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 1; j < w; j++) {
            count[i][j] = min(count[i][j], count[i][j - 1] + 1);
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = w - 1; j > 0; j--) {
            count[i][j - 1] = min(count[i][j - 1], count[i][j] + 1);
        }
    }
    for (int i = 1; i < h; i++) {
        for (int j = 0; j < w; j++) {
            count[i][j] = min(count[i][j], count[i - 1][j] + 1);
        }
    }
    for (int i = h - 1; i > 0; i--) {
        for (int j = 0; j < w; j++) {
            count[i - 1][j] = min(count[i - 1][j], count[i][j] + 1);
        }
    }
    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            ans = max(count[i][j], ans);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int min = N;
  int pos = 0;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (x <= min) {
      pos += 1;
      min = x;
    }
  }
  
  cout << pos << endl;
}

Measured memory_bytes: 256