akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N;
    cin>>N;
    vector<int> H(N);
    rep(i,N)cin>>H.at(i);
    int ans=0,ma=H.at(0);
    rep(i,N){
        if(H.at(i)>=ma){
            ans++;
        }
        chmax(ma,H.at(i));
    }
    cout<<ans<<endl;
}

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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  
  if(A+B>=C){
    cout <<C+B << endl;
  }else{
    cout  << A+B+1+B << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> PLL;
#define chmax(x, y) do { x = max(x, y); } while(0)
#define chmin(x, y) do { x = min(x, y); } while(0)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<ll>(a); i < static_cast<ll>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;


signed main() {
  ll x;
  cin >> x;
  switch (x % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
    case 3:
      cout << "bon" << endl;
      break;
  }
  return 0;
}


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

public class Main {

    private static final int LAST_NUM = 600;

    public static void main(String[] args) {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String input = null;

        try {
            while ((input = in.readLine()) != null) {
                int step = Integer.valueOf(input);
                int large = 0;

                for (int i = step; i < LAST_NUM; i += step) {
                    large += step * i * i;
                }

                System.out.println(large);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

Measured memory_bytes: 16848
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ll a; cin >> a;
    ans += a;
  }
  cout << ans - n << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main() {
   int n,m; cin >> n >> m;
   vector<vector<int>> s(m);
   rep(i,m){
       int k; cin >> k;
       s.at(i).resize(k);
       rep(j,k){
           cin >> s[i][j];
           s[i][j]--;
        }
   }

   vector<int> p(m);
   rep(i,m) cin >> p[i];

   int ans = 0;
   for(int bit = 0; bit < (1 << n); ++bit){
       bool flag = true;
       for(int j = 0; j < m; j++){
           int count = 0;
           int o = s.at(j).size();
            for(int k = 0; k < o; k++){
                if(bit & (1 << s.at(j).at(k))){
                    count++;
                }
            }
            count %= 2;
            if(count != p[j]){
                flag = false;
                break;
            }
        }
            if(flag)ans++;
    }
    print(ans);
}

Measured memory_bytes: 256
import java.util.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import static java.lang.System.*;
import java.util.*;
import java.math.BigInteger;
import static java.lang.System.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double d= sc.nextDouble();
		BigDecimal L = new BigDecimal(String.valueOf(d));
		BigDecimal three = new BigDecimal("3.0");
		
		BigDecimal num = L.divide(three,10,RoundingMode.HALF_UP);
		BigDecimal ans = num.multiply(num);
		ans = ans.multiply(num);
		
		out.println(ans);
		
	}
}

Measured memory_bytes: 25300
#include<stdio.h>
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(c>b) printf("0\n");
	if(c<=b)
	{
		if(a>c&&d>a)
		{
			if(b>d)
			printf("%d\n",d-a);
			else printf("%d\n",b-a);
		}
		if(d<=a) printf("0\n");
		if(a<=c)
	    {
		if(d>b) printf("%d\n",b-c);
		else printf("%d\n",d-c);
	    }
	}	
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>

int main(){
	int N, M, C;
	scanf("%d %d %d", &N, &M, &C);
	int B[M];
	for (int i = 0; i < M; ++i) scanf("%d", B + i);
	int answer = 0;
	for (int i = 0; i < N; ++i){
		int sum = C;
		for (int j = 0; j < M; ++j){
			int tmp;
			scanf("%d", &tmp);
			sum += tmp*B[j];
		}
		if(sum > 0) answer++;
	}
	printf("%d\n", answer);
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c; cin>>a>>b>>c;
    if (a<b && b<c){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}



Measured memory_bytes: 3208
N, T = [int(x) for x in input().split()]
t = [int(x) for x in input().split()]

T_start = 0
T_end = T
T_total = 0

for i in range(1, N):
    if t[i] <= T_end:
        T_end = t[i] + T
    else: # t[i] > T_end
        T_total += T_end - T_start
        T_start = t[i]
        T_end = t[i] + T

T_total += T_end - T_start

print(T_total)

Measured memory_bytes: 30824
#include <stdio.h>
#include <string.h>

int main()
{
    int a,b;
    int s[90005],p[90005];
    s[0]=10000;
    for(int i=0;i<90000;i++)
    {
        if(i!=0)
            s[i]=s[i-1]+1;
        if((s[i]/10000==s[i]%10)&&((s[i]/1000)%10==(s[i]%100)/10))
            p[i]=1;
        else
            p[i]=0;
       /*** if(i<10000)
        printf("%d   %d\n",p[i],s[i]);*/
    }
    while(~scanf("%d%d",&a,&b))
    {
        int sum=0;
        for(int i=a;i<=b;i++)
        {
            sum=sum+p[i-10000];
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 896
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	N := nextInt()
	MIN := 100000000000000000
	for i := 0; i < 5; i++ {
		n := nextInt()
		MIN = min(MIN, n)
	}
	fmt.Println((N-1)/MIN + 5)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 1804
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}

ll i,j,k,ii,jj,n,m,a,b,c,d,e,f,g,h,r,w,l;
ll num,ans,sum,ok,ng;
ll x[500005],y[500005],z[500005];
ll dp[205][500005];
char s[500005],t[500005],u[500005];
bool dame,flag;

int main(){
	cin >> n >> k;
	for(i=1;i<=n;i++){
		cin >> x[i];
	}
	for(j=0;j<=k;j++){
		dp[0][j] = 1;
	}
	for(i=1;i<=n;i++){
		for(j=0;j<=k;j++){
			dp[i][j] = dp[i-1][j];
			if(j - x[i] - 1>= 0){				
				dp[i][j] += (mod - dp[i-1][j-x[i]-1]);
				dp[i][j] %= mod;
			}
		}
		for(j=1;j<=k;j++){
			dp[i][j] += dp[i][j-1];
			dp[i][j] %= mod;
		}
	}
	for(i=0;i<=n;i++){
		for(j=0;j<=k;j++){
			//pe(dp[i][j]);
		}
		//el;
	}
	p((dp[n][k] - dp[n][k-1] + mod) % mod);
	return 0;
}

Measured memory_bytes: 311936
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pii pair<int,int>
const int mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    int mx = max(max(a,b),c);
    while(1) {
        int dif = mx * 3 - a - b - c;
        mx++;
        if (dif & 1)continue;
        cout << dif / 2 << '\n';
        exit(0);
    }
}


Measured memory_bytes: 256
/*input
6
1 2
2 4
5 1
6 3
3 2
*/

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

vector<int> edge[100005];

int dfs(int u, int p)
{
	int ret = 0;
	for(int v : edge[u])
	{
		if(v==p) continue;
		ret ^= 1 + dfs(v, u);
	}
	return ret;
}

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 0; i<n-1; i++)
    {
    	int u, v;
    	scanf("%d %d", &u, &v);
    	edge[u].push_back(v);
    	edge[v].push_back(u);
    }
    if(dfs(1, -1)) cout << "Alice" << endl;
    else cout << "Bob" << endl;
	return 0;
}

Measured memory_bytes: 10368
from bisect import bisect_left,bisect

N, M, K = map(int, input().split())
A = list(map(int, input().split())) 
B = list(map(int, input().split()))

AR = [0]
BR = [0]

for i in range(N):
  AR.append(AR[i] + A[i])

for j in range(M):
  BR.append(BR[j] + B[j])

ans = 0

for i in range(N+1):
  if AR[i] > K:
    break
  temp = K - AR[i]
  cntB = bisect(BR, temp) - 1
  ans = max(ans, i+cntB)

print(ans)

Measured memory_bytes: 47500
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, k;
	cin >> n >> m >> k;
	rep(i,n+1)rep(j,m+1){
		if(m*i + n*j - 2*i*j == k){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

int main()
{
  char a, b;

  cin >> a >> b;

  if ( (a=='H' && b=='H') 
    || (a=='D' && b=='D') )
  {
    cout << 'H' << endl;
  } else {
    cout << 'D' << endl;
  }
}


Measured memory_bytes: 256
a=int(input())
S=input()
if a%2 != 0:
  print("No")
else:
  b=0
  while	b<=a//2-1 and 0<=b:
        if S[b]==S[a//2+b]:
          b=b+1
        else:
          b=-1
  if b==a//2:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<numeric>
#include<cassert>
#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
//const ll inf=1e9+7;
//const ll ful=1e18;
using namespace std;
//namespace mp = boost::multiprecision;
int main() 
{
	vector<ll> n(5);
	ll ans=0;
	for(int i=0;i<5;i++)
	{
		cin>>n[i];
		if(n[i]==0) ans=i+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] x = new long[n+1];
		x[0] = 2;
		x[1] = 1;
		for(int i=2; i<n+1; i++){
			x[i] = x[i-1]+ x[i-2];
		}
		System.out.println(x[n]);

		sc.close();

	}
}


Measured memory_bytes: 21972
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    println!("{}", if s[0] != s[1] && s[1] != s[2] && s[2] != s[3] { "Good" } else { "Bad" });
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll n;cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    ll l=0;
    rep(i,n){
        if(i>l)dame("no");
        chmax(l,i+v[i]/10);
    }
    reverse(all(v));
    l=0;
    rep(i,n){
        if(i>l)dame("no");
        chmax(l,i+v[i]/10);
    }
    out("yes");
}


Measured memory_bytes: 5196
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node{
    int key;
    Node *right,*left,*parent;
};

Node *root,*NIL;

Node * treeMinimum(Node *x){
    while(x->left != NIL) x = x->left;
    return x;
}

Node * find(Node *u,int k){
    while(u != NIL && k != u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

Node * treeSuccessor(Node *x){
    if(x->right != NIL) return treeMinimum(x->right);
    Node *y = x->parent;
    while(y != NIL && x == y->right){
        x = y;
        y = y->parent;
    }
    return y;
}

void treeDelete(Node *z){
    Node *y;
    Node *x;
    
    if(z->left == NIL || z->right == NIL) y = z;
    else y = treeSuccessor(z);
    
    if(y->left != NIL){
        x = y->left;
    }else{
        x = y->right;
    }
    
    if(x != NIL){
        x->parent = y->parent;
    }
    
    if(y->parent == NIL){
        root = x;
    }else{
        if(y == y->parent->left){
            y->parent->left = x;
        }else{
            y->parent->right = x;
        }
    }
    
    if(y != z){
        z->key = y->key;
    }
    
    free(y);
}

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    z->parent = y;
    if(y == NIL){
        root = z;
    }else{
        if(z->key < y->key){
            y->left = z;
        }else{
        y->right = z;
       } 
    }    
}

void inorder(Node *u){
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u){
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n,i,x;
    string com;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        cin >> com;
        if(com[0] == 'f'){
            scanf("%d",&x);
            Node *t = find(root,x);
            if(t != NIL) printf("yes\n");
            else printf("no\n");
        }else if(com == "insert"){
            scanf("%d",&x);
            insert(x);
        }else if(com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }else if(com == "delete"){
            scanf("%d",&x);
            treeDelete(find(root,x));
        }
    }
    
    return 0;
}


Measured memory_bytes: 21940
/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input!(h: usize, w: usize, d: i64);
    let max_d = d * ((h * w) as i64);

    let mut ans = vec![vec![0; w]; h];
    for i in 0..h {
        for j in 0..w {
            let i = i as i64;
            let j = j as i64;
            let x = i + j;
            let y = i - j;

            let bi = x / d;
            let bj = if y < 0 { (y - d + 1) / d } else { y / d };
            let color = (bi % 2) * 2 + if bj < 0 { (-bj) % 2 } else { bj % 2 };

            // print!("({}, {})=>({}, {}), ", x, y, bi, bj);

            ans[i as usize][j as usize] = color as usize;
        }
        // println!();
    }

    let c: Vec<char> = "RYGB".chars().collect();

    for i in 0..h {
        for j in 0..w {
            print!("{}", c[ans[i][j]]);
        }
        println!();
    }
}


Measured memory_bytes: 6652
program test02
 implicit none
 integer N
 integer,allocatable :: A(:)
 integer i
 integer :: dame=0

 read *, N
 allocate(A(N))
 read *, A

 do i=1,N
  if ( mod(A(i),2)==0 ) then
   if ( mod(A(i),3)/=0 .and. mod(A(i),5)/=0 ) then
    dame=1
   end if
  end if
 end do

 if ( dame==0 ) print '(A)', 'APPROVED'
 if ( dame==1 ) print '(A)', 'DENIED'

endprogram test02


Measured memory_bytes: 768
q_num = int(input())
q_l = [tuple(map(int, input().split())) for _ in range(q_num)]

table = [1] * (10 ** 5 + 1)
table[0] = 0
table[1] = 0

# エラトステネスの篩
for i in range(2, int(len(table) ** 0.5)):
    if table[i] == 0:
        continue
    step = i * 2
    while True:
        if step >= len(table):
            break
        table[step] = 0
        step += i

# 2017 like number table
table_like_n = [0] * len(table)
for i in range(1, len(table_like_n)):
    if i % 2 == 0:
        continue
    if table[i] == 1 and table[(i+1)//2] == 1:
        table_like_n[i] = 1

# 累積和の作成
accum_sum = [0] * (len(table_like_n) + 1)
for i in range(len(table_like_n)):
    accum_sum[i+1] = accum_sum[i] + table_like_n[i]

# クエリの分析
for l, r in q_l:
    print(accum_sum[r+1]-accum_sum[l])



Measured memory_bytes: 21876
# 2019/11/16

import math
mod=10**9+7
X,Y=map(int,input().split())

x=(2*X-Y)/3
y=X-2*x
if x!=int(x) or y!=int(y):
    print(0)
    exit()
else:
    x=int(x)
    y=int(y)

def cmb(n,r,mod=10**9+7):
    fac=[1,1]
    for i in range(2,n+1):
        fac.append(fac[i-1]*i%mod)
    ret=fac[n]*pow(fac[r]*fac[n-r]%mod,mod-2,mod)%mod
    return ret

if x<0 or y<0:
    print(0)
    exit()

n=x+y
r=min(x,y)

ans=cmb(n,r)
if x==0:
    if Y==2*y and X==Y//2:
        print(ans)
    else:print(0)
elif y==0:
    if X==2*x and Y==X//2:
        print(ans)
    else:print(0)
else:
    print(ans)



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

int main()
{
    int a[5];
    int K;

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

    cin >> K;

    int ans = 1;
    for (int i = 0; i < 5; i++)
    {
        for (int j = 0; j < 5; j++)
        {
            if (a[i] - a[j] > K)
                ans = 0;
        }
    }

    if (ans == 1)
    {
        cout << "Yay!" << endl;
    }
    else
    {
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n, m, r;
  cin >> n >> m >> r;
  vector<int> town(r);
  for (int i = 0; i < r; i++) {
    cin >> town[i];
    town[i]--;
  }
  vector<vector<int>> dist(n, vector<int>(n, 1e14));
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    dist[a][b] = c;
    dist[b][a] = c;
  }
  for (int i = 0; i < n; i++) {
    dist[i][i] = 0;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  vector<int> per(r, 0);
  for (int i = 0; i < r; i++) {
    per[i] = i;
  }
  int ans = 1e14;
  do {
    vector<int> order(r);
    for (int i = 0; i < r; i++) {
      order[i] = town[per[i]];
    }
    int cost = 0;
    for (int i = 1; i < r; i++) {
      cost += dist[order[i]][order[i - 1]];
    }
    ans = min(ans, cost);
  } while (next_permutation(per.begin(), per.end()));
  cout << ans << "\n";
}



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

using namespace std;

int main(){
	
	long long int n,x,a=1000000000;
	cin >> n >> x;
	long long int ab[n];
	long long int t;
	for(int i=0;i<n;i++){
		cin >> t;
		ab[i]=abs(t-x);
		a=min(ab[i],a);
	}
	
	long long int ans=1;

	
	for(long long int i=a;i>0;i--){
		for(long long int j=0;j<n;j++){
			if(ab[j]%i!=0){
				break;
			}
			if(j==n-1){
				cout << i << endl;
				return 0;
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    let b: usize = read();
    if a <= 8 && b <= 8 {
        println!("Yay!");
    } else {
        println!(":(")
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;


int main(void) {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3580
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

N = int(input())
S = list(input())

ans = 0
for i in range(N):
    A = set(S[:i])
    B = set(S[i:])
    tmp = 0
    for a in A:
        if a in B:
            tmp += 1
    ans = max(ans, tmp)

print (ans)


Measured memory_bytes: 3060
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
// #include <iostream>
// #include <array>
// #include <cmath>
// #include <array>
// #include <vector>
// #include <set>
// #include <algorithm>
// #include <functional>
// #include <numeric>
// #include <map>
// #include <unordered_map>
// #include <queue>
using namespace std;
#define MOD  998244353
#define ll long long
#define LP pair<ll ,int>
const double PI = atan(1.0) * 4;
// const int N = 1e5 + 5 ;
// const ll INF = (int)1e9 ;
const int di[4] = { -1, 0, 1, 0} ;
const int dj[4] = {0, -1, 0, 1} ;
// const ll INF = (ll)2e18 + 50;
const int INF = (1 << 30) ;



int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t ;
	// cin >> t;
	// while (t--) {
	int n , m , k ;
	cin >> n >> m >> k ;
	int x1 , x2 , y1 , y2 ;
	cin >> x1 >> y1 >> x2 >> y2 ;
	--x1 ;
	--x2 ;
	--y1 ;
	--y2 ;
	vector<vector<char>> a(n, vector<char>(m)) ;
	vector<vector<int>> dis(n, vector<int>(m, INF)) ;

	for (int i = 0 ; i < n ; i++) {
		for (int j = 0 ; j < m ; j++) {
			cin >> a[i][j] ;
		}
	}
	queue<pair<int, int>> q ;
	q.push({x1 , y1});
	dis[x1][y1] = 0 ;
	while (!q.empty()) {
		int x = q.front().first ;
		int y = q.front().second ;
		q.pop() ;
		for (int i = 0 ; i < 4 ; i++) {
			for (int j = 1 ; j <= k ; j++) {
				int nx = x + j * di[i], ny = y + j * dj[i];
				if (nx >= 0 && nx < n && ny >= 0 && ny < m && a[nx][ny] == '.' && (dis[nx][ny] == INF || dis[nx][ny] == dis[x][y] + 1)) {
					if (dis[nx][ny] == INF) {
						dis[nx][ny] = dis[x][y] + 1;
						q.push({nx, ny});
					}
				} else break;
			}
		}
	}

	if (dis[x2][y2] == INF) cout << -1 << "\n";
	else cout << dis[x2][y2] << "\n";

	// }






	return 0 ;

}

Measured memory_bytes: 12008
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>


using namespace std;

typedef long long ll;

#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vld vector<ld>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define vvld vector<vector<ld>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M = 1000000007;
const ll MM = 998244353;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define trace(...)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

template<typename T, typename F>
void chmax( T &a, F b) {
  if (b > a)a = b;
}

template<typename T, typename F>
void chmin( T &a, F b) {
  if (b < a)a = b;
}



ll powM(ll a, ll b, ll m)
{
  if (a <= 0)return 0;
  a %= m;
  ll ans = 1LL;
  while (b)
  {
    if (b & 1)ans = ans * a % m;
    a = a * a % m;
    b >>= 1;
  }

  return ans;
}



ll poww(ll a, ll b)
{

  ll ans = 1;
  while (b)
  {
    if (b & 1)ans = ans * a;
    a = a * a;
    b >>= 1;
  }

  return ans;

}


string tostring(ll x) {
  stringstream sss;
  sss << x;
  string ans = sss.str();
  return ans;
}



const ll N = 1e6 + 5;


/* we are looking for non-zero suffixes,

a2 a1 a0

// so wee need to store the information regarding last digit so far

bcz it can be zero and then if next digit is non zero,then this needs to be taken into account.

eg : 0 --> NO
    30 --> YES

dp[n][k][par],if cur digit is zero ,then par =0,else par=1.

dp[i][l+(10^i)*p][(p!=0)]+=dp[i-1][l][].

.lets take an example  with n=5 and k=3.

dp[0][0][1]=3,dp[0][0][0]=1;

dp[1][]


*/


int main() {

  IOS;

#ifndef ONLINE_JUDGE

  freopen("input1.txt", "r", stdin);
  freopen("output1.txt", "w", stdout);

#endif


  ll n, a, b;
  cin >> n >> a >> b;

  ll ans = a * (n / (a + b));

  ans += min(a, n % (a + b));
  cout << ans;


  return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        String[] a = new String[n];
        for(int x = 0; x < n; x++){
            a[x] = scan.next() + " " + scan.nextInt();
        }
        String rank = "S";
        int ranks = 1;
        boolean have = false;
        while(ranks < 5) {
            for (int card = 1; card < 14; card++){
                for(int x = 0; x < n; x++){
                    if(a[x].equals(rank + " " + card)){
                        have = true;
                    }
                }
                if (have){
                    have = false;
                }
                else{
                    System.out.println(rank + " " + card);
                }
            }
            ranks++;
            if(ranks == 2){
                rank = "H";
            }
            else if(ranks == 3){
                rank = "C";
            }
            else{
                rank = "D";
            }
        }


    }
}


Measured memory_bytes: 27048
#include<bits/stdc++.h>
using namespace std;
long long t,s,p,n,h,a[100005],b[100005];
int main(){
	cin>>n>>h;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		t=max(t,a[i]);
	}
	sort(b+1,b+n+1);
	reverse(b+1,b+n+1);
	for(int i=1;i<=n;i++){
		if(b[i]<t) break;
		s+=b[i];
		if(s>=h){
			cout<<i;
			return 0;
		}
		p=i;
	}
	long long ans=(h-s)/t;
	if((h-s)%t!=0)
	ans++;
	cout<<ans+p;
}

Measured memory_bytes: 5132
#include <bits/stdc++.h>
using namespace std;
#define ll long long
string s, t;
int dp[3000][3000];
int f(int i, int j)
{
    if( i == s.length() || j == t.length() )
        return 0;
    if(dp[i][j] != -1)
        return dp[i][j];
    if( s[i] == t[j] )
        return dp[i][j] = f(i+1, j+1) + 1;
    return dp[i][j] = max(f(i+1, j), f(i, j+1));
}
void build(int i, int j)
{
    if( i == s.length() || j == t.length() )
        return;
    if( s[i] == t[j] )
    {
        cout << s[i];
        build(i+1, j+1);
    }
    else
    if( dp[i+1][j] > dp[i][j+1] )
        build(i+1, j);
    else
        build(i, j+1);

}
int main()
{
    /*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    cin >> s >> t;
    memset(dp, -1, sizeof dp);
    f(0, 0);
    build(0, 0);
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 55);
 
int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n, vector<int>(n, 0));
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a][b] = 1;
    g[b][a] = 1;
  }
  vector<int> v(n);
  rep(i,n) v[i] = i;
  int res = 0;
  do {
    int ok = 1;
    for (int i = 0; i < n-1; i++) {
      ok &= (g[v[i]][v[i+1]]);
    }
    res += ok;
  } while (next_permutation(v.begin() + 1, v.end()));
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>
int main(){
	int a[101],z,i,max;
	for(i=1;i<=100;i++)a[i]=0;
	while(scanf("%d",&z)!=EOF){
		a[z]++;
	}
	max=a[1];
	for(i=2;i<=100;i++)if(max<a[i])max=a[i];
	for(i=1;i<=100;i++)if(max==a[i])printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 596
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	pp := make([]pair, n)
	for i := 0; i < n; i++ {
		pp[i][0] = getNextInt(scanner)
		pp[i][1] = getNextInt(scanner)
	}
	sort.SliceStable(pp, func(i, j int) bool {
		if pp[i][0] == pp[j][0] {
			return pp[i][1] < pp[j][1]
		}
		return pp[i][0] < pp[j][0]
	})
	for i := 0; i < n; i++ {
		fmt.Fprintln(writer, fmt.Sprintf("%d %d", pp[i][0], pp[i][1]))
	}
}

type pair [2]int



Measured memory_bytes: 7676
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
int p2[9],dp[500001];
int solve(vector<int> a){
	int n=a.size(),sum=0;
	rep(i,n) sum+=a[i];
	rep(i,sum+1) dp[i]=-1;
	dp[0]=0;
	rep(i,n){
		for(int x=sum/a[i]*a[i];x>=a[i];x-=a[i]){
			if(dp[x-a[i]]>=0) dp[x]=max(dp[x],dp[x-a[i]]+1);
		}
	}
	int ret=0,s=1;
	while(s<=sum){
		ret=max(ret,dp[s]);
//		printf("dp[%d]=%d\n",s,dp[s]);
		s*=2;
	}
	return ret;
}
int main(){
	p2[0]=1;
	rep(i,8) p2[i+1]=p2[i]*2;
	while(true){
		int N,a[1000];
		cin>>N;
		if(N==0) break;
		rep(i,N) cin>>a[i];
		int ans=1;
		for(int p=1;p<=500;p++){
			vector<int> vc;
			bool ok=false;
			rep(i,N) if(a[i]%p==0){
				rep(j,9) if(p2[j]==a[i]/p){
					vc.pb(p2[j]);
					if(j==0) ok=true;
				}
			}
			if(ok) ans=max(ans,solve(vc));
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1752
K = int(input())

memo = set()
repunit = 7%K
n = 1
while True:
    if repunit == 0:
        print(n)
        exit()
    else:
        if repunit in memo:
            print(-1)
            exit()
        else:
            memo.add(repunit)
    repunit = (repunit*10 + 7)%K
    n += 1



Measured memory_bytes: 77968
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <list>
#include <map>
#include <string>
#include <functional>
#include <math.h>
#include <utility>
#define INF 100000000
using namespace std;
typedef pair<int,int> P;
int w,h,ans;
int main()
{
	while(cin>>w>>h&&(w||h)){
		ans=0;
		int dp[100][100][5];
		fill(dp[0][0],dp[100][0],0);
		for(int i=0;i<h;i++)dp[0][i][3]=1;
		for(int i=0;i<w;i++)dp[i][0][4]=1;
		for(int y=1;y<h;y++){
			for(int x=1;x<w;x++){
				dp[x][y][1]=dp[x][y-1][4];
				dp[x][y][2]=dp[x-1][y][3];
				dp[x][y][3]=(dp[x][y-1][1]+dp[x][y-1][3])%100000;
				dp[x][y][4]=(dp[x-1][y][2]+dp[x-1][y][4])%100000;
			}
		}
		for(int i=1;i<=4;i++)ans=(ans+dp[w-1][h-1][i])%100000;
		cout<<ans<<endl;
	}
}

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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)



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

    vector<ll> a(n);
    vector<ll> ans(n,0);


    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>a.at(i);
        if(i%2==0){
            ans.at(0) += a.at(i);
        }else{
            ans.at(0) -= a.at(i);
        }
        sum += a.at(i);
    }

    for(int i=1;i<n;i++){
        ans.at(i) = 2*a.at(i-1)-ans.at(i-1);
    }
    for(int i=0;i<n;i++){
        cout<<ans.at(i)<<" ";
    }
}

Measured memory_bytes: 2944
# ARC097D - Equals
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)


def dfs(v: int, color: int) -> None:
    group[v] = color  # make vertex v searched
    for u in G[v]:  # search vertices available from v recursively
        if not group[u]:  # skip if already searched
            dfs(u, color)


def main():
    # check i and Pi are connected components or not
    global G, group
    N, M = tuple(map(int, input().split()))
    P = tuple(map(int, input().split()))
    E = tuple(tuple(map(int, input().split())) for _ in range(M))
    G = [[] for _ in range(N + 1)]  # construct a graph (1-idx)
    for v, u in E:
        G[v] += [u]
        G[u] += [v]
    group = [0] * (N + 1)
    color = 1
    for v in range(1, N + 1):  # connected components have the same color
        if not group[v]:
            dfs(v, color)
            color += 1
    ans = sum(group[i] == group[p] for i, p in enumerate(P, 1))
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 90168
from collections import Counter as Ct
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n=INT()
    a=LIST()
    a=set(a)
    if n==len(a):
        print('YES')
    else:
        print('NO')
if __name__=='__main__':
    do()

Measured memory_bytes: 31656
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}

	int lowest_sum = 40000000;

	for (int i = -100; i <= 100; i++) {
		int sum = 0;
		for (int j = 0; j < N; j++) {
			sum += pow(abs(i - A.at(j)), 2);
		}
		lowest_sum = min(lowest_sum, sum);
	}

	cout << lowest_sum << endl;
}

Measured memory_bytes: 3608
// ------------------------------------
// Date:2018/ 3/ 1
// Problem:ABC 057 RemainingTime a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

int main()
{
  int A, B;
  cin >> A >> B;
  cout << ((A + B) % 24) << endl;
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#define M 100001
#define N -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[M];
int D[M];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

  if(T[u].p==N) printf("root, ");
  else if(T[u].l==N) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for (i=0, c = T[u].l; c != N; i++, c = T[c].r){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");

}

void cD(int u, int p){
  D[u] = p;
  if(T[u].r!=N) cD(T[u].r,p);
  if(T[u].l!=N) cD(T[u].l,p+1);
}

int main(){
  int i, j, k;
  int n;
  int id, sib, child;
  int root = N;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = N;

  for(i=0; i<n; i++){
    scanf("%d %d", &id, &k);
    for(j = 0, sib = N; j<k; j++){ //子を入力する (input children)                                         
      scanf("%d", &child);
   T[child].p = id;
      if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)                               
      else T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)                                    
      sib = child;//次の子供の左の兄弟 (the left sibling of the next child)                                  
    }
  }

  //根を求める (find the root)                                                                               
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }

  //それぞれのノードの深さを求める (find depth of each node)                                                 
 cD(root, 0);

  //出力 (output)                                                                                            
  for(i=0; i<n; i++) print(i);

  return 0;
}



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

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

//最初から見ていくO(n)

int main(){
    int N;
    cin >> N;
    if(N==1){
        cout << 1 << endl;
        return 0;
    }
    int ans = 0;
    bool up = false;
    bool down = false;
    //bool con = true;
    ll now, bef;
    FOR(i, 0, N){
        cin>>now;
        if(i==0){
            bef = now;
            continue;
        }
        else if(now>bef){
            if(down){
                ans++;
                up = false;
                down = false;
                bef = now;
                continue;
            }
            up = true;
            down = false;
        }
        else if(now<bef){
            if(up){
                ans++;
                up = false;
                down = false;
                bef = now;
                continue;
            }
            up = false;
            down = true;
        }
        bef = now;
    }
    cout << ans+1 << endl;
}

Measured memory_bytes: 256
//created by Ruchir Mehta
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include<cmath>
#include<iomanip>
#define fast ios_base::sync_with_stdio(0)
#define fast_in cin.tie(0)
#define fast_out cout.tie(0)
#define ll long long
#define MAX 1000000
#define MAX_MAX 10000000000
#define pb push_back
#define ppbk pop_back
#define mp make_pair
#define precise(i) cout<<fixed<<setprecision(i)
#define f first
#define s second
#define in insert
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,k,n) for(ll i=k;i<n;i++)
#define pll pair<ll,ll>
#define V vector<ll>
#define VV vector<V>
#define Mll map<ll,V>
#define Vpll vector<pll>
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define Sll set<ll>
#define MAXN 105
#define MOD 998244353
#define dg(x) cerr<<#x<<':'<<x<<endl;
#define dg2(x,y) cerr<<#x<<':'<<x<<' '<<#y<<':'<<y<<endl;
#define dg3(x,y,z) cerr<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<endl;
#define dg4(x,y,z,zz) cerr<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<' '<<#zz<<':'<<zz<<endl;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const double PI = 3.141592653589;
const char nl = '\n';
//ll random=uniform_int_distribution<int>(start,end)(rng);

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
 


ll binpow(ll a, ll b, ll m) 
{
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

//void dfs(ll a,vector<ll> adj[])
//{
//static unordered_set<ll> bag;
//if(bag.find(a)==bag.end())
//{
//bag.insert(a);
//cout<<a<<"\n";
//for(auto it:adj[a])
//dfs(it,adj);
//}
//}

void solve()
{
//	   clock_t time_req;
//    time_req = clock();
	V a(5);
	rep(i,5)
	cin>>a[i];
	rep(i,5)
	{if(a[i]==0)
	{cout<<i+1<<endl;
	return;
	}
	}
//	time_req = clock()-time_req;
//    cout<<"Time taken: "<<(float)time_req/CLOCKS_PER_SEC<<"s"<<endl;
}

int main()
{
fast;
fast_in;
fast_out;
ll no=1;

// cin>>no;
while(no--){
	solve();
}
return 0;
}

//Don’t keep debug print statements while submitting :stuck_out_tongue:

Measured memory_bytes: 3652