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

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	if(s[0] != s[1] || s[1] != s[2]){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N, M = [int(n) for n in input().split()]
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

def create_coords(x, y, l):
    return [(_x, _y) for _x in range(x, x + l) 
                     for _y in range(y, y + l)]

def concat(li, coords):
    return ''.join(map(lambda c: li[c[0]][c[1]], coords))

def main():
    ans = 'No'
    r = range(N - M + 1)
    l = M
    b = concat(B, create_coords(0, 0, l))
    for x in r:
        for y in r:
            a = concat(A, create_coords(x, y, l))
            if a == b:
                ans = 'Yes'
                break
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
	int m;cin>>m;
	ll ds=0,l=0;
	for(int i=0;i<m;i++){
		ll d,c;cin>>d>>c;
		l+=c;
		ds+=d*c;
	}
	ll res=l-1LL+(ds-1LL)/9LL;
	cout<<res<<endl;
}	


Measured memory_bytes: 256
N=int(input())
dp=[10**9 for i in range(N+1)]
dp[0]=0
for i in range(N+1):
    p=1
    while(p<=i):
        dp[i]=min(dp[i],dp[i-p]+1)
        p*=6
    p=1
    while(p<=i):
        dp[i]=min(dp[i],dp[i-p]+1)
        p*=9

print(dp[-1])

Measured memory_bytes: 44912
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
  long long x = 1;
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  ll n;
  std::cin>>n;

  std::map<P,ll> cnt;

  rep(i,1,n+1){
    ll low=i%10;
    ll high=i;
    while(high>=10)high/=10;
    cnt[{high,low}]++;
  }

  ll ans=0;

  rep(i,1,10){
    rep(j,1,10){
      ans+=cnt[{i,j}]*cnt[{j,i}];
    }
  }

  std::cout<<ans<<"\n";

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#include<stack>
#define ld long double
#define ll long long int
#define ull unsigned long long int
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;}
const long long INF=1LL<<60;
//set<int>::iterator it;

