akhauriyash/Code-Regression huggingface dataset:
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll n,m,c,ans,temp;
void solve()
{
   cin>>n;ll x[n],y[n];
   for(int i=0;i<n;i++) cin>>x[i];
   for(int i=0;i<n;i++) cin>>y[i];
   for(int i=0;i<n;i++)
   {
       if(x[i]-y[i]>0)
            ans+=x[i]-y[i];
   }
   cout<<ans<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
import math
K = int(input())
ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            x = math.gcd(i,j)
            y = math.gcd(j,k)
            ans += math.gcd(x,y)
print(ans)

Measured memory_bytes: 69588
#include <stdio.h>

int main(void)
{
	int n;
	int i,j ,count, ans;
	
	scanf("%d", &n);
	
	count = 0;
	for(i=2; i<=n; i+=2){
		int a = i;
		
		for(j=0; a%2==0; j++)
			a /= 2;
		
		if(j > count){
			count = j;
			ans = i;
		}
	}
	
	if(n == 1)
		ans = 1;
	
	printf("%d",ans);
	
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>
#include <cstdint>
#include <set>

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

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

#define EPS (1e-7)
#define ALL(x) begin(x), end(x)


template<class T>
T gcd(T a, T b) {
	return (b == 0) ? a : gcd(b, a % b);
}


int main() {
	ll r, D, x;
	cin >> r >> D >> x;

	for (size_t i = 0; i < 10; i++) {
		const ll ans = r * x - D;
		cout << ans << endl;
		x = ans;
	}

	return 0;
}

Measured memory_bytes: 256
N = int(input())
nums = list(map(int, input().split()))

evens = [nums[i] for i in range(N) if nums[i] % 2 == 0]
odds  = [nums[i] for i in range(N) if nums[i] % 2 != 0]

if len(odds) % 2 == 0:
    print('YES')
else:
    print('NO')

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

int main() {
	int n; cin >> n;
	map<int,int> m;
	set<int> s;
	for(int i=0;i<n;i++) {
		int x; cin >> x;
		m[x]++;
	}
	long long ans = 0;
	int _x = 0, _y = 0;
	for(auto pr:m) {
		if(pr.second >= 4) ans = max(ans,1LL*pr.first*pr.first);
		if(pr.second >= 2) {
			_x = _y;
			_y = pr.first;
		}
	}
	ans = max(ans,1LL*_x*_y);
	cout << ans;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
#define MAX_N 200100
struct BIT{
	ll bit[MAX_N+1];
	void init(){
		memset(bit,0,sizeof(bit));
	}
	void add(int i,ll x){
		assert(i>=0);
		i++;
		while(i<=MAX_N){
			bit[i]+=x;
			i+=i&-i;
		}
		return;
	}
	ll sum(int i){
		if(i<0)return 0ll;
		i++;
		ll res=0;
		while(i>0){
			res+=bit[i];
			i-=i&-i;
		}
		return res;
	}
	ll sum(int l,int r){// [l,r]
		if(l==0)return sum(r);
		else return sum(r)-sum(l-1);
	}
}bit,cnt;
int N;
ll M;
int a[100100];
const int GETA = 100000;
bool check(int x){
	bit.init();
	cnt.init();
	ll s = 0ll;
	for(int i=0;i<N;i++){
		if(a[i]>x)bit.add(i,-1);
		else bit.add(i,1);
	}
	cnt.add(GETA,1);
	for(int i=0;i<N;i++){
		cnt.add(GETA+bit.sum(i),1);
		s += cnt.sum(GETA+bit.sum(i)-1);
	}
	//cout << s << endl;
	return s>=(M/2+1);
}
int main(){
	cin >> N;
	for(int i=0;i<N;i++)cin >> a[i];
	M = N;
	M = M*(M-1)/2ll+M;
	int l = 0, r = 1000000000;
	while(r-l>1){
		int mid = (l+r)/2;
		if(check(mid))r = mid;
		else l = mid;
	}
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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 int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

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

int n,x;
cin >> n >> x;
int l;
int d=0;
int ans=1;
rep(i,n){
    cin >> l;
    d += l;
    if(d<=x)ans++;
}
fin(ans);

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> point;

// up right down left
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};

const double EPS = 1e-9;
const int days[]     = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

const int INF = 500000000;

struct Edge{
    int from,to,cost,danger;
    Edge(int from,int to,int cost,int danger)
        : from(from),to(to),cost(cost),danger(danger) {}
};

int solve(vector<vector<Edge> > graph,int L){
    int n = graph.size();
    vector<vector<int> > dp(n,vector<int>(L+1,INF));
    dp[0][0] = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<graph[j].size();k++){
                const Edge& edge = graph[j][k];
                for(int l=0;l<=L;l++){
                    if(dp[j][l] >= INF) continue;
                    if(l+edge.cost <= L){
                        int new_cost = l+edge.cost;
                        int to = edge.to;
                        int here = dp[j][l];
                        dp[to][new_cost] = min(dp[to][new_cost],dp[j][l]);
                    }
                    dp[edge.to][l] = min(dp[edge.to][l],dp[j][l]+edge.danger);
                }
            }
        }
    }
    int ret = INF;
    for(int i=0;i<=L;i++){
        ret = min(ret,dp.back()[i]);
    }
    return ret;
}

