akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long

using pi = pair<int, int>;

typedef tree< pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update>Order_Set;

Order_Set X;

const int mxn = 2e5+100;
const int Mod = 1e9+7;

int arr[mxn], qs[mxn];
int bitOn[55];
map<int,int>Mp, cnt, op;
vector<int>Pi, Ans;
vector<int>G[mxn];
set<int>seet[mxn];

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

int visit[3][100005];
int n, k;

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

    int n, k;
    cin>>n>>k;
    (n == k) ? puts("Yes") : puts("No");

    return 0;
}





Measured memory_bytes: 15488
#include<iostream>
    #include<string>
    #include<algorithm>
    #include<vector>
    #include<iomanip>
    #include<math.h>
    #include<complex>
    #include<queue>
    #include<deque>
    #include<stack>
    #include<map>
    #include<set>
    #include<bitset>
    using namespace std;
    #define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
    #define rep(i,n) REP(i,0,n)
    typedef long long ll;
    typedef pair<int,int> pint;
    typedef pair<ll,int> pli;
    const int inf=1e9+7;
    const ll longinf=1LL<<60 ;
    const ll mod=1e9+7 ;
        using namespace std;
     
    int b[200010]={1};
     
        int main(){
          ll n;
          cin >> n;
          ll x[n],y[n],h[n];
          rep(i,n)cin >> x[i] >> y[i] >> h[i];
          ll H=-1,cx=-1,cy=-1;
          int P=0;
          while(h[P]==0)P++;
          rep(i,101){
           rep(j,101){
             bool flag=true;
             ll C=abs(x[P]-i)+abs(y[P]-j)+h[P];
            rep(k,n){
              if(h[k]>0 && abs(x[k]-i)+abs(y[k]-j)+h[k]!=C)flag=false;
              if(h[k]==0 && C>abs(x[k]-i)+abs(y[k]-j))flag=false;
            }
             if(flag){
               cx=i;
               cy=j;
               H=C;
               break;
             }
           }
          }
          cout << cx << ' ' << cy << ' ' << H << endl;
          return 0;}

Measured memory_bytes: 256
#include<iostream>
 
using namespace std;
 
int main(void) {
	char moji[4];
	cin >> moji;
	if (moji[0] == moji[2]) {
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}
	return 0;
}

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



using namespace std;



#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(int i = f; i < (int)l; ++i)
#define repit(it, t) for(__typeof((t).begin()) it = (t).begin(); it != (t).end(); it++)
#define endl "\n"
#define pb emplace_back
#define lb lower_bound
#define int long long
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second
#define DBG0(x) { cout << #x << ": " << x << "\t"; }
#define DBG(x) {DBG0(x); cout << endl;}
#define DBG2(x, y) {DBG0(x); DBG(y);}
#define DBG3(x, y, z) {DBG0(x); DBG2(y, z);}
#define DBG4(w, x, y, z) {DBG0(w); DBG3(x, y, z);}

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;

