akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    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;
    }
}
 
 
#define comuse Comuse()
 
ll combi(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;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  vll A(n);
  FOR(i,0,n){
    ci(A[i])
  }
  REV(A);
  bl b=false;
  
  FOR(i,1,n){
    if(A[i]>A[i-1]&&A[i]-1==A[i-1]){
      A[i]--;
    }
    else if(A[i]>A[i-1]&&A[i]>A[i-1]){
      b=true;
      break;
    }
    
  }
  
  if(b){
    co("No")
  }
  else{
    co("Yes")
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FL          freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
//int dx[] = {1, 0}, dy[] = {0, 1};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0 ,1, 1, 1, 0, -1, -1, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int n, W;
ll w[101];
int v[101];
ll dp[101][N];
ll f(int i, int want){
    if(want < 0)return 1e18;
    if(i == n)return want == 0 ? 0 : 1e18;
    ll &ans = dp[i][want];
    if(ans == -1){
        ans = 1e18;
        ans = min(f(i + 1, want), ans);
        ans = min(ans, f(i + 1, want - v[i]) + w[i]);

    }return ans;
}
int main(){
    //FL;
    FIN;
    cin >> n >> W;
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> w[i] >> v[i];
        sum += v[i];
    }
    cls(dp, -1);
    int ans = 0;
    for(int i = 0; i < sum + 1; i++){
        ll cur = f(0, i);
        if(cur <= W)
            ans = i;
    }
    cout << ans << '\n';
    EjecuteTime;
    return 0;
}       

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

void rev(int &k, int y, int z) {
	k -= y;
	z -= y;
	k = z - k;
	k += y;
}

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

	int a, d;
	cin >> a >> d;

	int m;
	cin >> m;

	vector<tuple<int, int, int>> query;
	query.reserve(m);
	for(int i = 0; i < m; ++i) {
		int x, y, z;
		cin >> x >> y >> z;
		--y; --z;
		query.emplace_back(x, y, z);
	}

	int k;
	cin >> k;
	--k;

	for(int i = m - 1; i >= 0; --i) {
		int x, y, z;
		tie(x, y, z) = query[i];

		if(x == 0) {
			if(y <= k && k <= z) {
				rev(k, y, z);
			}
		}
	}

	int ans = a + k * d;
	for(int i = 0; i < m; ++i) {
		int x, y, z;
		tie(x, y, z) = query[i];

		if(!(y <= k && k <= z)) continue;

		switch(x) {
		case 0:
			rev(k, y, z);
			break;
		case 1:
			++ans;
			break;
		case 2:
			ans /= 2;
			break;
		default:
			assert(false);
		}
	}

	cout << ans << endl;

	return 0;
}

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

typedef long long ll;

ll gcd(ll a, ll b) {
	if (a < b) swap(a, b);
	while (b) {
		ll t = b;
		b = a % b;
		a = t;
	}
	return a;
}