int main(){
    while(true){
        int n,m,l;
        cin >> n >> m >> l;
        if(n == 0) break;
        vector<vector<Edge> > edges(n);
        for(int i=0;i<m;i++){
            int a,b,d,e;
            cin >> a >> b >> d >> e;
            a--;b--;
            edges[a].push_back(Edge(a,b,d,e));
            edges[b].push_back(Edge(b,a,d,e));
        }
        cout << solve(edges,l) << endl;
    }
    return 0;
}

Measured memory_bytes: 1560
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var mod = 1e9+7;
function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}
var fac=[],finv=[],invs=[],pow2=[];
function fset(n){
  fac.length=n+1,fac[0]=fac[1]=1;
  for(var i=2;i<=n;)fac[i]=mul(fac[i-1],i++);
  finv.length=n+1,finv[0]=finv[1]=1,finv[n]=inv(fac[n]);
  for(i=n;2<i;)finv[i-1]=mul(finv[i],i--);
  invs.length=n+1,invs[0]=invs[1]=1;
  for(i=2;i<=n;)invs[i]=mul(fac[i-1],finv[i++]);
  pow2.length=n+1,pow2[0]=1;
  for(i=1;i<=n;i++)pow2[i]=pow2[i-1]*2%mod;
}
function inv(b){for(var a=mod,u=0,v=1,t;b;v=t)t=a/b|0,a-=t*b,u-=t*v,t=a,a=b,b=t,t=u,u=v;u%=mod;return u<0?u+mod:u;}
function pow(a,n){for(var r=1;n;a=mul(a,a),n>>=1)if(n&1)r=mul(a,r);return r;}
function ncr(n,r){return mul(fac[n],finv[r],finv[n-r]);}
function npr(n,r){return mul(fac[n],finv[r]);}

console.log(main());
function main(){
  var n = o.a();
  var x = o.l();
  fset(n+1);
  var ans = 0;
  var u = fac[n-1];
  for(var i = 1; i < n; i++){
    ans += mul(x[i]-x[i-1],u);
    u = (u+mul(fac[n-1],invs[i+1]))%mod;
  }
  return ans%mod;
}

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

using namespace std;

