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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll dp[111111];

//ａをbで割る
long long mod_div(long long a,long long b){
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

void mod_add(ll &a, ll b){
	a +=b; a%= MOD;
}

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

	ll n, x;cin >> n >> x;
	vector<ll> v(n);
	REP(i, n)cin >> v[i];
	sort(ALL(v));

	dp[x] = 1;
	REV(i, 100001){
		if(dp[i] == 0)continue;
		int cou = 0;
		while(cou < n && v[cou] <= i)cou++;
		if(cou == 0)continue;
		ll rate = mod_div(1, cou);
		REP(j, cou){
			mod_add(dp[i % v[j]], dp[i] * rate);
		}
		dp[i] = 0;
	}

	ll ans = 0;
	REP(i, 111111){
		mod_add(ans, dp[i] * i % MOD);
	}
	REP(i, n)ans = (ans * (i + 1)) % MOD;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
def is_prime(n):
    if n < 2: return False
    if n == 2: return True
    if n % 2 == 0: return False

    i = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += 1

    return True


N = int(input())


l = []

n = 2
while len(l) < N:
    if is_prime(n) and n % 5 == 1:
        l.append(n)
    n += 1

print(' '.join(map(str, l)))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl

int d, t, s;
int main() {
    cin >> d >> t >> s;
    double time = (double)d / (double)s;
    if(time <= t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3100
N,K = map(int,input().split())
h = [int(i) for i in input().split()]

dp = [9999999999999999999999]*N

dp[0] = 0
for i in range(1,N):
    for k in range(1,K+1):
        if i > k-1:
            dp[i] = min(dp[i],dp[i-k]+abs(h[i]-h[i-k]))

print(dp[N-1])

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

//template
#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 ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//end

void dfs(int n,string s){
   if(n==0)cout<<s<<endl;
   else{
      auto c=*max_element(ALL(s));
      rep(i,0,c-'a'+2)dfs(n-1,s+(char)('a'+i));
   }
}

int main(){
   int n; scanf("%d",&n);
   dfs(n-1,"a");
   return 0;
}

Measured memory_bytes: 1536
#include<cstdio>
double dp[3000][3000];
int main(){
  int n;
  scanf("%d",&n);
  dp[0][0]=1;
  for(int i=1;i<=n;i++){
    double p;
    scanf("%lf",&p);
    dp[i][0]=dp[i-1][0]*(1-p);
    for(int j=1;j<i;j++)dp[i][j]=dp[i-1][j-1]*p+dp[i-1][j]*(1-p);
    dp[i][i]=dp[i-1][i-1]*p;
  }
  double ans=0;
  for(int i=n;i>n/2;i--)ans+=dp[n][i];
  printf("%.10lf",ans);
  return 0;
}

Measured memory_bytes: 68864
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n; cin >> n;
    vector<int> noten;
    int tenall = 0;
    int notenall = 0;
    rep(i,n){
        int num; cin >> num;
        if(num%10==0) tenall += num;
        else {
            noten.push_back(num);
            notenall += num;
        }
    }
    sort(ALL(noten));
    if(noten.size()==0) cout << 0 << endl;
    else{
        if(notenall%10==0){
            cout << notenall-noten[0]+tenall << endl;;
        }else cout << notenall+tenall << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#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 erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
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; }

signed main(){
  int n;
  cin >> n;
  vint A(n);
  rep(i,0,n){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  vbool list(10101010,false);
  int ans = 0;
  bool same = false;
  //rep(i,0,n) cout << A[i] << " ";
  //cout << endl;
  bool flag1 = false;
  rep(i,0,n){
    if(i > 0){
      if(A[i-1] == A[i]){
        if(!same){
          same = true;
          if(flag1){
            ans--;
            flag1 = false;
          }
        }
      }
      else{
        same = false;
      }
    }
    if(!same){
      bool flag = true;
      for(int j = 1;j <= (int)sqrt(A[i]);j++){
        if(A[i] % j == 0){
          if(list[j] == true || list[A[i]/j] == true){
            flag = false;
          }
        }
      }
      if(flag){
        //cout << A[i] << endl;
        flag1  = true;
        ans++;
      }
      else{
        flag1 = false;
      }
      list[A[i]] = true;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

int gcd(int a,int b)
{
	if(b==0)return a;
	else return gcd(b,a%b);
}

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++)
		cin >> a[i];
	vector<int> l(n),r(n);
	l[0]=a[0];
	for(int i=1;i<n;i++)
		l[i]=gcd(l[i-1],a[i]);
	r[n-1]=a[n-1];
	for(int i=n-2;i>=0;i--)
		r[i]=gcd(r[i+1],a[i]);
	int ans=max(r[1],l[n-2]);
	for(int i=1;i<n-1;i++)
	{
		if(ans<gcd(l[i-1],r[i+1]))
			ans=gcd(l[i-1],r[i+1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1408
// Etavioxy
#include<cstdio>
#include<cctype>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
#define il inline
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch; int f=1;
	while(!isdigit(ch=getchar())) f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar())) x=(x*10)+(ch^'0');
	return f*x;
}

//

int main(){
	char s[100];
	scanf("%s",s+1);
	int n=strlen(s+1);
	bool fail = 0;
	if( n&1 ) fail=1;
	for(int i=0;i<n;i+=2){
		if( s[i+1]!='h' || s[i+2]!='i' ) fail = 1;
	}
	puts(fail?"No":"Yes");
	return 0;
}


Measured memory_bytes: 128
function Main(input){
  // 文字列を格納
  input = input.trim().split(' ');
  let s = parseInt(input[0]);
  let w = parseInt(input[1]);

  let ans = 'safe';
  if (s <= w) ans = 'unsafe';

  console.log(ans);
};

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29628
#include <stdio.h>

int main(void)
{
    int N;
    char S[100000];
    int i;
    int n;
    
    scanf("%d%s", &N, S);

    n = 0;
    for (i = 0; i < N - 1; i++){
        if (S[i] != S[i + 1]){
            n++;
            i++;
        }
    }
    
    printf("%d\n", n);
    
    return (0);
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

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

  signed int N=0;
  REP(i,4) {
    char x;
    cin >> x;
    if(x=='+') N++;
    else N--;
  }
  cout << N;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int S, h, m, s;
	scanf("%d", &S);
	
	s = S % 60;
	m = S / 60 % 60;
	h = S / 60 / 60;
	
	printf("%d:%d:%d\n", h, m, s);
	
	return 0;
}

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

#define int long long

signed main() {
  int s, t, p, q, M, y;
  cin >> s >> t >> p >> q >> M >> y;

  int sum = y;
  int a = 0;
  int cnt = 1e8;  
  for ( int i = 0; i < cnt; i++ ) {
    sum ^= a;
    a = (a*p + q)%M;
  }

  cout << sum << endl;
  
  return 0;
}



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

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const double pi = acos(-1.0);

int main(){
    ll xs, ys, xg, yg;
    cin >> xs >> ys >> xg >> yg;
    if (xs > xg){
        swap(xs, xg);
        swap(ys, yg);
    }
    int n;
    cin >> n;
    vector<PL> p;
    REP(_,n){
        ll i, j;
        scanf("%lld %lld", &i, &j);
        if (i < xs || i > xg) continue;
        if ((j - ys) * (j - yg) > 0) continue;
        p.push_back(PL(i, j));
    }

    sort(ALL(p));

    if (yg < ys){
        REP(i,p.size()) p[i].second *= -1;
    }

    double ans = 100.0 * (xg - xs + abs(yg - ys));
    n = p.size();

    if (xs == xg || ys == yg){
        if (p.size() > 0) ans += 10.0*pi - 20.0;
    }else{
        VL dp(n+1,1e18);
        REP(i,n){
            *lower_bound(ALL(dp), p[i].second) = p[i].second;
        }
        ll d = lower_bound(ALL(dp), 1e18) - dp.begin();
        ans -= (20.0 - 5.0*pi) * d;
        if (d == min(xg - xs, abs(yg - ys)) + 1){
            ans += 20.0 - 5.0*pi + 10.0*pi - 20.0;
        }
    }
    printf("%.15f\n", ans);
    return 0;
}

Measured memory_bytes: 6516
#include <cstdio>
#include <iostream>
#include <limits>
#include <vector>
#include <string>
#include <cinttypes>
#include <algorithm>

using namespace std;

typedef unsigned char u8;
typedef int16_t  i16;
typedef int32_t  i32;
typedef int64_t  i64;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;

int N, Y;

int resolve(int a, int b, int c)
{
    return (10000 * a + 5000 * b + 1000 * c) == Y ? 1 : 0;
}

int main(int argc, char** argv)
{
    scanf("%d %d", &N, &Y);

    for (auto a = N; a >= 0; --a) {
        for (auto b = N - a; b >= 0; --b) {
            for (auto c = N - a - b; c >= 0; --c) {
                if (a + b + c == N && resolve(a, b, c)) {
                    printf("%d %d %d", a, b, c);
                    goto END;
                }
            }
        }
    }

    printf("-1 -1 -1");
END:
    return 0;
}


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

int n, m;
vector<pair<int, int> > target;
set<pair<int, int> > stars;

bool containsAll(int dx, int dy) {
	for (int i = 0; i < m; i++) {
		pair<int, int>& p = target[i];
		if (stars.find(make_pair(p.first + dx, p.second + dy)) == stars.end()) {
			return false;
		}
	}
	return true;
}

void solve() {
	for (int i = 0; i < m; i++) {
		for (set<pair<int, int> >::iterator it = stars.begin(); it != stars.end(); ++it) {
			int dx = it->first - target[i].first;
			int dy = it->second - target[i].second;
			if (containsAll(dx, dy)) {
				cout << dx << ' ' << dy << endl;
				return;
			}
		}
	}
}

int main() {
	while (cin >> m, m) {
		target = vector<pair<int, int> >(m);
		for (int i = 0; i < m; i++) {
			int x, y;
			cin >> x >> y;
			target[i] = make_pair(x, y);
		}
		stars.clear();
		cin >> n;
		for (int i = 0; i < n; i++) {
			int x, y;
			cin >> x >> y;
			stars.insert(make_pair(x, y));
		}
		solve();
	}
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, ans, cou[100010];
long long int a;

int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a;
		if(a<=n){
			cou[a]++;
		}else{
			ans++;
		}
	}
	for(int i=1;i<=n;i++){
		if(cou[i]>=i){
			ans += cou[i]-i;
		}else{
			ans += cou[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[]args){
Scanner sc = new Scanner(System.in);
while(true){
int n = sc.nextInt();
int r = sc.nextInt();
int[] x =new int[n];
for(int i = 0;i<n;i++){
  x[i]=n-i;
}
if(n==0 && r==0)break;
for(int i = 0;i<r;i++){
  int p = sc.nextInt();
  int c = sc.nextInt();
  int[] y=new int[p];
  for(int j = 0;j<p-1;j++){
    y[j]=x[j];
  }
  for(int j = 0;j<c;j++){
    x[j]=x[p-1+j];
  }
  for(int j=0; j<p-1;j++){
    x[c+j]=y[j];
  }
}
System.out.println(x[0]);
}
  }
}



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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  string s, t;
  cin >> s >> t;
  string ans = "";
  rep(i, 0, N) {
    ans += s[i];
    ans += t[i];
  }

  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 256
#include <iostream>

using namespace std;

char pos[15+1];

int step(int n) {
	if (n == 1) return 1;
	return 3*step(n-1) + 1;
}

int step2(char dest, int n) {
	if (dest == 'A') {
		if (n == 1) {
			if (pos[1] == 'A') return 0;
			if (pos[1] == 'B') return 1;
			return 2;
		} else {
			if (pos[n] == 'A') return step2('A', n-1);
			if (pos[n] == 'B') return step2('C', n-1) + 1 + 2*step(n-1);
			return step2('A', n-1) + 2 + 4*step(n-1);
		}
	} else /* if (dest == 'C') */ {
		if (n == 1) {
			if (pos[1] == 'C') return 0;
			if (pos[1] == 'B') return 1;
			return 2;
		} else {
			if (pos[n] == 'C') return step2('C', n-1);
			if (pos[n] == 'B') return step2('A', n-1) + 1 + 2*step(n-1);
			return step2('C', n-1) + 2 + 4*step(n-1);
		}
	}
}

int main() {
	int n, m;
	while (cin >> n >> m, n && m) {
		for (int i = 0; i < 3; i++) {
			int k; cin >> k;
			for (int j = 0; j < k; j++) {
				int l; cin >> l;
				pos[n-l+1] = 'A' + i;
			}
		}
		int a = step2('A', n);
		int b = step2('C', n);
		a = a<b ? a : b;
		cout << (a<=m ? a : -1) << endl;
	}
	return 0;
}

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

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(long long i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const ll MOD = (ll)1e9 + 7;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;

    ll x_sum = 0;
    ll prev_x;
    cin >> prev_x;
    FOR(i, 1, n - 1){
        ll x;
        cin >> x;
        x_sum = (((x - prev_x) * i % MOD) * (n - i) % MOD + x_sum) % MOD;
        prev_x = x;
    }

    ll y_sum = 0;
    ll prev_y;
    cin >> prev_y;
    FOR(i, 1, m - 1){
        ll y;
        cin >> y;
        y_sum = (((y - prev_y) * i % MOD) * (m - i) % MOD + y_sum) % MOD;
        prev_y = y;
    }

    cout << x_sum * y_sum % MOD << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26200
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
xl = []
for i in range(n):
    xx,ll = inm()
    xl.append((xx+ll,xx-ll))
xl.sort()

ddprint(xl)

cnt = 1
i = 0
while i<n-1:
    nxtj = -1
    for j in range(i+1,n):
        if xl[i][0]<=xl[j][1]:
            #ddprint("j {} found".format(j))
            cnt += 1
            nxtj = j
            break
    i = nxtj if nxtj>0 else n
    #ddprint("i {} j {} nxtj {}".format(i,j,nxtj))

print(cnt)


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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	
	int n,x,t;
	cin >> n >> x >> t;

	cout << t * ((n + x - 1) / x) << "\n";

}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

ll gcd(ll a, ll b){
  if(a < b){
    ll box = a;
    a=b;
    b = box;
  }
  if(b == 0){
    return a;
  }
  return gcd(b, a%b);
}

int N;
vector<int> a;

int main(){
  cin >> N;
  a.resize(N);
  REP(i, N){
    cin >> a[i];
  }

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

  int pre = a[0], cnt = 1, ans = 0;

  FOR(i, 1, N){
    if(pre != a[i]){
      if(pre > cnt){
        ans += cnt;
      }
      else{
        ans += cnt - pre;
      }
      pre = a[i];
      cnt = 1;
    }
    else{
      cnt++;
    }
  }
  if(pre > cnt){
    ans += cnt;
  }
  else{
    ans += cnt - pre;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll  = long long;
using ii  = pair<int, int>;
using vi  = vector<int>;
using vd  = vector<double>;
using vb  = vector<bool>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

ll memo[2][1005][1005] = { 0 };
char c;
ll x, y, bw, n, k;

ll solve() {
	ll ans = 1, now[2];

	for (int i = 0; i < k; ++i) {
		for (int j = 0; j < k; ++j) {
			for (int l = 0; l < 2; ++l) {
				now[l] = memo[l][i][j];

				if (i != k - 1 && j != k - 1) {
					now[l] += memo[l][k - 1][k - 1];
					now[l] -= memo[l][i][k - 1];
					now[l] -= memo[l][k - 1][j];
					now[l] += memo[l][i][j];
				}

				now[l] += (memo[1 - l][k - 1][j] - memo[1 - l][i][j]);
				now[l] += (memo[1 - l][i][k - 1] - memo[1 - l][i][j]);

				ans = max(ans, now[l]);
			}
		}
	}
	return ans;
}

int main() {
	ll i, j, l;
	cin >> n >> k;
	for (i = 0; i < n; ++i) {
		cin >> x >> y >> c;
		bw = (c == 'B');
		memo[(x / k + y / k + bw) % 2][x % k][y % k]++;
	}

	for (l = 0; l < 2; ++l) {
		for (i = 0; i < k; ++i) {
			for (j = 0; j < k; ++j) {
				if (j != 0) memo[l][i][j] += memo[l][i][j - 1];
				if (i != 0) memo[l][i][j] += memo[l][i - 1][j];
				if (i != 0 && j != 0)
					memo[l][i][j] -= memo[l][i - 1][j - 1];
			}
		}
	}
	cout << solve() << endl;
}


Measured memory_bytes: 16000
#include <iostream>
#include <stdlib.h>
#include <string.h>

using namespace std;

int main()
{
    unsigned n;
    int i,sum=0;
    char str[10];
    cin>>str;
    n=atoi(str);
    for(i=0;i<strlen(str);i++)
    {
        sum+=str[i]-48;
    }
    if(n%sum)
    {
        cout<<"No";
    }
    else
    {
        cout<<"Yes";
    }
    return 0;
}


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

#define ll long long int
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i))
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'



#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
/*typedef tuple<ll,ll,ll>tpl;

ll bigmod(ll n,ll pow)
{
    if(pow==0)
        return 1;
    if(pow==1)
        return n%MOD;

    ll ans=bigmod(n,pow/2);
    ans=(ans*ans)%MOD;

    if(pow%2==1)
    {
        ans=(ans*n)%MOD;
    }
    return ans%MOD;
}

ll fact[1000005];

ll nCr(ll n,ll r)
{

    ll ans=fact[n];
    ans=(ans*bigmod(fact[r],MOD-2))%MOD;
    ans=(ans*bigmod(fact[n-r],MOD-2))%MOD;
    return ans;
} */
ll mod(string num, ll a) 
{ 
    ll res = 0; 
    for (ll i = 0; i < num.length(); i++) 
         res = (res*10 + (ll)num[i] - '0') %a; 
  
    return res; 
} 
int main()
{
    _fastio
    ll cn=0,n,cn1=0,i,j;
    string s,ss;
    
    cin>>n>>s;
    for(i=0,j=n-1;i<j; )
    {
        if(s[i]=='R')
            i=i+1;
        if(s[i]=='W' && s[j]=='R')
        {
            //cout<<i<<" "<<j<<en;
            cn+=1;
            s[i]='R';
            s[j]='W';
        }
        if(s[j]=='W')
        {
            j=j-1;
        }
    }
    cout<<cn<<en;
}


Measured memory_bytes: 3736
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>

using namespace std;

int main(void) {
	string s;
	cin>>s;
	//cout<<s[0]<<"\n";
	int f=(s[0]-'0')*10+(s[1]-'0'),l=(s[2]-'0')*10+(s[3]-'0');
	//cout<<f<<"\n"<<l<<"\n";

	if(f<=12&&f>0&&l<=12&&l>0)cout<<"AMBIGUOUS\n";
	else if(f<=12&&f>0)cout<<"MMYY\n";
	else if(l<=12&&l>0)cout<<"YYMM\n";
	else cout<<"NA\n";


	return 0;
}


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

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

    if((c >= a) && (b >= c))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
/*
 * a.c
 *
 *  Created on: 2017/06/13
 *      Author: AWV060608
 */

#include	<stdio.h>
#include	<stdlib.h>
#include	<string.h>

#define		MXCLEN		100
#define		FGAD		10

int		main(void)
{
	int		i, j, k;
	int		plen, slen;
	int		rst;
	char	s[MXCLEN]={0};
	char	p[MXCLEN]={0};

	scanf("%s",s);
	scanf("%s",p);
	slen = strlen(s);
	plen = strlen(p);

	rst = 0;
	for(i=0; i<slen; i++)
	{
		k = i;
		for(j=0; j<plen; j++)
		{
			//printf("s[%d]=%c p[%d]=%c\n",k,s[k],j,p[j]);
			if( s[k] != p[j] )
			{
				rst = -1;
				break;
			}
			else
			{
				k++;
				rst = 0;
				if( k >= slen )
				{
					k=0;
				}
			}
		}
		if( rst == 0 )
			break;
	}
	if( rst == 0 )
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

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

void swap(int *v, int *u){
    int temp = *v;
    *v = *u;
    *u = temp;
}

void SelectionSort(int a[], int n, int *count){
    int minj;
    for(int i = 0; i < n; i++){
        minj = i;
        for(int j = i; j < n;j++){
            if(a[j]<a[minj])
                minj = j;
        }
        swap(&a[i], &a[minj]);
        if(i != minj)   *count = *count + 1;
    }
}

int main(void){
    int n, count=0;
    cin >> n;
    int a[n];
    for(int i = 0; i<n;i++){
        cin >> a[i];
    }
    SelectionSort(a, n, &count);
    for(int i=0;i<n;i++){
        if(i)   cout << " ";
        cout << a[i];
    }
    cout << endl;
    cout << count << endl;
    return 0;
}


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

#define fast_input() {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); }
#define For(i, l, r) for(int (i) = (l); (i) <= (r); ++(i))
#define For1(i, l, r) for(int (i) = (r); (i) >= (l); --(i))

/*
MIKUNO - 15/02/1999
*/
//	priority_queue <ll, vector<ll>, greater<ll> > q;
#define INF 1e9+5
using ll = long long;
const int N = 1e5 + 5;
const ll mod = 1e9 + 7;
void add_self(int& a, int b) {
	a += b;
	if (a > mod)
		a -= mod;
}

int main() {
	fast_input();
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	vector<bool> dp(k + 1); // true the first win
	// initially the first can't make a move if there no stones
	// so all dp is false
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i <= k; ++i) {
		for (int x : a) {
			if (i >= x && !dp[i - x]) { // if the first play lose at i 
				// then he can take stones x and win
				dp[i] = 1;
			}
		}
		//cout << dp[i] << " ";
	}
	puts(dp[k] ? "First" : "Second");
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[6] = {0,1,0,-1,1,-1};
const int vy[6] = {1,0,-1,0,1,1};




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

    string s;
    cin >> s;
    string key = "keyence";
    bool ok = false;
    rep(i,s.length()){
        rep(j,s.length()){
            rep(k,s.length()){
                auto t = s;
                if(k > s.length()-j) break;
                string a;
                t.erase(j,k);
                if(t == key) ok = true;
            }
        }
    }
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;

    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 2000001

int B[N], C[N];

void countingSort(int A[], int B[], int k, int n){
  int i, j;

  for(i = 0; i <= k; i++){
    C[i] = 0;
  }
  for(j = 1; j <= n; j++){
    C[A[j]]++;
  }   
  for(i = 1; i <= k; i++){
    C[i] = C[i] + C[i - 1];
  } 
  for(j = n; j >= 1; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i = 1; i <= n; i++){
    printf("%d", B[i]);
    if(i != n) printf(" ");
  }
  printf("\n");

}

int main(){
  int A[N];
  int i, j, n, k = 0;

  //input
  scanf("%d", &n); 
  for(i = 1; i <= n; i++){
    scanf("%d", &A[i]);
    if(k < A[i]) k = A[i];
  }

  //sort and out
  countingSort(A, B, k, n);

  return 0;
}



Measured memory_bytes: 17484
#include <iostream>
using namespace std;
int main(void){

    int a,b;
    int result;
    
    cin >> a >> b;
    
    if(a > 9 || b > 9){
        result = -1;
    }else{
        result = a*b;
    }
    
    cout << result << "\n" << endl;
}


Measured memory_bytes: 256
while True:
    n = input().split()
    a = int(n[0])
    op = str(n[1])
    b = int(n[2])
    if op == "/":
        print(a // b)
    elif op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    else:
        break


Measured memory_bytes: 5592
#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,ans=0;
    cin>>n;
    string s;
    cin>>s;
    string t=s;
    sort(s.begin(),s.end());
    for (int i=0; i<n; i++) ans+=(s[i]!=t[i]);
    cout<<ans/2+ans%2;
}

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

int main() {
  int N;
  scanf("%d", &N);

  vector<int> A(N, 0);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A.at(i));
    A.at(i) = A.at(i) - (i + 1);
  }

  sort(A.begin(), A.end());
  int b = A.at(N / 2);

  long long ans = 0;
  for (int i = 0; i < N; i++) {
    ans += (long long)abs(A.at(i) - b);
  }
  printf("%lld", ans);
  return 0;
}

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

static const int INF = (1<<29);
ll H,W;

ll area(ll h,ll w){
  if(h%3==0) return 0;
  ll x,y,z;
  ll ret = INF;
  for(int i=1;i<h;i++){
    x = i*w;
    // 縦分け
    y = (h-i)*(w/2);
    z = (h-i)*(w-(w/2));
    ll max_area = max(x,max(y,z));
    ll min_area = min(x,min(y,z));
    ret = min(ret,max_area-min_area);

    // 横分け
    y = ((h-i)/2)*w;
    z = ((h-i)-(h-i)/2)*w;
    max_area = max(x,max(y,z));
    min_area = min(x,min(y,z));
    ret = min(ret,max_area-min_area);
  }
  return ret;
}

int main(){
  cin >> H >> W;
  ll ans=INF;

  ans = min(ans,area(H,W));
  ans = min(ans,area(W,H));

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


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

using namespace std;

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

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

int n;
vector<int> p(200);
vector<int> ret;

void pswap()
{
    ret.push_back(n - 1);
    //cout << n - 1 << endl;
    swap(p[0], p[n - 1]);
}

void prot()
{
    ret.push_back(1);
    //cout << 1 << endl;
    int tmp = p[0];
    for (int i = 0; i < n - 1; i++)
    {
        p[i] = p[i + 1];
    }
    p[n - 1] = tmp;
}

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

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    for (int i = n - 2; i >= 0; i--)
    {
        // i を i+1 の左に持ってくる
        int index0 = -1, index1 = -1;
        for (int j = 0; j < n; j++)
        {
            if (p[j] == i)
            {
                index0 = j;
            }
            if (p[j] == i + 1)
            {
                index1 = j;
            }
        }
        if ((index0 + 1) % n == index1)
        {
            continue;
        }
        while (p[n - 1] != i)
        {
            prot();
        }
        // printv(p);
        pswap();
        while (p[0] != i || p[1] != i + 1)
        {
            prot();
            pswap();
        }
    }
    while (p[0] != 0)
    {
        prot();
    }
    cout << ret.size() << endl;
    for (auto v : ret)
    {
        cout << v << endl;
    }
    // printv(p);
    return 0;
}


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

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

    int ans_a = -1;
    int ans_b = -1;
    int ans_c = -1;
    for(int a = 0; a <= N; a++)
    {
        for(int b = 0; b <= N; b++)
        {
            int c = N - a - b;
            if(c >= 0 and a+b+c == N and 10000*a+5000*b+1000*c == Y)
            {
                ans_a = a;
                ans_b = b;
                ans_c = c;
            }
        }
    }

    cout << ans_a << " " << ans_b << " " << ans_c << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
//using namespace __gnu_pbds;
 
#define debug(s) cout << #s << " = " << s << endl
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define maxn 100010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;
 
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

string s, t;
int n, m;
int tree[30][maxn<<2];

void build(int node, int l, int r, int id) {
  if(l == r) { 
    if (id == (s[l - 1] - 'a')) {
      tree[id][node] = l; 
    }
    else tree[id][node] = INT_MAX;
    return;
  } int mid = (l + r) >> 1;
  build(node << 1, l, mid, id);
  build(node << 1|1, mid + 1, r, id);
  tree[id][node] = min(tree[id][node << 1], tree[id][node << 1|1]); 
}
int query(int node, int l, int r, int i, int j, int id) {
  if(r < i || l > j) return INT_MAX;
  if(i <= l && r <= j) {
    return tree[id][node]; 
  } int mid = (l + r) >> 1;
  return min(query(node << 1, l, mid, i, j, id), 
       query(node << 1|1, mid+1, r, i, j, id));
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> s >> t;
  n = s.size();
  m = t.size();
  for (int i = 0; i < 26; ++i) build(1, 1, n, i);
  int prev = 0;
  ll len = 0;
  for (int i = 0; i < m; ++i) { 
    int id = query(1, 1, n, prev + 1, n, t[i] - 'a');
    if (id == INT_MAX) {
      if (prev == 0) {
        cout << "-1" << endl;
        return 0;
      }
      else {
        id = query(1, 1, n, 1, n, t[i] - 'a');
        if (id == INT_MAX) {
          cout << "-1" << endl;
          return 0;
        }
        len += (n - prev) + id;
        prev = id;
      }
    }
    else {
      len += (id - prev);
      prev = id;
    }
  }
  cout << len << endl;
}





Measured memory_bytes: 41040
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, M;
    cin >> N >> M;
    vector<int>S(M), C(M);
    for (int i = 0; i < M; i++) {
        cin >> S.at(i) >> C.at(i);
    }
    for (int i = 0; i < 1000; i++) {
        string T = to_string(i);
        if (T.size() == N) {
        bool check = true;
        for (int j = 0; j < M; j++) {
            if (T.at(S.at(j) - 1) != C.at(j) + '0') {
                check = false;
            }
        }
        if (check) {
            cout << i << endl;
            return 0;
        }
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int N;
  int H;
  scanf("%d",&N);
  int i;
  int hight=0;
  int counter=0;
  for(i=0;i<N;i++)
  {
    scanf("%d",&H);
    if(H>=hight)
    {
      counter++;
      hight=H;
    }
  }
  printf("%d",counter);
  return 0;
}


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

bool com(int a, int b){
    return a > b;
}

int main(){
    int n, a, A[200005];
    vector <int> num;
    cin >> n;
    for(int i = 0; i < n; i++){
        //printf("%d", &a);
        scanf("%d", &a);
        num.push_back(a);
        A[i] = a;
    }
    sort(num.begin(), num.end(), com);
    for(int i = 0; i < n; i++){
        if(num[0] == A[i]){
            printf("%d\n", num[1]);
            //cout << "asd\n";
        }
        else{
            printf("%d\n", num[0]);
        }
    }
    return 0;
}


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

using namespace std;

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

#define ALL(obj)	(obj).begin(),(obj).end()

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

typedef pair<int,int>			P;

#define LINF		((ll)1 << 63 -1)
#define INF 		(1<<29)
#define MINF		-2000000007
#define MAX 		205

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

//
int main(){
	int suml=0;
	int ns = 0;
	REP(i,9){
		int a;
		cin>>a;
		if(i%4==0)ns+=a;
		suml+=a;
	}

	cout <<(suml%3==0 && ns*3==suml ? "Yes" : "No") << endl;



	return 0;
}




Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

int main() {
    int N;
    cin >> N;
    vector<ll> a(3 * N);
    rep(i, 3 * N) { cin >> a[i]; }

    ll ans = 0;
    sort(all(a), greater<ll>());
    for (int i = 0; i <= 2 * N - 1; i++) {
        if (i % 2 == 0)
            continue;
        ans += a[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 5556
#include<stdio.h>
int function(int n){
  int t=0;
  while(n>0){
    t+=n%10;
    n/=10;
  }
  return t;
}

int main(){
  int sum=0,total,i,n,a,b;
  scanf("%d %d %d",&n,&a,&b);
  for(i=1;i<=n;i++){
    total=function(i);
    if(total>=a&&total<=b){sum+=i;}
  }
  printf("%d\n",sum);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        1000005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}   

signed main()
{
    showoff;
    int n,tot = 0,c = 1,sum = 0;
    cin >> n;
    while(tot < n){
        if(c%3 && c%5)sum += c;
        tot++;
        c++;
    }
    cout << sum << "\n";
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ... 

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
#include<stdio.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

bool isOK(int a[],int index,int key){
    if(a[index] >= key){
        return true;
    }else{
        return false;
    }
}

int binary_search(int a[],int n,int key){
    int left = -1;
    int right = n;

    while(right-left>1){
        int mid = left + (right - left)/2;
        if(isOK(a,mid,key)){
            right = mid;
        }else{
            left = mid;
        }
    }
    return right;
}



int main(void){
    int k;
    string s;
    cin >> k >> s;
    int leng = s.size();

    if(leng<=k){
        cout << s << endl;
    }else{
        rep(i,k){
            cout << s[i];
        }
        cout << "..." << endl;
    }
    return 0;
}

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
long ans=0;


int count_753(long s,long N,int a, int b, int c){
    if(s>N) return ans;

    if(a+b+c==3) ans++;

    count_753((s*10+3),N,1,b,c);
    count_753((s*10+5),N,a,1,c);
    count_753((s*10+7),N,a,b,1);
}

int main(void){
    long N;
    scanf("%ld",&N);

    ans=count_753(0,N,0,0,0);

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

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long 
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
 
#define y1 what

using namespace std;
 
const int N = (int) 4e3 + 10;
const int M = (int) 700;
const ll LINF = (ll) 1e18;
const int mod = (int) 1e9 + 7;
const double EPS = (double) 1e-9;
const double PI =  3.14159265359;

ll solve(ll l, ll r) {
    if (l == r) 
        return 1;
    int k = 60;
    while ((l >> k) % 2 == (r >> k) % 2) {
        if ((l >> k) % 2) {
            l -= (1LL << k);
            r -= (1LL << k);
        }
        --k;
    }
    //[l ... 2 ^ k - 1], [2 ^ k ... r]
    //[2 ^ k + l ... 2 ^ k + 2 ^ k - 1]
    ll res = (1LL << k) - l;
    int large = k - 1;
    while (large >= 0 && (r >> large) % 2 == 0) --large;
    //if (large >= 0) {
        //2^k....2^k+2^large
        res += (1LL << (large + 1));
        //cout << large << endl;
        ll len = min((1LL << (large + 1)), (1LL << k)) - l;
        res -= max(0ll, len);
    //}
    res += (1LL << (k + 1)) - (1LL << k) - l;
    return res;
}

int main() {
    #define fn "balls"
    #ifdef witch
        freopen("input.txt", "r", stdin);   
        freopen("output.txt", "w", stdout);
    #else
//        freopen(fn".in", "r", stdin);
//        freopen(fn".out", "w", stdout);
    #endif
    ll l, r;
    cin >> l >> r;
    cout << solve(l, r);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int H, W;
  int i, j;
  char a[110][110];
  
  scanf("%d %d", &H, &W);
  for(i = 0; i < H; i++) scanf("%s", a[i]);
  
  for(i = 0; i < W + 2; i++) printf("#");
  printf("\n");
  for(i = 0; i < H; i++) {
    printf("#");
    for(j = 0; j < W; j++) printf("%c", a[i][j]);
    printf("#\n");
  }
  for(i = 0; i < W + 2; i++) printf("#");
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 128
use std::collections::*;
use std::io::*;
use std::cmp;
#[allow(dead_code)]
struct Io<'a> {
    r: BufReader<StdinLock<'a>>,
    w: BufWriter<StdoutLock<'a>>,
    buf: VecDeque<String>,
    buf_str: String,
}
#[allow(dead_code)]
impl<'a> Io<'a> {
    fn r<T: std::str::FromStr>(&mut self) -> T {
        if self.buf.len() == 0 {
            self.r.read_line(&mut self.buf_str).unwrap();
            for w in self.buf_str.split_whitespace() {
                self.buf.push_back(w.to_owned());
            }
            self.buf_str.clear();
        }
        self.buf
            .pop_front()
            .unwrap()
            .parse()
            .unwrap_or_else(|_| panic!())
    }
    fn w<T: std::fmt::Display>(&mut self, v: T) {
        writeln!(self.w, "{}", v).unwrap();
    }
    fn iter<'b, T: std::str::FromStr>(&'b mut self) -> IoIter<'a, 'b, T> {
        IoIter {
            io: self,
            p: std::marker::PhantomData,
        }
    }
}
#[allow(dead_code)]
struct IoIter<'a: 'b, 'b, T: std::str::FromStr> {
    io: &'b mut Io<'a>,
    p: std::marker::PhantomData<T>,
}
#[allow(dead_code)]
impl<'a, 'b, T: std::str::FromStr> Iterator for IoIter<'a, 'b, T> {
    type Item = T;
    fn next(&mut self) -> Option<T> {
        Some(self.io.r())
    }
}
fn main() {
    let stdin = stdin();
    let stdout = stdout();
    let r = BufReader::new(stdin.lock());
    let w = BufWriter::new(stdout.lock());
    let io = Io {
        r,
        w,
        buf: VecDeque::new(),
        buf_str: String::new(),
    };
    unsafe {
        problem(io);
    }
}


unsafe fn problem(mut io: Io) {
    let n: usize = io.r();

    let mut min: isize = io.r();
    let mut max_prof = std::isize::MIN;
    for r in io.iter::<isize>().take(n - 1) {
        max_prof = cmp::max(max_prof, r - min);
        min = cmp::min(min, r);
    }

    io.w(max_prof);
}



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

#define rep(i,a,b) for(int i=a;i<b;i++)

string solve(string s)
{
	stack<char> _stack;
	rep(i, 0, s.length())
	{
		switch (s[i])
		{
		case '(':
		case '[':
			_stack.push(s[i]);
			break;

		case ')':
			if (_stack.empty()) return "no";
			if (_stack.top() != '(') return "no";
			_stack.pop();
			break;

		case ']':
			if (_stack.empty()) return "no";
			if (_stack.top() != '[') return "no";
			_stack.pop();
			break;
		}
	}
	if (_stack.empty())
		return "yes";
	else
		return "no";
}

int main()
{
	while (1)
	{
		string s;
		getline(cin, s);
		if (s.length() == 1) return 0;

		cout << solve(s) << endl;
	}
}

Measured memory_bytes: 3060