akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
//  check the problem
//  again
// 	it always
//	has a simpler solution idiot
#define MOD 1000000000 + 7;
typedef long long ll;
typedef long double ld;

int main()
{
	ios_base::sync_with_stdio(0);
	for(int i{1}; i<=5; i++){
		int x; cin >> x;
		if(x==0){
			cout << i << "\n";
			break;
		}
	}

	}



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

int N, M;
vector< int > G[100005];
bool flag[100005] = {0};

int check(int node)
{
  for(int &e : G[node]) {
      if(!flag[e]) {
	flag[e] = true;
	return e;
      }
  }
  return node;
}

int main()
{
  int A, B;
  deque< int > ans;
  
  cin >> N >> M;

  while(M--) {
    cin >> A >> B; --A, --B;
    G[A].push_back(B); G[B].push_back(A);
  }

  int lnode = 0, rnode = 0;
  int l = -1, r = -1;
  flag[0] = true;
  ans.push_back(0);
  
  while(lnode != l || rnode != r) {
    l = lnode, r = rnode;
    lnode = check(lnode);
    rnode = check(rnode);
    if(lnode != l) ans.push_front(lnode);
    if(rnode != r) ans.push_back(rnode);
  }

  cout << ans.size() << endl;
  for(auto itr = ans.begin(); itr != ans.end(); itr++) {
    cout << *itr + 1;
    if((itr + 1) == ans.end()) cout << endl;
    else cout << " ";
  }

  return 0;
}


Measured memory_bytes: 6784
import java.util.Scanner;

/**
 * Created 2017/06/08.
 */
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    
    for(int i = 1; i <= n ; i++){
      String si = String.valueOf(i);
      if(i % 3 == 0 || si.contains("3") ) {
          System.out.print(" " + i);
      }
      if(i == n){
        System.out.println("");
      }
      
    }
  }
}

Measured memory_bytes: 30084
// Author : MohamedSameh
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<queue>
#include<list>
#include<stack>
#include<deque>
#include <sstream>
#include <string.h>

typedef long long ll ;
// random in each run --> srand(time(NULL));

