akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CSentou solver = new CSentou();
        solver.solve(1, in, out);
        out.close();
    }

    static class CSentou {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints(), t = in.ints();
            int ans = 0;
            int last = 0;
            for (int i = 0; i < n; i++) {
                int s = in.ints();
                if (s < last) {
                    s += t;
                    ans += s - last;
                    last = s;
                } else {
                    ans += t;
                    last = s + t;
                }
            }
            out.println(ans);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



Measured memory_bytes: 42320
#include <iostream>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

pll egcd(ll a, ll b) {
        if (a > b) {
                pll p = egcd(b,a);
                return pll(p.second,p.first);
        }

        ll s0=1,s1=0,s2=a;
        ll t0=0,t1=1,t2=b;
        while (t2 != 0) {
                ll q = s2/t2;
                ll r0=t0,r1=t1,r2=t2;
                t0=s0-q*t0,t1=s1-q*t1,t2=s2-q*t2;
                s0=r0,s1=r1,s2=r2;
        }

        return pll(s0,s1);
}

ll mod_inv(ll a, ll m) {
        pll p = egcd(a%m, m);
        return (p.first%m+m)%m;
}


const ll MOD=1e9+7;
const ll N=1e5+5;

ll fac[N],invfac[N];
ll bin(int n, int r) {
        if (r > n || r < 0) return 0;
        return ((fac[n]*invfac[r])%MOD*invfac[n-r])%MOD;
}

int n;
ll a[N];
map<ll,int> pos;

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

        fac[0] = 1, invfac[0] = 1;
        for (int i=1; i<n+5; i++) {
                fac[i] = (i*fac[i-1])%MOD;
                invfac[i] = mod_inv(fac[i],MOD);
        }

        int d=0;
        for (int i=0; i<n+1; i++) {
                if (pos.count(a[i]) == 1) {
                        d = i-pos[a[i]];
                        break;
                }
                pos[a[i]] = i;
        }

        for (int k=1; k<=n+1; k++) {
                ll cur = bin(n+1,k);
                //cout << "DBG: " << n+1 << " " << k << " " << bin(n+1,k) << "\n";
                if (d > 0)
                        cur -= bin(n-d,k-1);
                //cout << "DBG: " << n-d << " " << k-1 << " " << bin(n-d,k-1) << "\n";
                cout << (cur%MOD+MOD)%MOD << "\n";
        }
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
ll n, a, b, c;
string s;
int main() {
    init();
    cin >> s;
    string t = "hi";
    if(s.size()%2==1){
        cout << "No" << endl;
        return 0;
    }
    bool isok = true;
    rep(i,s.size()/2){
        if (s.substr(2 * i, 2) != t) isok = false;
    }
    cout << (isok ? "Yes" : "No") << endl;
}

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

int main() {
    int N, M, X; cin >> N >> M >> X;
    vector<int> C(N);
    vector< vector<int> > A(N, vector<int>(M));
    for (int i = 0; i < N; i++) {
        int c; cin >> C[i];
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }

    long long ans = (1LL<<63)-1;
    bool get_skill = false;
    for (int bit = 0; bit < (1 << N); bit++) {
        long long sum_price = 0;
        vector<int> skills(M);
        for (int i = 0; i < N; i++) {
            if (bit & (1 << i)) {
                sum_price += C[i];
                for (int j = 0; j < M; j++) {
                    skills[j] += A[i][j];
                }
            }
        }
        bool flag = true;
        for (int j = 0; j < M; j++) if (skills[j] < X) flag = false; 
        if (flag && sum_price < ans) {
            ans = sum_price;
            get_skill = true;
        }
    }

    if (!get_skill) cout << -1 << endl;
    else cout << ans << endl;

}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;

int main(){
	ll a,b,c,x;
	cin>>a>>b>>c>>x;
	ll ans=0;
	rep(i,0,a+1){
	   rep(j,0,b+1){
		   rep(k,0,c+1){
			   if(i*500+j*100+k*50==x)ans++;
		   }
	   }
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;



int main(void) {
  string s;
  cin >> s;
  ll ans=s.size();
  ll i;
  
  ll cnt=0;
  for(i=0; i<s.size(); i++) {
    if(s[i]=='0' && i&1) cnt++;
    if(s[i]=='1' && !(i&1)) cnt++;
  }
  chmin(ans, cnt);
  
  cnt=0;
  for(i=0; i<s.size(); i++) {
    if(s[i]=='1' && i&1) cnt++;
    if(s[i]=='0' && !(i&1)) cnt++;
  }
  chmin(ans, cnt);
  
  pt(ans);
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

s=input().rstrip()
if len(list(set(list(s))))==len(s):
    print("yes")
else:
    print("no")


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

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VI a(n + 1);  // 1-indexed
    REP(i, n) cin >> a[i + 1];
    VI ball_sum(n + 1, 0);
    VVI factors(n + 1);
    FOR(i, 1, n) { FOR(j, 1, n / i) factors[i * j].push_back(i); }
    VI ans;
    FORR(i, n, 1) {
        if (ball_sum[i] % 2 != a[i]) {
            for (auto& f : factors[i]) ball_sum[f]++;
            ans.push_back(i);
        }
    }

    cout << ans.size() << ln;
    REP(i, ans.size()) {
        if (i == (int)ans.size() - 1)
            cout << ans[i] << ln;
        else
            cout << ans[i] << " ";
    }
    return 0;
}


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

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

#define ll long long
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

const int mN=101;
const int mK=101010;

ll W[mN],V[mN];
ll dp[mK];
ll dp2[mK];

void solve(){
  ll n,w;cin>>n>>w;
  for(int i=1;i<=n;i++){
    cin>>W[i]>>V[i];    
  }

  for(int i=1;i<=n;i++){
    memset(dp,0,sizeof dp);
    for(int j=0;j<=w;j++){
      dp[j]=max(dp2[j],(j-W[i]>=0)?V[i]+dp2[j-W[i]]:0);
    }
    memcpy(dp2,dp,sizeof dp);
  }

  cout<<dp[w]<<endl;
}

int main(){solve();}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    string S, T;
    cin >> S >> T;

    ll SL = S.length();
    ll TL = T.length();

    ll ans = LINF;
    REP(i, SL-TL+1){
        ll temp = 0;
        REP(j, TL){
            if(S[i+j] != T[j]) temp++;
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  vector<int> p(n);
  rep (i, n) cin >> p[i];
  int cnt = 0;
  rep (i, n) {
    if (p[i] != i + 1) ++cnt;
  }
  cout << (cnt <= 2 ? "YES" : "NO") << endl;
  return 0;
}

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

int main(void){
  int A, B, C, X, Y;
  int sum = 0;
  int cntA = 0, cntB = 0, cntC = 0;
  cin >> A >> B >>C;
  cin >> X >> Y;
  //A > AB*2の時，全部ABピザでAを賄う
  if(A >= 2*C){
    cntC += 2*X;
    Y = Y - X;
    X = 0;
    /*cout << "0:" << X << " "<< Y << endl;
    cout << cntA << " " << cntB << " " << cntC << endl;
  	*/
  }
  //B > AB*2の時，全部ABピザでBを賄う
  if(B >= 2*C){
    cntC += 2*Y;
    X = X - Y;
    Y = 0;
    /*
    cout << "1:" << X << " " << Y << endl;
    cout << cntA << " " << cntB << " " << cntC << endl;
  	*/
  }
  //A + B > AB*2の時，ギリギリまでABピザを購入し，残りをA，B
  if(A + B >= C*2){
    cntC += 2*max(0, min(X, Y));
    int tempX = X;
    X = X - max(0, min(tempX, Y));
    Y = Y - max(0, min(tempX, Y));
    /*
    cout << "2:" << X << " " <<Y << endl;
    cout << cntA << " " << cntB << " " << cntC << endl;
 	*/
 	}
  //残りは全部A, Bを別々に買う
  cntA += max(0, X);
  cntB += max(0, Y);
  sum = cntA*A + cntB*B + cntC*C;
  //cout << cntA << " " << cntB << " " << cntC << endl;
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define bitget(a, b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(), x.end())

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;

int main() {
	int n;
	scanf("%d", &n);
	int ans=0;
	rep(i, 0, n+1){
		if (i*i > n){
			break;
		}
		else{
			ans = i*i;
		}
	}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 256
s=input()
t=input()
def convert(S):
  lis=[]
  dic=dict()
  con=""
  for i in range(len(S)):
    if S[i] in lis:
      con+=str(dic[S[i]])
    else:
      lis.append(S[i])
      con+=str(len(lis))
      dic[S[i]]=len(lis)
  return con
print("Yes" if convert(s)==convert(t) else "No")

Measured memory_bytes: 4144
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


char buf[100001];

int main(){

	scanf("%s",buf);

	int length;
	int ans = BIG_NUM;
	int tmp_min = BIG_NUM,tmp_max = 0,width;

	for(length = 0; buf[length] != '\0'; length++){ //?????????1???????????????
		tmp_min = min(tmp_min,buf[length]-'0');
		tmp_max = max(tmp_max,buf[length]-'0');
	}

	ans = tmp_max-tmp_min;

	if(ans == 0){
		printf("0\n");
		return 0;
	}

	vector<int> V; //length????´???°?????????

	for(int i = 2; i <= sqrt(length); i++){
		if(length%i == 0){
			V.push_back(i);
			V.push_back(length/i);
		}
	}

	sort(V.begin(),V.end());
	V.erase(unique(V.begin(),V.end()),V.end());


	bool FLG;
	char base_num;
	int loc,tmp;

	//??????????????????????¨??????????
	for(int i = 0; i < V.size(); i++){
		width = V[i];
		tmp_min = BIG_NUM,tmp_max = 0;

		//????????????2?????\??????????????????????????´????????????????????????
		FLG = true;

		for(int k = 0; k < width-2; k++){
			base_num = buf[k];
			loc = k+width;

			while(loc < length){
				if(buf[loc] != base_num){
					FLG = false;
					break;
				}
				loc += width;
			}
			if(!FLG)break;
		}

		if(!FLG)continue;

		//???2??????????¨??????????
		for(int k = 1; k <= length/V[i]; k++){
			tmp = 10*(buf[k*width-2]-'0')+buf[k*width-1]-'0';
			tmp_min = min(tmp_min,tmp);
			tmp_max = max(tmp_max,tmp);
		}
		ans = min(ans,tmp_max-tmp_min);
	}

	if(ans <= 2){
		printf("%d\n",ans);
		return 0;
	}

	//????????????????????????11???18??????2??????????????????1???
	tmp_min = BIG_NUM,tmp_max = 0;
	for(int i = 0; i < length;){
		if(buf[i] == '1'){
			if(i+1 == length){ //1??????1?????§??????????????£??????????????????????????§???10????????§ans?????????
				printf("%d\n",ans);
				return 0;
			}else{
				tmp = 10*(buf[i]-'0')+buf[i+1]-'0';
				tmp_min = min(tmp_min,tmp);
				tmp_max = max(tmp_max,tmp);
				i += 2;
			}
		}else{
			tmp_min = min(tmp_min,buf[i]-'0');
			tmp_max = max(tmp_max,buf[i]-'0');
			i += 1;
		}
	}

	if(tmp_min != BIG_NUM && tmp_max != tmp_min)ans = min(ans,tmp_max-tmp_min);

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

	return 0;
}

Measured memory_bytes: 3388
import java.util.*;


public class Main{ 


    public static void main(String args[]) {
    Scanner s=new Scanner(System.in);
	int n=s.nextInt();
	
	int arr[]=new int[n];
	long sum=0;
	for(int i=0;i<n;i++) {
		arr[i]=s.nextInt();
		sum+=arr[i];
	}
	long dp[][]=new long[n+1][n+1];
	for(int i=0;i<=n;i++) {
		for(int j=0;j<=n;j++) {
			dp[i][j]=-1;
		}
	}
	long Xans=f(0,n-1,n,arr,dp);
	long Yans=sum-Xans;
	 System.out.print(Xans-Yans);
	 
   }
    public static long f(int start,int end,int n,int arr[],long dp[][]) {
    	if(start>end) {
    		return 0;
    	}
    	if(dp[start][end]!=-1) {
    		return dp[start][end];
    	}
    	long a=arr[start]+ Math.min(f(start+2,end,n,arr,dp),
    			f(start+1,end-1,n,arr,dp));
    	long b=arr[end]+ Math.min(f(start,end-2,n,arr,dp),
    			f(start+1,end-1,n,arr,dp));
    	return dp[start][end]=(a>b)?a:b;
    }
}

Measured memory_bytes: 109128
#include <stdio.h>

int main(void)
{
	int a,b,c,d,n;
	while(scanf("%d",&n)!=EOF){
		int count=0;
		for(a=0;a<10;a++){
			for(b=0;b<10;b++){
				for(c=0;c<10;c++){
					for(d=0;d<10;d++){
						if(a+b+c+d==n) count++;
					}
				}
			}
		}	
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	vector<int> p(n);
	rep(i, 0, n - 1)cin >> p[i];
	int cnt = 0;
	rep(i, 0, n - 3)
	{
		if (p[i] < p[i + 1] && p[i + 1] < p[i + 2])++cnt;
		if (p[i] > p[i + 1] && p[i + 1] > p[i + 2])++cnt;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int f[101];
int main()
{
	int a,b,c,sum=0;
	cin>>a>>b>>c;
	f[a]++, f[b]++, f[c]++;
	for (int i = 1; i <= 100; i++) {
		if (f[i] > 0) sum++;
	}
	cout<<sum;
	return 0;
} 


Measured memory_bytes: 256
# coding: utf-8

#文字列読み込み
s = input()
t = input()

#それぞれの文字列を分解してソートし再結合
s_list = sorted(list(s))
t_list = sorted(list(t), reverse=True)

s_ana = ''.join(s_list)
t_ana = ''.join(t_list)

#比較
result = "Yes" if (s_ana < t_ana) else "No"

#出力
print(result)

Measured memory_bytes: 3060
#include<algorithm>
#include<bits/allocator.h>
#include<bits/basic_ios.h>
#include<bits/basic_string.h>
#include<bits/basic_string.tcc>
#include<bits/c++config.h>
#include<bits/char_traits.h>
#include<bits/cpp_type_traits.h>
#include<bits/cxxabi_forced.h>
#include<bits/ios_base.h>
#include<bits/locale_classes.h>
#include<bits/localefwd.h>
#include<bits/ostream_insert.h>
#include<bits/postypes.h>
#include<bits/range_access.h>
#include<bits/stl_algobase.h>
#include<bits/stl_function.h>
#include<bits/stl_iterator.h>
#include<bits/stl_iterator_base_funcs.h>
#include<bits/stl_iterator_base_types.h>
#include<bits/stringfwd.h>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwchar>
#include<cwctype>
#include<debug/debug.h>
#include<deque>
#include<exception>
#include<ext/atomicity.h>
#include<ext/numeric_traits.h>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
int n,a[100000]={2000000000},ans,last,num;
int main()
{
	scanf("%d",&n);
	for (int i=0;i<n;i++) scanf("%d",&a[i]);
	sort(a,a+n);
	last=a[0];num=1;
	for (int i=1;i<=n;i++){
		if (last!=a[i]){
			if (num<last){
				ans+=num;
			}
			else if (last<num){
				ans+=num-last;
			}
			num=0;
		}
		num++;
		last=a[i];
	}
	cout<<ans;
	return 0;
}

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

typedef long long ll;
#define mp make_pair
#define pb push_back
#define inf (ll)1e17
#define modz 1000000007
#define EPS (double)1e-9
#define fi first
#define se second

ll n,dp[5005][5005];
string s;

ll pangkat(ll a, ll b){
	if(b==0) return 1;
	ll tmp = pangkat(a,b/2)%modz;
	tmp = (tmp*tmp)%modz;
	if(b%2==1) tmp = (tmp*a)%modz;
	return tmp;
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n;
	cin >> s;
	dp[0][0] = 1;
	for (int i=0;i<=n;i++) {
        for (int j=0;j<=i;j++) {
            dp[i+1][j+1] = (dp[i][j]*2%modz+dp[i+1][j+1])%modz;
            dp[i+1][max(0,j-1)] = (dp[i+1][max(0,j-1)]+dp[i][j])%modz;
        }
    }
    cout << (pangkat(pangkat(2,s.length()),modz-2)*dp[n][s.length()])%modz << endl;
}

Measured memory_bytes: 194048
s = list(input())

ans = [0] * len(s)

cnt = 0
r_temp = 0
l_temp = 0
temp = "R"

for i in range(len(s)):
    if temp != s[i] and temp == "R":
        r_temp = cnt
        cnt = 0
        temp = "L"
    if temp != s[i] and temp == "L":
        l_temp = cnt
        cnt = 0
        temp = "R"
        
        if (r_temp-l_temp)%2 == 0:
            ans[i-l_temp] = (r_temp+l_temp)//2
            ans[i-l_temp-1] = (r_temp+l_temp)//2
        elif r_temp > l_temp:
            if r_temp%2 == 0:
                ans[i-l_temp] = ((r_temp+l_temp-1)//2)+1
                ans[i-l_temp-1] = (r_temp+l_temp-1)//2
            else:
                ans[i-l_temp] = (r_temp+l_temp-1)//2
                ans[i-l_temp-1] = ((r_temp+l_temp-1)//2)+1
        elif r_temp < l_temp:
            if l_temp%2 == 0:
                ans[i-l_temp] = (r_temp+l_temp-1)//2
                ans[i-l_temp-1] = ((r_temp+l_temp-1)//2)+1
            else:
                ans[i-l_temp] = ((r_temp+l_temp-1)//2)+1
                ans[i-l_temp-1] = (r_temp+l_temp-1)//2
            
    if i == len(s)-1:
        l_temp = cnt + 1
        #print(r_temp)
        #print(cnt)
        if (r_temp-l_temp)%2 == 0:
            ans[i-l_temp+1] = (r_temp+l_temp)//2
            ans[i-l_temp] = (r_temp+l_temp)//2
        elif r_temp > l_temp:
            if r_temp%2 == 0:
                ans[i-l_temp+1] = ((r_temp+l_temp-1)//2)+1
                ans[i-l_temp] = (r_temp+l_temp-1)//2
            else:
                ans[i-l_temp+1] = (r_temp+l_temp-1)//2
                ans[i-l_temp] = ((r_temp+l_temp-1)//2)+1
        elif r_temp < l_temp:
            if l_temp%2 == 0:
                ans[i-l_temp+1] = (r_temp+l_temp-1)//2
                ans[i-l_temp] = ((r_temp+l_temp-1)//2)+1
            else:
                ans[i-l_temp+1] = ((r_temp+l_temp-1)//2)+1
                ans[i-l_temp] = (r_temp+l_temp-1)//2
        
    cnt += 1
        
        

print(*ans)



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

int main()
{
	int n;
  cin>>n;
  int a[n][3],b[n][3];
  for(int i=0;i<n;i++)
  {
    cin>>a[i][0]>>a[i][1]>>a[i][2];
    if(i==0)
    {
      b[i][0]=a[i][0];
      b[i][1]=a[i][1];
      b[i][2]=a[i][2];
    }
    else
    {
      b[i][0]=max(b[i-1][1],b[i-1][2])+a[i][0];
      b[i][1]=max(b[i-1][0],b[i-1][2])+a[i][1];
      b[i][2]=max(b[i-1][1],b[i-1][0])+a[i][2];
    }
  }
  cout<<max(b[n-1][0],max(b[n-1][1],b[n-1][2]));
}

Measured memory_bytes: 2560
N = int(input())

lsts = []
for i in range(N):
  A,B = list(map(int, input().split()))
  lst = [A, B]
  lsts.append(lst)

sorted_lsts = sorted(lsts, key=lambda x: x[1])

sum = 0
for k,i in enumerate(sorted_lsts):
  sum += i[0]
  if (sum > i[1]):
    print('No')
    break
  if (k == len(sorted_lsts) - 1):
    print('Yes')

Measured memory_bytes: 40416
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,q;
  std::cin>>n>>q;

  std::vector<std::vector<ll>> graph(n);
  std::vector<ll> score(n),query(n,0);

  rep(i,0,n-1){
    ll a,b;
    std::cin>>a>>b;
    a--;b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  rep(i,0,q){
    ll p,x;
    std::cin>>p>>x;
    p--;
    query[p]+=x;
  }

  struct Point{ll now,prev,value;};

  std::queue<Point> que;

  que.push(Point{0,-1,0});

  while(que.size()){
    Point e=que.front();que.pop();
    score[e.now]=e.value+query[e.now];
    for(ll next:graph[e.now]){
      if(next!=e.prev){
        que.push(Point{next,e.now,e.value+query[e.now]});
      }
    }
  }

  rep(i,0,n)std::cout<<score[i]<<" ";

  return 0;
}


Measured memory_bytes: 22640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {
    int n; cin >> n;
    vi A(n, 0);
    rep(i, n) cin >> A[i];
    sort(A.begin(), A.end(),  greater<int>());
    ll sum = 0;
    rep(i, n-1) {
        sum += A[(i+1)/2];
    }

    cout << sum << endl;



    return 0;
}

Measured memory_bytes: 4040
def div(x):
    D = set()
    for i in range(1, int(x**0.5)+2):
        if x % i == 0:
            D.add(i)
            D.add(x//i)
    return D


n = int(input())
D0 = div(n)
D1 = div(n-1)
D0.remove(1)
D1.remove(1)
cnt = 0
for d in D0:
    n_ = n
    while n_ % d == 0:
        n_ = n_//d
    if n_ % d == 1:
        cnt += 1
cnt += len(D1)
print(cnt)


Measured memory_bytes: 39536
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    string s;
    cin >> s;
    reverse(s.begin(),s.end());
    int n = s.size();
    vector<int> amari(n+1); //i桁目までを2019で割ったあまり
    vector<int> div10(n+1); //10^i%2019
    div10[0] = 1;
    rep(i,n) div10[i+1] = (div10[i] * 10) % 2019;
    amari[0] = 0;  //こいつだけ0が0桁目を指してる
    rep(i,n) amari[i+1] = (amari[i] + (int(s[i]-'0') * div10[i])) % 2019;
    //rep(i,n+1) cout << amari[i] << endl;
    map<int,int> mp;
    for(int i=0; i<=n; i++){
        mp[amari[i]]++;
    }
    ll ans = 0;
    for(int i=0; i<2019; i++){
        ans += (ll)mp[i]*(mp[i]-1)/2;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int hp;
  int num;
  cin >> hp >> num;
  int skill[num];
  for(int i = 0; i < num; i++)
  {
    cin >> skill[i];
  }
  int sum = 0;
  for(int i = 0; i < num; i++)
  {
    sum += skill[i];
  }
  //cout << sum << endl;
  if(sum >= hp)
  {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

public class Main {
  // constant

  static final int MAX_INT = (1 << 31) - 1;

  // inner classes

  static class Point {
    int x, y, d;

    Point(int x, int y) {
      this.x = x;
      this.y = y;
      this.d = MAX_INT;
    }
  }

  // subroutines

  static int dist(Point p0, Point p1) {
    return Math.abs(p1.x - p0.x) + Math.abs(p1.y - p0.y);
  }

  // main

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

    Point[][] nodes = new Point[7][1024];
    int[] nlens = new int[7];

    while (true) {
      String[] wh = br.readLine().trim().split(" ");
      int w = Integer.parseInt(wh[0]);
      int h = Integer.parseInt(wh[1]);
      if (w == 0 && h == 0) break;

      for (int attr = 0; attr < 7; attr++) nlens[attr] = 0;

      Point start = null;
      Point goal = null;

      for (int y = 0; y < h; y++) {
        String hl = br.readLine().trim();

        for (int x = 0; x < w; x++) {
          char ch = hl.charAt(x);

          switch (ch) {
          case 'S':
            nodes[5][0] = start = new Point(x, y);
            nlens[5] = 1;
            break;
          case 'G':
            nodes[6][0] = goal = new Point(x, y);
            nlens[6] = 1;
            break;
          case '.':
            break;
          default:
            int attr = ch - '1';
            nodes[attr][nlens[attr]++] = new Point(x, y);
          }
        }
      }

      if (start == null || goal == null) {
        System.out.println("NA");
        continue;
      }

      int min_dist = MAX_INT;
      int min_attr = -1;

      for (int sattr = 0; sattr < 5; sattr++) {
        start.d = 0;
        goal.d = MAX_INT;

        int[] attrs = new int[6];
        for (int k = 1; k <= 4; k++) attrs[k] = (sattr + k) % 5;
        attrs[0] = 5;
        attrs[5] = 6;

        for (int k = 1; k < 6; k++) {
          int prev_attr = attrs[k - 1];
          int attr0 = attrs[k];

          if (nlens[attr0] == 0) break;

          for (int i = 0; i < nlens[attr0]; i++) {
            Point nd0 = nodes[attr0][i];
            nd0.d = MAX_INT;

            for (int j = 0; j < nlens[prev_attr]; j++) {
              Point p_nd = nodes[prev_attr][j];
              int d0 = p_nd.d + dist(p_nd, nd0);
              if (nd0.d > d0) nd0.d = d0;
            }
          }
        }

        //System.out.println("" + (sattr + 1) + " " + nodes[6][0].d);

        if (goal.d < MAX_INT && min_dist > goal.d) {
          min_dist = goal.d;
          min_attr = sattr + 1;
        }
      }

      if (min_attr < 0)
        System.out.println("NA");
      else
        System.out.println("" + min_attr + " " + min_dist);
    }
  }
}

Measured memory_bytes: 58312
// AOJ 0578
#include<iostream>
#include<string>
using namespace std;

const int NMAX = 200;
int n;
string old;
string news[NMAX];

int solve() {
  int ans = 0, olen = old.length();
  for (int str = 0; str < n; str++) {
    string ns = news[str];
    for (int ni = 0, nlen = ns.length(); ni < nlen; ni++) {
      if (ns[ni] != old[0]) continue;
      for (int step = 1; ni + (olen-1) * step < nlen; step++) {
        bool flag = true;
        for (int oi = 0; oi < olen; oi++) {
          if (ni + oi * step >= nlen or 
              old[oi] != ns[ni + oi * step]) {
            flag = false;
            break;
          }
        }
        if (flag) {
          ans++;
          goto BRK;
        }
      }
    }
  BRK:
    ;
  }
  return ans;
}

int main() {
  cin >> n >> old;
  for (int i = 0; i < n; i++) {
    cin >> news[i];
  }

  cout << solve() << endl;
}

Measured memory_bytes: 1228
fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfLong()
    var ans = 0L
    var left = 0
    var right = 0
    var sum = 0L
    while (left < N) {
        while (right < N && (sum + A[right]) == (sum xor A[right])) {
            sum += A[right]
            right++
        }
        ans += right - left
        sum -= A[left]
        left += 1
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map { it.toLong() }



Measured memory_bytes: 82708
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define all(v) v.begin(), v.end() // sort(all(array))
#define INF 1000000000
#define mod 1000000007
using namespace std;
using ll = long long;
using vi = vector<int>; //vi array(要素数, 初期値)
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>; //vvi table(行数, vi(列数, 初期値))
using vvc = vector<vc>;
using vvs = vector<vs>;
using vvb = vector<vb>;

int main() {
    ll n; cin >> n;
    string ans = "";

    while(n) {
        n--;
        ans += char('a' + (n % 26));
        n /= 26;
    }

    reverse(all(ans));
    cout << ans << endl;
}

Measured memory_bytes: 3632
<?php

    // AtCoder Beginner Contest 162
    // C - Sum of gcd of Tuples (Easy)

    $max = in_int();

    $sum = 0;
    for ($i = 1; $i <= $max; $i++) {
        for ($j = 1; $j <= $max; $j++) {
            for ($k = 1; $k <= $max; $k++) {
                $sum += gcd($i, gcd($j, $k));
            }
        }
    }

    out($sum);

    function gcd($m, $n) {
        if ($n > $m) {
            $tmp = $n;
            $n = $m;
            $n = $tmp;
        }
        while($n !== 0){
            $tmp = $n;
            $n = $m % $n;
            $m = $tmp;
        }
        return $m;
    }


    // -----------------------------------------------------
    function in() { return trim(fgets(STDIN)); }
    function in_int() { return (int)in(); }
    function in_vals() { return explode(' ', in()); }
    function in_ints() { return array_map('intval', in_vals()); }
    function out($s) { echo $s . PHP_EOL; }
    function yes() { out('Yes'); }
    function no() { out('No'); }


Measured memory_bytes: 16096
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */
  NodePointer y;
  y = nil->next;

  while(y->key != key){
    if(y == nil) break;
    y = y->next;
  }

  return y;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  t->prev->next = t->next;
  t->next->prev = t->prev;
    free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  NodePointer x = nil->prev;
  if(x == nil) return;
  deleteNode(x);

}

void delete(int key){
  /* your code */
  NodePointer x;
  x = listSearch(key);
  if(x == nil) return;
  deleteNode(x);

}

void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  /* your code                                                                  
  */
  x->next = nil->next;
  x->prev = nil;
  nil->next = x;
  x->next->prev = x;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L' ) deleteLast();
      } else {
        delete(key); nd++;
      }
      size--;
    }
  }

  printList();
  return 0;
}



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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define MP make_pair
#define PB push_back
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int INF = 1e9 + 7;
const int maxn = 1e5 + 5;

int n;
ll ans;
ll a[maxn], f[maxn];

int main(){
	scanf("%d", &n);
	REP(i, 0, n)
		scanf("%lld", a + i);
	f[n + 1] = 0;
	for(int i = n; i >= 0; --i){
		f[i] = f[i + 1] + a[i];
	}
	ll cur = 1;
	REP(i, 0, n){
		ans += cur;
		cur -= a[i];
		if(cur < 0){
			puts("-1");
			return 0;
		}
		cur = min(cur * 2, f[i + 1]);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 5320
def main():
    import sys
    input = sys.stdin.readline
    s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    i = int(input())
    print(s[i-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
using namespace std;

int main() {
  int A, B; cin >> A >> B;
  for(int i = 0; i <= 10000; i++) {
    if(int(i*0.08) == A && int(i*0.10) == B) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize(2)
//ÄÏ¾©ÊÐµÚÈýÇøOIÎ¯ÌáÐÑÄú£º
//´úÂëÇ§ÍòÌõ£¬-O2µÚÒ»Ìõ¡£
//-O2²»¹æ·¶£¬³¬Ê±Á½ÐÐÀá¡£
// Happy TLE and WA every day!
// by: zxb
#include<bits/stdc++.h>
#define mp              make_pair
#define rep(i,n)        for(int i = 0; i < n; i++)
#define foreach(i,c)    for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define BINF            0x7fffffff
#define INF             0x3f3f3f3f
#define LINF            4557430888798830399
#define pb              push_back
#define F               first
#define S               second
#define Time            clock()/CLOCKS_PER_SEC
#define read            ZXBs_fast_input
#define write           ZXBs_fast_output
//#define usingFiles
using namespace std;

typedef unsigned int ui;
typedef pair<int, int> pii;
typedef long long ll;

inline bool read(int& x){
	x = 0;
	int c;
	int sign = 1;
	while( (c = getchar()) < '0' || c > '9' ) if(c == '-') sign = -1;
	x = c ^ '0';
	while( (c = getchar()) >= '0' && c <= '9' ) x = (x<<3) + (x<<1) + (c ^ '0');
	x *= sign;
	return 1;
}

inline bool write(int x){
	if(x >= 10) write(x / 10);
	putchar(x % 10 + '0');
	return 1;
}

const int rp = 666666;
const bool debug = 1;
const bool I_good_vegetable_a = 1;

signed main(){
	ios::sync_with_stdio(false);
	#ifdef usingFiles
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int n;
	cin >> n;
	cout << ((ll)(n - 2) * 180) << endl;
	return 0;
}

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

#define ll long long

int main(){
    ll n;
    cin >> n;
    ll count = 0, i=1;
    ll z = 0;
    while(n>0){
        if(z==0){
            count = 1;
            z++;
            n = n/2;
            continue;
        }

        i *= 2;
        count += i;
        n = n/2;
        z++;
    }
    cout << count;
    return 0;
}


Measured memory_bytes: 3600
using System;
class Program
{
    static void Main ()
    {
        var input = Console.ReadLine ().Split (' ');
        var a = int.Parse (input[0]);
        var b = int.Parse (input[1]);
        if (a <= 9 && b <= 9)
        {
            Console.WriteLine (a * b);
        }
        else
        {
            Console.WriteLine (-1);
        }
    }
}

Measured memory_bytes: 11092
N=int(input())
W=[input() for _ in range(N)]
ans="Yes"
for i in range(N-1):
    if W[i][-1]!=W[i+1][0]:
        ans="No"
        break
for j in range(N):
    for k in range(N):
        if W[j]==W[k] and j!=k:
            ans="No"
            break
print(ans)

Measured memory_bytes: 38640
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

def main():
    a = sorted(list(map(int, input().split())))
    if a[0] == 5 and a[1] == 5 and a[2] == 7:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <cstdio>

int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

    if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H){
        printf("Yes\n");
    }
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 2684
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int f(int a, int b){
	string s = to_string(a);
	string t = to_string(b);
	return max(s.size(), t.size());
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int ans = INF;
	for(int i = 1; i * i <= n; i++){
		if(n % i == 0){
			ans = min(ans, f(i, n / i));
		}
	}
	cout << ans << endl;
}

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

int main() {
	int a;
	cin>>a;
	int b=(a-a%10)/10;
	int c=a%10;
	if(b==9||c==9){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
/*
author : seryu
title : AGC046A_"Takahashikun, The strider"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

template <typename T>
T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T>
T lcm(T a, T b) { T g = gcd(a, b); return a * b / g; }

void solve()
{
	int x;
	cin >> x;
	int ans;
	if(360 % x == 0)ans = 360/x;
	else ans = lcm(360, x)/x;
	cout << ans << endl;
	return;	
}

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


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////


int main() {

	ll N;
	cin >> N;

	vector<ll> a(N + 1);
	repn(i, N) cin >> a[i];

	
	ll v = 1;
	
	ll ans = 0;
	repn(i, 2 * N) {
		ans++;
		v = a[v];
		if (v == 2) { break; }
	}

	if (ans == 2 * N) { ans = -1; }
	cout << ans;

	system("PAUSE");
}


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

int main()
{
    long long n, t;
    cin >> n >> t;
    long long ans = 0;
    long long start = 0;
    long long stop = t;
    for(int i=0; i<n; i++){
        long long next;
        cin >> next;
        if(i == 0) continue;
        if(stop >= next){
            stop = next + t;
        }else{
            ans += stop-start;
            start = next;
            stop = next + t;
        }
    }
    ans += stop-start;

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

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

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  int N, M;
  cin >> N >> M;
  cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
<?php

list($n,$m) = explode(" ",trim(fgets(STDIN)));

$i=1;
while($i <= $n){
$ans[$i] = 0;
++$i;
}

$i=0;
while($i < $m){
list($a,$b) = explode(" ",trim(fgets(STDIN)));
++$ans[$a];
++$ans[$b];
++$i;
}

echo join("\n",$ans);


Measured memory_bytes: 3956
N = int(input())

k = list()
while(N >= 27):
  a = int(N%26)
  if a==0:
    a =26
  k.insert(0,a)
  N = (N-a)/26

k.insert(0,int(N))
ans = str()
for i in range(len(k)):
  x = k[i] + 64 +32
  ans = ans + str(chr(x))
#print(k)
print(ans)

Measured memory_bytes: 9232
#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 INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  
  vector<ll> L(N);
  vector<ll> R(N);
  ll lgcd=A[0];
  ll rgcd=A[N-1];
  L[0]=lgcd;
  R[N-1]=rgcd;
  FOR(i,1,N){
    lgcd=gcd(lgcd,A[i]);
    L[i]=lgcd;
  }
  REPR(i,N-2){
    rgcd=gcd(rgcd,A[i]);
    R[i]=rgcd;
  }
  
  ll MAX = 0;
  REP(i,N){
    if(i!=0&&i!=N-1){
      ll x = gcd(L[i-1],R[i+1]);
      MAX=max(MAX,x);
    }else if(i==0){
      MAX=max(MAX,R[1]);
    }else{
      MAX=max(MAX,L[N-2]);
    }
  }

  cout << MAX << endl;
}

Measured memory_bytes: 5628