akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ii d[MAXn];
int main(){
    IOS();
    int n;
    cin >> n;
    for (int i=0;i<n;++i) cin >> d[i].X >> d[i].Y;
    for (int i=0;i<n-2;++i) {
        if (d[i].X == d[i].Y && d[i+1].X == d[i+1].Y && d[i+2].X == d[i+2].Y) return cout << "Yes" << endl,0;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
int main() {
    int N;
    cin >> N;
    map<string, int> S;
    rep(i, 0, N){
        string s;
        cin >> s;
        S[s]++;
    }
    int maxS = 0;
    for (auto& s : S){
        maxS = max(maxS, s.second);
    }
    vector<string> ans;
    for (auto& s : S){
        if(maxS == s.second){
            ans.push_back(s.first);
        }
    }
    sort(ans.begin(), ans.end());
    rep(i, 0, ans.size()) {
        cout << ans[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 26868
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int maxW = sc.nextInt();
		
		int[] w = new int[n + 1];
		int[] v = new int[n + 1];
		
		int sumV = 0;
		for (int i = 1; i <= n; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
			sumV += v[i];
		}
		
		long[][] dp = new long[n + 1][sumV + 1];
		for (int i = 1; i <= sumV; i++) {
			dp[0][i] = Integer.MAX_VALUE;
		}
		
		for (int i = 1; i <= n; i++) {
			for (int j = 0; j <= sumV; j++) {
				dp[i][j] = dp[i - 1][j];
				if (j - v[i] >= 0) {
					dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
				}
			}
		}

		long ans = 0;
		for (int i = sumV; i >= 0; i--) {
			if (dp[n][i] <= maxW) {
				ans = i;
				break;
			}
		}
		
		System.out.println(ans);
		
		sc.close();
	}
}



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

int main()
{
    int n,s,a[2020],i;
    cin>>s;
    a[0]=a[1]=a[2]=0;a[3]=1;
    for(i=4;i<=s;i++)
    {
        a[i]=(a[i-1]+a[i-3])%1000000007;
    }
    cout<<a[s]<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define mp(a, b) make_pair(a, b)
typedef pair<int, int> pii;
const int maxn = 2e5 + 10;
int n;
int a[maxn], b[maxn];
typedef long long ll;
ll ans;
priority_queue<pii> Q;
inline int pre(int x) { return x == 1 ? n : x - 1;}
inline int nxt(int x) { return x == n ? 1 : x + 1;}
void no() { puts("-1"); exit(0);}
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for(int i = 1; i <= n; ++i) 
	{
		scanf("%d", &b[i]); 
		if(b[i] > a[i]) Q.push(mp(b[i], i));
		if(b[i] < a[i]) no();
	}
	while(!Q.empty())
	{
		pii x = Q.top(); Q.pop();
		int i = x.second;
		int sum = b[pre(i)] + b[nxt(i)];
		if(b[i] < sum) no();
		if((b[i] - a[i]) % sum == 0)
		{
			ans += (b[i] - a[i]) / sum;
			b[i] = a[i];
			continue;
		}
		int step = b[i] / sum;
		b[i] -= step * sum;
		ans += step;
		if(b[i] < a[i]) no();
		Q.push(mp(b[i], i));
	}
	printf("%lld\n", ans);
	return 0;
}
			
	
	

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

using namespace std;

typedef long long ll;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

double get(double x) {
  return (x * (x + 1.0)) / 2.0;
}

int main() {
  int n, k; read(n, k);
  vector <double> a(n);
  vector <double> prd(n);
  vector <double> pref(n);
  for(int i = 0; i < n; i++) {
    read(a[i]);
  }
  pref[0] = get(a[0]) / a[0];
  //prd[0] = a[0];
  for(int i = 1; i < n; i++) {
    pref[i] = pref[i - 1] + get(a[i]) / a[i];
    prd[i] = prd[i - 1] * a[i];
  }
  double mx = 0.0;
  for(int i = 0; i + k - 1 < n; i++) {
    double L1, L2;
    if(i == 0) {
      L1 = 0.0, L2 = 1.0;
    }
    L1 = pref[i - 1];
    L2 = prd[i - 1];
    double niche = prd[i + k - 1] / L1;
    double upore = pref[i + k - 1] - L1;
    mx = max(mx, upore);
  }
  printf("%0.8lf\n", mx);
}


Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
int MaxTastyCoookies(int a, int b, int c)
{
  int lnMaxTastyCookies = 0;
  if(c <= b + a)
    lnMaxTastyCookies = b + c;
  else
  	lnMaxTastyCookies = std::min(a + b, c) + b + 1;
  return lnMaxTastyCookies;
}
 
int main()
{
  int a, b, c;
  std::cin>> a>>b>>c;
  std::cout<< MaxTastyCoookies(a, b, c);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma comment(linker,"/STACK:1024000000,1024000000")
//251103FD
using namespace std;
#define PB pop_back
#define PF pop_front
#define np next_permutation
#define eb emplace_back
#define bf push_front
#define mp make_pair
#define s second
#define f first
#define mt make_tuple
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define forn(i, a) for(int i=0; i<a; i++)
#define Forn(i, a) for(int i=1; i<=a; i++)
#define read(x) ((scanf("%s", &_), (x) = _))
#define INF 1e9
#define memINF 127
#define inf 1e18
#define all(x) x.begin(), x.end()
#define MOD 1e9+7 
#define HASH 1543 

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef unsigned int uint;

using namespace std;

inline int in() 
{
    int x=0, c;
    for(; (uint)((c=getchar())-'0')>=10;) 
	{ 
		if(c=='-') 
			return -in(); 
		if(!~c)
			throw ~0; 
	}
    do 
	{ 
		x=(x<<3)+(x<<1)+(c^48); 
	} 
	while((uint)((c=getchar())^48)<10);
    return x;
}
inline int gcd(int a, int b){if(a>b) swap(a, b); return a==0?b:gcd(b%a, a);}
inline int lcm(int a, int b){return a*b/gcd(a, b);}

int N, M, par[1000010], ranks[1000010], a, b, c, dist[1000010], all, newNode[1000010], mx;
vector<pi> e[1000010];
vi adj[1000010];
bool used[1000010];

inline int find(int x)
{
	return par[x]==x?x:par[x]=find(par[x]);
}

inline void unite(int x, int y)
{
	x=find(x), y=find(y);
	if(x==y)
		return;
	if(ranks[x]<ranks[y])
		par[x]=y;
	else
	{
		par[y]=x;
		if(ranks[x]==ranks[y])
			ranks[x]++;
	}
}

int main()
{
	while(~scanf("%d %d",&N,&M))
	{
		mx=0;
		while(M--)
		{
			a=in(), b=in(), c=in();
			e[c].eb(mp(a, b));
			mx=max(mx, c);
		}
		all=N;
		Forn(i, mx)
		{
			if(!e[i].size())
				continue;
			int pa;
			foreach(it, e[i])
	        {
	            used[it->f]=used[it->s]=false,
	            newNode[it->f]=newNode[it->s]=-1,
	            ranks[it->f]=ranks[it->s]=0;
	            par[it->f]=it->f;
				par[it->s]=it->s;
	        }
			foreach(it, e[i])
				unite(it->f, it->s);
			foreach(it, e[i])
	        {
	            if(!used[it->f])
	            {
	                used[it->f]=true;
	                pa=find(it->f);
	                if(newNode[pa]<=0)
	                    newNode[pa]=++all;
	                adj[it->f].eb(newNode[pa]);
	                adj[newNode[pa]].eb(it->f);
	            }
	            if(!used[it->s])
	            {
	                used[it->s]=true;
	                pa=find(it->s);
	                if(newNode[pa]<=0)
	                    newNode[pa]=++all;
	                adj[it->s].eb(newNode[pa]);
	                adj[newNode[pa]].eb(it->s);
	            }
	        }
		}
		queue<int> q;
		q.push(1);
		memset(dist, -1, sizeof(dist));
		dist[1]=0;
		while(!q.empty())
		{
			int cur=q.front();
			q.pop();
			foreach(it, adj[cur])
				if(dist[*it]<0)
					dist[*it]=dist[cur]+1, q.push(*it);
		}
		if(dist[N]<0)
			puts("-1");
		else
			printf("%d\n", dist[N]>>1);
		forn(i, all+1)
	    {
	    	e[i].clear();
	    	adj[i].clear();
	    	used[i]=0;
	    	newNode[i]=0;
	    }
	}
	return 0;
}

Measured memory_bytes: 72960
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
int n, m, p, dep[N];
vector <pii> G[N];
int dis[N];
bool inq[N];
void bellmanford(int s)
{
	memset(dis,0x3f,sizeof(dis));
	dis[s] = 0;
	for(int k=1;k<2*n;k++) 
	{
		for(int u=1;u<=n;u++)
		{
			if(dis[u]>=INF) continue;
			for(auto it: G[u])
			{
				int v = it.first, w = it.second;
				if(dis[u]+w<dis[v]) 
				{
					if(k<n) dis[v] = max(-INF, min(INF, dis[u] + w));
					else dis[v] = -INF; 
				}
			}
		}
	}
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> m >> p;
 	for(int i=1; i<=m; i++)
 	{
 		int u, v, w;
 		cin >> u >> v >> w;
 		G[u].pb(mp(v, p-w));
 	}
 	bellmanford(1);
 	if(dis[n]==-INF) cout << -1;
 	else cout << max(0, -dis[n]);
	return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
int main(){

int A, B, C, cnt;
  cin >> A >> B >> C;
  
  vector<int> vec = {A, B, C};
  sort(vec.begin(), vec.end());

  if((vec.at(1) - vec.at(0)) % 2 == 0){
  cnt += (vec.at(1) - vec.at(0)) / 2;
  cnt += vec.at(2) - vec.at(1);
    cout << cnt << endl;
  }
  
  else{
  cnt += (vec.at(1) - vec.at(0)) / 2;
  cnt += vec.at(2) - vec.at(1) + 2;
    cout << cnt << endl;
  }
  
return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
typedef pair<P,P>P2;
#define F first
#define S second
std::chrono::system_clock::time_point start;
std::chrono::system_clock::time_point owari;

signed main(){
	int n;
	vector<P>v;
	cin>>n;
	r(i,n){
		int a,b;
		cin>>a>>b;
		v.push_back(P(a+b,a-b));
	}
	sort(v.begin(),v.end());
	int s=0,now=-1e10;
	r(i,n){
		if(v[i].S>now){
			now = v[i].F-1;
			s++;
		}
	}
	cout<<s<<endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(n));
	rep(i, n) rep(j, n) cin >> a[i][j];
	int ans = 0;
	vector<vector<bool>> use(n, vector<bool>(n, true));
	rep(k, n) {
		rep(i, n) {
			rep(j, n) {
				if (a[i][k] + a[k][j] < a[i][j]) {
					cout << -1 << endl;
					return 0;
				}
				if (a[i][k] + a[k][j] == a[i][j] && i != k && k != j) {
					use[i][j] = false;
				}
			}
		}
	}
	rep(i, n) {
		rep(j, n) {
			if (use[i][j]) ans += a[i][j];
		}
	}
	cout << ans / 2 << endl;
}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
        var a, b, c, d int
        fmt.Scan(&a, &b, &c, &d)

        switch {
        case abs(a-c) <= d:
                fmt.Println("Yes")
        case abs(a-b) <= d && abs(b-c) <= d:
                fmt.Println("Yes")
        default:
                fmt.Println("No")
        }
}

func abs(x int) int {
        if x < 0 {
                return -x
        }
        return x
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
    int kazu;
     
    public void solve(){
        Scanner sc = new Scanner(System.in);
        kazu = sc.nextInt();
        System.out.println(kazu*kazu*kazu);
    }
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17160
import sys
input=sys.stdin.readline
h,w,k=map(int,input().split())
si,sj,ti,tj=map(int,input().split())
si-=1
sj-=1
ti-=1
tj-=1
b=[input()for _ in range(h)]
ans=[[-1]*w for _ in range(h)]
ans[si][sj]=0
from collections import deque
d=deque()
d.append((si,sj))
while d:
  x,y=d.popleft()
  if x==ti and y==tj:
    exit(print(ans[x][y]))
  for dx,dy in [[1,0],[-1,0],[0,-1],[0,1]]:
    for i in range(1,k+1):
      xx=x+dx*i
      yy=y+dy*i
      if not(0<=xx<h and 0<=yy<w) or b[xx][yy]=="@":break
      if 0<=ans[xx][yy]<=ans[x][y]:break
      if ans[xx][yy]==-1:d.append((xx,yy))
      ans[xx][yy]=ans[x][y]+1
print(-1)

Measured memory_bytes: 93516
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, H;
    cin >> N >> H;
    int a[N];
    int b[N];
    rep(i, N) cin >> a[i] >> b[i];
    sort(a, a+N, greater<int>());
    sort(b, b+N, greater<int>());
    int cnt = 0;
    rep(i, N) {
        if (a[0] <= b[i]) {
            H -= b[i];
            cnt++;
        }
        if (H <= 0) {
            cout << cnt << endl;
            return 0;
        }
    }
    cout << cnt + (H + a[0] - 1)/a[0] << endl;


    return 0;
}


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

int main() {
    ll N;
    cin >> N;
    ll ans = N*(N - 1)/2;
    cout << ans << endl;
    return 0;
}

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

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int ABC[3];
    for (int i=0; i<3; i++) {
        cin>>ABC[i];
    }
    sort(ABC,ABC+3);
    int K;
    cin>>K;
    int ans=ABC[2];
    while (K--) {
        ans*=2;
    }
    ans+=ABC[0]+ABC[1];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll k,s,ans;
  cin >> k >> s;
  ans=0;
  rep(i,k+1){
    rep(j,k+1){
      if(s-i-j<=k&&0<=s-i-j)ans++;
    }
  }
  printf("%lld",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
struct data{
  int a,b,c,id;
 
  bool operator < (const data& p) const{
    if(a!=p.a)return a<p.a;
    if(b!=p.b)return b<p.b;
    if(c!=p.c)return c<p.c;
    return false;
  }
};
 
string t[5][5];
bool u[5][5];
 
double ans=0;
int target;
 
bool used[10];
double mem[10];
double calc(int x){
  if(used[x])return mem[x];
  used[x]=true;
 
  double A=1;
 
  for(int i=8;i>8-x;i--)A*=(double)i;
 
  for(int i=1;i<=x;i++)A/=(double)i;
 
  for(int i=1;i<=x;i++)
    A*=0.25;
 
  for(int i=1;i<=(8-x);i++)
    A*=0.75;
 
  return mem[x]=A;
}
 
bool eq(data a,data b){
  if(a<b)return false;
  if(b<a)return false;
  return true;
}
 
double func(vector<data> vec,int k,bool debug=false){
  if(k<0)return 0;
  int size=vec.size();
 
  if(size<=k+1)return 1.0;
 
  for(int i=0;i<size;i++)
    vec[i].a=vec[i].b=vec[i].c=0;
   
  for(int i=0;i<size;i++){
    for(int j=0;j<size;j++){
 
      int ai=vec[i].id+1;
      int aj=vec[j].id+1;
      if(ai>=aj)continue;
 
      int vi=t[ai][aj][1]-'0';
      int vj=t[ai][aj][3]-'0';
       
      vec[i].b+=(vi-vj);
      vec[j].b+=(vj-vi);
 
      vec[i].c+=vi;
      vec[j].c+=vj;
 
      if(vi>vj)vec[i].a+=3;
      else if(vi<vj)vec[j].a+=3;
      else vec[i].a++,vec[j].a++;
    }
  }
 
 
 
  bool flag=true;
  for(int i=0;i<size;i++)
    if( !eq(vec[i],vec[0]) )flag=false;
  if(flag)return ( (double)(k+1) / (double)size);
   
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
 
  if(debug){
    for(int i=0;i<size;i++){
      cout<<vec[i].a<<' '<<vec[i].b<<' '<<vec[i].c<<' '<<vec[i].id<<endl;
    }
    cout<<endl;
  }
 
  vector<data> divi[4];
  int C=0,tc;
 
  for(int i=0;i<size;i++){
    if(i>0&&!eq(vec[i],vec[i-1]))C++;
    divi[C].push_back(vec[i]);
    if(vec[i].id==target)tc=C;
  }
 
  int sum=0;
  for(int i=0;i<tc;i++)
    sum+=(int)divi[i].size();
   
  if(sum>k)return 0.0;
  return func( divi[tc], k-sum);
}
 
int cc=0;
void check(double p){
  vector<data> vec(4);
  for(int i=0;i<4;i++)vec[i].id=i;
  ans+=p*func(vec,1, (cc==2) );
}
 
void dfs(int y,int x,double p){
 
  if(y==4){
    check(p);
    return;
  }
  if(x==5){
    dfs(y+1,1,p);
    return;
  }
  if(y>=x){
    dfs(y,x+1,p);
    return;
  }
 
 
 
 
 
  if(u[y][x]){
 
    for(int i=0;i<=8;i++){
      for(int j=0;j<=8;j++){
        t[y][x][1]= ('0'+i);
        t[y][x][3]= ('0'+j);
        dfs(y,x+1,p*calc(i)*calc(j));
      }
    }
 
  }else{
    dfs(y,x+1,p);
  }
 
}
 
int main(){
  int Tc;
  cin>>Tc;
  while(Tc--){
    for(int i=0;i<5;i++){
      string s;
      cin>>s;
      for(int j=0;j<5;j++){
        t[i][j]=s.substr(j*5,4);
      }
    }    
    for(int i=1;i<5;i++)
      if(t[i][0][0]=='*')target=i-1;
    memset(u,false,sizeof(u));
 
    for(int i=1;i<5;i++)
      for(int j=1;j<5;j++)
        if(t[i][j][1]=='_')
          u[i][j]=true;
 
    ans=0;
    dfs(1,1,1);
 
    printf("%.10f\n",ans);
  }
   
  return 0;
}

Measured memory_bytes: 3080
def power(x, y, p):
	res = 1
	x = x % p
	while y > 0:
		if (y & 1) == 1 :
			res = (res * x) % p
		y = y >> 1
		x = (x * x) % p
	return res

data = [int(x) for x in input().split()]
print(power(data[0], data[1], 1000000007))


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

using namespace std;

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    ll a = 0, b, answer = 0, n;
    cin >> n;

    for (int i = 1; i <= n; ++i)
    {
        cin >> b;
        if(!b)
        {
            a = 0;
            continue;
        }
        b += a;
        answer += b / 2;
        b %= 2;
        a = b;
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
typedef long long ll;
typedef long double ld;


#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll S[1000] = { 0 };
ll N,M,Q;


int main() {
	map<string, int>A;
	cin >> Q;
	rep(i, Q) {
		ll a;
		cin >> a ;
		if (a==0) {
			string key;
			int x;
			cin >> key >> x;
			A[key] = x;
		}
		else {
			string key;
			cin >> key;
			cout << A[key] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 27688
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

#include<cstdio>

#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORq(i, m, n) for(int i = (m); i < (n); i++)
#define FORr(i, n) for (int i = (n); i >= 0; i++)


int main() {
	int N, A, B;
	cin >> N >> A >> B;

	cout << min(N * A, B) << endl;
}

Measured memory_bytes: 256
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];
ll a[N];

void GraphConst(vector<pair<int,int> >* E,int nodes,int edges)
{
	int x,y,z; 	
	for(;edges>0;edges--)
	{
		cin>>x>>y;
		E[x].push_back(make_pair(y,1));
        E[y].push_back(make_pair(x,1));
	}
}

typedef pair<int,int> iPair;
void DASP(int* pre,int* d,vector< pair<int,int> >* E,int root,int nodes,int edges)
{
	priority_queue< iPair, vector <iPair> , greater<iPair> > pq;
	//greater creates pq using min heap.
	d[root]=0;
	
	pq.push(make_pair(0,root));
	
	while(!pq.empty())
	{
		int u=pq.top().second;
		pq.pop();
		
		for(int i=0;i<E[u].size();i++)
		{
			int v=E[u][i].first;
			int weight=E[u][i].second;
			
			if(d[u]+weight<d[v])
			{
				d[v]=d[u]+weight;
				pq.push(make_pair(d[v],v));
				pre[v]=u;	
			}	
		}
	}
}

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    cin>>n>>m; 
    vector<pair<int,int> > E[n+1];
    GraphConst(E,n,m);
    int pre[n+1];
	int d[n+1];
	for(int i=1;i<=n;i++)
	d[i]=INT_MAX;
	DASP(pre,d,E,1,n,m);

    for(int i=2;i<=n;i++)
    {
        if(d[i]==INT_MAX)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    for(int i=2;i<=n;i++)
    cout<<pre[i]<<endl;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 20560
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX;
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	ll a,b,ab=0,A,B,C,t;
	cin>>A>>B>>C>>a>>b;
	if(A+B>=C*2){
		ab+=min(a,b)*2;
		t=min(a,b);
		a-=t;
		b-=t;
	}
//	cout<<a<<" "<<b<<" "<<ab<<endl;
	ll ans=a*A+b*B+ab*C;
//	cout<<ans<<endl;
	if(max(a,b)*2*C+ab*C<ans){
		ans=max(a,b)*2*C+ab*C;
	}
	cout<<ans<<endl;
	
	
	
//////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    String b = sc.next();
    String[] bb = b.split("");
    int ans = 1;
    for(int i=1;i<a;i++){
      if(bb[i-1].equals(bb[i])){
      }else{
        ans++;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 32328
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;
typedef long long ll;


bool debug = false;

struct Q
{
	ll a,b,c,d;
	Q(ll a, ll b, ll c, ll d) : a(a), b(b), c(c), d(d) {}
};

void generate(vector<vector<ll>> &a, ll n, ll m, ll id, vector<ll>& currentBuild)
{
	vector<ll> soFar = currentBuild;

	if (id == 0)
	{
		for (int i = 1; i <= m; i++)
		{
			vector<ll> soFar = currentBuild;
			soFar.push_back(i);
			generate(a,n,m,id+1,soFar);
		}

		return;
	}

	if (id == n)
		a.push_back(currentBuild);
	else
	{
		for (int i = currentBuild.back(); i <= m; i++)
		{
			vector<ll> soFar = currentBuild;
			soFar.push_back(i);
			generate(a,n,m,id+1,soFar);
		}		
	}

}


ll score(vector<ll> &A, ll m, vector<Q> &quad)
{
	ll res = 0;

	for (int i = 0; i < quad.size(); i++)
	{
		if (A[quad[i].b] - A[quad[i].a] == quad[i].c)
			res += quad[i].d;
	}


	return res;
}

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

	ll res = 0;

	ll n,m,q;

	cin >> n >> m >> q;

	vector<Q> quad;

	for (int i = 0; i < q; i++)
	{
		ll a,b,c,d;
		cin >> a >> b >> c >> d;
		a--,b--;

		quad.push_back(Q(a,b,c,d));
	}


	vector<vector<ll>> a;
	vector<ll> curr;

	generate(a,n,m,0,curr);

	for (int i = 0; i < a.size(); i++)
	{
		if (debug) cout << "for seq: " << endl;

		if (debug) for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << " ";
		if (debug) cout << endl;
		if (debug) cout << "score = ";


		ll sc = score(a[i], m, quad);

		if (debug) cout << sc << endl;
		if (sc > res) res = sc;
	}


	cout << res << endl;

	return 0;
}

Measured memory_bytes: 13968
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int x,a;
    cin>>x>>a;
    if (x<a)
        cout<<0;
    else
        cout<<10;
    return 0;
}


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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define PI (3.141592653589793238462643383279502884197169399375105820974944)
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDB pair<double,double>
#define PLD pair<long double, long double>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define VS vector<string>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1000000007;
const int N = 300555;
const int M = 1155;

void solve() {
    ll a, b, c;
    cin >> a >> b >> c;

    ll x = c-a-b;
    if (x*x > 4*a*b && c >= a+b){
        cout << "Yes";
    } else cout << "No";

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << 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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  int n = s.size(), len;
  for (len = n - 2; len >= 2; len -= 2) {
    auto L = s.substr(0, len / 2);
    auto R = s.substr(len / 2, len / 2);
    if (L == R) break;
  }
  cout << len << endl;
  return 0;
}


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

typedef long long ll;

const ll MOD = 998244353;

ll ncr[300005];
ll fact[300005];
ll inv[300005];

ll ex(ll a, ll b)
{
	if (b == 0) return 1;
	ll r = ex(a, b>>1);
	r *= r; r %= MOD;
	if (b&1) r = (r*a)%MOD;
	return r;
}

int main()
{
	ll n, a, b, k, ans = 0;
	cin >> n >> a >> b >> k;

	fact[0] = 1; inv[0] = 1;
	for (ll i = 1;i <= n;i++)
	{
		fact[i] = fact[i-1]*i; fact[i] %= MOD;
		inv[i] = ex(fact[i], MOD-2);
	}
	for (ll i = 0;i <= n;i++)
	{
		ncr[i] = fact[n]*inv[i];
		ncr[i] %= MOD;
		ncr[i] *= inv[n-i];
		ncr[i] %= MOD;
	}

	for (ll i = 0;i <= n;i++)
	{
		ll rem = k-i*a;
		if (rem >= 0 && rem%b == 0 && rem/b <= n)
		{
			ans += ncr[i]*ncr[rem/b];
			ans %= MOD;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7296
#include <iostream>

using namespace std;

int main(void){
  int x,y;
  while(true){
    cin >> x >> y;
    if((x == 0) && (y == 0)){
      break;
    }
    if(x <= y){
      cout <<x <<" "<<y <<endl;
    }else{
      cout <<y <<" "<<x <<endl;
    }

  }
  return 0;
}



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

int main() {
    int n, k;
    cin >> n >> k;
    int a[n + 1];
    for (int i = 0; cin >> a[i]; i++) {
    }
    a[n] = 0;
    long long result = 0, current = 0, prefix = 0, dp[n + 1];
    dp[n] = 0;
    for (int i = n - 1; i >= 0; i--) {
        dp[i] = max(a[i], 0) + dp[i + 1];
    }
    for (int i = 0; i < k; i++) {
        current += a[i];
    }
    for (int i = 0; i + k <= n; i++) {
        result = max({result, prefix + current + dp[i + k], prefix + dp[i + k]});
        current = current - a[i] + a[i + k];
        prefix += max(a[i], 0);
    }
    cout << result;
    return 0;
}


Measured memory_bytes: 1408
//make sure to make new file!
import java.io.*;
import java.util.*;

public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      StringTokenizer st = new StringTokenizer(f.readLine());
      
      int n = Integer.parseInt(st.nextToken());
      int m = Integer.parseInt(st.nextToken());
      
      if((n+m) % 2 == 1){
         out.println("IMPOSSIBLE");
      } else {
         out.println((n+m)/2);
      }
      
      
      
      
      out.close();
   }
   
      
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int answer = 0;
for (int i = 1;i <= n;i+=2){
    int num = 0;
    for (int j = 1;j <= i;j++){
        if (i % j== 0){
            num++;
        }
    }
    if(num == 8){
            answer++;
        }
}
cout << answer << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

int N;
vector<P> E[101010];
int ans [101010];
void dfs(int cu,int pa=-1,int col=0){
    set<int> used;
    used.insert(col);
    int c = 1;
    for(auto to:E[cu]){
        if(to.first!=pa){
            while(used.count(c)) c++;
            ans[to.second] = c;
            dfs(to.first,cu,c);
            c++;
        }
    }
}
int main(){
    cin >> N;
    rep(i,N-1){
        int a,b;cin >> a >> b;
        a--,b--;
        E[a].push_back({b,i});
        E[b].push_back({a,i});
    }
    dfs(0);
    int ma = 0;
    rep(i,N) chmax(ma,(int)E[i].size());
    cout << ma << endl;
    rep(i,N-1) cout << ans[i] << endl;
    
}

Measured memory_bytes: 13952
#include <iostream>
#include <set>
#include <iterator>
#define ll long long 
#define mod 1000000007
using namespace std;

int main() {
	ll n, m;
	cin >> n >> m;
	ll a[m+1];
	set <ll> s;
	set <ll> :: iterator it;
	ll dp [n+1];
	
	for(int i = 1; i < m+1; i++)
	{
		cin >> a[i];
		if(i > 1 && a[i-1] == a[i]-1)
		{
			cout << 0;
			return 0;
		}
		s.insert(a[i]);
	}
	
	if(a[1] == 1)
	{
		dp[1] = 0;
		dp[2] = 1;
	}
	else if(a[1] == 2)
	{
		dp[1] = 1;
		dp[2] = 1;
	}
	else
	{
		dp[1] = 1;
		dp[2] = 2;
	}
	
	for(int i = 3; i < n+1; i++)
	{
		if(s.find(i) == s.end())
		dp[i] = (dp[i-1] + dp[i-2]) % mod;
		
		else dp[i] = 0;
		
	}
	
	cout << dp[n];
	// your code goes here
	return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<string>
using namespace std;
int main()
{
  long long n,m=26,t=26,i,j;
  char c[15];
  cin >> n;
  n--;
  for(i=1;i<15;i++)
    if(n<m){
      break;
    }else{
      n-=m;
      m*=t;
    }
  j=i;
  for(;i>0;i--){
    c[i]='a'+(n%t);
    n/=t;
  }
  for(i=1;i<=j;i++)
    cout << c[i];
  cout << endl;
  return 0;
}

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

int main(){
	int t,n,s,e,sum;
	while(cin>>t,t){
		cin>>n;
		sum=0;
		while(n--){
			cin>>s>>e;
			sum+=e-s;
		}
		if(t<=sum)cout<<"OK\n";
		else cout<<t-sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e3+5;

long long a;
long long b;
long long c;
long long d;

long long get(long long A , long long B){
        return A / B;
}

int main(){
    cin >> a >> b >> c >> d;
    long long ans = (b - a + 1) - (get(b , c) + get(b , d) - get(b , c*d/__gcd(c , d)));
    ans +=  get(a-1 , c) + get(a-1 , d) - get(a-1 , c*d/__gcd(c , d));
    cout << ans << endl;
}

// a <= b

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin - 1; end <= i; i--)		// repeat reverse

#endif


const ll A = 0;
const ll B = 1;
const ll C = 2;

class DPC
{
public:
	DPC()
	{
		cin >> n;
		a.resize(n);
		b.resize(n);
		c.resize(n);
		rep(i, 0, n)
			cin >> a[i] >> b[i] >> c[i];
	}
	void Run(void)
	{
		vector<vector<ll>> sum(n, vector<ll>(3));
		sum[0][A] = a[0];
		sum[0][B] = b[0];
		sum[0][C] = c[0];
		rep(i, 1, n)
		{
			sum[i][A] = max(sum[i - 1][B], sum[i - 1][C]) + a[i];
			sum[i][B] = max(sum[i - 1][A], sum[i - 1][C]) + b[i];
			sum[i][C] = max(sum[i - 1][A], sum[i - 1][B]) + c[i];
		}

		cout << *max_element(all(sum[n-1]));
	}
private:
	ll n;
	vector<ll> a;
	vector<ll> b;
	vector<ll> c;
};

int main(void)
{
	DPC dpc;
	dpc.Run();

	return 0;
}


Measured memory_bytes: 8064
n=int(input())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
f=list(map(int,input().split()))
g=list(map(int,input().split()))
ans=[n*[0]for _ in range(n)]
for b in range(64):
  e=1<<b
  u=[a&e for a in f]
  v=[a&e for a in g]
  l=[0]*n
  m=[0]*n
  for i in range(n):
    for j in range(n):
      if(u[i]&v[j])|((s[i]^1)*u[i])|((t[j]^1)*v[j]):ans[i][j]|=e;l[i]+=1;m[j]+=1
  for i in range(n):
    if s[i]*u[i]*(l[i]==0):
      for j in range(n):
        if(t[j]^1)*(n-m[j]>1):ans[i][j]|=e;m[j]+=1;break
  for j in range(n):
    if t[j]*v[j]*(m[j]==0):
      for i in range(n):
        if(s[i]^1)*(n-l[i]>1):ans[i][j]|=e;l[i]+=1;break
h=ans[0][:]
w=[i[0]for i in ans]
for i in range(n):
  for j in range(n):
    if s[i]:w[i]|=ans[i][j]
    else:w[i]&=ans[i][j]
    if t[j]:h[j]|=ans[i][j]
    else:h[j]&=ans[i][j]
if(g!=h)|(f!=w):print(-1);exit() 
for i in ans:print(*i)

Measured memory_bytes: 99888
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
using namespace std;

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

const int MAXN = 7, MAXS = 3000 ;
int n, m, s;
unsigned int dp[MAXN * MAXN + 2][MAXS + 10], UB = 100000;

int main()
{
    while(cin >> n >> m >> s && n)
    {
        memset(dp, 0, sizeof(dp));
        dp[0][0] = 1;

        for(int i_m = 1; i_m <= m; i_m++)
            for(int i_n = n * n; i_n > 0; i_n--)
                for(int i_s = i_m; i_s <= s; i_s++)
                    dp[i_n][i_s] = (dp[i_n][i_s] + dp[i_n - 1][i_s - i_m]) % UB;

        cout << dp[n * n][s] << endl;
    }
    return 0;
}

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


int main() {

	int r, g, b;
	cin >> r >> g >> b;

	int num = r*100 + g*10 + b;

	if(num%4==0){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
///   ***   ---   |||		 In the name of ALLAH		|||   ---   ***   ///



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


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {			cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

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


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

const int mx = 2e5+123;
vi v[1000123];
int vis[1000123];
int a[mx];

int main()
{
	optimize();

	int lim = 1e6;
	for ( int i = 1; i <= lim; i++ ) {
		for ( int j = i; j <= lim; j+=i ) {
			v[j].PB ( i );
		}
	}

	int n;
	cin >> n;

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

	int ans = 0;
	for ( int i = 0; i < n; i++ ) {
		bool done = 1;
		vis[a[i]]--;
		for ( auto u : v[a[i]] ) {
			if ( vis[u] ) {
				done = 0;
				break;
			}
		}

		vis[a[i]]++;
		if ( done ) ans++;
	}


	cout << ans << endl;

	return 0;
}


















Measured memory_bytes: 122344
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	int a = 0, b = 0;
	for (auto ss : s) {
		if (ss == 'A')
			a++;
		else
			b++;
	}
	if (a == 3 || b == 3)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
}









Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,sum=0;
   cin>>A>>B;
  for(int i=A;i<=B;i++){
    if(i/10000==i%10&&i/1000%10==i%100/10)
      sum++;
    }
  cout<<sum<<endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  for(int i=0;i<b.size();i++){
    cout<<a.at(i)<<b.at(i);
  }
  if(a.size()>b.size()){cout<<a.at(a.size()-1);}
}
  

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N int
	arr := []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
	fmt.Scanf("%d", &N)
	fmt.Printf("%d\n", arr[N-1])
}


Measured memory_bytes: 512
from bisect import bisect_right
n = int(input())
l = list(map(int, input().split()))

l = sorted(l)
ans = 0
for i in range(n - 1, -1, -1):
    for j in range(i - 1, -1, -1):
        x = l[i] - l[j]
        index = bisect_right(l, x, 0, n)
        #print(l[i], l[j], i, j, index, max(0, i - index - 1))
        ans += max(0, j - index)

print(ans)

Measured memory_bytes: 3316
N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(min(K,41)):
    imos = [0]*(N+1)
    for i, ai in enumerate(A):
        imos[max(0, i-ai)] += 1
        imos[min(N, i+ai+1)] -= 1
    A = [imos[0]]
    for i in range(1, N):
        A += [imos[i]+A[i-1]]
print(' '.join(map(str, A)))

Measured memory_bytes: 189964
#include <iostream>
#include <string>
#include <stack>

using namespace std;

string w,i;
int x1,x2;
stack<int> s;

int main()
{
    while(1)
    {
        cin >> w;
        i=cin.get();
        if(w=="+")
        {
            x1=s.top();
            s.pop();
            x2=s.top();
            s.pop();
            s.push(x1+x2);
        }
        else if(w=="-")
        {
            x1=s.top();
            s.pop();
            x2=s.top();
            s.pop();
            s.push(x2-x1);
        }
        else if(w=="*")
        {
             x1=s.top();
            s.pop();
            x2=s.top();
            s.pop();
            s.push(x1*x2);
        }
        else
        {
            s.push(stoi(w));
        }
        if(i=="\n")
        {
            break;
        }
    }
    cout << s.top() << endl;
    return 0;
}


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

int main() {
  int S;
  cin >> S;
  cout << S / 3600 << ":" << (S % 3600) / 60 << ":" << S % 60 << endl;
  return 0;
}


Measured memory_bytes: 3120
// Problem: A - Plural Form
// Contest: AtCoder - AtCoder Beginner Contest 179
// URL: https://atcoder.jp/contests/abc179/tasks/abc179_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define deb(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    string s;
    cin >> s;
    
    if (s[s.size()-1] == 's') {
        s += "es";
    } else {
        s += "s";
    }
    
    cout << s << endl;
    
	return 0;
}

Measured memory_bytes: 3648
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define count(v,x) count(v.begin(),v.end(),x)
#define find(v,x) find(v.begin(),v.end(),x)


priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


void solve(){
    int n,x;
    while(1){
        cin >> n >> x;
        if(n==0 && x==0) break;
        int ans=0;
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                for(int k=j+1;k<=n;k++){
                    if(i==j || j==k || i==k)continue;
                    if(i+j+k==x)ans++;
                }
            }
        }
        cout << ans << endl;
    }
}

int main(){
    solve();
    return 0;
}





Measured memory_bytes: 3092