int main() {
	int N;
	cin >> N;
	set<ll> ts;
	for (int i = 0; i < N; i++) {
		ll tm;
		cin >> tm;
		ts.insert(tm);
	}
	vector<ll> tv(ts.begin(), ts.end());
	int n = tv.size();
	if (tv.size() == 1) {
		cout << tv[0] << endl;
	}
	else {
		ll N_gcd =  tv[0] / gcd(tv[0], tv[1]) * tv[1];
		for (int i = 2; i < tv.size(); i++) {
			N_gcd = tv[i] / gcd(N_gcd, tv[i]) * N_gcd;
		}
		cout << N_gcd << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;
long long int maxi(long long int A, long long int B) {
	return (A > B) ? A : B;
}
int main() {
	int K, T, a, maxi = -1;
	cin >> K >> T;
	for (int i = 0; i < T; i++)
	{
		cin >> a;
		maxi = max(a, maxi);
	}
	cout << max(0, maxi - (K - maxi) - 1);
}


Measured memory_bytes: 256
#include<cstdio>

bool linearSearch(int A[], int n, int key){
    int i = 0;
    A[n] = key;
    while(A[i] != key) i++;
    return i != n;
}

int main(){
    int n, A[10001], q, key, sum=0;
    
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d", &A[i]);
    
    scanf("%d", &q);
    for(int i=0;i<q;i++){
        scanf("%d", &key);
        if(linearSearch(A, n, key)) sum++;
    }
    printf("%d\n", sum);
    
    return 0;

}
    
    
    
    


Measured memory_bytes: 2796
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int n, m, u, v;
int ans[100000];
int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; i++){
		scanf("%d%d", &u, &v);
		ans[u]++;
		ans[v]++;
	}
	for(int i = 1; i <= n; i++)printf("%d\n", ans[i]);
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

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

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll nCrmod(ll n,ll r){ll x=1,y=1; rep(i,r){x=x*(n-i)%mod; y=y*(i+1)%mod;} return x*powmod(y,mod-2)%mod;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,m;
	cin >> n >> m;
	vll a(m);
	rep(i,m) cin >> a[i];
	vll dp(n+1,INF);
	dp[0]=0;
	for(ll i=1;i<=n;i++){
		rep(j,m){
			if(i-a[j]<0) continue;
			chmin(dp[i],dp[i-a[j]]+1);
		}
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
vector<pair<char, int>> runLengthEncoding(string s) {
	int n = s.length();
 
	vector<pair<char, int>> res;
	char pre = s[0];
	int cnt = 1;
	rep(i, 1, n) {
		if (pre != s[i]) {
			res.push_back({ pre, cnt });
			pre = s[i];
			cnt = 1;
		}
		else cnt++;
	}
 
	res.push_back({ pre, cnt });
	return res;
}
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/
 
 
 
 
 
 
int N, K; string S;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> K >> S;
 
	auto blocks = runLengthEncoding(S);
	int M = blocks.size();
	int ans = 0;
	int sm = 0;
	int L = 0;
	int zero = 0;
	rep(R, 0, M) {
		sm += blocks[R].second;
		if (blocks[R].first == '0') zero++;
 
		while (K < zero) {
			sm -= blocks[L].second;
			if (blocks[L].first == '0') zero--;
			L++;
		}
 
		chmax(ans, sm);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1724
def selectSort(A, N):
      cnt = 0
      for i in range(0,N):
            mina = A[i]
            k = 0
            for j in range(i+1,N):
                  if int(mina) > int(A[j]):
                        mina = A[j]
                        k = j
            if int(A[i]) > int(mina):
                  swap = A[i]
                  A[i] = mina
                  A[k] = swap
                  cnt = cnt + 1
      for t in range(0,N):
            if t < N-1:
                  print(A[t], end=" ")
            else:
                  print(A[t])
      print(cnt)
            

if __name__ == "__main__":
      N = int(input())
      A = (input()).split()
      selectSort(A,N)

Measured memory_bytes: 7780
#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll l2(ll n)
{
	ll a = 0;
	n /= 2;
	while (n)
	{
		a++;
		n /= 2;
	}
	return a;
}


int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	ll a, b;
	cin >> a >> b;
	cout << a*b << endl;
}



Measured memory_bytes: 3584
fun main(args: Array<String>){
    var a = readLine()!!.map { it.toString() }.toMutableList()
    var b = readLine()!!.map { it.toString() }.toMutableList()
    var c = readLine()!!.map { it.toString() }.toMutableList()

    var str = a.removeAt(0)

    while (true){
        if(str == "a"){
            if(a.size <= 0){
                println("A")
                break
            }else{
                str = a.removeAt(0)
            }
        }else if(str == "b"){
            if(b.size <= 0){
                println("B")
                break
            }else{
                str = b.removeAt(0)
            }
        }else{
            if(c.size <= 0){
                println("C")
                break
            }else{
                str = c.removeAt(0)
            }
        }
    }
}

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


const int mod=1e9+7;

vector<int> A,B;

int main(){
	int n,a;
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> a;
		A.push_back(a);
		B.push_back( abs((i-1)-(n-i)) );
	}
	
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	
	if(A!=B){
		cout << 0 << endl;
		return 0;
	}
	
	long long sum=1;
	for(int i=0;i<n/2;i++){
		sum=(sum*2)%mod;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1276
import sys,math,collections,itertools
input = sys.stdin.readline

N,A,B = list(map(int,input().split()))
X = sorted(list(map(int,input().split())))
cnt=0
for i in range(N-1):
    if X[i+1]-X[i] >B/A:
        cnt+=B
    else:
        cnt +=A*(X[i+1]-X[i])
print(cnt)


Measured memory_bytes: 21300
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define INF 1e9

static const int seed=20;
static const int D=365;
static const int ntype=26;
static int ans[D+1];
static int max_score=0;
static int t=3e5;

class Contest{
public:
    Contest(){
        last=0;
    }
    int s[D+1];
    int c;
    int last;
};

static Contest contest[ntype+1];

void Input(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int d;
    cin>>d;
    for(int i=1;i<=ntype;++i){
        int t;
        cin>>t;
        contest[i].c=t;
    }
    for(int day=1;day<=D;++day){
        for(int type=1;type<=ntype;++type){
            int t;
            cin>>t;
            contest[type].s[day]=t;
        }
    }
}

int Score(int type){
    int sum=0;
    contest[type].last=0;
    for(int day=1;day<=D;++day){
        if(ans[day]==type){
            sum+=contest[type].s[day];
            int n=day-contest[type].last;
            sum-=contest[type].c*(n*(n-1)/2);
            contest[type].last=day;
        }
    }
    if(ans[D]!=type){
        int n=D-contest[type].last;
        sum-=contest[type].c*(n*(n+1)/2);
    }
    return sum;   
}

void Output(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    for(int d=1;d<=D;++d) cout<<ans[d]<<'\n';
}

void Init(){
    for(int d=1;d<=D;++d) ans[d]=rand()%ntype+1;
}

void Greedy(){
    vector<int> l(ntype+1,0);
    int score=0;
    for(int d=1;d<=D;++d){
        for(int i=1;i<=ntype;++i) score-=contest[i].c*(d-l[i]);
        int temp=score;
        int t=-1;
        for(int i=1;i<=ntype;++i){
            int k=contest[i].s[d]+contest[i].c*(d-l[i])+score;
            if(k>temp){
                temp=k;
                t=i;
            }
        }
        ans[d]=t;
        l[t]=d;
    }
}

void change(){
    int p=rand()%D+1;
    int temp=ans[p];
    int temp_score=Score(temp);
    ans[p]=rand()%ntype+1;
    //cout<<"p: "<<p<<" from: "<<temp<<" to: "<<ans[p]<<endl;
    int delta=Score(ans[p])-temp_score;
    if(delta>0){
        max_score+=delta;
    }
    else ans[p]=temp;
}

void swap(){
    int p1=rand()%D+1;
    int p2=rand()%D+1;
    while(p1==p2) p2=rand()%D+1;
    int temp_score=Score(ans[p1])+Score(ans[p2]);
    int temp=ans[p1];
    ans[p1]=ans[p2];
    ans[p2]=temp;
    int delta=Score(ans[p2])+Score(ans[p1])-temp_score;
    if(delta>0){
        max_score+=delta;
    }
    else{
        ans[p2]=ans[p1];
        ans[p1]=temp;
    }
}

void Solve(int times){
    Greedy();
    for(int i=1;i<=ntype;++i) max_score+=Score(i);
    for(int i=0;i<times;++i){
        swap();
        change();
    }
}

int main(){
    srand(seed);
    Input();
    Solve(t);
    Output();
}


Measured memory_bytes: 3704
import java.util.*;
 
class Main{
  static int mod=1000000007;
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
 
    int n = s.nextInt();
    int[] q = new int[n];
    Arrays.setAll(q, i -> s.nextInt());
 
    boolean[] a = new boolean[n+1];
    int c = 0;
 
    for(int i = n; i > 0; i--) {
      boolean t = q[i-1] == 1;
      for(int j = i*2; j <= n; j += i)
        t ^= a[j];
      a[i] = t;
      if(a[i])
        c++;
    }
    System.out.println(c);
    StringBuilder builder = new StringBuilder();
    for(int i = 0;i <= n;++i)
      if(a[i])
        builder.append(i).append("\n");
    System.out.println(builder.toString());
  }
}

Measured memory_bytes: 65784
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

ls = []
ls.extend(s)
ls.extend(t)

ls = set(ls)
d = {l:0 for l in ls}

for sn in s:
    d[sn] += 1
for tn in t:
    d[tn] -= 1
# print(d)
d = sorted(d.items(),key = lambda x:x[1],reverse = True)
if d[0][1] > 0:
    print(d[0][1])
else:
    print(0)

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


int main() {
  
  int n;
  cin >>n;
  
  vector<string>vec(n);
  for(int i=0;i<n;i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  
  int c=1;
  for(int i=1;i<n;i++){
    if(vec.at(i)!=vec.at(i-1)){
      c++;
    }
  }
  
  cout << c << endl;
}
      

Measured memory_bytes: 9532
package main

import (
	"fmt"
)

func main() {
	var h, w int
	fmt.Scan(&h)
	fmt.Scan(&w)
	for i := 0; i < w+2; i++ {
		fmt.Print("#")
	}
	fmt.Print("\n")

	for i := 0; i < h; i++ {
		fmt.Print("#")
		var s string
		fmt.Scan(&s)
		fmt.Print(s)
		fmt.Print("#")
		fmt.Print("\n")
	}

	for i := 0; i < w+2; i++ {
		fmt.Print("#")
	}
	fmt.Print("\n")
}


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

int a(int n) {
  if(n % 1000 == 0) {
    return 0;
  }
  return  (((int (n / 1000)) + 1) * 1000) - n;
}

int main() {
  int n;
  cin >> n;
  cout << a(n);
}

Measured memory_bytes: 3640
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    long S = Long.parseLong(sc.next());
    
    long x1 = S;
    long y1 = 0;
    long x2 = 1;
    long y2 = 1;
    long x3 = 0;
    long y3 = 0;

    long g = (long)Math.sqrt(x1);
    if(g*g != x1){
      g++;
    }

    x1 = g;
    y2 = g;
    y1 = g*g-S;
    
    System.out.println(x1+" "+y1+" "+x2+" "+y2+" "+x3+" "+y3);
  }
}


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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pi;
typedef long double ld;
typedef pair<long double, long double> pld;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll i, j, k, l;

    ll N;
    cin >> N;
    vector<pll> P;
    for(i = 0; i < N; i++) {
        ll x, y;
        cin >> x >> y;
        pll p = pll(x + y, y - x);
        P.push_back(p);
    }
    ll xmax = 0;
    ll xmin = INF;
    ll ymax = 0;
    ll ymin = INF;
    for(i = 0; i < N; i++) {
        xmax = max(xmax, P[i].first);
        xmin = min(xmin, P[i].first);
        ymax = max(ymax, P[i].second);
        ymin = min(ymin, P[i].second);
    }
    ll ans = max(xmax - xmin, ymax - ymin);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7416
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(b<=c||a>=d)
	{
		cout<<"0"<<endl;
	}
	else if(a<c&&b>c&&b<d)
	{
		cout<<b-c<<endl;
	}
	else if(a>c&&a<d&&b>d)
	{
		cout<<d-a<<endl;
	}
	else if(a>=c&&b<=d)
	{
		cout<<b-a<<endl;
	}
	else if(a<=c&&b>=d)
	{
		cout<<d-c<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n=input()
n=int(n)
now = 0
nowx=0
nowy=0
for i in range(n):
    temp=input().split(" ")
    
    t=int(temp[0])
    
    x=int(temp[1])
    y=int(temp[2])
    #終了条件
    #間に合わない or 偶奇が違う
    if abs(nowx-x)+abs(nowy-y)>t-now  or ((abs(nowx-x)+abs(nowy-y))%2==1 and  (t-now)%2==0) or ((abs(nowx-x)+abs(nowy-y))%2==0 and  (t-now)%2==1):
        print("No")
        exit()
        
    else:
        now=t
        nowx=x
        nowy=y
        


print("Yes")



Measured memory_bytes: 3064
N = int(input())

a = list(map(int,input().split()))

cnt = 0

for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if a[i] == a[j] or a[j] == a[k] or a[i] == a[k]:
                continue
            if a[i] + a[j] <= a[k] or a[i] + a[k] <= a[j] or a[k] + a[j] <= a[i]:
                continue
            cnt += 1

print(cnt)

Measured memory_bytes: 68200
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;
typedef pair <ll, ll> pll;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int k;
string s;
main() {
    file("stars");
    ios;
    cin >> k >> s;
    for (int i = 0; i < s.size(); ++i) {
        int num = (s[i] - 'A');
        num += k;
        num %= 26;
        cout << char(num + 'A');
    }
    cerr << "\nTime elapsed: " << (clock() + 0.0) / CLOCKS_PER_SEC;
    return 0;
}
/**

*/


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

int main(){
	int a, b;
	scanf("%d%d", &a, &b);
	bitset<32> bita(a);
	bitset<32> bitb(b);
	cout << (bita & bitb) << '\n';
	cout << (bita | bitb) << '\n';
	cout << (bita ^ bitb) << '\n';
}



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

using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
int main() {
  int N;
  cin >>N;
  string S;
  cin >>S;
  int count=0;
  if (N%2 !=0) {
cout <<"No"<< endl;
  }
  else {
  rep(i,N/2) {
if(S.at(i)==S.at(i+N/2)) {
count++;
}
  }
    
        if (count==N/2) {
cout <<"Yes"<< endl;
        }
    else {
cout <<"No"<< endl;
    }
  }
}
 
  


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

using namespace std;

vector<pair<int, int>> movement = { make_pair(0, 1),
                                    make_pair(0, -1),
                                    make_pair(-1, 0),
                                    make_pair(1, 0) };

int main (void) {
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    for ( int i = 0; i < H; i++ ) {
        cin >> s.at(i);
    }

    int ans_init = H * W;
    vector<vector<int>> dist(H, vector<int>(W, 0));
    for ( int row = 0; row < H; row++ ) {
        for ( int col = 0; col < W; col++ ) {
            if ( s.at(row).at(col) == '#' ) {
                dist.at(row).at(col) = -1;
                ans_init--;
            }
        }
    }

    int ans = ans_init;
    queue<pair<int, int>> next;

    next.push(make_pair(0, 0));

    while ( !next.empty() ) {
        pair<int, int> now = next.front(); next.pop();
        int x = now.first;
        int y = now.second;

        if ( x == W-1 && y == H-1 ) {
            ans = ans - dist.at(y).at(x) - 1;
            break;
        }

        for ( auto m : movement ) {
            int x_ = x + m.first;
            int y_ = y + m.second;
            if ( x_ < 0 || W <= x_ || y_ < 0 || H <= y_ )
                continue;
            if ( dist.at(y_).at(x_) != 0 )
                continue;
            dist.at(y_).at(x_) = dist.at(y).at(x) + 1;
            next.push(make_pair(x_, y_));
        }
    }

    if ( ans == ans_init )
        cout << "-1" << endl;
    else
        cout << ans << endl;
    return 0;
}



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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int cnt = 1;
    rep(i, n) {
        if (cnt == a[i]) cnt++;
    }
    cnt--;
    if (n - cnt == n) {
        cout << -1 << endl;
    } else {
        cout << n - cnt << endl;
    }
    return 0;
}

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

int main() {
  string S,T;
  cin >> S >> T;

  int Slength = S.length();
  int Tlength = T.length();

  int ans = Slength;

  rep(i,Slength-Tlength+1){
    int sum = 0;
    rep(j,Tlength){
      if (S[i+j] != T[j]) sum++;
    }
    ans = min(ans,sum);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3552
#include<iostream>

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    
    string op;
    
    if(a>b)
    {
        op = ">";
    }
    
    if (a<b)
    {
        op = "<";
    }
    
    if (a==b)
    {
        op = "==";
    }
    
    cout << "a " << op << " b" << endl;
    
    return 0;
}


Measured memory_bytes: 3188
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    var total = 0.0
    for (i in 0 until n) {
        val (x, type) = readLine()!!.split(" ")
        total += if (type == "BTC") x.toDouble() * 380000 else x.toDouble()
    }
    print(total)
}

Measured memory_bytes: 37984
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,i,j;
    while(~scanf("%d",&i))
    {
        if(i%2==0)
        {
            printf("%d\n",i);
        }
        else
        {
            printf("%d\n",2*i);
        }
    }
    return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

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

int main(){
	cout<<fixed;
	//cout<<setprecision(9)<<...
	double l;
	cin>>l;
	cout<<setprecision(9)<<pow(l/3,3)<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
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;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(A+B==C+D) cout<< "Balanced"<<"\n";
  if(A+B>C+D) cout<< "Left"<<"\n";
  if(A+B<C+D) cout<< "Right"<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <math.h>

using namespace std;

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)

#define INF 		2000000007
#define MOD			998244353

#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int ll;


int main(){
	int N;cin>>N;
	int minl=INF,maxl=0;
	REP(i,N){
		int t;cin>>t;
		minl = min(minl,t);
		maxl = max(maxl,t);
	}

	cout << (maxl-minl) << endl;

	return 0;
}

Measured memory_bytes: 384
N = int(raw_input())

data = []

for i in range(N):
    t, x, y = map(int, raw_input().split())
    data.append((t, x, y))


for d in data:
    t, x, y = d
    if t < x + y:
        print('No')
        exit()
    if (x+y)%2 != t%2:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 19344
#include <bits/stdc++.h>
using namespace std;
int main (){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int l=a+b;
  int r=c+d;
  if (l<r)cout<<"Right";
  else if (l>r)cout<<"Left";
  else
    cout<<"Balanced";


 return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define INF 100100100
typedef long long ll;

int main(void)
{
    int ans = INF;
    int n, x[101];
    int min = 101, max = 0;

    scanf("%d", &n);
    rep(i, n)
    {
        scanf("%d", &x[i]);
        min = min(min, x[i]);
        max = max(max, x[i]);
    }
    //printf("min:%d max:%d\n", min, max);

    for(int p = min; p <= max; p++)
    {
        int tmp = 0;
        rep(i, n)
            tmp += (x[i] - p) * (x[i] - p);
        //printf("tmp:%d\n", tmp);
        ans = min(ans, tmp);
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll s=0;
    ll sum=0;
    rep(i,0,n-1){
        s+=a[i];
        if(i%2==0){
            if(s<=0){
                sum+=(1-s);
                s+=(1-s);
            }
        }else{
            if(s>=0){
                sum+=(s+1);
                s-=(s+1);
            }
        }
        //cout<<s<<' '<<sum<<endl;
    }
    ll ans=sum;
    s=0;
    sum=0;
    rep(i,0,n-1){
        s+=a[i];
        if(i%2==1){
            if(s<=0){
                sum+=(1-s);
                s+=(1-s);
            }
        }else{
            if(s>=0){
                sum+=(s+1);
                s-=(s+1);
            }
        }
        //cout<<s<<' '<<sum<<endl;
    }
    ans=min(ans,sum);
    cout<<ans<<endl;
    
    return 0;
}






Measured memory_bytes: 1024
#include<iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{      
    int n,a;
    cin >> n;
    a=(n*100)/108;
    if((int)(a*1.08)==n){
        cout << a;
    }else if((int)((a+1)*1.08)==n){
        cout << a+1;
    }else{
        cout << ":(";
    }
    


}
 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	int a,b,x;
	cin>>a>>b>>x;
	if(a>x){
		cout<<"NO"<<endl;
	}
	else if(a+b<x){
		cout<<"NO"<<endl;
	}
	else{
		cout<<"YES"<<endl;
	}
}

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

#define int ll

#define pb push_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

const int MAX = 3010, MOD = 1E9 + 7;

int n, dp[MAX][MAX];
string s;

int f(int i, int last) {
	// returns the number of ways to place [1 : i + 1] such that s[1 : i] is respected and last character placed is last
	if(last > i + 1)
		return 0;
	if(i == 0)
		return (last == 1);
	if(dp[i][last] > -1)
		return dp[i][last];
	int ret = 0;
	if(s[i - 1] == '>') 
		for(int j = last; j <= i + 1; j++)
			ret = (ret + f(i - 1, j)) % MOD;	
	else
		for(int j = 1; j < last; j++)
			ret = (ret + f(i - 1, j)) % MOD;
	return dp[i][last] = ret;
}


int32_t main() {
	memset(dp, -1, sizeof(dp));
	cin >> n >> s;
	vvi ways(n + 1, vi(n + 1));
	ways[0][1] = 1;
	vi pref(n + 2, 1);
	pref[0] = pref[1] = 0;
	//ways[i][j] = number of ways to place [1 : i + 1] st. cond holds and last element = j
	for(int i = 1; i < n; i++) {
		for(int j = 1; j <= i + 1; j++) {
			if(s[i - 1] == '>') {
				ways[i][j] = (pref[j] - pref[1] + MOD) % MOD;
				// for(int k = 1; k < j; k++)
				// 	ways[i][j] = (ways[i][j] + ways[i - 1][k]) % MOD;
			}
			else {
				ways[i][j] = (pref[i + 1] - pref[j] + MOD) % MOD;
				// for(int k = j; k <= i; k++)
				// 	ways[i][j] = (ways[i][j] + ways[i - 1][k]) % MOD;
			}
		}
		vi tmp(n + 2);
		for(int j = 1; j <= i + 1; j++)
			tmp[j + 1] = (tmp[j] + ways[i][j]) % MOD;
		swap(tmp, pref);
	}
	int res = 0;	
	for(int i = 1; i <= n; i++)
		res = (res + ways[n - 1][i]) % MOD;
	cout << res << '\n';
}


Measured memory_bytes: 141568
#include<iostream>

using namespace std;

int main()
{
    int a,b,c,i;
    for(i = 1;i <= 3000; i++)
    {
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        if(a > b)
        {
            c = a;
            a = b;
            b = c;
        }
        cout << a << " " << b << endl;

    }
    return 0;
}


Measured memory_bytes: 3044
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=3007;
const ll inf=1e18;

char a[nax];
char b[nax];
int ra, rb;

int dp[nax][nax];

int main()
{
	scanf("%s", a+1);
	scanf("%s", b+1);
	ra=strlen(a+1);
	rb=strlen(b+1);
	for (int i=1; i<=ra; i++)
	{
		for (int j=1; j<=rb; j++)
		{
			if (a[i]==b[j])
			{
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else
			{
				dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}
	vector <char> wyp;
	while(ra && rb)
	{
		if (a[ra]==b[rb])
		{
			wyp.push_back(a[ra]);
			ra--;
			rb--;
		}
		else
		{
			if (dp[ra-1][rb]>dp[ra][rb-1])
				ra--;
			else
				rb--;
		}
	}
	reverse(wyp.begin(), wyp.end());
	for (char i : wyp)
		printf("%c", i);
	printf("\n");
	return 0;
}


Measured memory_bytes: 35584
#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: String
    }
    let result = if n.chars().fold(false, |cond, c| cond || c == '7') {
        "Yes"
    } else {
        "No"
    };

    println!("{}", result);
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  int x = 1e7;
  int y = 1e7;
  rep(i, n) {
    cin >> a[i];
    if (x > a[i]) {
      x = a[i];
      y = i;
    }
  }
  cout << (n + k - 3)/(k-1) << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
    using namespace std;
     
    typedef unsigned long long llint;
    #define FOR(i, a, b) for(llint i = a; i <= b; ++i)
    #define REP(i, n) for(llint i = 0; i < n; ++i)
     
    const llint maxSUM = 111'111;
    const llint mod = 1'000'000'007;
     
    llint fact[maxSUM + 1];
    llint inv[maxSUM + 1];
     
    void scale(llint &value) {
        value %= mod;
    }
     
    llint fastExp(llint a, llint n) {
        if (a == 0) {
            return 0;
        }
        llint res = 1;
        while (n > 0) {
            if (n & 1) {
                res = res * a % mod;
            }
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }
     
    void preProcess() {
        fact[0] = inv[0] = 1;
        FOR(i, 1, maxSUM) {
            fact[i] = fact[i - 1] * i;
            scale(fact[i]);
            inv[i] = fastExp(fact[i], mod - 2);
            scale(inv[i]);
        }
    }
     
    llint combination(llint N, llint K) {
        llint res = inv[K] * inv[N - K];
        scale(res);
        res *= fact[N];
        scale(res);
        return res;
     
    }
     
    llint double_combination(llint sum, llint nTerms) {
        llint N = sum + nTerms - 1; // <= 30 + 10^5 - 1
        llint K = nTerms - 1; // <= 10^5 - 1
        return combination(N, K);
    }
     
    void run() {
        llint ans = 1, n, m;
     
        preProcess();
        cin >> n >> m;
     
        for (llint p = 2; p * p <= m; ++p) {
            if (m % p == 0) {
                llint deg = 0;
                while (m % p == 0) {
                    m /= p;
                    deg += 1;
                }
                ans *= double_combination(deg, n);
                scale(ans);
            }
        }
     
        if (m > 1) {
            ans *= double_combination(1, n);
            scale(ans);
        }
     
        cout << ans << "\n";
    }
     
    static void run_with_stack_size(void (*func)(), size_t stackSize) {
        char *stack, *send;
        stack = (char*) malloc(stackSize);
        send = stack + stackSize - 16;
        send = (char*) ((uintptr_t) send / 16 * 16);
        asm volatile(
        "mov %%rsp, (%0)\n"
        "mov %0, %%rsp\n"
        :
        : "r" (send));
        func();
        asm volatile(
        "mov (%0), %%rsp\n"
        :
        : "r" (send));
        free(stack);
    }
     
    int main() {
    #ifdef LOCAL
        freopen("input", "r", stdin);
    #endif
        run_with_stack_size(run, 256*1024*1024);
    #ifdef LOCAL
        fclose(stdin);
    #endif
        return 0;
    }

Measured memory_bytes: 3968
from itertools import product


def li():
    return list(map(int, input().split()))


def is_on(state, p, s_list):
    return sum(list(map(lambda x: state[x - 1], s_list))) % 2 == p


if __name__ == '__main__':
    [n, m] = li()
    ks_list = [li() for _ in range(m)]
    p_list = li()

    pattern = 0

    for state in product([0, 1], repeat=n):
        is_all = True
        for index, ks in enumerate(ks_list):
            if not is_on(state, p_list[index], ks[1:]):
                is_all = False
        if is_all:
            pattern = pattern + 1
    print(pattern)


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

int main()
{
	int a, b, c, x, n=0;
	cin >> a >> b >> c;
	for (x = a; x <= b; x++) {
		if (c%x == 0) {
			n = n + 1;
		}
	}
	cout << n << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define wzh(x) cerr<<#x<<' '<<x<<endl
int t,n;
struct uzi{
  int k,l;
  bool operator < (const uzi & t)const{
    return k<t.k;
  }
}L[N],R[N];
int dx,dy;
int main() {
  ios::sync_with_stdio(false);
  for(cin>>t;t;t--){
    cin>>n;LL ans=0;dx=dy=0;
    for(int i=1;i<=n;i++){
      int k,l,r;
      cin>>k>>l>>r;
      if(l>r){
        ans+=r;
        L[++dx]={k,-l+r};
      }else if(l<r){
        ans+=l;
        R[++dy]={k,-r+l};
      }else ans+=l;
    }
    sort(L+1,L+1+dx);
    sort(R+1,R+1+dy);
    int x=1;
    priority_queue<int>q;
    for(int i=1;i<=n;i++){
      while(x<=dx&&L[x].k==i)q.push(L[x].l),x++;
      while(q.size()>i)q.pop();
    }
    while(!q.empty())ans-=q.top(),q.pop();
    x=dy;
    for(int i=n;i>=1;i--){
      while(x>=1&&R[x].k==i)q.push(R[x].l),x--;
      while(q.size()>n-i)q.pop();
    }
    while(!q.empty())ans-=q.top(),q.pop();    
    cout<<ans<<'\n';
  }
  return 0;
}


Measured memory_bytes: 5448