#define ll long long
#define endl '\n'

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int bingo[3][3];
    bool mat[3][3];
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> bingo[i][j];
            mat[i][j] = false;
        }
    }
    int n;
    cin >> n;
    while (n--) {
        int m, i, j;
        cin >> m;
        for (i = 0; i < 3; ++i) {
            for (j = 0; j < 3; ++j) {
                if (bingo[i][j] == m) {
                    mat[i][j] = true;
                    if ((mat[i][0] && mat[i][1] && mat[i][2]) || (mat[0][j] && mat[1][j] && mat[2][j]) ||
                        (mat[0][0] && mat[1][1] && mat[2][2]) || (mat[0][2] && mat[1][1] && mat[2][0])) {
                        cout << "Yes" << endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll T[100005];

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

int main()
{
    int N;
    cin >> N;
    REP(i, N)
    {
        cin >> T[i];
    }

    ll a = T[0];
    FOR(i, N, 1)
    {
        ll k = gcd(a, T[i]);
        a = a / k * T[i];
    }
    cout << a << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"	
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var x, y int
	if sc.Scan() {
		s := strings.Split(sc.Text(), " ")
		x, _ = strconv.Atoi(s[0])
		y, _ = strconv.Atoi(s[1])
	}

	fmt.Println(x + (y/2))
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,N,ans = 0;
  cin>>A>>B>>C>>N;
  for(int i = 0;i<=A;i++){
    for(int k = 0;k<=B;k++){
      for(int p = 0;p<=C;p++){
        if(500*i+100*k+50*p == N){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin>>n;
  vector<long long int> s(n);
  for(long long int i=0; i<n; i++){
    cin>>s.at(i);
  }
  int q;
  cin>>q;
  vector<long long int> t(q);
  int ans=0;
  for(long long int i=0; i<q; i++){
    cin>>t.at(i);
    for(int j=0; j<n; j++){
      if(t.at(i)==s.at(j)){
        ans++;
        break;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
     
     
#define fs first
#define sc second
     
using namespace std;
     
     
typedef long long ll;
typedef pair<ll, ll> P;
     
     
int main(){
  string str;
  cin >> str;

#ifdef DEBUG
  cout << "str=" << str << endl;
#endif

  vector<string> vs;

  size_t i = 0;
  string tmp = "";  
  while(i < str.length()){
    //cout << str[i] << endl;
    if(str[i] == 'A'){
      tmp += 'x';
      ++i;
    }
    else if(str[i] == 'B' && i + 1 < str.length() && str[i+1] == 'C'){
      tmp += 'y';
      i += 2;
    } else {
      if(tmp.length() > 0) vs.emplace_back(tmp);      
      tmp = "";
      i += 1;
    }
  }

  if(tmp.length() > 0) vs.emplace_back(tmp);

  ll cnt = 0;
  for(size_t i = 0;  i < vs.size(); ++i){
    ll xcnt = 0;
    for(size_t j = 0; j < vs[i].length(); ++j){
      if(vs[i][j] == 'x') xcnt++;
      else if(vs[i][j] == 'y') cnt += xcnt;
    }
  }

  cout << cnt << endl;
  
  return 0;
}


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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  bool res = false;
  for(int i=1;i<=B;i++){
    if((A*i)%B == C){
      res = true;
      break;
    }
  }
  if(res){
    cout << "YES";
  }else{
    cout << "NO";
  }
  cout << endl;
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	for(int i=k-n+1;i<=k+n-2;i++){
		if(i>=-1000000&&i<=1000000)
		cout<<i<<" ";
	}
	if(k+n-1>=-1000000&&k+n-1<=1000000)
	cout<<k+n-1;
	cout<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define sp(x) setprecision(x)
#define ceil(a,b)   (a+(b-1))/b
#define PI 3.141592653589793238462643383279502884

//#define sumup(x)	(x*(x+1))/2
using namespace std;

int sumup(int n)
{
	return (n*(n+1))/2;
}

int32_t main()
{
	string str;
	cin>>str;
	for(int i=0;i<str.size();i++)
		cout<<"x";
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,m,i,x,k=1010;
	cin >> n >> x;
	for(i=0;i<n;i++)
	{
	    cin >> m;
	    if(k>m)
            k=m;
	    x-=m;

	}
	cout << n+x/k << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
list_XYH1, list_XYH = [ list(map(int,input().split(" "))) for _ in range(n)], []
for x, y, h in list_XYH1:
    if h != 0:
        list_XYH.append([x, y, h])

for i in range(0, 101):
    for j in range(0, 101):
        cnt = 0
        x, y, h = list_XYH[0]
        H = h + abs(i - x) + abs(j - y)
        for x, y, h in list_XYH:
            if h + abs(i - x) + abs(j - y) == H:
                cnt += 1

        if cnt == len(list_XYH) and cnt != 0 and cnt != 1:
            print(i, j, H)
            exit()

list_XYH2 = []
m = pow(10, 10)
for x, y, h in list_XYH1:
    m = min(m, h)
    list_XYH2.append([x, y, h])

for X in range(0, 101):
    for Y in range(0, 101):
        for H in range(m, m + 201):
            cnt = 0
            for x, y, h in list_XYH2:
                if max(H - abs(x - X) - abs(y - Y), 0) == h:
                    cnt += 1

            if cnt == n:
                print(X, Y, H)
                exit()

Measured memory_bytes: 68960
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(S: str, T: str):
    if S == T[:-1]:
        yes()
    else:
        no()
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9124
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
template<typename T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v)cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clz(x) - 1;	}


//Variables Declaration
int N ;
vector<vector<ll>> vect;
ll dp[3][MAXN];

ll solve(int n, int t) {
	if (n >= N) return 0;
	if (dp[t][n] >= 0) return dp[t][n];
	ll sol = 0;

	for (int k = 0 ; k < 3 ; ++k) {
		if (k != t) {
			sol = max ( sol, solve(n + 1 , k ) + vect[t][n] );
		}
	}
	return dp[t][n] = sol ;

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


	memset(dp, -1, sizeof(dp));

	cin >> N;
	vect.resize(3, vector< ll>(N));
	for (int i = 0 ; i < N ; ++i) {
		for (int j = 0 ; j < 3 ; ++j) {
			cin >> vect[j][i];
		}
	}

	ll ans = 0;

	dp[0][0] = vect[0][0] ;
	dp[1][0] = vect[1][0] ;
	dp[2][0] = vect[2][0] ;
	for (int i = 1 ; i < N ; ++i) {
		dp[0][i] = max(dp[0][i], max(dp[1][i - 1] , dp[2][i - 1] )) + vect[0][i];
		dp[1][i] = max(dp[1][i], max(dp[0][i - 1] , dp[2][i - 1] )) + vect[1][i] ;
		dp[2][i] = max(dp[2][i], max(dp[0][i - 1] , dp[1][i - 1] )) + vect[2][i] ;
	
	}
	ans = max(dp[0][N-1], dp[1][N-1]);
	ans = max(ans		, dp[2][N-1]);
	/*
	ans = max( solve(start, 0) , solve(start, 1));
	ans = max( ans 			  , solve(start, 2));*/
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int n, dp[1000];
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    dp[0] = dp[1] = 1;
    erep(i, 2, n) { dp[i] = dp[i - 1] + dp[i - 2]; }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <climits>
#include <cstdio>
#include <stdio.h> 
#include <map>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;


int main() {
	char ch;
	cin>>ch;
	
	map<char, char> mp;
	mp['A'] = 'T';
	mp['C'] = 'G';
	mp['G'] = 'C';
	mp['T'] = 'A';
	
	cout << mp[ch];
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()

{
	int A, B;
	scanf("%d %d", &A, &B);
	
	if (A == 1 && B != 1) printf("Alice");
	else if (A != 1 && B == 1) printf("Bob");
	else if (A == B) printf("Draw");
	else if(A > B ) printf("Alice");
	else printf("Bob");	

		return 0;
		}

Measured memory_bytes: 128
n, k = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)

dp = [0]

1.upto(n - 1) do |i|
  min = 10000000001
  [0, i - k].max.upto(i - 1) do |j|
    d = (h[i] - h[j]).abs + dp[j]
    min = d if min > d
  end
  dp[i] = min
end

puts dp[n - 1]


Measured memory_bytes: 11528
s=input()
if s=="SUN":
    print(7)
elif s=="SAT":
    print(1)
elif s=="FRI":
    print(2)
elif s=="THU":
    print(3)
elif s=="WED":
    print(4)
elif s=="TUE":
    print(5)
elif s=="MON":
    print(6)

Measured memory_bytes: 8944
#include <iostream>

using namespace std;

typedef long long ll;

void failure () {
  cout << -1 << endl;
  exit(0);
}

const int MAX_N = 1e5 + 5;

ll arr [MAX_N];
ll lb [MAX_N], ub [MAX_N];

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

  for (int i = 0; i < k; i++) {
    cin >> arr[i];
  }

  if (arr[k - 1] != 2) failure();
  
  lb[k] = 2;
  ub[k] = 2;

  for (int i = k - 1; i >= 0; i--) {
    lb[i] = lb[i + 1];
    ub[i] = ub[i + 1] + arr[i] - 1;

    if (i != 0) {
      ll to_add = (-lb[i]) % arr[i - 1];
      if (to_add < 0) to_add += arr[i - 1];
      lb[i] += to_add;

      ll to_rem = ub[i] % arr[i - 1];
      ub[i] -= to_rem;

      if (lb[i] > ub[i]) failure();
    }
  }

  cout << lb[0] << " " << ub[0] << endl;
}


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

using namespace std;

int main(){
    int n,k,q,a;
    cin >>n >>k >>q;
    vector<signed int> one(n,k-q);

    for(int i=0; i<q;i++){
        signed int num=0;
        cin >>a;
        num=one[a-1];

        one[a-1] =1+num;
    }
    int ans=0;

    for(int i=0;i<n;i++){
        if(one[i]>0){
            cout <<"Yes" <<endl;
        }else if(one[i]<=0){
          cout << "No" <<endl;
        }
    }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<int mod> class ModInt
{   
 private:
    int val;
 public:
    int value(){ return val; }
    ModInt(int x=0){ val=x%mod; }
    ModInt pow(int n){
        ModInt res(1),x(val);
        while(n>0){ if(n&1) res*=x; x*=x; n>>=1; }
        return res;
    }
    ModInt inv(){ return pow(mod-2); }
    ModInt& operator+=(ModInt rhs){ val+=rhs.val; if(val>=mod) val-=mod; return *this; }
    ModInt& operator-=(ModInt rhs){ val+=mod-rhs.val; if(val>=mod) val-=mod; return *this; }
    ModInt& operator*=(ModInt rhs){ val=val*rhs.val%mod; return *this; }
    ModInt& operator/=(ModInt rhs){ *this*=rhs.inv(); return *this; }
    ModInt operator+(ModInt rhs){ return ModInt(val)+=rhs; }
    ModInt operator-(ModInt rhs){ return ModInt(val)-=rhs; }
    ModInt operator*(ModInt rhs){ return ModInt(val)*=rhs; }
    ModInt operator/(ModInt rhs){ return ModInt(val)/=rhs; }
};

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

    int N; cin>>N;
    vector<int> d(N);
    for(int i=0;i<N;i++) cin>>d[i];

    if(d[0]!=0){
      cout<<0<<endl;
      return 0;
    }

    int mx=*max_element(d.begin(),d.end());
    vector<int> cnt(mx+1);
    for(int i=0;i<N;i++) cnt[d[i]]++;

    if(cnt[0]!=1){
      cout<<0<<endl;
      return 0;
    }    

  using mint=ModInt<998244353>;
  mint ans=1,pre=1;
  for(int i=1;i<=mx;i++){
    if(cnt[i]==0){
      cout<<0<<endl;
      return 0;
    }
    ans*=pre.pow(cnt[i]);
    pre=cnt[i];
  }
  cout<<ans.value()<<endl;
  return 0;
}

Measured memory_bytes: 1792
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=q
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)

def hgrn(n):
	if n>=0:
		return n
	else:
		return n+k

k,n = readInts()
a = readInts()

ans = k

dis = []

for i in range(n):
	if i==n-1:
		dis.append(k-a[i]+a[0])
	else:
		dis.append(a[i+1]-a[i])

print(k-max(dis))

Measured memory_bytes: 27208
# ITP_10_B
import math

a, b, C = map(int, input().split())
rad = math.radians(C)
L = math.sqrt(a**2 + b**2 -2 * a * b * math.cos(rad)) + a + b
h = b*math.sin(rad)
S = a*h/2
print(S)
print(L)
print(h)



Measured memory_bytes: 5708
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int H,W;
        for (;;) { 
        H = sc.nextInt();
        W = sc.nextInt();
          if(H==0)
       break;
          
        	   
          
             
            for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){
                	if((i+j)%2==0){
                		System.out.print('#');
                }else{
                	System.out.print('.');
                }
                }
                System.out.println();
            }
            System.out.println();
        }
           sc.close();
        }
    

}



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

int kai(string s){
	int f=1;
	for(int i=0;i<s.size()/2;i++){
		if(s[i]!=s[s.size()-1-i])f=0;
	}
	return f;
}

int main(){
	int a,b;
	cin>>a>>b;
	int ans=0;
	for(int i=a;i<=b;i++){
		ans+=kai(to_string(i));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));    
    private static StringTokenizer st;

    public static void main ( String [] args ) throws IOException
    {
	new Main().cal();
    }

 
    private void cal() throws IOException 
    {
	int N = Integer.parseInt(br.readLine());
	int [] nums = new int[N];

	st = new StringTokenizer(br.readLine());
	for(int i = 0; i < N; i++)
	    nums[i] = Integer.parseInt(st.nextToken());

	int count = 0;
	for(int i = 0; i < nums.length; i++)
	    for( int j = nums.length-1; j > i; j--) {
		if ( nums[j] < nums[j-1] ) {
		    count++;
		    swap(nums, j, j-1);
		}

	    }
	
	for(int i = 0; i < nums.length; i++){
	    if ( i > 0 ) System.out.print(" ");
	    System.out.print(nums[i]);
	}
	System.out.println("");
	    
	System.out.println(count);
    }

    private void swap(int [] nums, final int i, final int j) {
	int temp = nums[j];
	nums[j] = nums[i];
	nums[i] = temp;
    }

}

Measured memory_bytes: 9456
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,cnt=0;
cin>>N;
map<int,int>m;
for(int i=0;i<N;i++){
    int num;
    cin>>num;
    m[num]++;
}
for(pair<int,int>p:m){
    if(p.second<p.first)cnt+=p.second;
    else if(p.second>p.first)cnt+=p.second-p.first;
}
cout<<cnt;
return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int mod=1e9+7;
const int INF=1001001001;

int dp[105][10];
int main() {
  int H,W,K;
  cin>>H>>W>>K;
  
  dp[0][0]=1;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(dp[i][j]==0){continue;}
      for(int s=0;s<(1<<W-1);s++){  
        vector<int>t(W-1);
        for(int k=0;k<W-1;k++){
          if((s>>k)&1){t[k]=1;}
        }
        bool ok=true;
        for(int k=0;k<W-2;k++){
          if(t[k]==1&&t[k+1]==1){ok=false;}
        }
        if(ok){
          if(j<W-1&&t[j]){(dp[i+1][j+1]+=dp[i][j])%=mod;}
          else if(j>0&&t[j-1]){(dp[i+1][j-1]+=dp[i][j])%=mod;}
          else{(dp[i+1][j]+=dp[i][j])%=mod;}
        }
      }
    }
  }
  
  cout<<dp[H][K-1]<<endl;
  return 0;  
}

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

using namespace std;

using ll = long long;

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

queue<vector<ll>> lunlun(int K)
{
    queue<vector<ll>> que;
    if(K>=1)
    que.push({1});
    if(K>=2)
    que.push({2});
    if(K>=3)
    que.push({3});
    if(K>=4)
    que.push({4});
    if(K>=5)
    que.push({5});
    if(K>=6)
    que.push({6});
    if(K>=7)
    que.push({7});
    if(K>=8)
    que.push({8});
    if(K>=9)
    que.push({9});
    for(int i=9;i<K;)
    {
        if(que.front()[que.front().size()-1]>=1)
        {
            vector<ll> add = que.front();
            add.push_back(add[add.size()-1]-1);
            que.push(add);
            i++;
            if(i==K) break;
        }
        if(que.front()[que.front().size()-1]>=0)
        {
            vector<ll> add = que.front();
            add.push_back(add[add.size()-1]);
            que.push(add);
            i++;
            if(i==K) break;
        }
        if(que.front()[que.front().size()-1]>=-1 && que.front()[que.front().size()-1]<9)
        {
            vector<ll> add = que.front();
            add.push_back(add[add.size()-1]+1);
            que.push(add);
            i++;
            if(i==K) break;
        }
        que.pop();
    }
    return que;
}

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

    queue<vector<ll>> que = lunlun(K);

    ll quesize = que.size();

    for(int i=0;i<quesize-1;i++)
    {
        que.pop();
    }

    for(auto x : que.front())
    {
        cout << x;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 7808
import sys

a = [[0]*3 for _ in range(3)]
a[0] = list(map(int, input().split()))
a[1] = list(map(int, input().split()))
a[2] = list(map(int, input().split()))

n = int(input())
f = [[False]*3 for _ in range(3)]
for _ in range(n):
  b = int(input())
  for i in range(3):
    for j in range(3):
      if a[i][j] == b:
        f[i][j] = True

for i in range(3):
  if (f[i][0] and f[i][1] and f[i][2]):
    print("Yes")
    sys.exit()
  if (f[0][i] and f[1][i] and f[2][i]):
    print("Yes")
    sys.exit()
if ((f[0][0] and f[1][1] and f[2][2]) or (f[0][2] and f[1][1] and f[2][0])):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N=1E5+7;
typedef long long ll;
const ll xx=2;
priority_queue<ll>que;
int main(){
	int n,m;
	cin>>n>>m;
	ll x;
	for(int i=1;i<=n;i++){
		scanf("%lld",&x);
		que.push(x);
	}
	while(m--){
		ll y=que.top();
		que.pop();
		y=y/xx;
		que.push(y);
	}
	ll ans=0;
	while(que.size()){
		ans+=que.top();
		que.pop();
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1400
import java.io.IOException;

public class Main {

	public static void main(String[] args) throws IOException {
		while (true) {
			int N = nextInt();
			if (N == 0) {
				break;
			}
			int M = nextInt();
			int[] h = new int[N];
			int totalH = 0;// 高さの和を調べておく
			for (int i = 0; i < h.length; i++) {
				h[i] = nextInt();
				totalH += h[i];
			}

			int[] w = new int[M];
			int totalW = 0;// 幅の和も調べておく
			for (int i = 0; i < w.length; i++) {
				w[i] = nextInt();
				totalW += w[i];
			}

			int[] heightType = new int[totalH + 1];// 作りうる高さの種類
			int[] widthType = new int[totalW + 1];// 作りうる幅の種類

			for (int i = 0; i < h.length; i++) {
				int height = h[i];
				heightType[height]++;
				for (int j = i + 1; j < h.length; j++) {
					height += h[j];
					heightType[height]++;
				}
			}

			for (int i = 0; i < w.length; i++) {
				int width = w[i];
				widthType[width]++;
				for (int j = i + 1; j < w.length; j++) {
					width += w[j];
					widthType[width]++;
				}
			}

			int ans = 0;// 解答
			for (int i = 1; i <= Math.min(totalH, totalW); i++) {
				ans += heightType[i] * widthType[i];
			}

			System.out.println(ans);

		}

	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

	static char nextChar() {
		try {
			int b = System.in.read();
			while (b != -1 && (b == ' ' || b == '\r' || b == '\n'))
				;
			if (b == -1)
				return 0;
			return (char) b;
		} catch (IOException e) {
		}
		return 0;
	}

}

Measured memory_bytes: 53140
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#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 ALL(a) (a).begin(), (a).end()

ll X, Y, Z, K, A[1000], B[1000], C[1000], AB[1000000], ABC[3000000];

int main() {
    cin >> X >> Y >> Z >> K;
    REP(i, X) cin >> A[i];
    REP(i, Y) cin >> B[i];
    REP(i, Z) cin >> C[i];
    REP(i, X) REP(j, Y) AB[i * Y + j] = A[i] + B[j];
    sort(AB, AB + X * Y, greater<ll>());
    REP(i, min(K, X * Y)) REP(j, Z) ABC[i * Z + j] = AB[i] + C[j];
    sort(ABC, ABC + min(K, X * Y) * Z, greater<ll>());
    REP(i, K) cout << ABC[i] << endl;
    return 0;
}

Measured memory_bytes: 31488
S = list(input().split())
a = int(S[0])
b = S[1].replace('.', '')
B = int(b)

ans = (a * B) // 100
print(ans)

# a, b = input().split()
# A = int(a)
# b = b.replace('.', '')
# B = int(b)
# ans = (A * B) // 100
# print(ans)

Measured memory_bytes: 9116
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		
		// 入出力高速化 java.io.* とthrows IOExceptionを忘れずに
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int X = Integer.parseInt(br.readLine());
		String ans = "No";
		if(X>=30) {
			ans  = "Yes";
		}
		
		System.out.println(ans);	
	}
}

Measured memory_bytes: 32484
a = input()
b = input()
c = input()
d = input()
e = input()
k = input()
k = int(k)

items = [int(a), int(b), int(c), int(d), int(e)]
flg = False
for i in range(len(items)):
    for j in range(i, len(items)):
        if items[j] - items[i] > k:
            flg = True
        if flg:
            break
    if flg:
        break
if flg:
    print(':(')
else:
    print('Yay!')

Measured memory_bytes: 3064
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <vector>
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;
#define MAXN (600000+10)
#define MAXM (600000+10)
int par[MAXN];
struct Edge
{
    int u ,v, w;
} edge[MAXM];
int tol = 0;
void addEdge(int u, int v, int w)
{
    edge[tol].u = u;
    edge[tol].v = v;
    edge[tol].w = w;
    tol ++;
}
bool cmp(Edge a, Edge b)
{
    return a.w  < b.w;
}
int find(int x)
{
    if(par[x] == -1) return x;
    return par[x] = find(par[x]);
}
int kruskal(int n)
{
    memset(par, -1, sizeof(par));
    sort(edge ,edge + tol, cmp);
    int cnt = 0, ans = 0;
    for(int i = 0; i < tol; i++)
    {
        int u = edge[i].u;
        int v = edge[i].v;
        int w = edge[i].w;
        int t1 = find(u);
        int t2 = find(v);
        if(t1 != t2)
        {
            ans += w;
            par[t1] = t2;
            cnt ++;
        }
        if(cnt == n - 1)
            break;
    }
    if(cnt < n - 1) return -1;
    return ans;
}
int n;

struct City {
    ll x, y, id;
} city[100002];

bool cmp1(City a, City b) {
    return a.x < b.x;
}
bool cmp2(City a, City b) {
    return a.y < b.y;
}

int main()
{
    scanf("%d", &n);
    for(int i=1;i<=n;i++) {
        scanf("%lld %lld", &city[i].x, &city[i].y);
        city[i].id = i;
    }

    sort(city+1, city+1+n, cmp1);
    for(int i=2;i<=n;i++) {
        addEdge(city[i-1].id, city[i].id, city[i].x - city[i-1].x);
        addEdge(city[i].id, city[i-1].id, city[i].x - city[i-1].x);
    }

    sort(city+1, city+1+n, cmp2);
    for(int i=2;i<=n;i++) {
        addEdge(city[i-1].id, city[i].id, city[i].y - city[i-1].y);
        addEdge(city[i].id, city[i-1].id, city[i].y - city[i-1].y);
    }
    cout << kruskal(n) <<endl;
}




Measured memory_bytes: 12032
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            // 文字列の入力
            string s = Console.ReadLine();

            var countN = CountChar(s, 'N');
            var countS = CountChar(s, 'S');
            var countE = CountChar(s, 'E');
            var countW = CountChar(s, 'W');

            if(countN != 0) {
                if(countS == 0) {
                    Console.WriteLine("No");
                    return;
                }
            }
            if (countS != 0) {
                if (countN == 0) {
                    Console.WriteLine("No");
                    return;
                }
            }
            if (countE != 0) {
                if (countW == 0) {
                    Console.WriteLine("No");
                    return;
                }
            }
            if (countW != 0) {
                if (countE == 0) {
                    Console.WriteLine("No");
                    return;
                }
            }

            Console.WriteLine("Yes");

        }

        // 文字の出現回数をカウント
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
    }
}

Measured memory_bytes: 11092
#include<stdio.h>
int main(void)
{
	int data[3],asc;
	scanf("%d %d %d",&data[0],&data[1],&data[2]);
	while(data[0]>data[1]||data[1]>data[2])
	{
		if(data[0]>data[1])
		{
			asc=data[0];
			data[0]=data[1];
			data[1]=asc;
		}
		if(data[1]>data[2])
		{
			asc=data[1];
			data[1]=data[2];
			data[2]=asc;
		}
	}
	printf("%d %d %d\n",data[0],data[1],data[2]);
	return 0;
}


Measured memory_bytes: 2104
#define _CRT_SECURE_NO_WARNINGS
#include <array>
#include <cstdio>
#include <map>

using namespace std;

int INF = 1000000007;

array<int, 100002> FCT;
array<int, 100002> INV;

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || c > '9') break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

int modmulti(int a, int b)
{
    int res = 0;
    int mod = a % INF;
    while (b > 0)
    {
        if ((b & 1) == 1)
        {
            res += mod;
            if (res > INF)
            {
                res -= INF;
            }
        }
        mod <<= 1;
        if (mod > INF)
        {
            mod -= INF;
        }
        b >>= 1;
    }
    return res;
}

int modcalc(int a, int b)
{
    // O(log b)
    int d = 0;
    if (b == 0)
    {
        return 1;
    }
    else if ((b & 1) == 0)
    {
        // 偶数 bを半分にできる
        d = modcalc(a, b / 2);
        return modmulti(d, d);
    }
    else
    {
        // 奇数 -1乗から1乗をかける
        return modmulti(a, modcalc(a, b - 1));
    }
}

int combination(int a, int b)
{
    // tmp = a! / b!
    int tmp = modmulti(FCT[a], INV[b]);
    // tmp / (a - b)!
    return modmulti(tmp, INV[a - b]);
}

void factorial(int x)
{
    FCT[0] = 1;
    FCT[1] = 1;
    for (int i = 2; i <= x; i++)
    {
        FCT[i] = modmulti(FCT[i - 1], i);
    }
}

void inverse(int x)
{
    INV[0] = 1;
    INV[1] = 1;
    INV[x] = modcalc(FCT[x], INF - 2);
    for (int i = x - 1; 2 <= i; i--)
    {
        INV[i] = modmulti(INV[i + 1], i + 1);
    }
}

int main()
{
    int n;

    gc(n);

    int tmp;

    map<int, int> cnt;
    map<int, int> idx;

    int first = 0;
    int second = 0;

    int dbl;

    for (int i = 0; i < n + 1; i++)
    {
        gc(tmp);

        cnt[tmp]++;

        if (cnt[tmp] == 2)
        {
            first = idx[tmp];
            second = i;
            dbl = tmp;
            break;
        }
        else
        {
            idx[tmp] = i;
        }
    }

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

    // 階乗テーブル作成
    factorial(100001);

    // 逆元テーブル作成
    inverse(100001);

    for (int i = 2; i < n + 1; i++)
    {
        // n+1Ci - n-(second-first)Ci-1
        int ans = combination(n + 1, i);

        if (i - 1 <= n - second + first)
        {
            ans -= combination(n - second + first, i - 1);
        }

        if (ans < 0) ans += INF;

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

    printf("%d\n", 1);
    return 0;
}

Measured memory_bytes: 11392
import scala.io.StdIn._

object Main extends App {
  val Array(x, n) = readLine.split(" ").map(_.toInt)

  if (n > 0) {
    val p = readLine.stripMargin.split(" ").map(_.toInt).toSet

    val up = (x to 101).find(!p.contains(_)).get
    val down = (x - 1 to 0 by -1).find(!p.contains(_)).get

    val upDiff = up - x
    val downDiff = x - down

    val ans = if (downDiff <= upDiff) down else up

    println(ans)
  } else {
    println(x)
  }
}



Measured memory_bytes: 55156
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int l = 2000;

bool match(char c1, char c2) {
  return (c1 == '?' || c2 == '?' || c1 == c2);
}

vector<bool> ab(100000), bc(100000), ac(100000);

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

  int na = a.length();
  int nb = b.length();
  int nc = c.length();

  rep(i, na) rep(j, nb) if (!match(a[i], b[j])) ab[i - j + 50000] = true;
  rep(i, nb) rep(j, nc) if (!match(b[i], c[j])) bc[i - j + 50000] = true;
  rep(i, na) rep(j, nc) if (!match(a[i], c[j])) ac[i - j + 50000] = true;

  int ans = l * 3;
  FOR(i, -2 * l, 2 * l + 1) {
    FOR (j, -2 * l, 2 * l + 1) {
      if (!ab[i + 50000] && !bc[j - i + 50000] && !ac[j + 50000]) {
        int left = min({0, i, j});
        int right = max({na, nb + i, nc + j});
        ans = min(ans, right - left);
      }
    }
  }
  cout << ans << endl;


  
  return 0;
}

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


int main(){
	int n;
	cin >> n;
	int a[n],b[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i)
	{
		b[a[i]-1] = i+1;
	}
	for (int i = 0; i < n; ++i)
	{
		cout << b[i]<<" ";
	}
    return 0;
}

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

int a[100100];

int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}n++;
	a[0]=0;
	long long sum=0;
	for(int i=1;i<n;i++)sum+=abs(a[i]-a[i-1]);
	sum+=abs(a[n-1]-a[0]);
	//printf("sum = %d\n",sum);
	for(int i=1;i<n;i++){
		if(i==0){
			printf("%lld\n",sum+abs(a[n-1]-a[1])-abs(a[0]-a[1])-abs(a[0]-a[n-1]));
		}else if(i==n-1){
			printf("%lld\n",sum+abs(a[n-2]-a[0])-abs(a[0]-a[n-1])-abs(a[n-1]-a[n-2]));
		}else{
			printf("%lld\n",sum+abs(a[i+1]-a[i-1])-abs(a[i+1]-a[i])-abs(a[i]-a[i-1]));
		}
	}
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb emplace_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define ll long long
#define INF 2000000000
vector<int> s[15];
int p[15];
int main(){
        int n,m;
        while(~getII(n,m)){
                F(i,0,15) s[i].clear();
                F(i,0,m){
                        VgetI(k);
                        F(j,0,k){
                                VgetI(x);
                                x--;
                                s[i].pb(x);
                        }
                }
                F(i,0,m) getI(p[i]);
                int ans=0;
                F(i,0,(1<<n)){
                        bitset<15> now=i;
                        int on[15]={};
                        F(j,0,m) F(k,0,s[j].size()) on[j]+=now[s[j][k]];
                        int cnt=0;
                        F(j,0,m) if(on[j]%2==p[j]) cnt++;
                        //F(j,0,m) debug(p[j]);
                        ans+=(cnt==m);
                }
                printf("%d\n",ans);
        }
}

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

int main()
{
    int n;
    cin>>n;
    int a[n];
    cin>>a[0]>>a[1];
    int dp[n];
    dp[0]=0;dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        cin>>a[i];
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 4344
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
int const INF = 1001001001;


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

int N;
cin >> N;
ll T = 1, A = 1;

rep(i,N) {
    ll t,a;
    cin >> t >> a;
    ll k = (t + T - 1) / t;
    ll l = (a + A - 1) / a;
    T = t * max(k,l);
    A = a * max(k,l);
}

cout << T + A << endl;
return 0;
}

Measured memory_bytes: 256