signed main(void) {
    int n, m, d;
    cin >> n >> m >> d;

    int x = n - 2 * d;
    x = x <= 0 ? 0 : x;

    int y = 2 * d;
    y = n <= y ? n : y;

    if (d == 0) {
        x = 0;
        y = n;
    }

    double ans = (2 * x + y) / (double)n / n;
    printf("%.8lf\n", ans * (m - 1));
    return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main
{
   public static void main(String args[]) throws IOException
   {
	
	BufferedReader br =
	 new BufferedReader(new InputStreamReader(System.in));

	String str1 = br.readLine();
	String str2[] = str1.split(" ");
	int a = Integer.parseInt(str2[0]);
	int b = Integer.parseInt(str2[1]);
	int c = a*b;
	int d = 2*(a+b);
	System.out.println(c + " " + d);
   }
}

Measured memory_bytes: 24200
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define en "\n"
#define pair <int, int> pii
#define all(x) x.begin(),x.end()
#define loop(i,q,n) for(int i=q;i<n;i++)
#define dloop(i,a,b) for(int i=a;i>=b;i--)
#define speed ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
const ld PI = 3.14159265358979323;
const ll mod = 1e9+7;
const int N=100005;
//******************************************************************************             
int gcd(int a,int b)
{
	if(b==0)return a;
	else return gcd(b,a%b);
}
vector<int> g[N];
bool vis[N];
int dp[N];
int dfs(int node)
{
    int s=1;
    int r=0;
    if(g[node].size()==0)dp[node]=1;
    if(dp[node]!=-1)return dp[node];
    loop(i,0,g[node].size())
    {
        r=max(r,dfs(g[node][i]));
    }
    dp[node]=max(dp[node],s+r);
    return dp[node];
}
int main()
{
	speed;
	int n,m,maxi=0;
	cin>>n>>m;
	memset(dp,-1,sizeof(dp));
	while(m--)
	{
	    int x,y;
	    cin>>x>>y;
	    g[x].pb(y);
	}
	loop(i,1,n+1)dfs(i);
	//loop(i,1,n+1)cout<<dp[i]<<" ";
	loop(i,1,n+1)
	maxi=max(maxi,dp[i]);
	cout<<maxi-1;
	return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  auto palindrome = [](string s){
    for (int i = 0; i < s.size()/2; i++)
      if (s[i] != s[s.size() - i - 1])
        return 0;
    return 1;
  };
  if (!palindrome(s))
    cout << "No\n";
  else if (!palindrome(s.substr(0, (s.size())/2)) || !palindrome(s.substr(s.size()/2+1, (s.size()/2))))
    cout << "No\n";
  else cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 256
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

#include <bits/stdc++.h>
 
using namespace std;

//Ordered Set Implementaton:

/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;

typedef tree<
    int,
    null_type,
    less_equal<int>,
    rb_tree_tag,
    tree_order_statistics_node_update>
ordered_set;*/

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair 
 
typedef long long ll;
typedef long double ld;

void solve(){
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k - 1] << "\n";
    return;
}
 
int main(){
    IOS;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <bitset>
#include <tuple>
#include <queue>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i <(int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i,k,n) for (int i = (int)(n)-1; i >= k; i--)
#define INF 1LL<<61

using namespace std;
int main(){
    int n,k;
    int h[100100];
    cin >> n >> k;
    rep(i,n) cin >> h[i];
    sort(h,h+n);
    int mi = 1<<30;
    rep(i,n-k+1){
        mi = min(mi,h[i+k-1]-h[i]);
    }
    cout << mi << endl;;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int a[10000],b[10000];
int main(void)
{
	int n,m,f[501]={0},z,i;
	scanf("%d",&n);
	scanf("%d",&m);
        while(n!=0&&m!=0){
	for(i=0;i<501;i++){
        f[i]=0;
        z=0;
	}
	for(i=0;i<m;i++){
		scanf("%d %d",&a[i],&b[i]);
	}
	for(i=0;i<m;i++){
	if(1==a[i]){
		f[b[i]]=1;
		f[a[i]]=1;
		z=z+1;
	}
	}
	for(i=0;i<m;i++){
	if(f[a[i]]==1 && f[b[i]]==0){
		f[b[i]]=2;
		z=z+1;
	}
	if(f[a[i]]==0 && f[b[i]]==1){
		f[a[i]]=2;
		z=z+1;
	}
	}
	printf("%d\n",z);
scanf("%d %d",&n,&m);
}
	return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
 
using vc = vector<char>;
using vi = vector<int>;
using vll = vector<ll>;

using cd = complex<double>;
const double PI = acos(-1);

void fft(vector<cd> & a, bool invert) {
    ll n = a.size();
    if (n == 1)
        return;

    vector<cd> a0(n / 2), a1(n / 2);
    for (ll i = 0; 2 * i < n; i++) {
        a0[i] = a[2*i];
        a1[i] = a[2*i+1];
    }
    fft(a0, invert);
    fft(a1, invert);

    double ang = 2 * PI / n * (invert ? -1 : 1);
    cd w(1), wn(cos(ang), sin(ang));
    for (ll i = 0; 2 * i < n; i++) {
        a[i] = a0[i] + w * a1[i];
        a[i + n/2] = a0[i] - w * a1[i];
        if (invert) {
            a[i] /= 2;
            a[i + n/2] /= 2;
        }
        w *= wn;
    }
}

vector<ll> multiply(vector<ll> const& a, vector<ll> const& b) {
    vector<cd> fa(a.begin(), a.end()), fb(b.begin(), b.end());
    ll n = 1;
    while (n < a.size() + b.size()) 
        n <<= 1;
    fa.resize(n);
    fb.resize(n);

    fft(fa, false);
    fft(fb, false);
    for (ll i = 0; i < n; i++)
        fa[i] *= fb[i];
    fft(fa, true);

    vector<ll> result(n);
    for (ll i = 0; i < n; i++)
        result[i] = round(fa[i].real());
    return result;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll N, M;
    ll MAX_N = 1e5+1;
    cin >> N >> M;
    vll arr (N);
    F0R(i, N) cin >> arr[i];

    vll occ (MAX_N); 
    F0R(i, N) ++occ[arr[i]];
    vll count = multiply(occ, occ);
    ll sum = 0;
    R0F(i, 2*MAX_N) {
        if (M < 0) break;
        ll use = min(M, count[i]);
        sum += 1LL * use * i;
        M -= use;
    }  
    cout << sum << endl;
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll lik, ch;
  string a, b;
  cin >> a >> b;
  lik = stoi(a + b);
  ch = sqrt(lik);
  if (ch * ch == lik) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
def ARC061D():
    H, W, N = map(int, input().split())
    ab = [list(map(int, input().split())) for i in range(N)]
    ab.sort()
    tmp_list = []
    ans_list = [0 for i in range(10)]
    for x, y, in ab:
        for i in range(x - 3, x):
            for j in range(y - 3, y):
                if 0 <= i < H - 2 and 0 <= j < W - 2:
                    #print(x, y, i, j)
                    tmp_list.append([i, j])
    #print(tmp_list)
    tmp_list.sort()
    temp = 1
    #print(tmp_list)
    cnt = 0
    for i in range(1, len(tmp_list) + 1):
        if i != len(tmp_list):
            if tmp_list[i] == tmp_list[i - 1]:
                temp += 1
            else:
                ans_list[temp] += 1
                temp = 1
                cnt += 1
        else:
            ans_list[temp] += 1
            cnt += 1
    #print(ans_list)

    key = 0
    for i in range(len(ans_list)):
        key += i * ans_list[i]
    ans_list[0] = (H - 2) * (W - 2) - cnt
    #print(key)
    #print((H - 2) * (W - 2) - key)

    for i in range(10):
        print(ans_list[i])

ARC061D()


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

vector<int> buf;
vector<int> G[10000000] ;
int k = 0 ;
void dfs(int i, const int size, const int range_start, const int range_end)
{
    if ( i-1 == size ) {
        for(int i = 1 ; i <= size ; ++i){
          	G[k].push_back(buf[i]) ;
        }
        k++ ;
    }
    else{
        for(int j = buf[i-1] ; j <= range_end ; ++j){
            buf[i] = j ;
            dfs(i + 1, size, range_start, range_end);
        }
    }
}

int main(void)
{
  	int n , m , q ;
  	cin >> n >> m >> q ;
  	int a[q] , b[q] ,c[q] , d[q] ;
  	rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i] ;
    int size = n ;
    int range_start = 1 ;
    int range_end = m  ;
    buf.resize(size+1)  ;
    buf[0] = 1 ;
  	ll ans = 0 ;
    dfs(1, size, range_start, range_end);
	for(int i = 0 ; i < k ; i++ ){
      
      vector<int> A(size) ;
      int j = 0 ;
      for( auto p : G[i] ) A[j++] = p ;
      ll tem =  0 ;
      rep(l,q) if( A[b[l]-1] - A[a[l]-1] == c[l] ) tem += d[l] ; 
      ans = max(tem,ans) ;
      
      //for( auto p : G[i] ) cout << p << ' ' ;
      //cout << endl;
    }
  	cout << ans << endl;
}

Measured memory_bytes: 245192
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String[] args){
        Scanner ir=new Scanner(System.in);
        for(;;){
            int n=ir.nextInt();
            int m=ir.nextInt();
            if(n==0){
                return;
            }
            Graph[] g=new Graph[n];
            int[] col=new int[n];
            for(int i=0;i<n;i++){
                g[i]=new Graph();
            }
            for(int i=0;i<m;i++){
                int u=ir.nextInt()-1;
                int v=ir.nextInt()-1;
                g[u].add(v);
                g[v].add(u);
            }
            if(!dfs(0,1,col,g)){
                System.out.println(0);
            }
            else{
                int b=0;
                for(int i=0;i<n;i++){
                    if(col[i]==1){
                        b++;
                    }
                }
                TreeSet<Integer> st=new TreeSet<>();
                if(b>=2&&b%2==0){
                    st.add(b/2);
                }
                if(n-b>=2&&(n-b)%2==0){
                    st.add((n-b)/2);
                }
                System.out.println(st.size());
                for(int x : st){
                    System.out.println(x);
                }
            }
        }
    }

    static boolean dfs(int cur,int c,int[] col,Graph[] g){
        if(col[cur]==0){
            col[cur]=c;
        }
        else if(col[cur]!=c){
            return false;
        }
        else{
            return true;
        }
        for(int to : g[cur]){
            if(!dfs(to,c*-1,col,g)){
                return false;
            }
        }
        return true;
    }

    static class Graph extends ArrayList<Integer>{}
}


Measured memory_bytes: 68028
CHARACTER(20)S
INTEGER(16)N,F
READ*,S
F=0
DO I=1,LEN_TRIM(S)
F=F+ICHAR(S(I:I))-ICHAR("0")
END DO
READ(S,*)N
PRINT"(A)",MERGE("Yes"," No",MOD(N,F)==0)
END

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "Yes\n";
string no = "No\n";

ll power(ll x, ll y, ll p)  {  
    ll res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)  { 
      if (y & 1)  
        res = (res*x) % p; 
      y = y>>1;  
      x = (x*x) % p;  
    }  
    return res;  
}  

int32_t main() {
  fastio;
  #ifndef ONLINE_JUDGE
  freopen("i.txt", "r", stdin);
  freopen("o.txt", "w", stdout);
  #endif
  ll k;
  cin>>k;
  k *= 9;
  for(ll n=1;n<=1000000;n++) {
    ll remainder = ( 7 % k ) * (power(10, n, k)) % k;
    if(remainder == 7) {
      cout<<n<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600
#define long long long // for codeforces

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

  rep(i,n){
    int ans=-1, best=INF;
    rep(j,m){
      int nd = abs(a[i]-c[j]) + abs(b[i]-d[j]);
      if(nd < best) best=nd, ans=j;
    }
    cout<<ans+1<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
#define R(i,a,n) for(int i=a;i>n;i--)
using namespace std ;
int main(){
  int a,b;
  while(cin>>a>>b,a){
    int aa[5001][2],bb[5001][2],c=0,cc=0;
    bool ac[10001],bc[10001];
    r(i,0,10001)ac[i]=0;
    r(i,0,10001)bc[i]=0;
    r(i,1,a+1){
      if(!ac[i]&&a%i==0)R(j,a,0){
	if(i*j==a){
	  aa[c][0]=i;
	  ac[i]=1;ac[j]=1;
	  aa[c++][1]=j;
	  break;
	}
      }
    }
    r(i,1,b+1){
      if(!bc[i]&&b%i==0)R(j,b,0){
	if(i*j==b){
	  bb[cc][0]=i;
	  bc[i]=1;bc[j]=1;
	  bb[cc++][1]=j;
	  break;
	}
      }
    }//cout<<bb[0][0]<<bb[0][1];
    long long l[7];
    long long m=999999999999;
    r(i,0,c){
      r(j,0,cc){
	int t[4];
	t[0]=aa[i][0];t[1]=aa[i][1];
	t[2]=bb[j][0];t[3]=bb[j][1];
	sort(t,t+4);
	l[0]=t[1]-t[0];
	l[1]=t[2]-t[1];
	l[2]=t[3]-t[2];
	m=min(m,l[0]*l[0]+l[1]*l[1]+l[2]*l[2]);
      }
    }
    //if(m==100000000)m=0;
    cout<<m<<endl;
  }
}

Measured memory_bytes: 3172
/*
hey stop, don't skip the shit till it's solved
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
int n;
cin>>n;
int a[n];
map<int,int> ps;
for(int i=0;i<n;i++)
{
cin>>a[i];
ps[a[i]]=i;
}
multiset<int> st;
ll ans=0;
st.insert(ps[n]);
for(int i=n-1;i>0;i--)
{
int a=0,b=0,c=0,d=0;
multiset<int>::iterator k=st.lower_bound(ps[i]);
if(k!=st.end())
{
c=(*k)+1;
k++;
if(k!=st.end())
{
d=(*k)+1;
}
k--;
}
if(k!=st.begin())
{
k--;
b=*k+1;
if(k!=st.begin())
{
k--;
a=*k+1;
}
}
if(a!=0 && b!=0 && c!=0 && d!=0)
{
ans+=(ll)(b-a)*(c-ps[i]-1)*i+(ll)(d-c)*(ps[i]+1-b)*i;
}
else if(a==0 && b!=0 && c!=0 && d!=0)
{
ans+=(ll)(c-ps[i]-1)*b*i+(ll)(d-c)*(ps[i]+1-b)*i;
}
else if(a!=0 && b!=0 && c!=0 && d==0)
{
ans+=(ll)(n+1-c)*(ps[i]+1-b)*i+(ll)(b-a)*(c-ps[i]-1)*i;
}
else if(a==0 && d==0 && b!=0 && c!=0)
{
ans+=(ll)(ps[i]+1-b)*(n+1-c)*i+(ll)b*(c-ps[i]-1)*i;
}
else if(a==0 && b==0)
{
if(d==0)
{
d=n+1;
}
ans+=(ll)(d-c)*(ps[i]+1)*i;
}
else if(c==0 && d==0)
{
ans+=(ll)(b-a)*(n-ps[i])*i;
}
st.insert(ps[i]);
}
cout<<ans<<endl;
}

Measured memory_bytes: 13292
#include <bits/stdc++.h>
#define pb push_back
#define INF 0x3f3f3f3
#define NMAX int(10e5+3)
#define ll long long
using namespace std;
typedef pair<int, string> pii;

ll n, k, dp[2][NMAX], val[105], p[105];

int main() {
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> p[i] >> val[i];

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= k; j++) {
            dp[i & 1][j] = dp[~i & 1][j];
            if(p[i] <= j) dp[i & 1][j] = max(dp[i & 1][j], dp[~i & 1][j-p[i]]+val[i]);
        }
    }
    cout << dp[n & 1][k] << endl;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(1){
        c-= b;
        if(c<=0){
            cout << "Yes" << endl;
            return 0;
        }
        a-= d;
        if(a<=0){
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3652
class Node:
    def __init__(self):
        self.name=-1
        self.parent=-1
        self.children=[]
        self.degree=0
        self.depth=-1
        self.state="leaf"




def get_depth(Tree,node,depth):
    for child in node.children:
        Tree[child].depth=depth+1
        get_depth(Tree,Tree[child],depth+1)



Tree=[]
n=int(input())
for i in range(n):
    Tree.append(Node())
for loop in range(n):
    info=list(map(int,input().split()))
    i=info[0]
    Tree[i].name=info[0]
    Tree[i].degree=info[1]
    for j in range(2,len(info)):
        (Tree[i].children).append(info[j])
        Tree[i].state="internal node"
        Tree[info[j]].parent=i


for node in Tree:
    if(node.parent==-1):
        node.state="root"
        node.depth=0
        get_depth(Tree,node,0)



        


for node in Tree:
    print(f"node {node.name}: parent = {node.parent}, depth = {node.depth}, {node.state}, {node.children}")



Measured memory_bytes: 44048
N,M,K=map(int,input().split())
MOD=10**9+7
ans=0
x,y=1,1
k=min(K-2,N*M-K)
for i in range(k):
    x*=N*M-2-i
    y*=k-i
    x%=MOD
    y%=MOD
comb=x*pow(y,MOD-2,MOD)
comb%=MOD
for i in range(1,N):
    a=i*comb*(N-i)*M**2
    ans+=a
    ans%=MOD
for i in range(1,M):
    a=i*comb*(M-i)*N**2
    ans+=a
    ans%=MOD
print(ans%MOD)

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

int main() {
	
	ll d, g; cin >> d >> g;
	vector<ll> p(d), c(d);	
	for (ll i = 0; i < d; i++) {
		cin >> p[i] >> c[i];
	}
	ll ans = 9223372036854775807LL;
	for (int bit = 0; bit < (1 << d); ++bit) {
		ll tmpAns = 0;
		ll tmpPointSum = 0;
		vector<bool> used(d, false);
		for (ll i = 0; i < d; ++i) {
			if (bit & (1 << i)) {
				used[i] = true;
				tmpAns += p[i];
				tmpPointSum += (i + 1) * 100 * p[i];
				tmpPointSum += c[i];
			}
		}
		if (g <= tmpPointSum) {
			ans = min(ans, tmpAns);
			continue;
		}
		for (ll i = d - 1; i >= 0; i--) {
			if (used[i]) continue;
			ll p_cnt = p[i] - 1;
			while (p_cnt--) {
				tmpPointSum += (i + 1) * 100;
				tmpAns++;
				if (g <= tmpPointSum) {
					ans = min(ans, tmpAns);
					break;
				}				
			}
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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


    int a;
    cin >> a;
    cout << 48 - a << endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e5 + 5;
const int inf = 1000000000;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338; // double PI = 4*atan(1);



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	//ifstream cin (".in");
	//ofstream cout (".out");
	int n;
	cin >> n;
	std::vector<int> a(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	std::vector<int> rev(n);
	for(int i=0; i<n; i++)rev[a[i]-1]=i+1;
	for(int i=0; i<n; i++)cout << rev[i] << endl;
	return 0;	
}    






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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define STDIO
#define mp make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front 
#define pb push_back
#define pp push
#define lb lower_bound 
#define ub upper_bound

inline void checkmin(int &x, int y){x = min(x, y);}
inline void checkmax(int &x, int y){x = max(x, y);}

string s;
int q;
string a1 = "", a2 = "";

int main() {
	#ifndef STDIO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>s>>q;
    bool flag = true;
    while(q--) {
    	int a;
    	cin>>a;
    	if(a == 1) {
    		if(flag) {
    			flag = false;
			}else {
				flag = true;
			}
    		continue;
		}
		cin>>a;
		char c;
		cin>>c;
		if(!flag) {
			a = 3 - a;
		}
		if(a == 1) {
			a1 += c;
		}else {
			a2 += c;
		}
	}
	if(!flag) {
		reverse(all(s));
		reverse(all(a2));
		cout<<a2<<s<<a1<<endl;
	}else {
		reverse(all(a1));
		cout<<a1<<s<<a2<<endl;
	}
    /* end code */
	return 0;
}

Measured memory_bytes: 1040
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <math.h>
#include <string>
#include <stdlib.h>
#include <iomanip>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define mset(a, b) memset(a, b, sizeof(a))
#define LL long long
#define P pair<int, int>
#define PLL pair<LL, LL>
const int MAX = 1e5 +5;
const int inf = 0x3f3f3f3f;
using namespace std;

int main()
{
    LL n;
    cin >> n;
    vector<PLL> w(n);
    rep(i, 0, n)
        cin >> w[i].first >> w[i].second;
    sort(w.begin(), w.end(), [](const PLL &a, const PLL &b){
        return a.second < b.second;
    });
    LL t = 0;
    rep(i, 0, n){
        t += w[i].first;
        if(t > w[i].second){
            cout << "No" <<endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3328
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

[[maybe_unused]] constexpr ll LL_MAX = numeric_limits<ll>::max();
[[maybe_unused]] constexpr ll LL_MIN = numeric_limits<ll>::min();
[[maybe_unused]] constexpr ull ULL_MAX = numeric_limits<ull>::max();

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

template <typename T>
void chmin(T& x, T y) {
    x = min(x, y);
}

template <typename T>
void chmax(T& x, T y) {
    x = max(x, y);
}

ll csum(ll x, ll y) {
    if (x > 0 && y > 0 && x > LL_MAX - y) {
        return LL_MAX;
    }
    if (x < 0 && y < 0 && x < LL_MIN - y) {
        return LL_MIN;
    }
    return x + y;
}

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

struct Vec {
    double x = 0;
    double y = 0;
    
    Vec() {}
    Vec(double x, double y)
    : x(x)
    , y(y) {}
    Vec operator+(const Vec& rhs) const { return {x + rhs.x, y + rhs.y}; }
    Vec operator-(const Vec& rhs) const { return {x - rhs.x, y - rhs.y}; }
    Vec operator-() { return {-x, -y}; }
    double operator*(const Vec& rhs) const { return x * rhs.x + y * rhs.y; }
    double cross(const Vec& rhs) const { return x * rhs.y - y * rhs.x; }
    Vec operator*(double k) const { return {x * k, y * k}; }
    Vec operator/(double k) const { return {x / k, y / k}; }
    double len_sq() const { return (*this) * (*this); }
    double len() const { return sqrt(len_sq()); }
    void rotate() {
        swap(x, y);
        x *= -1;
    }
    double angle(const Vec& rhs) const {
        double len_prod = len() * rhs.len();
        double c = (*this * rhs) / len_prod;
        double s = (cross(rhs)) / len_prod;
        return atan2(s, c);
    }
    double angle_abs(const Vec& rhs) const { return abs(angle(rhs)); }
    bool operator==(const Vec& rhs) const { return x == rhs.x && y == rhs.y; }
};

int main() {
    ll A, B, H, M;
    cin >> A >> B >> H >> M;
    double angleA = 2.0 * M_PI * ((double)H + (double)M / 60.0) / 12.0;
    double angleB = 2.0 * M_PI * (double)M / 60.0;
    Vec vecA = Vec{cos(angleA), sin(angleA)} * (double)A;
    Vec vecB = Vec{cos(angleB), sin(angleB)} * (double)B;
    cout << fixed << setprecision(10) << (vecA - vecB).len() << endl;
}


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

using namespace std;

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

#define N 100010
#define M 200010
#define endl "\n"
#define mod 1000000007 

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int n, m, x, y;
	int h[N];
	
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> h[i + 1];
	}
	
	vector<vector<int>> v(N);
	
	for(int i = 0; i < m; i++){
		cin >> x >> y;
		//cout << x << " == " << y << endl;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	
	int ans = 0;
	for(int i = 1; i <= n; i++){
		bool flag = true;
		//cout << "i = " << i << endl;
		for(int j = 0; j < v[i].size(); j++){
			x = v[i][j];
			
			if(h[i] <= h[x]){
				flag = false;
				break;
			}
			
		//	cout << x << " ";
		}
		//cout << endl;
		if(flag){
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 8740
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	int n ; 
	cin >> n ;
	int i = 1 ;
	while(n- (i*1000) > 0 ) i++;
	cout <<(1000* i) - n  << endl;
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3644
class path_compressed_quick_union:
    def __init__(self, n):
        self.n = n
        self.data = [i for i in range(n)]
        self.size = [1 for i in range(n)]

    def root(self, p):
        while p != self.data[p]:
            self.data[p] = self.data[self.data[p]]
            p = self.data[p]
        return p

    def connected(self, p, q):
        return self.root(p) == self.root(q)

    def union(self, p, q):
        proot = self.root(p)
        qroot = self.root(q)
        if self.size[proot] < self.size[qroot]:
            self.data[qroot] = proot
            self.size[qroot] += self.size[proot]
        else:
            self.data[proot] = qroot
            self.size[proot] += self.size[qroot]



N, M = map(int,input().split())
uf = path_compressed_quick_union(N)
for i in range(M):
    a,b=map(int,input().split())
    uf.union(a-1,b-1)
ans = []
for i in range(N):
    ans.append(uf.root(i))
print(len(set(ans))-1)

Measured memory_bytes: 22432
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
#include<list>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	int s[100];
	REP(i, n) cin >> s[i];
	int ans = 0;
	REP(i, n) {
		ans += s[i];
	}
	sort(s, s + n);
	if (ans % 10 == 0) {
		REP(i, n) {
			if (s[i] % 10 != 0) {
				ans -= s[i];
				cout << ans << endl;
				return 0;
			}
		}
		ans = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //ll H,W; cin >> H >> W;
  	map<pair<int,int>,int> mp;
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    pair<int,int> pe=make_pair(min(x,i+1),max(x,i+1));
    mp[pe]++;
  }
  int asn=0;
  for(auto x:mp){
    if(x.second==2)asn++;
  }
  cout << asn;
}

/*



 */




Measured memory_bytes: 6528
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int N;cin>>N;
    string S;cin>>S;
    if(N%2==1){
        cout<<"No"<<endl;
        return 0;
    }
    else {
        for(int i=0;i<N/2;i++){
            if(S[i]!=S[i+N/2]){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
N, K = map(int, input().split())
li = [False]*N
for i in range(K):
    d = int(input())
    l = list(map(int, input().split()))
    for x in l:
        li[x-1] = True
ans = 0
for i in range(N):
    if not li[i]:
        ans += 1
        
print(ans)

Measured memory_bytes: 67628
import sys
h,w = map(int,input().split())
square = [input() for i in range(h)]
y = "." * w
ans = []
index = []
for s in square:
  if s != y:
    ans.append(s)
h = len(ans)
for i in range(w):
  dot = 0
  for a in ans:
    if a[i] == ".":
      dot += 1
  if dot == h:
    index.append(i)

if len(index) == 0:
  for a in ans:
    print(a)
else:
  for a in ans:
    f = []
    for i,l in enumerate(a):
      if i not in index:
        f.append(l)
    print("".join(f))





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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

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

    sort(p,p+n);
    int sum = 0;
    rep(i,0,k){
        sum += p[i];
    }
    cout << sum << "\n";
}

Measured memory_bytes: 3636
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
using namespace std;

const double pi = acos(-1);
#define nyan cout<<"(=^•ω•^=)"<<endl;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)

int N,W;
int v[110],w[110];
int dp[110][11000];
// dp[i][j] := i番目(1-leading)の品物まででコストのj以下の最大値

signed main(){
    cin>>N>>W;
    for(int i=1;i<=N;i++)cin>>v[i]>>w[i];
    for(int i=1;i<=W;i++)dp[0][i]=0;
    for(int i=1;i<=N;i++)dp[i][0]=0;//本当はいらない（グローバルで宣言したため）
    for(int i=1;i<=N;i++){
        for(int j=1;j<=W;j++){
            if(w[i]>j)dp[i][j]=dp[i-1][j];
            else dp[i][j]=max(dp[i-1][j-w[i]]+v[i],dp[i-1][j]);
        }
    }
    cout<<dp[N][W]<<endl;
    return 0;
}


Measured memory_bytes: 11368
#include <iostream>
#include <utility>
#include <stdint.h>
#include <vector>
#include <algorithm>

using namespace std;

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

  vector<double> V(N);
  for (int n=0; n<N; ++n)
    cin >> V[n];

  sort(V.begin(),V.end());

  double value = V[0];
  for (int n=1; n<N; ++n)
    value = (V[n]+value)/2.0;

  cout << value << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

const int INF = INT_MAX / 2;

vector<int> as;

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

    as.resize(N + 2);
    as[0] = INF;
    for (int i = 1; i <= N; i++) {
        cin >> as[i];
    }
    as[N + 1] = -INF;

    ll money = 1000;
    ll stock = 0;
    for (int i = 1; i <= N; i++) {
        if (as[i - 1] >= as[i] && as[i] < as[i + 1]) {
            // buy stocks
            stock += money / as[i];
            money = money % as[i];
            // printf("buy at %d: stock: %lld, money: %lld\n", i, stock, money);
        } else if (as[i - 1] <= as[i] && as[i] > as[i + 1]) {
            // sell stocks
            money += stock * as[i];
            stock = 0;
            // printf("sell at %d: stock: %lld, money: %lld\n", i, stock, money);
        }
    }

    cout << money << endl;

    return 0;
}


Measured memory_bytes: 3612
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

pair<int,int> a[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for(int i=0;i<n;i++) {
		int x;
		cin >> x;
		a[i] = make_pair(x, i+1);
	}
	sort(a, a+n);
	for(int i=0;i<n;i++) {
		cout << a[i].second << " ";
	}
	return 0;
}


Measured memory_bytes: 1664
#!/usr/bin/env python
# coding: utf-8
#

def main(input_str):

    val = 700
    for i in range(3):
        if 'o' == input_str[i]: val += 100
    print(val)
            


if __name__ == '__main__':
    try:
        main(input().strip())
    except EOFError:
        pass


Measured memory_bytes: 2940
#include <iostream>
#include <map>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int main (void) {
    int n;
    map<string, int> m;

    cin >> n;
    string s;
    rep(i, n){
        cin >> s;
        m[s]++;
    }

    cin >> n;
    rep(i, n){
        cin >> s;
        m[s]--;
    }

    int ma = 0;
    for(auto itr = m.begin(); itr != m.end(); itr++) {
        // cout << itr->first << " " << itr->second << endl;
        if (itr->second > ma) ma = itr->second;
    }
    cout << ma << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <climits>
using namespace std;
using ll = long long;

int n, m, x;
int c[12], a[12][12];
int cost; int val[12];
int mincost = INT_MAX;
bool able = false;
void dfs(int nxti, int minj) {
  if (minj >= x) {
    if (cost < mincost) mincost = cost;
    able = true;
    return;
  } else {
    for (int i = nxti; i < n; i++) {
      int mj = INT_MAX;
      for (int j = 0; j < m; j++) {
        val[j] += a[i][j];
        if (val[j] < mj) mj = val[j];
      }
      cost += c[i];
      dfs(i + 1, mj);
      for (int j = 0; j < m; j++)
        val[j] -= a[i][j];
      cost -= c[i];
    }
  }
}

int main() {
  cin >> n >> m >> x;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  dfs(0, INT_MIN);
  if (!able) cout << "-1" << endl;
  else cout << mincost << endl;
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;


bool solve(){
	int a = 0;
	for(int i=0;i<2;i++){
		string str;
		cin>> str;
		int num = 1;
		for(int j=0;j<str.size();j++){
			char c = str[j];
			if(c == 'm'){
				a += num * 1000;
				num = 1;
			}else if(c == 'c'){
				a += num * 100;
				num = 1;
			}else if(c == 'x'){
				a += num * 10;
				num = 1;
			}else if(c == 'i'){
				a += num * 1;
				num = 1;
			}else{
				num = c - '0';
			}
		}
	}
	
	string ans;
	char c2[4] = {'m', 'c', 'x', 'i'};
	for(int i=0;i<4;i++){
		int n = a % 10;
		char c = n + '0';
		a /= 10;
		if(n != 0) ans += c2[3-i];
		if(n >= 2) ans += c;
	}
	reverse(ans.begin(), ans.end());
	cout<< ans<< endl;
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	int n;
	cin>> n;
	for(int i=0;i<n;i++){
		solve();
	}
	return 0;
}

 

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n, m;
    cin >> n >> m;
    vector<ll> ret(n + 1, 0);
    ret[0] = 1;
    vector<ll> a(n + 1, 1);
    for (int i = 0; i < m; i++)
    {
        int p;
        cin >> p;
        a[p] = 0;
    }
    for (int i = 1; i <= n; i++)
    {
        ret[i] += a[i - 1] * ret[i - 1];
        if (i - 2 >= 0)
            ret[i] += a[i - 2] * ret[i - 2];
        ret[i] %= MOD;
    }
    cout << ret[n] << endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  string s;
  scan(s);
  string a = s.substr(0, 2);
  string b = s.substr(2, 2);
  string ans;
  if ((a == "00" || a >= "13") && (b == "00" || b >= "13")) {
    ans = "NA";
  } else if ("01" <= a && a <= "12") {
    if ("01" <= b && b <= "12") {
      ans = "AMBIGUOUS";
    } else {
      ans = "MMYY";
    }
  } else if ("01" <= b && b <= "12") {
    ans = "YYMM";
  } else {
    assert (false);
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();	//S
		long m=sc.nextLong();	//C
		long cnt=0;
		if(m>=n*2) {
			cnt+=((m-2*n)/4)+n;
		}else{
			cnt+=m/2;	
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 20820
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int a ,b ,c ;
    cin >> a >> b >> c ;
    int f = 0;
    if(a==b){
        f += 1;
    }
    if (b == c){
        f += 1;
    }
    if(a == c){
        f += 1;
    }
    
    if(f == 1){
        cout << "Yes" << endl;
    }else{
        cout <<"No" << endl;
    }

    
    return 0;
}

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

public class Main {
  public static void main(String args[] ) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    double sum = 100000;

    for (int i = 0;i < n; i++) {
      sum = (1000 * Math.ceil((sum * 1.05) * 0.001));
    }

    System.out.println((int)sum);
  }
}

Measured memory_bytes: 24256