#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define IN(n) scanf("%d" , &n )
#define debug(x) cout<<#x<<" = { "<<x<<" }\n"
void fo (){fflush(stdout);}
using namespace std;
ll divs (ll a , ll b , ll d )
{
  return (b/d) - ((a-1)/d );
}
int main ()
{
  ll a , b , c , d ;
  scanf ("%lld%lld%lld%lld" , &a , &b ,&c , &d );

  ll ans = (b-a+1) - (divs (a,b,c) + divs (a,b,d) - divs(a,b,(c/__gcd(c,d)) * d ));
  printf ("%lld\n" ,ans );
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <tuple>
#define rf(x) (x)=0;while(*p<48)im=*p=='-';while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);if(im)(x)=-(x);
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
#define MAXN (300005)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
ll operator * (pll a, pll b) { return a.first*b.second - b.first*a.second; }
ll ccw(pll a, pll b, pll c) { return a*b + b*c + c*a; }
struct CHT {
	vector<pll> V;
	void init() { clv(V); }
	void push(ll a, ll b) { // a must be smaller
		for(; 1 < sz(V) && ccw(befv(V), V.back(), {a, b}) <= 0; V.pop_back());
		V.pb({a, b});
	}
	ll f(ll x, int idx) { return V[idx].first*x + V[idx].second; }
	ll f(ll x) {
		if(V.empty()) return -INFLL;
		int s = 0, e = sz(V)-1; for(int m; s < e;) {
			m = (s+e)/2;
			ll l = f(x, m), r = f(x, m+1);
			if(l < r) s = m+1; else e = m;
		}
		return f(x, s);
	}
};

CHT cht;
ll L[MAXN], R[MAXN], P[MAXN];
ll S[MAXN];
ll T[MAXN];
int N, M;

void f(ll d[]) {
	for(int i = 1; i <= N; i++) S[i] = S[i-1] + T[i];
	cht.init(); cht.push(0, 0);
	for(int i = 1; i <= N; i++) {
		d[i] = max(d[i-1], cht.f(i) + ((ll)i*i + i) / 2 - S[i]);
		cht.push(-i, d[i] + S[i] + ((ll)i*i - i) / 2);
	}
}
void f(ll d[], int s, int e) {
	if(s > e) return;
	if(s == e) {
		upmax(d[s], L[s-1] + R[s+1] + 1 - T[s]);
		return;
	}
	int m = (s+e)/2; ll x = -INFLL;
	cht.init();
	for(int j = m+1; j <= e; j++)
		cht.push(-j, R[j+1] - S[j] + ((ll)j*j + 3*j) / 2);
	for(int i = s; i <= m; i++) {
		ll t = cht.f(i) + L[i-1] + S[i-1] + ((ll)i*i - 3*i + 2) / 2;
		upmax(x, t); upmax(d[i], x);
	}
	cht.init(); x = -INFLL;
	for(int i = s; i <= m; i++)
		cht.push(-i, L[i-1] + S[i-1] + ((ll)i*i - 3*i) / 2);
	for(int j = e; m < j; j--) {
		ll t = cht.f(j) + R[j+1] - S[j] + ((ll)j*j + 3*j + 2) / 2;
		upmax(x, t); upmax(d[j], x);
	}
	f(d, s, m); f(d, m+1, e);
}
int main() {
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%lld", &T[i]);
	f(L); reverse(T+1, T+N+1); f(R); reverse(R+1, R+N+1); reverse(T+1, T+N+1);
	for(int i = 1; i <= N; i++) S[i] = S[i-1] + T[i];
	fill(P+1, P+N+1, -INFLL); f(P, 1, N);
	for(scanf("%d", &M); M--;) {
		int p; ll x; scanf("%d%lld", &p, &x);
		printf("%lld\n", max({L[p-1] + R[p+1], P[p] + T[p] - x, 0ll}));
	}
	return 0;
}

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

int main() {
    int n,k;cin>>n>>k;
    int a[n];
    for (int i=0;i<n;i++)
        cin>>a[i];
    int ans=0;
    for (int i=0;i<n;i++)
        for (int j=0;i+j<=min(n,k);j++) {
            int sum=0;
            priority_queue<int> q;
            for (int l=0;l<i;l++) {
                sum+=a[l];
                q.push(-a[l]);
            }
            for (int l=n-1;l>n-1-j;l--) {
                sum+=a[l];
                q.push(-a[l]);
            }
            int l=0;
            while (q.size()&&q.top()>0&&l<k-j-i) {
                sum+=q.top();
                q.pop();
                l++;
            }
            ans=max(ans,sum);
        }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 5;
const int P = 998244353;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, k, ans, fac[MAXN], inv[MAXN];
int power(int x, int y) {
	if (y == 0) return 1;
	int tmp = power(x, y / 2);
	if (y % 2 == 0) return 1ll * tmp * tmp % P;
	else return 1ll * tmp * tmp % P * x % P;
}
int binom(int x, int y) {
	if (y > x) return 0;
	else return 1ll * fac[x] * inv[y] % P * inv[x - y] % P;
}
int func(int x, int y) {
	if (x < 0 || y < 0) return 0;
	else return binom(x + y, x);
}
int func(int x, int y, int LimOnX) {
	if (x < 0 || y < 0) return 0;
	else return (func(x, y) - func(x - LimOnX - 1, y + LimOnX + 1) + P) % P;
}
void init(int n) {
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = 1ll * fac[i - 1] * i % P;
	inv[n] = power(fac[n], P - 2);
	for (int i = n - 1; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1ll) % P;
}
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
int main() {
	read(n), read(k), init(k);
	for (int i = n; i <= k; i++) {
		int x = i, y = k - i, d = x - y;
		if (x < y) continue;
		// Final Red
		if (d > 0) update(ans, func(x - 1, y, x - n + d - 1));
		// Final Blue
		update(ans, func(x, y - 1, x - n + d + 1));
	}
	writeln(ans);
	return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rll() {
	long long n;
	scanf("%lld", &n);
	return n;
}

int main() {
	std::string s;
	std::cin >> s;
	std::sort(s.begin(), s.end());
	std::cout << (s == "abc" ? "Yes" : "No") << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,x,y,z,i,p,mod=0,sum=0;
	scanf("%d %d",&a,&b);
	a=a+1;
	for(i=0;i<b;i++){
		scanf("%d",&p);
		sum=sum+p;
	}
	x=sum/a;
	mod=sum%a;
	if(mod!=0){
		x=x+1;
	}
	printf("%d\n",x);
	return 0;
}


Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

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

  vector<bool> check(X+1);
  check[0] = true;
  vector<int> d = {100,101,102,103,104,105};
  rep(i,X) {
    rep(j,6) {
      if (d[j] <= i+1) {
        if(check[i+1- d[j]]) check[i+1] = true;
      }
    }
  }

  cout << check[X] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<unordered_set>

int main(){
    std::string S, T;
    std::cin >> S >> T;
    std::unordered_set<char> Sset, Tset;
    for(int i = 0; i < S.size(); i++){
        Sset.insert(S[i]);
        Tset.insert(T[i]);
    }

    if(Sset.size() == Tset.size()){
        // 同じ文字は相手も同じでないとだめ
        std::vector<std::vector<int>> same(26);
        for(int i = 0; i < S.size(); i++) same[S[i] - 'a'].push_back(i);
        for(int i = 0; i < 26; i++){
            if(same[i].size() == 0) continue;
            std::unordered_set<char> tmp;
            for(int j = 0; j < same[i].size(); j++){
                tmp.insert(T[same[i][j]]);
            }
            if(tmp.size() != 1){
                std::cout << "No" << std::endl;
                return 0;
            }
        }
    }else{
        std::cout << "No" << std::endl;
        return 0;
    }

    std::cout << "Yes" << std::endl;
    return 0;
}


Measured memory_bytes: 1800
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
    string S, T;
    cin >> S >> T;
 
    //答えansを仮置きする。
    //これが十分に大きくないと不正解となるので、
    //この値なら絶対に正しい答えが出る、という値を仮置きすること
    int ans = T.size();
 
    //Sの何文字目から調べるかを全探索する
    for (int start = 0; start <= S.size() - T.size(); start++)
    {
        int diff = 0;
        for (int i = 0; i < T.size(); i++)
        {
            if (T[i] != S[start + i]) {
                diff++;
            }
        }
        ans = min(ans, diff);
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 3588
//#pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(int i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(int i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(int i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    #define mp make_pair
    #define pb push_back
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 100224;
    
    void solve(){
      ll n,k;
      cin>>n>>k;
      ll val  = (n+1)/2 ;
      cout<<(val>=k ? "YES":"NO")<<endl;
    } 
    
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      solve();
      return 0;
    } 

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>
#include<cmath>
#include<limits.h>
#include<math.h>
#include<map>
#include<climits>
#include<numeric>
#include<ctype.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef unsigned long long Ull;
int w,h;
int n;
int X1[1010];
int X2[1010];
int Y1[1010];
int Y2[1010];
bool fld[6010][6010];
int res=0;
int d[4][2]= {{-1,0},{1,0},{0,-1},{0,1}};
void init() {
	vector<int> X;
	vector<int> Y;
	for(int i=0; i<n; i++) {
		for(int d=-1; d<=1; d++) {
			if(X1[i]+d>=0&&X1[i]+d<w) {
				X.push_back(X1[i]+d);
			}
			if(X2[i]+d>=0&&X2[i]+d<w) {
				X.push_back(X2[i]+d);
			}
			if(Y1[i]+d>=0&&Y1[i]+d<h) {
				Y.push_back(Y1[i]+d);
			}
			if(Y2[i]+d>=0&&Y2[i]+d<h) {
				Y.push_back(Y2[i]+d);
			}
		}
	}
	sort(X.begin(),X.end());
	X.erase(unique(X.begin(),X.end()),X.end());
	sort(Y.begin(),Y.end());
	Y.erase(unique(Y.begin(),Y.end()),Y.end());
	for(int i=0; i<n; i++) {
		X1[i]=find(X.begin(),X.end(),X1[i])-X.begin();
		X2[i]=find(X.begin(),X.end(),X2[i])-X.begin();
		Y1[i]=find(Y.begin(),Y.end(),Y1[i])-Y.begin();
		Y2[i]=find(Y.begin(),Y.end(),Y2[i])-Y.begin();
	}
	w=X.size();
	h=Y.size();
}
void solve() {
	for(int i=0; i<w; i++) {
		for(int j=0; j<h; j++) {
			if(fld[i][j]) {
				continue;
			}
			fld[i][j]=true;
			res++;
			queue<P> myQ;
			myQ.push(P(i,j));
			while(!myQ.empty()) {
				int x=myQ.front().first;
				int y=myQ.front().second;
				myQ.pop();
				for(int k=0; k<4; k++) {
					int xx=x+d[k][0];
					int yy=y+d[k][1];
					if(xx>=0&&xx<w&&yy>=0&&yy<h) {
						if(!fld[xx][yy]) {
							fld[xx][yy]=true;
							myQ.push(P(xx,yy));
						}
					}
				}
			}
		}
	}
}
int main() {
	while(scanf("%d%d",&w,&h)!=EOF) {
		if(w==0&&h==0) {
			break;
		}
		scanf("%d",&n);
		for(int i=0; i<n; i++) {
			scanf("%d%d",&X1[i],&Y1[i]);
			scanf("%d%d",&X2[i],&Y2[i]);
			X2[i]--;
			Y2[i]--;
		}
		init();
		memset(fld,false,sizeof(fld));
		for(int i=0; i<n; i++) {
			for(int x=X1[i]; x<=X2[i]; x++) {
				for(int y=Y1[i]; y<=Y2[i]; y++) {
					fld[x][y]=true;
				}
			}
		}
		res=0;
		solve();
		printf("%d\n",res);
	}

	return 0;
}



Measured memory_bytes: 38584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    int sum = 0;
    int tmp = N;
    for(int i=0; i<N; i++) {
        sum += tmp % 10;
        tmp /= 10;
        if(tmp < 0) {
            break;
        }
    }
    if(N % sum == 0) {
        cout << "Yes" <<endl;    
    }else {
        cout << "No" <<endl;
    }
}

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

using namespace std;
#define ll long long int
#define rep(i,n) for(i=0;i<(n);i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
typedef pair< ll, ll > lpair;

void solve()
{
    ll n, i, x, y, d;
    cin >> n >> d;

    ll cnt = 0;
    while(n--)
    {
        cin >> x >> y;

        if(x * x + y * y <= d * d) cnt++;
    }
    cout << cnt << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    ll t = 1;
    // cin >> t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;


int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  ll ans=0;
  //c
  if(a+b>=c){
    ans+=c;
    ans+=b;
  }else{
    ans+=b*2;
    ans+=min((c-b),a+1);
  }
cout<<ans<<endl;





}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>

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

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

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,M;
    cin>>N>>M;
    vll X(M);
    for(ll i=0;i<M;i++)cin>>X[i];
    
    if(N>=M) {
        cout<<0<<endl;
        return 0;
    }
    
    sort(X.begin(),X.end());
    
    vll sub(M-1);
    for(ll i=0;i<M-1;i++){
        sub[i]=X[i+1]-X[i];
    }
    
    sort(sub.begin(),sub.end());
    
    //for(int i=0;i<M-1;i++)printf("sub[%d]=%d\n",i,sub[i]);
    
    ll ans=0;
    for(ll i=0;i<M-1-N+1;i++){
        ans+=sub[i];
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll x; cin >> x;
    ll mod = x % 500;
    ll ans = 0;
    ans += (x / 500) * 1000;
    ans += (mod / 5) * 5;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;
int main(){
    ll n;
    cin>>n;
    vector<ll>a(5);
    REP(i,5)IN(a[i]);
    ll ans=0;
    ll m=a[0];
    ans=(ll)(a[0]+n-1)/a[0];
    for(int i=1;i<5;i++){
        if(m<=a[i]){
            ans++;
        }else{
            ans=(ll)(a[i]+n-1)/a[i]+i;
            m=a[i];
        }
    }
    OUT(ans);
    return 0;
}

Measured memory_bytes: 256
from itertools import combinations
import math
N, D = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
for perm in list(combinations(range(N), 2)):
    d = sum(map(lambda x: (x[0] - x[1]) ** 2, zip(X[perm[0]], X[perm[1]])))
    if d == int(math.sqrt(d)) ** 2:
        cnt += 1
print(cnt)


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

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

Measured memory_bytes: 3080
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define FRE freopen("in.txt", "r", stdin);
#define endl "\n"
#define PI acos(-1.0)
typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int N = 1e5 + 10, M = 510;

LL cacl(LL num) {
	LL res = 1;
	for(int i = 1; i <= 5; i++) res *= num;
	return res;
}

void solve() {
	long long x;
	scanf("%lld", &x);
	for(int a = -200; a <= 200; a++) {
		for(int b = -200; b <= 200; b++) {
			if(cacl(a) - cacl(b) == x) {
				printf("%d %d\n", a, b);
				return;
			}
		}
	}
}


int main() {
	//FRE;
	//LL t; cin >> t; while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 3812
#include<stdio.h>
int main()
{
   int size,count;
   scanf("%d",&size);
   scanf("%d",&count);

   int arr[size];
   for (int i = 0; i < size; i++)
   {
      scanf("%d",&arr[i]);
   }
   
   
   for (int i = 0; i < size; i++)
   {
      int temp;
      for (int j = i+1; j < size; j++)
      {
         if(arr[j] < arr[i])
         {
            temp = arr[j];
            arr[j] = arr[i];
            arr[i] = temp;
         }
      }
      
   }

   int sum=0;
   for (int i = 0; i < count; i++)
   {

      sum += arr[i];
   }
   printf("%d\n",sum);
   



}

Measured memory_bytes: 2168
import Foundation
// Decimal型の有効桁数は38桁
let line = readLine()!.components(separatedBy: " ").map { Int($0)! }
let X = line[0]
let N = line[1]

var z = Array.init(repeating: 1000, count: 102)

guard N != 0 else {
    print(X)
    exit(EXIT_SUCCESS)
}

for i in 0...101 {
    z[i] = abs(X - i)
}

var p = readLine()!.components(separatedBy: " ").map { Int($0)! }

for j in 0..<N {
    z[p[j]] = 1000
}

let min = z.sorted().first!

for (i, v) in z.enumerated() {
    if v == min {
        print(i)
        exit(EXIT_SUCCESS)
    }
}


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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;


int main() {
  int N,K; cin >> N >> K;
  vector <int> L(N);
  rep(i, N) cin >> L[i];
  sort(L.begin(), L.end(), greater<int>());
  int cnt;
  rep(i,K) cnt += L[i];
  dump(cnt);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <bitset>
#include <map>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>
#include <math.h>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecchar vector<char>
#define vecstr vector<string>
#define vec2str vector<vector<string>>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define pairll pair<ll,ll>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s >= 0;s--)

#define Pi 3.1415926535897932384626

int main() {
	ll n,ans=0;
	string s="No";
	bool flag = false;

	cin >> n;

	vecll a(n);

	forll(i, 0, n)
		cin >> a[i];

	forll(i, 0, n)
	{
		ans += a[i] - 1;
	}

	cout << ans;
}

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

public class Main {

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

		int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split(" ");

		int ans = 0;
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(str[i]);

			if (a % 2 != 0) {
				if ((i + 1) % 2 != 0) {
					ans++;
				}
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 32452
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <int, pii> piii;

#define F first
#define S second
#define mkp make_pair
#define pb push_back
#define ppb pop_back
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define show(x) cerr << "# " << #x << " = " << (x) << endl
//#define int ll

const int N = 2e6 + 1;
const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int szT = (1 << 17) - 1;
const double PI = acos(-1.0);
const int dx[] = {0,0,1,-1};
const int dy[] = {1,-1,0,0};

int a, b, c;

int main () {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base :: sync_with_stdio(0);
    cin >> a >> b >> c;
    if(a == b && b == c && a == c) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int,int>;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main() {
    int x = 0, c1 = 0, c2 = 0;
    cin >> x;
    c1 = x / 500 * 1000;
    c2 = (x % 500) / 5 * 5;
    cout << c1 + c2 << endl;
}

Measured memory_bytes: 256
//21171_somesh || asomesh999

#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(long long i=a;i<b;i++)
#define io ios::sync_with_stdio(false);cin.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
long int mod=1000000007;

template<typename T>
void debug(T arr) {
	for(auto it : arr) {
		cout << it << ' ';
	}
	cout << '\n';
}

int main()
{
	io
	#ifdef CODE
		clock_t startTime = clock();
		freopen("input.txt","r",stdin);
	#endif

	string s;
	cin >> s;
	int n = s.size();
	int rev = 0;
	deque<char> dq;
	for (auto it : s) {
		dq.push_back(it);
	}
	int q;
	cin >> q;
	while (q--) {
		int x;
		cin >> x;
		if (x == 1) {
			rev ^= 1;
		} else {
			int f;
			char ch;
			cin >> f >> ch;
			f -= 1;
			f ^= rev;
			if (f == 0) {
				dq.push_front(ch);
				// debug(dq);
				// cout << " " << q << "\n";
			} else {
				dq.push_back(ch);
			}
		}
	}
	if (rev == 1) {
		for (auto it = dq.rbegin(); it != dq.rend(); it++) {
			cout << *it;
		}
	} else {
		for (auto it : dq) {
			cout << it;
		}
	}

	#ifdef CODE
		cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
	#endif
	return 0;
}

Measured memory_bytes: 976
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
const long long INF = 1e13;
int main()
{
    int n;
    cin >> n;
    vector<int> L(n);
    for(int i=0;i<n;i++)
        cin >> L[i];
    sort(L.begin(),L.end());
    int ans = 0;
    for(int a = 0;a < n;a++){
        for(int b = a+1; b<n;b++){
            int ab = L[a] + L[b];
            int r = lower_bound(L.begin(),L.end(),ab) - L.begin();
            int l = b + 1;
            ans += (r-l);
        }
    }
    cout << ans << endl;
}


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

template <class T>
struct SegTree {
    int NN;            // tree size: 2 * NN - 1
    T dflt;            // default val
    vector<T> seg;     // 0-based index

    int init(int n, T val) {
        dflt = val;
        NN = 1;
        while (NN < n)
            NN <<= 1;
        seg.clear();
        seg.resize(2 * NN, dflt);
        return NN;
    }

    T func(T a, T b) {
        return max(a, b);
    }

    void gather(int u, int l, int r) {
        seg[u] = func(seg[u * 2 + 1], seg[u * 2 + 2]);
    }

    void build(int u, int l, int r) {
        if (r - l == 1)
            return;
        int m = (l + r) / 2;
        build(u * 2 + 1, l, m);
        build(u * 2 + 2, m, r);
        gather(u, l, r);
    }

    T query(int a, int b, int u, int l, int r) {
        if (l >= b || r <= a)
            return dflt;
        if (l >= a && r <= b)
            return seg[u];
        int m = (l + r) / 2;
        T res1 = query(a, b, u * 2 + 1, l, m);
        T res2 = query(a, b, u * 2 + 2, m, r);
        return func(res1, res2);
    }

    void update(int idx, T x, int u, int l, int r) {
        if (idx < l || idx >= r)
            return;
        if (idx == l && r - l == 1) {
            seg[u] += x;
            return;
        }
        int m = (l + r) / 2;
        update(idx, x, u * 2 + 1, l, m);
        update(idx, x, u * 2 + 2, m, r);
        gather(u, l, r);
    }
};

int solve() {
    int H, W, M;
    cin >> H >> W >> M;

    auto cntR = vector<int>(H, 0);
    auto cntC = vector<int>(W, 0);
    auto t = vector<vector<int>>(H, vector<int>());
    for (int i = 0; i < M; i++) {
        int r, c; 
        cin >> r >> c;
        r--; c--;
        cntR[r]++;
        cntC[c]++;
        t[r].push_back(c);
    }

    auto seg = SegTree<int>();
    int NN = seg.init(W, 0);
    copy(cntC.begin(), cntC.end(), seg.seg.begin() + NN - 1);
    seg.build(0, 0, NN);

    int ans = -1;
    for (int r = 0; r < H; r++) {
        for (auto c : t[r]) {
            seg.update(c, -1, 0, 0, NN);
        }

        int val = cntR[r] + seg.query(0, W, 0, 0, NN);
        ans = max(ans, val);
        for (auto c : t[r]) {
            seg.update(c, +1, 0, 0, NN);
        }
    }
    return ans;
}

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

    cout << solve() << endl;

    return 0;
}

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

int main() {
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;

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

		int up = 0, down = 0;
		for (int i = 0; i < n - 1; i++) {
			if (h[i] < h[i + 1]) {
				up = max(up, abs(h[i] - h[i + 1]));
			}
			else {
				down = max(down, abs(h[i] - h[i + 1]));
			}
		}

		cout << up << " " << down << endl;
	}
}

Measured memory_bytes: 1196
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

int main()
{
    int d;
    std::cin >> d;

    switch (d) {
    case 25: { std::cout << "Christmas"             << std::endl; break; }
    case 24: { std::cout << "Christmas Eve"         << std::endl; break; }
    case 23: { std::cout << "Christmas Eve Eve"     << std::endl; break; }
    case 22: { std::cout << "Christmas Eve Eve Eve" << std::endl; break; }
    default: { break; }
    }

    return 0;
}

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

int minimumChar(string S1, string S2)
{
    int n = S1.size(), m = S2.size();

    int ans = INT_MAX;

    for (int i = 0; i < m - n + 1; i++) {
        int minRemovedChar = 0;

        for (int j = 0; j < n; j++) {
            if (S1[j] != S2[i + j]) {
                minRemovedChar++;
            }
        }

        ans = min(minRemovedChar, ans);
    }

    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string s,t;
    cin>>s>>t;
    cout << minimumChar(t,s);

    return 0;
} 


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define sz(a) int((a).size()) 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ld(a) while(a--)
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define tcf(v,i) for(auto i : v)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define repd(i,start,lim) for(long long (i)=(start);i>=(lim);i--)
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator
#define MOD 		1000000007
#define INF 		0x3f3f3f3f
#define LLINF       1000111000111000111LL
#define pi 			3.14159265358979323
#define endl '\n'
#ifdef WIN32
#define getchar_unlocked getchar
#endif
#define gc getchar
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define N 1003
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long int ll;
typedef vector<long long int> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<ii,vii,greater<ii> > spq;
template<typename T> T sqr(T x){return x*x;}
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename T>void read(T &x) { register T c = gc(); x = 0; int t = 0; if (c == '-') t = 1, c = gc(); for (; (c < 48 || c>57); c = gc()); for (; c > 47 && c < 58; c = gc()) { x = (x << 1) + (x << 3) + c - 48; }if (t) x = -x; }
template<typename T> T pow(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y%2==1) ans=(ans*x)%m;y/=2;x=(x*x)%m;}return ans%m;} //using this instead of inbuilt pow due to precision issues in that
template<typename T> ll roundp(T x){ll ans=x;if(x-floor(x)<=0.001) ans=floor(x);else if(ceil(x)-x<=0.001) ans=ceil(x);return ans;}
bool prime[N];
vll primes;
ll getfac(ll n,ll i){
	if(n/i==0) return 0;
	return n/i +getfac(n/i,i);
}
int main(){
	ll n; cin>>n;
	memset(prime,1,sizeof(prime)); prime[0]=prime[1]=0;
	for(int i=2;i*i<=N;i++){
		if(!prime[i]) continue;
		for(int j=i*i;j<=N;j+=i){
			prime[j]=0;
		}
	}
	rep(i,2,N){
		if(prime[i]) 
		primes.eb(i);
	}
	ll ans=1;
	tcf(primes,i){
		ll temp=getfac(n,i); ++temp;
		if(temp==0) break;
		ans=(ans*temp)%MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i = 0;
        boolean flag = false;
        String s = sc.next();
        String p = sc.next();
        
        s = s.concat(s);
        
        for(i = 0; i < s.length() - p.length(); i++) {
        	if(p.equals(s.substring(i, p.length() + i))) {
        		flag = true;
        		break;
        	}
        }
        
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 26208
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

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

    int n;
    cin >> n;
    vector<ll> vec(n);
    rep(i,n){
      cin >> vec[i];
    }
    ll ans=vec[0];
    for(int i=1;i<n;i++){
      ans = lcm(ans,vec[i]);
    }
    cout << ans << endl;
    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#warning do not forget to change size of N and M 
#define popcnt(a) __builtin_popcount(a)
#define gcd(a,b) __gcd(a,b)
#define IO() assert(freopen("in.in", "rt", stdin)), assert(freopen("out.out", "wt", stdout))
#define FastIO() ios::sync_with_stdio(false),cin.tie(0);
#define debug(x) cout << __LINE__ << ": " << #x << " = " << (x) << endl


typedef long long ll;

const ll MOD = 1e9 + 7;
const int N = 1e7 + 9, M = 1e5 + 9, OO = 0x3f3f3f3f;
const double EPS = 1e-10,PI=acos(-1.0);

//Number Theory
inline bool dCMP(const long double &a, const long double &b) { return fabsl(a - b) < EPS;}

//Geometry 
inline double MintoDeg(double min){return min/60;}
inline double to_Radian(double deg){return deg*PI/180.0;}
inline double to_Degree(double radian){if(radian<0) radian+=2*PI; return radian*180/PI ;}
inline double fixAngle(double A){return A>1 ? 1 : (A<-1 ? -1 : A);}
int T[N];
pair<int,int> P[N]; 
int main()
{
  int n,m;
  scanf("%d",&n);
  for(int i=0;i<n;++i) scanf("%d",T+i);
  
  scanf("%d",&m);
  for(int i=0;i<m;++i){
    int x,y;
    scanf("%d%d",&x,&y);
    x--;
    P[i]={x,y};
  }
  for(int i=0;i<m;++i)
  {
    
    int idx = P[i].first;
    int val = P[i].second;
    ll sum = 0;
    for(int j=0;j<n;++j) 
      if(idx==j) sum+=val;
      else sum+=T[j];
      
    printf("%lld\n",sum);
      
  }
    
  
  return 0;
}


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

int main() {
  int N, ans = 1;
  cin  >> N;

  vector<int> d(N);
  loop(i, N) {
    cin >> d.at(i) ;
  }

  sort(d.begin(), d.end(), greater<int>());

  loop(i, N - 1) {
    d.at(i) > d.at(i + 1) ? ans += 1 : 0;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
main(){
  double h,s;
  while(1){
  scanf("%lf %lf",&h,&s);
  if(h==0.0&&s==0.0)break;
  printf("%f\n",h*sqrt(4*s*s+h*h)+h*h);
  }
  return 0;
}

Measured memory_bytes: 644
/*
  整数nが与えられるので、
  二つの素数の和がnになるような組み合わせの数を出力する
 */
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	boolean[] p = new boolean[35000];
	setP(p);
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    if(n!=0) solve(n, p);
	}
    }

    static void solve(int n, boolean[] p){
	int i;
	int cnt = 0;
	for(i=2; i<=n/2; i++){
	    if(p[i] && p[n-i]) cnt++;
	}
	System.out.println(cnt);
    }

    static void setP(boolean[] p){
	Arrays.fill(p, true);
	p[0] = false; p[1] = false;
	for(int i=2; i<p.length; i++){
	    for(int j=i+i; j<p.length; j+=i){
		p[j] = false;
	    }
	}
    }
}

Measured memory_bytes: 19524
#include<stdio.h>
int a[100005][5];
int main()
{
	int t, i, k;
	scanf("%d", &t);

	for (i = 1; i <= t; i++)
		for (k = 1; k <= 3; k++)
			scanf("%d", &a[i][k]);

	/*for (i = 1; i <= t; i++)
	{
		for (k = 1; k <= 3; k++)
			printf("%d", a[i][k]);
		putchar('\n');
	}*/
	int flag = 1, time = 0,x,y;
	x = 0; y = 0;
	for (i = 1; i <= t; i++)
	{
		x = a[i][2] - x; y = a[i][3] - y;
		time = a[i][1] - time;
		if (time < x + y)
		{
			printf("No"); flag = 0; break;
		}
		if (time - x - y== 0)
		{
			continue;
		}
		if ((time - x- y) % 2 == 1)
		{
			printf("No"); flag = 0; break;
		}
	}
	if (flag)
		printf("Yes");
	//getchar();	getchar();
	return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    a += b;
    for(auto c : s)
    {
        string ans = "No";
        if(c=='a')
        {
            if(a != 0)
            {
                ans = "Yes";
                a--;
            }
        }
        else if(c=='b')
        {
            if(a != 0 && b != 0)
            {
                ans = "Yes";
                b--;
                a--;
            }
        }
        cout << ans << endl;
    }

    return 0;
}


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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 998244353;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

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

    int a, b;
    cin >> a >> b;
    cout << (b - 1 + a - 2) / (a - 1);
    return 0;
}


Measured memory_bytes: 256
from collections import deque
s = deque(input())
q = int(input())

rev = False

for _ in range(q):
    t = [x for x in input().split()]
    if t[0] == "1":
        rev = not rev
    else:
        if t[1] == "1":
            s.append(t[2]) if rev else s.appendleft(t[2])
        else:
            s.appendleft(t[2]) if rev else s.append(t[2])

if rev:
    s.reverse()
print("".join(s))


Measured memory_bytes: 8436
package main

import "fmt"
import "strings"
import "strconv"
import "bufio"
import "os"
var sc = bufio.NewScanner(os.Stdin)

func swap(a, b int)(int, int){
    return b, a 
}

func main(){

    var n []int
    var s string
    var words []string
    
    
    if sc.Scan() {
        s = sc.Text()
    }
    //s = "1 9 4 2"    

    words = strings.Fields(s) 

    for _, v := range words{
        val, _ := strconv.Atoi(v) 
        n = append(n, val) 
    }
 
    for i:= 0; i < len(n) - 1; i++ {
        for j := i + 1 ; j < len(n) ; j++{
           if n[i] > n[j]{
                n[i], n[j] = swap(n[i], n[j])
           }
        }
    } 
    
    for i, v := range n{
	fmt.Printf("%d", v)
        if i < (len(n) - 1) {
            fmt.Printf(" ")
        }
    }
    fmt.Printf("\n")

}


Measured memory_bytes: 1104
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	string s;
	cin >> s;
	if(s ==  "Sunny"){
		cout << "Cloudy" << endl;
	}else if(s == "Rainy"){
		cout << "Sunny" << endl;
	}else{
		cout << "Rainy" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

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

    std::vector<long long> a(n), b(n);
    std::cin >> a.at(0);
    b.at(0) = a.at(0);
    for(int i = 1; i < n; ++i){
        std::cin >> a.at(i);
        b.at(i) = a.at(i) + b.at(i - 1);
    }

    std::vector<long long> c(n - 1);
    for(int i = 0; i < n - 1; ++i){
        c.at(i) = std::abs(b.at(n - 1) - 2 * b.at(i));
    }

    std::cout << *min_element(c.begin(), c.end()) << std::endl;

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

vector<vector<int>> to;

void bfs(int s, vector<vector<int>> &d) {
    d[s][0] = 0;
    queue<P> q;
    q.emplace(s, 0);
    while (!q.empty()) {
        int v = q.front().fi, t = q.front().se;
        q.pop();
        int nt = (t+1) % 3;
        for (auto nv : to[v]) {
            if (d[nv][nt] >= 0) continue;
            d[nv][nt] = d[v][t] + 1;
            q.emplace(nv, nt);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, m;
    cin >> n >> m;
    to.resize(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].pb(b);
    }
    int s, t;
    cin >> s >> t;
    s--; t--;
    vector<vector<int>> d(n, vector<int>(3, -3));
    bfs(s, d);
    cout << d[t][0] / 3 << endl;
}

Measured memory_bytes: 11264
#!/usr/bin/perl
#abc082_a.pl
#Thu Jan 11 23:07:27 2018
#

use warnings;
use strict;

my $temp = <STDIN>;
chomp $temp;

my @temps = split(" ",$temp);

my $a = $temps[0];
my $b = $temps[1];

if (($a+$b)%2>0){
	print int(($a+$b)/2)+1,"\n";
}else{
	print int(($a+$b)/2),"\n";
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main(){
    string s;
    long long k;
    cin>>s>>k;
    long long x=0;
    while(s[x]=='1'){
	x++;
	if(x==static_cast<int>(s.length())){
	    break;
	}
    }
    if(k-1<x) cout<<"1"<<endl;
    else cout<<s[x]<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n, q;
    string s;
    cin >> n >> q >> s;
    vector<int> a(n, 0);
    for (int i = 1; i < n; i++) {
        if (s[i - 1] == 'A' && s[i] == 'C') {
            a[i]++;
        }

        a[i] = a[i] + a[i - 1];
    }

    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        cout << a[r - 1] - a[l - 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 1408
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
#define INF 2000000000
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
ll N, M, K,H,W,L,R,l,r,mi1,mi2,sum,Q;
LL ans;
LL no;
bool b,bb[100001];
string s,t;

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

	for (int i = 1; i <= N; i++) {
		if (s[i - 1] == '(') {
			R++;
		}
		else {
			L++;
		}

		if (L > R) {
			r++;
			L--;
		}
	}

	ans = R - L;
	if (ans > 0) {
		l = ans;
	}
	for (int i = 0; i < r; i++) {
		cout << "(";
	}
	cout << s ;
	for (int i = 0; i < l; i++) {
		cout << ")";
	}
	cout << endl;
	return 0;
}



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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> C(H);
  for (int i=0; i<H; i++) {
    cin >> C[i];
  }
  for (int j=0; j<H; j++) {
    cout << C[j] << endl;
    cout << C[j] << endl;
  }
}

Measured memory_bytes: 3620