int main(void){
    
    int i,n,p,sum,ans=0;
    cin>>n>>p;
    int a[n],j;
    bool even=true;
    for(i=0;i<n;i++){
    	cin>>a[i];
    	if(a[i]%2==1)even=false;
	}
    if(even){
    	if(p==0)cout<<(ll)pow(2,n)<<endl;
    	else cout<<0<<endl;
	}
	else cout<<(ll)pow(2,n-1)<<endl;
    
    
	
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int maxn=10000+10,mo=998244353;
char s[maxn];
int f[maxn][maxn],fac[maxn],inv[maxn],bz[maxn];
int i,j,k,l,t,n,m,ans,x,y;
int qsm(int x,int y){
    if (!y) return 1;
    int t=qsm(x,y/2);
    t=(ll)t*t%mo;
    if (y%2) t=(ll)t*x%mo;
    return t;
}
int C(int n,int m){
    if (n<m||m<0) return 0;
    return (ll)fac[n]*inv[m]%mo*inv[n-m]%mo;
}
int main(){
    scanf("%s",s+1);
    n=strlen(s+1);
    fo(i,1,n)
        if (s[i]=='1') y++,bz[i]++;
    scanf("%s",s+1);
    fo(i,1,n)
        if (s[i]=='1'&&bz[i]) x++;
    y-=x;
    fac[0]=1;
    fo(i,1,n) fac[i]=(ll)fac[i-1]*i%mo;
    inv[n]=qsm(fac[n],mo-2);
    fd(i,n-1,0) inv[i]=(ll)inv[i+1]*(i+1)%mo;
    f[0][0]=1;
    fo(i,1,y) f[0][i]=(ll)fac[i]*fac[i]%mo;
    fo(i,1,x)
        fo(j,1,y)
            f[i][j]=(ll)((ll)f[i-1][j]*i%mo+(ll)f[i][j-1]*j%mo)*j%mo;
    fo(i,0,x)
        (ans+=(ll)f[x-i][y]*qsm(fac[i],2)%mo*C(x,i)%mo*C(x+y,i)%mo)%=mo;
    (ans+=mo)%=mo;
    printf("%d\n",ans);
}

Measured memory_bytes: 389632
/*  "Sahand Alitanloo"  */
#include <bits/stdc++.h>
#define F first
#define S second
#define fast() ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define per(i) cout<<fixed<<setprecision(i)
#define pb push_back
#define all(v) begin(v),end(v)
#define endl '\n'
using namespace std;
typedef pair<int,int> pii;
typedef long double ld;
typedef long long ll;
const int MAX_N = 1e5+10;
const ll mod = 1e9+7;
const ll INF = 1e9;
inline ll bpow(ll t,ll n){ll ans=1;while(n>0){if(n&1)ans=(ans*t)%mod;t=(t*t)%mod,n>>=1;}return ans;}
/*
ll fact[MAX_N],ifact[MAX_N];
inline ll c(ll n,ll k){if(k>n||k<0)return 0;return (fact[n]*ifact[k]%mod*ifact[n-k])%mod;}
inline void get_fact(){fact[0]=1;ifact[0]=1;for(ll i=1;i<MAX_N;i++)fact[i]=(fact[i-1]*i)%mod,ifact[i]=bpow(fact[i],mod-2);}
*/

main(){
    fast();per(0);
    //get_fact();
    int n,y;cin>>n>>y;
    y/=1000;
    //1 5 10
    for(int i=0;i<=n;i++)
    for(int j=0;j<=n;j++){
        if(i+j<=n){
            int k=n-i-j;
            if(i+j*5+k*10==y){
                cout<<k<<" "<<j<<" "<<i;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1";
}


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

int n;
vector<int> a;
void print(){
    bool f = 0;
    for(int p = 0; p < a.size(); p++){
        if(f == 1) cout << ' ';
        cout << a[p];
        f = 1;
    }
    cout << endl;
}
int main(){
    int n;
    cin >> n;
    a.resize(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++){
        int tmp = a[i];
        int j = i - 1;
        while(j >= 0 && a[j] > tmp){
            a[j + 1] = a[j];//ソート済みの場所の大きさを右側から調べる
            j--;
        }
        a[j + 1] = tmp;//空いたスペースに入れる
        print();
    }
    return 0;
}



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

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

  if (a <= b && b <= c ) cout << a << " " << b << " " << c <<endl;
  else if (c <= a && a <= b ) cout << c << " " << a << " " << b <<endl;
  else if (b <= c && c <= a ) cout << b << " " << c << " " << a <<endl;
  else if (c <= b && b <= a ) cout << c << " " << b << " " << a <<endl;
  else if (b <= a && a <= c ) cout << b << " " << a << " " << c <<endl;
  else if (a <= c && c <= b ) cout << a << " " << c << " " << b <<endl;

  return 0;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#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"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  vi a(3);
  rep (i, 3) {
    scanf("%d", &a[i]);
  }
  sort(all(a));
  int ans = a[2] - a[0];
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int main()
{
 string s;int k;
 cin>>k;
 cin>>s;
 int l=s.size();
 if(l<=k)
 {
 	cout<<s;
 	
 }
 else
 {
 	for(int i=0;i<k;i++)
 	cout<<s[i];
 	cout<<"...";
 }
 return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
#define double long double
const int INF = (int)1e18 + 18;
const int maxn = (int) 1e6 + 6; 
using namespace std;

int r;

signed main() {
	cin >> r;
	cout << 3 * r * r;

	return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
sc=[[int(i) for i in input().split()] for j in range(M)]
res=["x"]*N
flag=True
for s,c in sc:
    if N<s or res[s-1] not in ['x', str(c)]:
        flag=False
        break
    res[s-1]=str(c)
if len(res)>1 and res[0]=='0':flag=False
if not flag:
    print(-1)
else:
    if res[0]=='x':
        res[0] = '0' if len(res)==1 else '1'
    for i in range(1,N):
        if(res[i]=='x'):
            res[i]='0'
    print(''.join(res))


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream> 
#include <cstring>
using namespace std;
int main()
{
	bool exi[(int)1e5+10];
	memset(exi,0,sizeof(exi));
	int n;
	cin>>n;
	int sum=0;
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		if(!exi[a])
		{
			sum++;
			exi[a]=1;
		 } 
	} 
	if(sum%2==0) cout<<sum-1<<endl;
	else cout<<sum<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<chrono>
#include<random>
#define ll long long
#define int ll
#define INF 1e+18
#define EPS 1e-18
#define pii pair<int,int>
#define endl "\n"
#define all(mas) mas.begin(),mas.end()
#define forn(i,n) for(int i = 0; i < n; i++)
#define forn_(i,n) for(int i = n - 1; i >= 0; i--)
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 1e5 + 1;
int n, m, mas[MAXN];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	cin >> n >> m;

	forn(i, n) {
		cin >> mas[i];
	}
	sort(mas, mas + n);

	deque<pii> q(m);
	forn(i, m) {
		cin >> q[i].second >> q[i].first; //c b
	}
	sort(all(q), greater<pii>());

	forn(i,n) {
		if (!q.size() || q.front().first <= mas[i]) break;
		
		mas[i] = q.front().first;
		q.front().second--;

		if (q.front().second == 0) q.pop_front();
	}

	int sum = 0;
	forn(i,n) {
		sum += mas[i];
	}

	cout << sum;
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (int i=(m);i<(n);i++)
#define FOP(i,m,n) for (int i=(m)-1;i>=(n);--i)
#define test(x) cout << #x << ' ' << x << endl;
#define printv(a) {\
    for (auto i : a) cout << i << ' ';\
    cout << '\n';\
}
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define ld long double
#define pll pair<lli,lli>
#define tiii tuple<int,int,int>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define X first
#define Y second
#define oset tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update>
auto SEED = chrono::steady_clock::now().time_since_epoch().count();
mt19937 rng(SEED);

// AC automaton will help me get AC!
struct AC {
    vector <vector <int>> ch;
    vector <int> cnt, f;
    AC () {extend();}
    void extend() {
        ch.pb(vector <int>(26, 0));
        cnt.pb(0);
    }
    int next(int u, int v) {
        if (!ch[u][v]) {
            ch[u][v] = ch.size();
            extend();
        }
        return ch[u][v];
    }
    void insert(string &s) {
        int now = 0;
        for (char c : s) {
            now = next(now, c - 'a');
        }
        cnt[now]++;
    }
    void build_fail() {
        f.assign(ch.size(), 0);
        queue <int> q;
        for (int i = 0; i < 26; ++i) if (ch[0][i]) q.push(ch[0][i]);
        while (q.size()) {
            int v = q.front(); q.pop();
            for (int i = 0; i < 26; ++i) if (ch[v][i]) {
                    int k = f[v];
                    while (k && !ch[k][i]) k = f[k];
                    if (ch[k][i]) k = ch[k][i];
                    f[ch[v][i]] = k;
                    cnt[ch[v][i]] += cnt[k];
                    q.push(ch[v][i]);
                }
        }
    }
    int match(string &s) {
        int k = 0, ans = 0;
        for (char c : s) {
            while (k && !ch[k][c - 'a']) k = f[k];
            if (ch[k][c - 'a']) k = ch[k][c - 'a'];
            ans += cnt[k];
        }
        return ans;
    }
};

const int mod = 1e9 + 7, x = 864197532, N = 1000087, logN = 17;

int main () {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector <lli> a(n);
    fop (i,0,n) cin >> a[i];
    lli all = accumulate(all(a), 0ll) % mod;
    all = all * all % mod;
    fop (i,0,n) {
        lli tmp = a[i] * a[i] % mod;
        all = (all + mod - tmp) % mod;
    }
    cout << all * ((mod + 1) / 2) % mod << endl;
}

Measured memory_bytes: 4732
#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;

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

  if(k>a+b+c)cout<<a-c;
  else if(k<=a)cout<<k;
  else if(k<=a+b)cout<<a;
  else if(k<=a+b+c)cout<<a-(k-a-b);

  return 0;
}

Measured memory_bytes: 3624
def main():
    s = str(input())
    n = len(s)
    ans = 0
    for i in range(n + 1):
        for j in range(i + 1, n + 1):
            x = int(s[i:j])
            p = 2 ** max(0, i - 1)
            q = 2 ** max(0, n - j - 1)
            ans += x * p * q

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2568
s = list(input())
n = len(s)-1
def bfs(i,formula):
  if i == n:
    return sum(list(map(int,formula.split("+"))))
  return bfs(i+1,formula + "+" + s[i+1])+bfs(i+1,formula + s[i+1])
print(bfs(0,s[0]))

Measured memory_bytes: 38896
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <queue>
#include <stack>
#include <tuple>

using namespace std;


typedef long long ll;
const int MAX_V = 210;
const int INT_INF = 1<<30;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
struct edge {
	int cap, cost;
};
int V;

edge G[MAX_V][MAX_V];
int h[MAX_V], dist[MAX_V];
int prevv[MAX_V];

void add_edge(int from, int to, int cap, int cost) {
	G[from][to] = (edge){cap, cost};
	G[to][from] = (edge){0, -cost};
}

int bit_matching_cost(int s, int t, int f) {
	int res = 0;
	fill_n(h, V, 0);
	while (f > 0) {
		priority_queue<P, vector<P>, greater<P>> que;
		fill_n(dist, V, INT_INF);
		dist[s] = 0;
		que.push(P(0, s));
		while (!que.empty()) {
			P p = que.top(); que.pop();
			int v = p.second;
			if (dist[v] < p.first) continue;
			for (int i = 0; i < V; i++) {
				edge &e = G[v][i];
				if (e.cap > 0 && dist[i] > dist[v] + e.cost + h[v] - h[i]) {
					dist[i] = dist[v] + e.cost + h[v] - h[i];
					prevv[i] = v;
					que.push(P(dist[i], i));
				}
			}
		}
		if (dist[t] == INT_INF) {
			return -1;
		}
		for (int v = 0; v < V; v++) {
			h[v] += dist[v];
		}
		int d = f;
		for (int v = 0; v != s; v = prevv[v]) {
			d = min(d, G[prevv[v]][v].cap);
		}
		f -= d;
		res += d * h[t];
		for (int v = t; v != s; v = prevv[v]) {
			edge &e = G[prevv[v]][v];
			e.cap -= d;
			G[v][prevv[v]].cap += d;
		}
	}
	return res;
}
int cost[MAX_V][MAX_V];


const int MAX_N = 105;
int N;
int W[MAX_N][MAX_N], E[MAX_N][MAX_N];
bool F[MAX_N][MAX_N], F2[MAX_N][MAX_N];

int main(int argc, char *argv[]) {
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			scanf("%d", &(W[i][j]));
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			scanf("%d", &(E[i][j]));
		}
	}
	int min_f = 0, f = 0;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < N; j++) {
			F[i][j] = (s[j] == 'o');
			if (F[i][j]) {
				min_f = min(min_f, -E[i][j]);
				f += E[i][j];
			}
		}
	}
	min_f *= -1;
	V = (N+1)*2;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (F[i][j]) {
				add_edge(i, N+j, 1, -E[i][j]+min_f);
			} else {
				add_edge(i, N+j, 1, W[i][j]+min_f);
			}
		}
	}
	for (int i = 0; i < N; i++) {
		add_edge(N*2, i, 1, 0);
	}
	for (int i = 0; i < N; i++) {
		add_edge(N+i, N*2+1, 1, 0);
	}
	f += bit_matching_cost(N*2, N*2+1, N);
	f -= min_f*N;
	int c = 0;
	vector<T> q;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (F[i][j] == G[i][N+j].cap) {
				c++;
				q.push_back(T(i, j, F[i][j]));
			}
		}
	}
	printf("%d\n%d\n", f, c);
	for (T t: q) {
		printf("%d %d %s\n", get<0>(t)+1, get<1>(t)+1, get<2>(t) ? "erase" : "write");
	} 
    return 0;
}

