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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

struct UnionFind {
  vector<int> data;

  UnionFind(int n){
    data.resize(n+1);
    fill(data.begin(), data.end(), -1);
  }

  int root(int x){
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }

  void unite(int x, int y){
    int rx=root(x);
    int ry=root(y);

    if(rx!=ry){
      if(data[ry] < data[rx])swap(rx, ry);

      data[rx]+=data[ry];
      data[ry]=rx;
    }
  }

  bool same(int x, int y){
    return root(x)==root(y);
  }

  int size(int x){
    return -data[root(x)];
  }
};

int main(){
  int n,m;cin>>n>>m;
  vector<int>a(m),b(m);
  rep(i, m){
    cin>>a[i]>>b[i];
  }

  UnionFind uf(n);

  rep(i, m){
    uf.unite(a[i], b[i]);
  }

  int result = 0;
  rep1(i, n){
    if(!uf.same(1, i)){
      result++;
      uf.unite(1, i);
    }
  }

  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 4580
import java.util.Scanner;

public class Main
{
    public static void main( String[] args ) 
    {
        Scanner sc = new Scanner(System.in);
        String  s = sc.next();

        if (s.equals("ABC"))
            System.out.println("ARC"); 
        else 
            System.out.println ("ABC") ;
            sc.close();
        }
    }

Measured memory_bytes: 35592
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111

	int dp[3001][3001];
	int mo = 998244353;


	void solve(){


		ini(n);
		ini(n1);
		dp[0][0] = 1;
		FOR(i,0,n){
			ini(x);
			FOR(i1,0,3001){
				dp[i+1][i1] += dp[i][i1]*2;
				dp[i+1][i1]%=mo;
			}
			FOR(i1,0,3001){
				if(dp[i][i1]!=0 and i1+x<=n1){
					dp[i+1][i1+x]+=dp[i][i1];
					dp[i+1][i1+x]%=mo;
				}
			}
			//FOR(i1,0,3001)if(dp[i+1][i1]!=0)out(i+1,i1,31,dp[i+1][i1]);
		}
		out(dp[n][n1]);



		
	}























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


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

int N, t;
string S[100005];

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> S[i];
		sort(S[i].begin(), S[i].end());
	}
	sort(S + 1, S + 1 + N);
	for (int i = 1, c = 0; i <= N; i++) {
		c++;
		if (S[i] != S[i + 1]) {
			t += c * (c - 1) / 2;
			c = 0;
		}
	}
	cout << t << '\n';
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    string s,t;
    cin >> s >> t;
    int ans = 2000;
    int n = s.size();
    int m = t.size();
    rep(i,n-m+1){
        int cnt = 0;
        rep(j,m){
            if(s[j+i] != t[j])cnt++;
        }
        ans = min(ans,cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main (void )
{
    int a,b,i,s;
    int t = 0;
    scanf("%d %d %d",&a,&b,&s);

    for (i=a;i<=b;++i)
    {
       if (i%s==0)
         t++;
    }

    printf("%d",t);
return 0;
}


Measured memory_bytes: 1732
N,K,Q=[int(s) for s in input().split()]
ls=[0 for i in range(N)]
for i in range(Q):
  ls[int(input())-1]+=1
#print(ls)
for i in range(N):
  if K-(Q-ls[i]) <= 0:
    print("No")
  else:
    print("Yes")
  

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


void solve(long long K){
  long long acc = 7;
  for(long long i = 1; i <= 2000000; i++){
    if(acc%K == 0) {
      cout << i << endl;
      return;
    }

    acc *= 10;
    acc += 7;
    acc %= K;
  }

  cout << -1 << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
  scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);

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

    int res = 0;
    
    if (K - A > 0) {
        int A_K = K - A;
        res += A;
        if (A_K - B > 0) {
            int B_K = A_K - B;
            res -= B_K;
        }
    } else {
        res += K;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  int n,W;
  cin>>n>>W;
  vi w(n),v(n);
  rep(i,n) cin>>w[i]>>v[i];
  //i番目までで重さj以下
  vvi dp(n+1,vi(W+1,0));
  REP(i,1,n+1){
    rep(j,W+1){
      dp[i][j]=dp[i-1][j];
      if(j>=w[i-1]) chmax(dp[i][j],dp[i-1][j-w[i-1]]+v[i-1]);
    }
  }
  out(dp[n][W]);
  //outvv(dp);
}

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


Measured memory_bytes: 83168
#include <cstdio>
int factor[1001];
const int MOD = 1e9+7;
void factorize(int N)
{
    for(int i=2; i*i <= N; ++i)
    {
        while(N%i==0)
        {
            factor[i]++;
            N /= i;
        }
    }
    if(N != 1) factor[N]++;
}
int main()
{
    int N; scanf("%d", &N);
    for(int i=1; i<=N; ++i)
        factorize(i);
    int ans = 1;
    for(int i=2; i<=N; ++i)
        ans = 1LL*ans*(1+factor[i])%MOD;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#define INF 1000000001

int A[500000];
int L[250001], R[250001];
int cnt = 0;

int merge(int left, int mid, int right)
{
  int i, j, k;
  int n1, n2;
 
  n1 = mid - left;
  for(i = 0; i < n1; i++)
    {
      L[i] = A[left + i];
    }
  L[n1] = INF;
  
  n2 = right - mid;
  for(i = 0; i < n2; i++)
    {
      R[i] = A[mid + i];
    }
  R[n2] = INF;

  i = 0;
  j = 0;
  for(k = left; k < right; k++)
    {
      cnt++;
      if(L[i] <= R[j])
	    {
	    A[k] = L[i];
	    i = i + 1;
	    }
      else
	    {
	    A[k] = R[j];
	    j = j + 1;
	    }
    }
}

void mergeSort(int left, int right)
{
  int mid;

  if(left + 1 < right)
    {
      mid = (left + right)/2;
      mergeSort(left, mid);
      mergeSort(mid, right);
      merge(left, mid, right);
    }
}

int main()
{
  int i;
  int n;

  scanf("%d", &n);
  for(i = 0; i < n; i++)
    {
      scanf("%ld", &A[i]);
    }

  mergeSort(0, n);

  for(i = 0; i < n - 1; i++)
    {
      printf("%ld ", A[i]);
    }
  printf("%d\n%d\n", A[n - 1], cnt);

  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> t(N+1), v(N+1);
  for (int i=0; i<N; i++) cin >> t[i];
  for (int i=0; i<N; i++) cin >> v[i];
  int tsum = 0;
  for (int i=0; i<N; i++) tsum += t[i];
  v[N] = 0;
  vector<double> speed(tsum*2+1,1e6);
  int tm = 0;
  for (int i=0; i<=N; i++){
    tm += t[i]*2;
    int ve = v[i+1];
    for (int j=tm; j>=0; j--){
      speed[j] = min(speed[j], ve + (tm-j)*0.5);
    }
  }
  tm = 0;
  for (int i=0; i<N; i++){
    for (int j=tm; j<=tm+2*t[i]; j++){
      speed[j] = min((double)v[i], speed[j]);
    }
    tm += t[i]*2;
  }
  double ans = 0;
  double befsp = 0;
  for (int i=1; i<=tsum*2; i++){
    // cout << befsp << endl;
    ans += (befsp+min(speed[i],befsp+0.5))*0.5*0.5;
    befsp = min(speed[i],befsp+0.5);
  }
  cout << fixed << setprecision(10);
  cout << ans << endl;
}


Measured memory_bytes: 512
import sys

dic = {}

n = int(input())
for _ in range(n):
    c, k = input().split()
    if c[0] == "i":
        dic[k] = True
    else:
        if k in dic.keys():
            sys.stdout.write("yes\n")
        else:
            sys.stdout.write("no\n")



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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 1; i <= n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

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

  ll now = 0, ans;

  for (ll i = min(a, b); i > 0; i--) {
    if (a % i == 0 && b % i == 0) {
      now++;
    }
    if (now == k) {
      ans = i;
      break;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1000000010
#define N 1000010
#define P 1000000007
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
int n,h,d,f[N],sum[N],s,t;
int ksm(int a,int k)
{
	int s=1;
	for (;k;k>>=1,a=1ll*a*a%P) if (k&1) s=1ll*s*a%P;
	return s;
}
int inv(int a){return ksm(a,P-2);}
signed main()
{
	n=read(),h=read(),d=read();
	s=t=1;
	for (int i=2;i<=n;i++)
	{
		t=1ll*t*i%P;
		s=(s+t)%P;
	}
	f[0]=inv(s);sum[0]=f[0];
	for (int i=1;i<=h;i++)
	{
		int u=(sum[i-1]-(i>d?sum[i-d-1]:0)+P)%P;
		f[i]=1ll*u*s%P;
		sum[i]=(sum[i-1]+f[i])%P;
	}
	for (int i=n-1;i>=1;i--) f[h]=1ll*f[h]*i%P;
	cout<<1ll*f[h]*n%P;
	return 0;
	//NOTICE LONG LONG!!!!!
}
//一个序列，每次将某个最小值改成最大值~最大值+d之间的数，求令序列所有数均为h的方案数
//只与最大值是啥以及有几个最大值有几个最小值有关 
//最小值移动时的选择方案数 可以直接在移动最大值时乘上移动后的最大值数量 
//f[i][j]最大值为i且有j个时的方案数
//f[i][j]=f[i][j-1]*j (j>1)
//f[i][1]=Σf[i-x][y] (x=1~D,y=1~n) 
//Σf[i][x]=f[i][1]*(1+(n-1)+(n-1)*(n-2)+……) 

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

int main()
{
    int n,k,p;
    cin>>n>>k>>p;
    
    int a[n+1];
    for(int i=0;i<n+1;i++)
    a[i]=0;
    
    while(p--)
    {
        int l;
        cin>>l;
        a[0]--;
        a[l]++;
        a[l+1]--;

    }
    
    for(int i=1;i<n+1;i++)
    {
        
        a[i]+=a[i-1];
        
        if((a[i]+k)>0)
        cout<<"Yes"<<endl;
        else
        cout<<"No"<<endl;
    }
    return 0;
}


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

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

    int abc[3];
    int max_idx = 0;
    int max_val = -1;
    rep(i, 3){
        cin >> abc[i];
        if(max_val < abc[i]){
            max_idx = i;
            max_val = abc[i];
        }
    }
    int k;
    cin >> k;

    rep(i, k){
        abc[max_idx] *= 2;
    }
    
    cout << abc[0] + abc[1] + abc[2] << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  vector<int> a(9);
  vector<int> x(9);

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> a[3 * i + j];
    }
  }

  int n;
  cin >> n;

  int c;
  for (int k = 0; k < n; k++) {
    cin >> c;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (a[3 * i + j] == c) {
          x[3 * i + j] = 1;
        }
      }
    }
  }

  bool bingo = false;
  for (int i = 0; i < 3; i++) {
    int sum_r = 0;
    int sum_c = 0;
    for (int j = 0; j < 3; j++) {
      sum_r += x[3 * i + j];
      sum_c += x[3 * j + i];
    }
    if (sum_r == 3 || sum_c == 3) {
      bingo = true;
      break;
    }
  }
  if (x[0] + x[4] + x[8] == 3 || x[2] + x[4] + x[6] == 3) {
    bingo = true;
  }

  if (bingo) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=100005,INF=1<<30;
vector<int> fake[MAX],G[MAX];
bool black[MAX],use[MAX];

bool maketree(int u,int p){
    bool check=false;
    for(int to:fake[u]){
        if(to==p) continue;
        
        bool x=maketree(to,u);
        
        check|=x;
        
        if(x){
            G[u].push_back(to);
            G[to].push_back(u);
            use[u]=1;
            use[to]=1;
        }
    }
    if(black[u]==0||check) return true;
    else return false;
}

int dp[MAX],ma[MAX];

void solve(int u,int p){
    int a=0,b=0;
    
    for(int to:G[u]){
        if(to==p) continue;
        solve(to,u);
        
        if(a<dp[to]){
            b=a;
            a=dp[to];
        }else if(b<dp[to]){
            b=dp[to];
        }
    }
    
    if(!black[u]){
        dp[u]=a+1;
        ma[u]=a+b+1;
    }else{
        dp[u]=a;
        ma[u]=a+b;
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    for(int i=0;i<N-1;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        fake[a].push_back(b);
        fake[b].push_back(a);
    }
    
    int cnt=0;
    
    for(int i=0;i<N;i++){
        char c;cin>>c;
        if(c=='B'){
            black[i]=1;
        }else cnt++;
    }
    
    if(cnt==1){
        cout<<1<<endl;
        return 0;
    }
    
    int root=0;
    
    for(int i=0;i<N;i++){
        if(black[i]==0){
            maketree(i,-1);
            root=i;
            break;
        }
        if(i==N-1){
            cout<<0<<endl;
            return 0;
        }
    }
    
    int ans=0;
    
    for(int i=0;i<N;i++){
        if(use[i]){
            ans+=si(G[i]);
            black[i]^=(si(G[i])&1);
        }
    }
    
    solve(root,-1);
    
    int m=0,ng=0;
    
    for(int i=0;i<N;i++){
        if(use[i]){
            chmax(m,ma[i]);
            if(!black[i]) ng++;
        }
    }
    
    ng-=m;
    
    cout<<ans+ng-m<<endl;
    
}


Measured memory_bytes: 19968
while True:
    count = 0
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    else:
        for i in range(1, n + 1):
            for j in range(i + 1, n + 1):
                for k in range(j + 1, n + 1):
                    if i + j + k == x:
                        count += 1
    print(count)


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

class cD
{
public:
	void N()
	{
		int nTemp = 0;
		nTemp = nD[1];
		nD[1] = nD[2];
		nD[2] = nD[6];
		nD[6] = nD[5];
		nD[5] = nTemp;
	}

	void S()
	{
		int nTemp = 0;
		nTemp = nD[1];
		nD[1] = nD[5];
		nD[5] = nD[6];
		nD[6] = nD[2];
		nD[2] = nTemp;
	}

	void W()
	{
		int nTemp = 0;
		nTemp = nD[1];
		nD[1] = nD[3];
		nD[3] = nD[6];
		nD[6] = nD[4];
		nD[4] = nTemp;
	}

	void E()
	{
		int nTemp = 0;
		nTemp = nD[1];
		nD[1] = nD[4];
		nD[4] = nD[6];
		nD[6] = nD[3];
		nD[3] = nTemp;
	}

	void Rotate()
	{
		int nTemp = 0;
		nTemp = nD[2];
		nD[2] = nD[3];
		nD[3] = nD[5];
		nD[5] = nD[4];
		nD[4] = nTemp;
	}

	int nD[7] = { 0 };
};
int main()
{
	cD D;
	for (int i = 1; i <= 6; i++)
	{
		cin >> D.nD[i];
	}
	int nCount;
	cin >> nCount;
	for (int i = 0; i < nCount; i++)
	{
		int nT, nF;
		cin >> nT >> nF;
		for (int j = 1; j <= 6; j++)
		{
			if (nT == D.nD[j])
			{
				if (1 == j)
				{
					break;
				}
				else if (2 == j)
				{
					D.N();
				}
				else if (3 == j)
				{
					D.W();
				}
				else if (4 == j)
				{
					D.E();
				}
				else if (5 == j)
				{
					D.S();
				}
				else
				{
					D.S();
					D.S();
				}
			}
		}

		while (D.nD[2] != nF)
		{
			D.Rotate();
		}
		cout << D.nD[3] << endl;
	}

	//system("pause");
	return 0;
}

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

int main() {
  int n, T;
  cin >> n >> T;
  vector<int> c(n);
  vector<int> t(n);
  for (int i=0; i<n; i++){
    cin >> c.at(i) >> t.at(i);
  }
  int ans = 1010;
  for (int i=0; i<n; i++){
    if (t.at(i) > T){
      continue;
    }
    else{
      if (c.at(i) < ans){
        ans = c.at(i);
      }
    }
  }
  if (ans == 1010){
    cout << "TLE" << endl;
  }
  else{
    cout << ans << endl;
  }
  return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextInt();

  vector<string> ss;
  vector<int> ts;
  REP(i, N) {
    string s; cin >> s;
    int t; cin >> t;
    ss.push_back(s);
    ts.push_back(t);
  }

  string X; cin >> X;
  ll ans = 0;

  int in = 0;
  REP(i, N) {
    if (in) ans += ts[i];
    if (X == ss[i]) in = true;
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.Char

data Dice = Dice [Int] deriving (Show, Eq)

rollDice :: Char -> Dice -> Dice
rollDice 'N' (Dice [a,b,c,d,e,f]) = Dice [b,f,c,d,a,e]
rollDice 'E' (Dice [a,b,c,d,e,f]) = Dice [d,b,a,f,e,c]
rollDice 'S' d = foldr1 (.) (replicate 3 $ rollDice 'N') $ d
rollDice 'W' d = foldr1 (.) (replicate 3 $ rollDice 'E') $ d

topDice :: Dice -> Int
topDice (Dice (a:_)) = a

question :: Dice -> Dice -> Bool
question d e = not $ null setFront
  where
    setTop = filter ((==(topDice e)) . topDice) ([d] ++ [rollDice 'N' . rollDice 'N' $ d] ++ map (flip rollDice d) "NESW")
    setFront = setTop >>= \f -> filter (==(rollDice 'E' e)) (scanr rollDice (rollDice 'E' f) "NNN")

main = do
  as <- map read . words <$> getLine
  bs <- map read . words <$> getLine
  let d = Dice as
  let e = Dice bs
  putStrLn $ if question d e then "Yes" else "No"
  
  

Measured memory_bytes: 3708
#include<iostream>
using namespace std;
int main() {
    int n;
    cin>>n;
    int t;
    while(n>0) {
        t = n%10;
        if(t==7) {
            cout<<"Yes";
            return 0;
        }
        n /= 10;   
    }
    cout<<"No";
}

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

using namespace std;

int a[100010];

int main()
{
    int n,k,t,m;
    cin>>n>>k;
    for(int i=0; i<n; i++)
    {
        cin>>t;
        a[t]++;
    }
    m=0;
    for(int i=0; i<100010; i++)
        if(a[i]>m)m=a[i];
    t=0;
    t=(n-m+1-k)%(k-1);
    if(t)cout<<(n-m+1-k)/(k-1)+2;
    else cout<<(n-m+1-k)/(k-1)+1;

    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main()
{
    cin.tie(0);

    int n;
    cin >> n;
    int a, b;
    cin >> a >> b;

    cout << (abs(a - b) % 2 == 0 ? "Alice" : "Borys") << endl;

    return 0;
}

Measured memory_bytes: 256
<>;
for(<>){
	($A,$B)=sort{$a-$b}glob;
	$C=int(sqrt($A*$B));
	$C-=$C*$C==$A*$B;
	if($C*($C+1)>=$A*$B){
		print$C*2-2,$/
	}else{
		print$C*2-($A!=$B),$/
	}
}


Measured memory_bytes: 768
#include<stdio.h>
#include<string.h>
int main(void){
    char s[200];
    int  i, j, n, S[200], sum;
    while ( scanf("%s", s) != EOF ) {
        sum = 0;
        for ( i = 0; i < strlen(s); i++ ) {
            if ( s[i] == 'I' ) S[i] = 1;
            if ( s[i] == 'V' ) S[i] = 5;
            if ( s[i] == 'X' ) S[i] = 10;
            if ( s[i] == 'L' ) S[i] = 50;
            if ( s[i] == 'C' ) S[i] = 100;
            if ( s[i] == 'D' ) S[i] = 500;
            if ( s[i] == 'M' ) S[i] = 1000;
        }
        S[i] = 0;
        n = i;
        for ( i = 0; i < n; i++ ) {
            if ( S[i] < S[i + 1] ) S[i] *= -1;
        } 
        for ( i = 0; i < n; i++ ) sum += S[i];
        printf("%d\n", sum);
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int p[n];
  rep(i,n) cin >> p[i];
  int count=0;

  int mi = n+1;
  for(int i=0;i<n;i++){
      if(p[i]<=mi){
          count++;
          mi =p[i];

      }

  }
  cout << count << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<string, int>;

int main(){
    int n, maxim=0;
    cin >> n;
    map<string, int> mp;
    rep(i, n){
        string s;
        cin >> s;
        if(mp.find(s)!=mp.end()){
            mp[s]++;
        }else{
            mp[s] = 1;
        }
        maxim = max(maxim, mp[s]);
    }
    for (map<string, int>::iterator it = mp.begin(); it != mp.end();it++){
        P item = *it;
        if(item.second==maxim){
            cout << item.first << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 19176
#include <bits/stdc++.h>
using namespace std;
int main(){
  int w,a,b,c;
  cin>>w>>a>>b;
  c=a-b;
  if(abs(c)<=w){
    cout<<"0";
  }
  else{
    cout<<abs(c)-w;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s, t;
long long n, m, l;
int main(void)
{
	cin>>n>>m>>s>>t, l = n*m/__gcd(n, m);
	for(int i=0;i<n;i++)
		if(i*m%n == 0&&s[i]!=t[i*m/n])
			{
				cout<<-1;
				return 0;
			}
	cout<<l;
}

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

typedef long long ll;
typedef long double ld;

using namespace std;

void INeedIt() {
	ios_base::sync_with_stdio(0);
    cin.tie(0);		
    cout.tie(0);
}
int l[100001];
int main() {
	INeedIt();
	int n, k=0;
	cin>>n;
	for (int i=0;i<n*2;i++) {
		cin>>l[i];
	}
	sort(l, l+n*2);
	for (int i=0;i<n*2;i+=2) {
		k+=min(l[i], l[i+1]);
	}
	cout<<k;
	
	return 0;
}

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

int main(){
  int n,z,w;
  int a[100000];

  cin>>n>>z>>w;
  
  for(int i=0;i<n;i++)
    cin>>a[i];

    if(n==1)
      cout<<abs(a[0]-w)<<endl;
    else
    cout<<max(abs(a[n-1]-w),abs(a[n-2]-a[n-1]))<<endl;

  return 0;
}


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

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x = 0): x((x % mod + mod) % mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

ll sum(ll l, ll r) {
  return (l + r) * (r - l + 1) / 2;
}

int main() {
  int n, k;
  cin >> n >> k;
  mint ans;
  for (int i = k; i <= n+1; i++) {
    ll l = sum(0, i - 1);
    ll r = sum(n - i + 1, n);
    ans += r - l + 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
import collections
import bisect

n, m = map(int, input().split())#入力
s = [[int(_) for _ in input().split() ] for _ in range(m)]
a = collections.defaultdict(list)#「県」と「市の誕生順」を分けて管理

for x,y in sorted(s):#ソート⇒県の順番に並ぶ
    a[x]+=[y]
for x,y in s:
    z = bisect.bisect(a[x],y)#二分検索⇒市の誕生順のインデックスが返る
    print("%06d%06d"%(x,z))#形式を整えて出力

Measured memory_bytes: 41012
/*Hey, What's up?*/

#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<long long>v;
int main()
{
    fastio;
    long long a=0,b=0,c,d,e,f=0,l,g,m,n,k,i,j,t,p,q;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a;
        f^=a;
    }
    if(f==0){
        cout<<"Yes\n";
    }
    else cout<<"No\n";


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int N; ll K; cin >> N >> K;
    vector<int> A(N);
    rep(i, N) {
        int a; cin >> a;
        a--;
        A[i] = a;
        // cout << a << " ";
    }
    // cout << endl;
    if (A[0] == 1) {
        cout << 1 << endl;
        return 0;
    }
    vector<int> al(N, -1);
    al[0] = 0;

    // int start_i = 0;
    int nb_loop = 0;
    int cur_i = 0;// A[start_i];
    // al[cur_i] = nb_loop;

    while (1) {
        nb_loop += 1;
        cur_i = A[cur_i];
        if (al[cur_i] != -1) {
            K -= nb_loop;
            nb_loop = nb_loop - al[cur_i];
            break;
        }
        if (nb_loop == K) {
            cout << cur_i +1 << endl;
            return 0;
        }
        al[cur_i] = nb_loop;
        // cout << cur_i << endl;
    }

    // cout << "nb_loop " << nb_loop << endl;
    K %= nb_loop;
    // cur_i = 0;
    rep(i, K) {
        cur_i = A[cur_i];
    }
    cout << cur_i + 1 << endl;
    return 0;
}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string s, t;
    cin >> s >> t;
    string ans = "";
    for (int i = 0; i < s.size(); i++) {
        ans += s[i];
        if (i < t.size())
        ans += t[i];
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
N, Q = map(int, input().split())
G = [[] for _ in range(N)]
score = [0]*N
visited = [False]*N

for i in range(N-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  G[a].append(b)
  G[b].append(a)
  
for j in range(Q):
  p, x = map(int, input().split())
  p -= 1
  score[p] += x

def dfs(pos):
  visited[pos] = True
  for next_pos in G[pos]:
    if visited[next_pos] == True:
      continue
    score[next_pos] += score[pos]
    dfs(next_pos)
dfs(0)
score = [str(s)  for s in score]
ans = ' '.join(score)
print(ans)

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

int main(){
    string x, y;
    cin >> x >> y;

    if(x < y){
        cout << "<" << endl;
    }else if(x > y){
        cout << ">" << endl;
    }else{
        cout << "=" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define itrep(type, it, t) for(type::iterator it=t.begin(); it!=t.end(); it++)
using namespace std;

#define ll long long

int main(void) {

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

    ll left = 4 * a * b;
    ll right = (c-b-a)*(c-b-a);
    if((c-b-a)<0) right *= -1;
    // cout << left << endl;
    // cout << right << endl;


    string ans = (left<right) ? "Yes" : "No";
    cout << ans;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define INF 0x3f3f3f3f
#define pb push_back
#define se second
#define fi first
using namespace std;
const int N=2e5+5;
ll a[N],p[N];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n; cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    p[0]=0;
    for(int i=1;i<=n;i++) p[i]=p[i-1]+a[i];
    ll ans=1e18;
    for(int i=1;i<n;i++){
        ll x=p[i];
        ll y=p[n]-p[i];
        ans=min(ans,abs(x-y));
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>
int main(){
  int max,min,a;
  scanf("%d%d",&min,&max);
  if(max<min){
    a=min;
    min=max;
    max=a;
  }
  scanf("%d",&a);
  if(a>=max)
    max=a;
  if(min>a)
    min=a;
  printf("%d\n",max-min);
  return 0;
}


Measured memory_bytes: 128
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define MAX(a,b) (a>b?a:b)
using namespace std;

int main(){
  int N;
  cin >> N;
  set<long long int> st;
  rep(i ,N){
    long long int tmp;
    cin >> tmp;
    int j = st.erase(tmp);
    if(j==0) st.insert(tmp);
  }

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

Measured memory_bytes: 4864
#include <stdio.h>
int main() {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (a == b) printf("%d\n", c);
	if (a == c) printf("%d\n", b);
	if (c == b) printf("%d\n", a);
	return 0;
}

Measured memory_bytes: 128
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include <bits/stdc++.h>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007


#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(int a,int b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 

 
int main() {
    ll N=0;
    cin >>N;
    ll tmp=0;
    ll count=0;
    while(tmp<N*2){
      count++;
      tmp=count*(count+1);
      if(tmp==N*2){
        cout<<"Yes"<<endl;
        cout<<count+1<<endl;
        int ans[count+1][count];
        int stack[N];
        int next=0;
        FOR(i,0,N-1){
          stack[i]=0;
        }

        FOR(j,0,count-1){

        FOR(i,0,count-1-j){
          ans[j][j+i]=i+1+next;
          ans[j+i+1][j]=i+1+next;

        }
        next=next+count-j;
                    }

        FOR(i,0,count){
          cout<<count;
          cout<<" ";
          FOR(j,0,count-1){
            cout<<ans[i][j];
            cout<<" ";
          }
          cout<<endl;
        }

        return 0;
      }
    }
    cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 2560
class Node:
  def __init__(self, num):
    self.key = num
    self.p = None
    self.left = None
    self.right = None

class BinarySearchTree:
  def __init__(self):
    self.root = None

  def insert(self, z):
    y = None
    x = self.root
    while x != None:
      y = x
      if z.key < x.key:
        x = x.left
      else:
        x = x.right
    z.p = y

    if y is None:
      self.root = z
    elif z.key < y.key:
      y.left = z
    else:
      y.right = z

def print_inorder(node):
  if node is None: return
  print_inorder(node.left)
  print(" {}".format(node.key), end="")
  print_inorder(node.right)

def print_preorder(node):
  if node is None: return
  print(" {}".format(node.key), end="")
  print_preorder(node.left)
  print_preorder(node.right)

T = BinarySearchTree()
for i in range(int(input())):
  params = input().split()
  if params[0] == "insert":
    T.insert(Node(int(params[1])))
  if params[0] == "print":
    print_inorder(T.root)
    print("")
    print_preorder(T.root)
    print("")

Measured memory_bytes: 153676
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[3][n + 1];
    for (int i = 0 ; i <= 2 ; i++) for (int j = 0 ; j <= n ; j++) a[i][j] = 0;
    for (int i = 1 ; i <= 2 ; i++) for (int j = 1 ; j <= n ; j++) {
    	int b;
        cin >> b;
        a[i][j] = max (a[i - 1][j] , a[i][j - 1]) + b;
    }
    cout << a[2][n];
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int n;
	string s;
	cin >> n >> s;
	
	vector<int> rcnt(26);
	rep(i,0,n) rcnt[ s[i] - 'a' ]++;
	
	vector<int> cnt(26);
	int ans = 0;
	rep(i,0,n){
		cnt[ s[i] - 'a' ]++;
		rcnt[ s[i] - 'a' ]--;

		int sum = 0;
		rep(i,0,26)
			if( cnt[i] > 0 && rcnt[i] > 0 )
				sum++;	

		ans = max(sum , ans );
	}

	cout << ans << endl;
	ret 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;

int main(){
    string S;


    int Q;
    cin >> S;
    cin >> Q;
    deque<char> L;
    rep(i,S.size()) {
        L.push_back(S[i]);
    }
    bool flag = true;
    rep(i, Q){
        int T, F;
        char C;
        cin >> T;
        if (T == 1) {
            flag = !flag;
        } else {
            cin >> F >> C;
            if (flag) {
                if (F == 1) {
                    L.push_front(C);
                } else {
                    L.push_back(C);
                }
            } else {
                if (F == 1) {
                    L.push_back(C);
                } else {
                    L.push_front(C);
                }
            }
        }
    }

    if (flag) {
        for (auto s: L) {
            cout << s;
        }
    } else {
        reverse(L.begin(), L.end());
        for (auto s: L) {
            cout << s;
        }

    }

    cout << endl;


}

Measured memory_bytes: 896
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main(){
  int a, b;
  scanf("%d%d", &a, &b);
  int val = a - 1;
  if (b >= a) val++;
  std::cout << val << '\n'; 
  return 0;
}


Measured memory_bytes: 256
x, k, d = map(int, input().split())
x = abs(x)
if k * d < x:
    print(x - k * d)
    exit()

if (k - x // d) % 2 == 0:
    print(x - x // d * d)
else:
    print(abs(x - (x // d + 1) * d))


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    ii3(n,m,x);
    int c1 = 0, c2 = 0;
    rep(i, m){
        ii(y); if(y < x) c1++; else c2++;
    }
    out(min(c1, c2));
}

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[], int n) {
	for (int i = 0; i < n; i++) {
		cout << a[i] << " ";
	}
	cout << endl;
}



int check(int n) {

	int temp = n + 9;

	temp = temp / 10;
	return temp * 10;



}

bool comp(pair<string,pair<int,int>> a , pair<string,pair<int,int>> b) {


	// return a % 10 > b % 10;
	if(a.F!=b.F)
		return a.F<b.F;
	return a.S.F>b.S.F;

}

int main() {
	int i, n, m, k, c = 0;
	c_p_c();
	int l;
	cin>>n>>l;
	int a[n];
	int sm=INF;
	for (int i = 0; i < n; ++i)
	{
		/* code */
		a[i]=(i+l);
		sm=min(sm,abs(a[i]));
		c+=a[i];
	}
	// watch(c+21);
	// parray(a,n);
	if(c>0)
		cout<<c-sm<<endl;
	else
	cout<<c+sm<<endl;
}



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

int main(){
    int t;
    cin >> t;
    t = t-(t/10)*10;
    // cout << t;
    if (t==3){
        cout << "bon";
    }else if (t==0||t==1||t==6||t==8){
        cout << "pon";
    }else{
        cout << "hon";
    }
}

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

int main()
{
	int N, A, B;
	string S;
	cin >> N >> A >> B >> S;

	for( int i = 0; i < N; i++ ) {
		char c = S[i];
		string ans = "No";
		if( c == 'c' ) {
		}
		else if( c == 'a' ) {
			if( A + B > 0 ) {
				ans = "Yes";
				if( A == 0 ) B--;
				else A--;
			}
		}
		else {
			if( A + B > 0 && B ) {
				ans = "Yes";
				B--;
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 896
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;


int main() {

    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    vector<ll > A(X,0);
    vector<ll > B(Y,0);
    vector<ll > C(Z,0);

    for(ll i = 0; i < X; i++){
        cin >> A[i];
    }

    for(ll i = 0; i < Y; i++){
        cin >> B[i];
    }

    for(ll i = 0; i < Z; i++){
        cin >> C[i];
    }

    sort(C.rbegin(), C.rend());

    vector<ll > AB;

    for(ll i = 0; i < X; i++){
        for(ll j = 0; j < Y; j++){
            AB.push_back(A[i]+B[j]);
           //cout << A[i]+B[j] << endl;
        }        
    }
    
    sort(AB.rbegin(), AB.rend());

    vector<ll > ans;

    ll cn = 0;
    for(ll i = 0; i < AB.size(); i++){
        for(ll j = 0; j < Z; j++){
            ans.push_back(AB[i] + C[j]);
            cn++;
            if(cn >= K * K){
                break;
            }
        }
        if(cn >= K * K){
            break;
        }
    }
    
    sort(ans.rbegin(), ans.rend());
    for(ll i = 0; i < K; i++){
        cout << ans[i] << endl;
    }

}

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define FOR(i, n, m) for(ll i = (ll)n; i < (ll)(m); i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define PRINT(x) std::cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dx[8] = {0,1,0,-1, 1, -1, 1, -1}, dy[8] = {1,0,-1,0,1,1,-1,-1};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{ 
  ll N, K;
  cin >> N >> K;
  
  vector<ll> A(N);
  REP(i, N) { 
      cin >> A[i];
  }

  REP(i, min(50LL, K)) {
    vector<ll> B(N);
    REP(j, N) {
      ll l = max(j - A[j], 0LL);
      ll r = min(j + A[j], N-1);
      B[l] ++;
      if (r+1 < N) B[r+1]--;
    }
    REP(j, N-1) {
      B[j+1] += B[j];
    }
    A = B;
  }
  PRINT(A);
  return 0;
} 


Measured memory_bytes: 6428
import java.util.Scanner;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int h, w;
		while(true)
		{
			h = sc.nextInt();
			w = sc.nextInt();
			if(h == 0 && w == 0)
			{
				break;
			}
			for (int i = 0; i < h; i++)
			{
				for (int j = 0; j < w; j++)
				{
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
		sc.close();
	}
}


Measured memory_bytes: 33928