Measured memory_bytes: 1772
H,W=map(int,input().split())
N=0
L= [list(map(int,input().split(" "))) for i in range(H)]
ans1=list()
ans2=list()
ans3=list()
ans4=list()
for i in range(H):
  for j in range(W):
    if i==H-1:
      if j==W-1:
        break
      else:
        for k in range(L[i][j]%2):
          ans1.append(i+1)
          ans2.append(j+1)
          ans3.append(i+1)
          ans4.append(j+2)
        L[i][j+1]+=L[i][j]%2
        N+=L[i][j]%2
    else:
      for k in range(L[i][j]%2):
        ans1.append(i+1)
        ans2.append(j+1)
        ans3.append(i+2)
        ans4.append(j+1)
      L[i+1][j]+=L[i][j]%2
      N+=L[i][j]%2
print(N)
for i in range(N):
  print(ans1[i],ans2[i],ans3[i],ans4[i])

Measured memory_bytes: 108688
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 9223372036854775807
#define mini 9223372036854775807
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	if(b%2==0)
		return ((c%mod)*(c%mod))%mod;
	else
		return ((((c%mod)*(c%mod))%mod)*a)%mod;
}
int main()
{
	boost
	ll n;
	cin>>n;
	vector<ll>v;
	for(ll i=1; i<n; i++)
	{
		ll x;
		cin>>x;
		v.pb(x);
	}
	ll ans=v[0]+v[n-2];
	for(ll i=1; i<n; i++)
		ans+=min(v[i],v[i-1]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<string>
using namespace std;
const int MOD=1000000007;
const int MAX = 1000001;

long long fac[MAX],finv[MAX],inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*/
int main(){
    int x,y;
    cin >> x >> y;
    int a,b;
    COMinit();
    long long ans=0;
    if(x%2 == 0){
        b = x/2;
        a = 0;
    }
    else{
        b = x/2;
        a = 1;
    }
    //cout << a << " "<<b << endl;
    //cout << COM(100,2) << endl;
    while(b != -1){
        if(2*a + b == y){
          //  cout << a << " "<<b << endl;
            ans = (ans + COM(a+b,b))%MOD;
        }
        b -=1;
        a += 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
int n,a[1<<18],b[1<<18],i;
int main(){
	cin>>n;
	for(i=0;i<n;i++)cin>>a[i]>>b[i];
	sort(a,a+n);sort(b,b+n);
	if(n%2)cout<<b[n/2]-a[n/2]+1;
	else cout<<(b[n/2-1]+b[n/2])-(a[n/2-1]+a[n/2])+1;
}


Measured memory_bytes: 5212
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
int n,m;
void yb(int x,int y)
{
	printf((y>=(x%500))?("Yes"):("No"));
}
int main()
{
	scanf("%d%d",&n,&m);
	yb(n,m);
	putchar(10);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int top, N[1000];
 
void push(int x)
{
  top++;
  N[top] = x;
}
 
int pop()
{
  top--;
  return N[top+1];
}
 
int main()
{
 
  char n[100];
  int a, b, top=0;
 
  while(scanf("%s", n) != EOF){
    if(n[0] == '+'){
      a = pop();
      b = pop();
      push(a+b);
    }
    else if(n[0] == '-'){
      a = pop();
      b = pop();
      push(b-a);
    }
    else if(n[0] == '*'){
      a = pop();
      b = pop();
      push(a*b);
    }
    else push(atoi(n));
  }
  printf("%d\n", pop());
 
  return 0;
}

Measured memory_bytes: 552
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
#define all(x) x.begin(),x.end() 
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define per(i,a,b) for(ri i=(a);i>=(b);--i)
#define ls (x<<1)
#define rs (x<<1|1)
#define mid (l+r>>1)
#define db(x) cout << "#x:" << x << endl
#define dd() cout << "Out put!\n"
const int mod=1e9+7,eps=1e-6,pi=acos(-1.0),maxn=1000010;
const int inf=0x7f7f7f7f7f7f7f7f;
using namespace std;
int a[maxn],b[maxn],c[maxn];
string s; 
signed main()
{
	ios::sync_with_stdio(0);
	int t=1;
//	cin >> t;
	while(t--)
	{
		int x,y;
		cin >> x >> y;
		rep(i,0,x)
		{
			int j = x-i;
			int sum = i*2+j*4;
			if(sum == y)
			{
		
				cout <<"Yes";
				return 0;
			}
		}
		cout <<"No";
	}
	return 0;
}

Measured memory_bytes: 3688
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;


int main(int argc, const char * argv[]) {
    int a, b, c;
    
    cin >> a >> b >> c;
    
    if(a + b + c <= 21) cout << "win" << endl;
    else cout << "bust" << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>

using namespace std;

void bubble_sort(vector<string> &strA, int len)
{
    for (int i = 0; i < len; i++)
    {
        for (int j = len - 1; j >= i + 1; j--)
        {
            if (strA[j][1] < strA[j - 1][1])
            {
                swap(strA[j], strA[j - 1]);
            }
        }
    }
}

void selection_sort(vector<string> &strB, int len)
{
    for (int i = 0; i < len; i++)
    {
        int min = i;
        for (int j = i; j < len; j++)
        {
            if (strB[j][1] < strB[min][1])
            {
                min = j;
            }
        }
        
        if (i != min)
        {
            swap(strB[i], strB[min]);
        }
    }
}

bool IsStable(vector<string> strA, vector<string> strB, int len)
{
    bool bFlag = false;
    for (int i = 0; i < len; i++)
    {
        if (strA[i] != strB[i])
        {
            bFlag = true;
            break;
        }
    }
    
    if (true == bFlag)
    {
        return false;
    }
    else
    {
        return true;
    }
}

void print_str(vector<string> str, int len)
{
    for (int i = 0; i < len; i++)
    {
        if (i > 0)
        {
            cout << " ";
        }
        
        cout << str[i];
    }
    
    cout << endl;
}

int main()
{
    int num_cnt = 0;
    bool bFlag = false;
    string str_tmp;
    vector<string> strA;
    vector<string> strB;
    
    cin >> num_cnt;
    for (int i = 0; i < num_cnt; i++)
    {
        cin >> str_tmp;
        strA.push_back(str_tmp);
    }
    
    for (int i = 0; i < num_cnt; i++)
    {
        strB.push_back(strA[i]);
    }
    
    bubble_sort(strA, num_cnt);
    selection_sort(strB, num_cnt);
    
    print_str(strA, num_cnt);
    cout << "Stable" << endl;
    print_str(strB, num_cnt);
    bFlag = IsStable(strA, strB, num_cnt);
    if (true == bFlag)
    {
        cout << "Stable" << endl;
    }
    else
    {
        cout << "Not stable" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3184
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define ll long long
#define LIM 1000
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  cout << max(0, a * a - b) << endl;
  return 0;
}


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

int main() {
	int w,h,x,y,r;
	cin >> w >> h >> x >> y >> r;
	
	if(x >= r && x <= w-r && y >= r && y <= h-r){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3132
# -*- coding: utf-8 -*-
from bisect import bisect, bisect_left
from collections import defaultdict

def inpl(): return list(map(int, input().split()))
N = int(input())
A = sorted(inpl())
beki = [2**i for i in range(1, 31)]
D = defaultdict(list)


for i, a in enumerate(A):
    D[a].append(i)

answer = 0
matched = [0]*(N)

for t in range(31, 0, -1):
    S = 2 ** (t)
    R = bisect_left(A, S) - 1
    for i in range(R, 0, -1):
        if A[i] + A[i-1] < S:
            break
        if matched[i]:
            continue
        X = S - A[i]
        if len(D[X]) >= 1 + (X == A[i]):
            a = D[A[i]].pop()
            b = D[X].pop()
            assert a == i
            matched[a] = 1
            matched[b] = 1
            answer += 1
print(answer)


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

using namespace std;
using ll = long long;

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

struct Sieve {
  vector<ll> p;

  Sieve(ll n) : p(n + 1, 1) {
    p[1] = 0;
    for (ll i = 2; i <= n; ++i) {
      if (p[i] != 1) continue;
      p[i] = i;
      for (ll j = i * i; j <= n; j += i) {
        if (p[j] == 1) p[j] = i;
      }
    }
  }

  vector<ll> factorList(ll x) {
    vector<ll> f;
    while (p[x] != 0) {
      f.push_back(p[x]);
      x /= p[x];
    }
    return f;
  }

  map<ll, ll> factor(ll x) {
    auto l = factorList(x);
    map<ll, ll> mp;
    for (auto v : l) {
      ++mp[v];
    }

    return mp;
  }

  bool isPrime(ll x) { return p[x] == x; }
};

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

  // int ans = 0;
  // for (int i = 2; (ll)i * i <= n; ++i) {
  //   if (n % i != 0) continue;
  //
  //   int p = i;
  //   while (n % p == 0) {
  //     n /= p;
  //     p *= i;
  //     ++ans;
  //   }
  //
  //   while (n % i == 0) n /= i;
  // }
  //
  // if (n != 1) ++ans;
  // cout << ans << endl;

  // auto s = Sieve(sqrt(n) + 1);
  //
  // ll ans = 0;
  // for (int i = 2; (ll)i * i <= n; ++i) {
  //   if (!s.isPrime(i)) continue;
  //   int d = i;
  //   while (n % d == 0) {
  //     n /= d;
  //     d *= i;
  //     ++ans;
  //   }
  //
  //   while (n % i == 0) n /= i;
  // }
  //
  // if (n != 1) ++ans;
  // cout << ans << endl;

  vector<pair<ll, int>> fs;
  for (ll i = 2; i * i <= n; ++i) {
    int cnt = 0;
    while (n % i == 0) {
      n /= i;
      ++cnt;
    }
    if (cnt != 0) fs.push_back({i, cnt});
  }
  if (n != 1) fs.push_back({n, 1});

  int ans = 0;
  for (auto p : fs) {
    int e = p.second;
    int a = 1;
    while (e - a >= 0) {
      e -= a;
      ++a;
      ++ans;
    }
  }

  cout << ans << endl;
  return 0;
}


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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int n,h,w,a,b,ans;

main() {
    cin >> n >> h >> w;
    rep(i,n) {
        cin >> a >> b;
        if (a >= h && b >= w) ans++;
    }
    ct(ans)
}


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

int dp[1005][10005];
int INF = 1001001001;

int main() {
    int H, N; cin >> H >> N;
    vector<int> A(N), B(N);
    rep(i, N){
        cin >> A[i] >> B[i];
    }
    rep(i, N+1){
        rep(j, H+1){
            if(j == 0){
                dp[i][j] = 0;
            } else {
                dp[i][j] = INF;
            }
        }
    }

    for (int i = 0; i < N; i++){
        for (int j = 1; j <= H; j++){
            dp[i+1][j] = dp[i][j];
            if(j >= A[i]){
                dp[i+1][j] = min(dp[i][j], dp[i+1][j-A[i]]+B[i]);
            } else {
                dp[i+1][j] = min(dp[i][j], B[i]);
            }
        }
    }

    cout << dp[N][H] << endl;


    return 0;
}

Measured memory_bytes: 42720
#include<iostream>
#include<string>
#include<queue>
using namespace std;
class info{
    public:
    int x,y;
    int sz;
};

int main(){
    int H,W;
    cin>>H>>W;
    string str[9];
    for(int i=0;i<H;i++){
        cin>>str[i];
    }
    int tot=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<str[i].size();j++){
            if(str[i][j]=='#') tot++;
        }
    }
    queue<info> q;
    info aa;
    aa.x=0; aa.y=0; aa.sz=1;
    q.push(aa);
    bool fl=false;
    while( !q.empty() ){
        info i=q.front(); q.pop();
        if(i.x==W-1 && i.y==H-1){
            if(i.sz==tot){
                fl=true;
                break;
            }
        }
        if(i.x+1<W && str[i.y][i.x+1]=='#'){
            info inpu=i;
            inpu.x++;
            inpu.sz++;
            q.push(inpu);
        }
        if(i.y+1<H && str[i.y+1][i.x]=='#'){
            info inpu=i;
            inpu.y++;
            inpu.sz++;
            q.push(inpu);
        }
    }
    if(fl){
        cout<<"Possible"<<endl;
    }else{
        cout<<"Impossible"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
vector<int> v;
int main(){
  int n,k;cin>>k>>n;
  if(k%2==0){
    cout<<k/2;
    for(int i=1;i<n;i++)cout<<" "<<k;
    cout<<endl;
  }
  if(k%2==1){
    lol(i,n)v.push_back((k+1)/2);
    lol(i,n/2){
      if(v[v.size()-1]>1){
	v[v.size()-1]--;
	while(v.size()!=n)v.push_back(k);
      }
      else v.pop_back();
    }
    lol(i,v.size()){
      if(i)cout<<" ";
      cout<<v[i];
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 3568
def main():
    abcd = input()
    n = len(abcd)
    for i in range(2**(n-1)):
        num = ""
        # print(i)
        for j in range(n):
            num += abcd[j]
            if j < n-1:
                if (i >> j) & 1:
                    num += "-"
                else:
                    num += "+"
        if eval(num) == 7:
            print(num+"=7")
            exit()


if __name__ == "__main__":
    main()


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

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

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


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

typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector< vector<char> > vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main(){
    int n;
    cin >> n;
    vector<long long> l(n);
    map<int,int> mp;
    for(int i=0;i<n;i++){
        cin >> l[i];
    }

    sort(l.begin(),l.end());
    
    long long count=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(l[i]==l[j]) continue;
                if(l[i]==l[k]) continue;
                if(l[j]==l[k]) continue;
                if(l[i]+l[j]>l[k]){
                    count++;
                    //cout << l[i] << " " << l[j] << " " << l[k] << endl;
                }
            }
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int ans[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int w, a, b;
	cin >> w >> a >> b;
	if (a > b) swap(a, b);
	if (b <= a + w) cout << 0 << endl;
	else cout << b - a - w << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

using namespace std;

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

    string s, t;

    getline(cin, s);
    getline(cin, t);

    map<char, int> s_map;
    map<char, int> t_map;

    REP(i,(int)s.size()){
        s_map[s[i]]++;
        t_map[t[i]]++;
    }

    REP(i, (int)s.size())
    {
        if (s_map[s[i]] != t_map[t[i]]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";

}

Measured memory_bytes: 916
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3")
#include<bits/stdc++.h>
#define int long long
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 1<<20, mod = 1e9 + 7;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int r, c, n;
vector<array<int, 2>> lx, rx, ly, ry;
bool border(int x, int y) {
	return x == 0 || x == r || y == 0 || y == c;
}
void add(int x, int y, int i) {
	if(x == 0) {
		lx.push_back({y, i});
	} else if(x == r) {
		rx.push_back({y, i});
	} else if(y == 0) {
		ly.push_back({x, i});
	} else if(y == c) {
		ry.push_back({x, i});
	}
}
array<ll, 2> h[maxn];
signed main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> r >> c >> n;
	for(int x, y, u, v, c = 0, i = 0; i < n; i++) {
		cin >> x >> y >> u >> v;
		if(!border(x, y) || !border(u, v)) continue;
		add(x, y, i);
		add(u, v, i);
	}
	vector<int> r;
	int rev = 0;
	for(auto V : {lx, ry, rx, ly}) {
		if(rev > 1)
			sort(all(V), greater<array<int, 2>>());
		else
			sort(all(V), less<array<int, 2>>());
		rev++;
		for(auto &[v, idx] : V) r.push_back(idx);
	}
	for(int i = 0; i < n; i++) h[i][0] = rng(), h[i][1] = rng();
	array<ll, 2> cur = {0, 0};
	vector<array<ll, 2>> ps;
	vector<int> lst(n, -1);
	for(int i = 0; i < r.size(); i++) {
		if(lst[r[i]] != -1) {
			if((ps.back()[0]^ps[lst[r[i]]][0])||(ps.back()[1]^ps[lst[r[i]]][1])) return cout << "NO\n", 0;
		} else lst[r[i]] = i;
		cur[0] ^= h[r[i]][0];
		cur[1] ^= h[r[i]][1];
		ps.push_back(cur);
	}
	cout << "YES\n";
}



Measured memory_bytes: 16396
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007
//#define MOD 7

using namespace std;

int main(void){
    // Your code here!
    long long x, a, b;
    
    cin >> x >> a >> b;
    
    cout << x - a - ((x - a) / b) * b << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

const int INF = (1 << 30);

int n, t;
int c[111], tt[111];
int ans = INF;

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

  cin >> n >> t;
  for(int i=0;i<n;i++){
    cin >> c[i] >> tt[i];
  }
  
  for(int i=0;i<n;i++){
    if(tt[i] <= t){
      ans = min(ans, c[i]);
    } 
  }

  if(ans == INF){
    cout << "TLE" << endl;
  } else {
    cout << ans << endl;
  }
  
  return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <map>
#include <algorithm>
#include <vector>
#include <queue>
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
typedef long long ll;
using namespace std;

int A[20],n,q,B[200];

bool slove(int i, int m) {
	if (m - A[i] == 0) return true;
	else if(m>0&&i<n)
	return slove(i + 1, m) || slove(i + 1, m - A[i]);
	else return false;
}

int main() {
	cin >> n;
	for (int i = 0;i < n;i++)	cin >> A[i];
	cin >> q;
	for (int i = 0;i < q;i++) {
		cin >> B[i];
		cout << (slove(0, B[i]) ? "yes" : "no") << endl;
	}
}

Measured memory_bytes: 3044
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll H, W;
    char a[105][105];
    in2(H, W);
    rep(i, H) ins(a+i);
    rep(_, W+2) printf("#");
    printf("\n");
    rep(i, H) printf("#%s#\n", a[i]);
    rep(_, W+2) printf("#");
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	int n,k;
	while(cin>>n>>k){
		if(n%k==0){
			cout<<"0"<<endl;
		}
		else{
			cout<<"1"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
ans = 0
for i in range(1, N+1):
    if len(str(i))%2==1:
        ans += 1
print(ans)

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

//define-----------------------------------------------------------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)

//typedef----------------------------------------------------------------------------------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
//const------------------------------------------------------------------------------------------------------------------------
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
//global-----------------------------------------------------------------------------------------------------------------------
int n, m;
int a, now = 1;
LL ans = 0;
VLL b;
//#define DEBUG
//function-------------------------------------------------------------------------------------------------------------------
int main() {
	b.PB( 0 );
	b.PB( 0 );
	scanf( "%d %d", &n, &m );
	n--;
	rep( i, n ) {
		scanf( "%d", &a );
		b.PB( b[ i + 1 ] + a );
	}
	rep( i, m ) {
		scanf( "%d", &a );
		if ( a < 0 ){
			ans += b[ now  ] - b[ now + a ];
		}
		else {
			ans += b[ now + a ] - b[ now ];
		}
		ans %= 100000;
		now += a;
	}
	printf( "%d\n", ans );
	return 0;
}

Measured memory_bytes: 2064
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main() {
    int n;
    int total = 0;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    rep(i,n) cin >> a.at(i);
    rep(i,n) {
        cin >> b.at(i);
        total += b[i];
    }
    rep(i,n-1) cin >> c.at(i);
    for(int i=0; i<n; ++i) {
        if (a[i]==a[i-1]+1) {
            total += c[a[i-1]-1];
        }
    }
    cout << total << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#define P pair<int, string>


using namespace std;
const long long int MOD=1e9+7;

int main(){
  string s[200009];
  vector<string> v;
  int n;
  map<string, int> mp;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s[i];
  }
  int mx=0;
  for(int i=0;i<n;i++){
    mp[s[i]]++;
    mx = max(mx, mp[s[i]]);
  }
  map<string, bool> check;
  for(int i=0;i<n;i++){
    if(mp[s[i]]==mx && !check[s[i]]){
      v.push_back(s[i]);
      check[s[i]]=true;
    }
  }
  sort(v.begin(), v.end());
  for(int i=0;i<v.size();i++)cout << v[i] << endl;
}


Measured memory_bytes: 40816
import numpy as np

n,W=list(map(int,input().split()))

dp=np.zeros([n+1,W+1],dtype=int)

for i in range(1,n+1):
    w,v=list(map(int,input().split()))
    dp[i]=dp[i-1]
    dp[i][w:]=np.maximum(dp[i-1][:W-w+1]+v,dp[i-1][w:])
print(np.max(dp))

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

int main() {
  int n, i, count = 0;
  cin >> n;
  
  vector<int> p(n);
  for(i = 0; i < n; i++){
    cin >> p.at(i);
    if(p.at(i) == i + 1) count++;
  }
  
  if(count >= n - 2) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for(int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        Arrays.sort(a);

        if(n % 2 == 0) {
            long ans = 0;
            ans += a[n - 1];
            for(int i = 0; i < n / 2 - 1; i++) {
                ans += a[n - i - 2] * 2;
            }
            System.out.println(ans);
        }else {
            long ans = 0;
            ans += a[n - 1];
            for(int i = 0; i < n / 2 - 1; i++) {
                ans += a[n - i - 2] * 2;
            }
            ans += a[n - n / 2 - 1];
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 61656