akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main() {
    int n;
    cin >> n;
    int t[n], a[n];
    for (int i = 0; i < n; i++) {
        cin >> t[i] >> a[i];
    } 
    ll T = t[0];
    ll A = a[0];
    for (int i = 1; i < n; i++) {
        ll t_hiritu = T/t[i];
        ll a_hiritu = A/a[i];
        if (T%t[i]) t_hiritu++;
        if (A%a[i]) a_hiritu++;
        ll hiritu = (t_hiritu > a_hiritu) ? t_hiritu : a_hiritu;
        T = t[i] * hiritu;
        A = a[i] * hiritu;
    }
    cout << T + A << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace   std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define double    long double
#define ull       unsigned long long
#define mod       1000000007
#define vi        vector<ll>
#define ppi       pair<ll,pair<ll,ll>>
#define pb        push_back
#define mp        make_pair
#define str       string
#define pi        2*acos(0.0)
#define pr(a,x,n) for(int i=x;i<n;i++){cout<<a[i]<<" ";}
#define p(a)      cout<<a;
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define endl      '\n'
#define all(v)    v.begin(), v.end()
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
int32_t main(){
	kehsihba();
	ll a,b;cin>>a>>b;
	cout<<max({a-b,a+b,a*b});
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N,K;
  cin >> N >> K;
  vector<double> p(N);
  for(int i=0; i<N; i++){
    cin >> p[i];
    double temp = p[i]*(p[i]+1)/2;
    temp /= p[i];
    p[i] = temp;
  }
  double ans = 0;
  for(int i=0; i<K; i++){
    ans += p[i];
  }
  double temp=ans;
  for(int i=K; i<N; i++){
    temp -= p[i-K];
    temp += p[i];
    chmax(ans,temp);
  }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {
		public static void main(String[] args){
	    	Scanner sc =new Scanner(System.in);
	    	int a = sc.nextInt();
	    	int b = sc.nextInt();
	    	double c= sc.nextInt();	
	    	if(a + b >= c) {
				System.out.println("Yes");
			}
	    	else {
	    		System.out.println("No");
	    	}
	    	
	    }
	}


Measured memory_bytes: 23124
//To debug :  g++ -g file.cpp -o code
//to flush output : fflush(stdout) or cout.flush()
//cout<<setprecision(p)<<fixed<<var
//use 1LL<<i to for 64 bit shifting , (ll)2 because by default 2 is ll
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 ll_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 ll_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<ll>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define MOD 998244353
#define ld long double
#define pi acos(-1.0)

#define SZ(x)  (ll)(x.size())

//comment the below if now required

#define ss second.second
#define ff first.first
#define f first
#define s second
#define sf second.first
#define fs first.second


#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int main()
{

    ll n;
   
    string s;

    map<string,ll> m;

    cin>>n;

    while(n--)
    {
        cin>>s;
        ++m[s];

       

    }

 cout<<"AC"<<" x "<<m["AC"]<<"\n";

                cout<<"WA"<<" x "<<m["WA"]<<"\n";

                            cout<<"TLE"<<" x "<<m["TLE"]<<"\n";

                cout<<"RE"<<" x "<<m["RE"]<<"\n";



    return 0;
}

Measured memory_bytes: 3632
#!/usr/bin/perl
#abc85_d.pl
#Sun Jan  7 20:56:39 2018
#

use warnings;
use strict;

my $fir = <STDIN>;
chomp $fir;

my @temp = split(" ",$fir);

my $n = $temp[0];
my $h = $temp[1];

my $loopnum = $n;

my @cut;
my @throw;

while ($loopnum > 0){
	my $stdin = <STDIN>;
	chomp $stdin;
	my @temp = split(" ",$stdin);
	push (@cut, $temp[0]);
	push (@throw, $temp[1]);
	$loopnum--;
}

my $maxcut = 0;

foreach (@cut){
	if ($maxcut < $_){
		$maxcut = $_;
	}
}


my $thrownum;
my $throwdamage = 0;

my @throwkatana;

foreach (@throw){
	if ($maxcut <= $_){
		$thrownum++;
		push (@throwkatana,$_);
		$throwdamage = $throwdamage+$_;
	}
}

if ($throwdamage >= $h){
	my @throwsorted = sort {$b <=> $a} @throwkatana;
	my $throwcount = 1;
	foreach (@throwsorted){
		$h = $h - $_;
#		print "HP: ${h}\n";
		if ($h <= 0){
			print $throwcount,"\n";
			last;
		}
		$throwcount++;
	}
#	print $throwcount,"\n";
}else{	
	my $cutnum = int(($h - $throwdamage)/$maxcut);
	if (($h - $throwdamage)%$maxcut>0){
		$cutnum++;
	}
	print $cutnum+$thrownum,"\n";
}





Measured memory_bytes: 39420
x,y = map(int,input().split())
if x in (1,3,5,7,8,10,12):
    x = 1
elif x in (4,6,9,11):
    x = 2
else:
    x = 3

if y in (1,3,5,7,8,10,12):
    y = 1
elif y in (4,6,9,11):
    y = 2
else:
    y = 3

if x == y:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N,M,sum=0;
	cin>>N>>M;
	std::vector<int> A(M);
	for(int i=0;i<M;i++) cin>>A[i];
	for(int i=0;i<M;i++) sum+=A[i];
	if(sum>N)
	    cout<<-1<<"\n";
	else
	    cout<<(N-sum)<<"\n";
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long  int s,n;
    long long int wt[10100],val[10010];
    cin >> n >> s;
    long long int w[n+1][s+1];
    for(int i=0;i<n;i++)
        {
            cin >> wt[i]  >> val[i];   
        }
    for(int i=0;i<=n;i++)
    {
            for(int j=0;j<=s;j++)
                {
                    if(i==0 || j==0)
                    w[i][j]=0;

                    else if(j>=wt[i-1])
                    {
                        w[i][j]=max((val[i-1]+w[i-1][j-wt[i-1]]),w[i-1][j]);
                    }
                    else 
                    w[i][j]=w[i-1][j];

                }
    }
            cout << w[n][s] << endl ;
        return 0;
}

Measured memory_bytes: 79104
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int mod=1e9+7;

inline void add(int &x,int y){x+=y;if(x>=mod)x-=mod;}
char s[5111];
int n,m,dp[5111][5111];
int main()
{
	get1(n);scanf("%s",s+1);m=strlen(s+1);
	dp[0][0]=1;
	for(int i=0;i<n;i++)for(int j=0;j<=n;j++)
	{
		//backspace
		add(dp[i+1][j-(j>0)],dp[i][j]);
		//0/1
		add(dp[i+1][j+1],dp[i][j]);
		add(dp[i+1][j+1],dp[i][j]);
	}
	for(int i=1;i<=m;i++)dp[n][m]=1ll*dp[n][m]*(mod+1)/2%mod;
	printendl(dp[n][m]);
	return 0;
}

Measured memory_bytes: 100736
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        if(A + B < 10){
            System.out.println(A + B);
        }else if(A + B >= 10){
            System.out.println("error");
        }
    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
    using namespace std;
    
    typedef long long ll;
    
    long long comb(long long n , long long r){
        //cout << "comb_n:" << n << " comb_r:" << r << endl;
        if(n < 0 || r < 0 || r > n){
            cout << "comb-error" << endl;
        }
        if(n - r < r) r = n - r;
        if(r == 0) return 1;
        if(r == 1) return n;
        vector<long> num, deno;
        for(long long k = 0 ; k < r; k++){
            num.push_back(n-r+k+1);
            deno.push_back(k+1);
        }
        long long pivot , offset;
        for(long long p = 2; p <= r ; p++){
            pivot = deno[p-1];
            if(pivot > 1){
                offset = (n - r) % p;
                for(long long k = p - 1 ; k < r; k+= p){
                    num[k - offset] /= pivot;
                    deno[k] /= pivot; 
                }
            }
            
        }
        long long result = 1;
        for(long long k = 0;  k < r ; k++){
            if(num[k] > 1) result *= num[k];
        }
        //cout << "comb:" << result << endl;
        return result;
    }
    
    
    int main(){
        ll  n , a , b;
        cin >> n >> a >> b;
        ll ans = 0;
        ll t;
        vector<ll> v;
        map<ll , ll> mp;
        for(ll i = 0 ; i < n ; i++){
            cin >> t;
            v.push_back(t);
            mp[t] = mp[t] + 1;
        }
        sort(v.begin() , v.end() , greater<ll>() );
        double ans2 = 0;
        ll q = 0;
        for(ll i = 0 ; i < a ; i++){
            ans2 += v[i];
            if(v[i] != v[a-1]){
                q += 1;
            }
        }
        ans2 = ans2 / a * 1.0;
        cout << fixed << setprecision(6) << ans2 << endl;
        if(mp[v[a-1]] == 1){
            cout << 1 << endl;
            return 0;
        }
        ll r;
        r = a - q;
        //cout << "r:"  << r << " q:" << q << endl; 
        if(r < mp[v[a-1]] && v[0] == v[a-1]){
            for(ll i = r ; i <= min(b - q , mp[v[a-1]] ) ; i++){
                //cout << "i:" << i << endl;
                ans += comb(mp[v[a-1]] , i );
            }
        }else if(r < mp[v[a-1]]){
            ans = comb(mp[v[a-1]] , r);
        }else{
            ans = 1;
        }
        cout << ans << endl;
        
        return 0;
    }

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

string S,T;
int k;

int ans=-1;
void solve(int x,vector<int>&nums) {
	if(k>=S.size())throw(false);

	if (x) {

		solve(x - 1, nums);
	}

	while (true) {
		auto ch = S[k];
		if (T[nums[x]] == ch) {
			nums[x]++;
			k++;
			if (x) {
				solve(x - 1, nums);
			}
			if (nums[x] == T.size()) {
				ans=max(ans,x);
				nums[x]=0;
				return;
			}
		}
		else {
			k++;
		}
		
		if (k >= S.size())throw(false);
	}
	
}

int main() {
	
	{
 cin >> S >> T;

		vector<int>nums(100);
		int x=100;
		try {
			solve(x,nums);
		}
		catch(...){

		};
		cout<<ans+1<<endl;
	}


	return 0;
}


Measured memory_bytes: 3332
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>
//#include<ctype.h>
using namespace std;
int main(void){
    int i;
    string s;
    getline(cin,s);
    for(i=0;i<s.size();i++){
        if(isupper(s[i])!=0) s[i]=tolower(s[i]);
        else if(islower(s[i])!=0) s[i]=toupper(s[i]);
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3148
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

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; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}


int solve(int a, int b, int c) {
    if(a % 2 + b % 2 + c % 2 > 0) return 0;
    return 1 + solve((b + c) / 2, (c + a) / 2, (a + b) / 2);
}

signed main(void) {
    int a, b, c; cin >> a >> b >> c;
   if(a == b && b == c && a % 2 + b % 2 + c % 2 == 0) {
       print(-1);
       return 0;
   } 
   print(solve(a, b, c));

    return 0;
}


Measured memory_bytes: 256
# Template 1.0
import sys, re
from decimal import *
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, floor, trunc, log
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()

print(n+n**2+n**3)

Measured memory_bytes: 71032
class LCG:
    def __init__(self, a, b, c, x):
        self.a = a
        self.b = b
        self.c = c
        self.x = x
        self.count = 0

    def get_next(self):
        self.x = (self.a * self.x + self.b) % self.c
        self.count += 1
        return self.x

    def get_count(self):
        return self.count

if __name__ == "__main__":
    while True:
        n, a, b, c, x = map(int, input().split())
        if n == 0: break
        ran = LCG(a, b, c, x)
        reel = map(int, input().split())
        try:
            for r in reel:
                while x != r:
                    x = ran.get_next()
                    if ran.get_count() > 10000:
                        raise Exception
                else:
                    x = ran.get_next() # 同じrが連続した時の対応
            print(ran.get_count() - 1)
        except Exception:
            print(-1)

Measured memory_bytes: 6728
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
  double t, x;
  cin >> t >> x;

  std::cout<<std::fixed<<std::setprecision(10);
  cout << t/x << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

signed main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, n) cin >> l[i];
  int L = *max_element(all(l));
  int sum = accumulate(all(l), 0LL);
  cout << (L < sum - L ? "Yes" : "No") << endl;
  return 0;
}


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

int main(){
  int n;
  int a[1000],b[1000];
  int p[1000000];
  int tmp,ans;

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

  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      if(b[i] > b[j]){
	tmp = a[i];
	a[i] = a[j];
	a[j] = tmp;
	tmp = b[i];
	b[i] = b[j];
	b[j] = tmp;
      }
    }
  }

  p[0] = 0;
  for(int i=1;i<=b[n-1];i++)p[i] = -1;

  for(int i=0;i<n;i++){
    for(int j=b[i]-a[i];j>=0;j--){
      if(p[j]>=0){
	if(p[j+a[i]]<p[j]+1)p[j+a[i]] = p[j]+1;
      } 
    }
  }

  ans = 0;
  for(int i=0;i<=b[n-1];i++){
    if(ans<p[i])ans = p[i];
  }

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

Measured memory_bytes: 0
#include <bits/stdc++.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 msa = 0;
  for (int i=0; i<n; i++){
    for (int j=0; j<i; j++){
      int sa = abs(a.at(i)-a.at(j));
      if (msa<sa) msa = sa;
    }
  }
  
  cout << msa << endl;
  
}


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

int main(){
  int i,j;
  string s;
  cin>>s;
  for(i=0;i<s.size();i++){
    for(j=0;j<i;j++){
      if(s[i]==s[j]){
        cout<<"no";
        return 0;
      }
    }
  }
  cout<<"yes";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<climits>
#include <iomanip>
using namespace std;

int main() {
  int ans=0;
  long long  W = 0;
  long long  H = 0;
  long long  x = 0;
  long long  y = 0;
  cout << fixed;

  cin >> W >> H >> x >> y;

  if(x == W-x && y == H-y ){
    //W, Hの中心
    cout << setprecision(8) << (double)W*H/2.0 << " " << 1 << endl;
    
  }else if(x == W-x || y == H-y){
    //W or Hの二分線上
    cout << setprecision(8) << (double)W*H/2.0 << " " << 0 << endl;
  }else if( y == x){
    //y=x 線上
    cout << setprecision(8) << (double)W*H/2.0 << " " << 0 << endl;    
  }else if( y == -x){
    //y=-x 線上
    cout << setprecision(8) << (double)W*H/2.0 << " " << 0 << endl;    
  }else{
    //
    cout << setprecision(8) << (double)W*H/2.0 << " " << 0 << endl;
  }

}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main () {
	var a,b int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Println(max(a+b, a-b, a*b))
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
typedef long long int ll;
typedef unsigned long long int ull;
ll gcd(ll x,ll y){if(!y)return x;return gcd(y,x%y);}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
void swap(ll *x,ll *y){ll tmp=*x;*x=*y;*y=tmp;}
int asc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}

int main(){
    ll a,b,c,d;scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
    ll GCD=c*d/gcd(max(c,d),min(c,d));

    ll a_c=a/c;
    ll a_d=a/d;
    ll a_cd=a/GCD;
    ll a_cnt=a_c+a_d-a_cd;
    //printf("%lld\n",a-a_cnt);

    ll b_c=b/c;
    ll b_d=b/d;
    ll b_cd=b/GCD;
    ll b_cnt=b_c+b_d-b_cd;
    //printf("%lld %lld\n",b-b_cnt,gcd(d,c));

    ll ans=-(a-a_cnt)+(b-b_cnt);
    if(a%c!=0&&a%d!=0)ans++;
    printf("%lld\n",ans);
}

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

int main() {
  int N, K, result=1, ans=1025;
  cin >> N >> K;
  
  for (int i = 0; i <= N; i++) {
    //cout << i << endl;
    for (int j = 0; j < i; j++) {
      //if (j == 0) result =1;
      //cout << "j : " << j << endl;
      result = result * 2;
    }
    for (int a = 0; a < N-i; a++) {
      //if (result == 0) result = 1;
      //cout  << "a : " << a << endl;
      result = result + K;
    }
    //cout << "result : " << result << endl;
    if (result < ans) ans = result;
    result = 1;
  }

  //ans = 0;
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int n, m, q;
vector<int> a, b, c, d;
int ans;

void DFS(vector<int> A)
{
	if (A.size() == n + 1) {
		int score = 0;
		for (int i = 0; i < q; i++) {
			if (A[b[i]] - A[a[i]] == c[i]) score += d[i];
		}
		ans = max(ans, score);
		return;
	}

	A.push_back(A.back());
	while (A.back() <= m) {
		DFS(A);
		A.back()++;
	}
}

int main()
{
	cin >> n >> m >> q;
	a = b = c = d = vector<int>(q);
	for (int i = 0; i < q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
	ans = 0;
	DFS(vector<int>(1, 1));
	cout << ans << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号  (例) par[3] = 2 : 3の親が2
    vector<ll> rank; // 木の深さ

    UnionFind(ll N) : par(N), rank(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) { // xとyの木を併合
        x = root(x);
        y = root(y);
        if (x == y) return; //xとyの根が同じ(=同じ木にある)時はそのまま

        if(rank[x] < rank[y]){
            par[x] = y;
        }
        else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main(void)
{
    ll N, M, i, j, k, a[10000], b[10000], judge, ans=0;

    cin >> N >> M;

    for(i=1; i<=M; i++){
        cin >> a[i] >> b[i];
    }

    for(i=1; i<=M; i++){ // 取り除く辺
        UnionFind tree(N+1);

        for(j=1; j<=M; j++){
            if(i!=j){
                tree.unite(a[j], b[j]);
            }
        }

        judge = 0;

        for(j=1; j<=N-1; j++){ // 頂点
            for(k=j+1; k<=N; k++){
                if(!tree.same(j, k)) judge = 1;
            }
        }

        if(judge==1) ans++;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	const ll INF = 1e18;
	int N;
	cin >> N;
	vector<ll> h(N + 1, 0);
	for (int i = 1; i <= N; ++i) { cin >> h[i]; }

	vector<ll> dp(N + 1, INF);
	dp[1] = 0;
	for (int i = 1; i < N; ++i) {
		if (i + 1 <= N) {
			dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
		}
		if (i + 2 <= N) {
			dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
		}
	}

	cout << dp[N] << endl;

	return 0;
}


Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

class Data{
	private int time,mass;
	public int getTime(){return time;}
	public int getMass(){return mass;}
	Data(){return;}
	Data(int time, int mass){this.time=time;this.mass=mass;}
}
class DataComparator implements Comparator<Data>{
	public int compare(Data d1, Data d2) {
		return d1.getTime()-d2.getTime();
	}
}
	
public class Main {
	Boolean solve(ArrayList<Data> enter,ArrayList<Data> leave,int m){
		int w=0;
		int i=0,j=0;
		while(i<enter.size()){
			if(enter.get(i).getTime()==leave.get(j).getTime()){
				w+=(enter.get(i++).getMass()-leave.get(j++).getMass());
			}
			else if(enter.get(i).getTime()<leave.get(j).getTime()){
				w+=enter.get(i++).getMass();
			}
			else if(enter.get(i).getTime()>leave.get(j).getTime()){
				w-=leave.get(j++).getMass();
			}
			if(w>m)return false;
		}
		return true;
	}
	
	void io(){
		Scanner sc=new Scanner(System.in);
		while(true){
			ArrayList<Data> enter=new ArrayList<Data>();
			ArrayList<Data> leave=new ArrayList<Data>();
			
			int n=sc.nextInt();
			if(n==0)break;
			for(int i=0;i<n;++i){
				int m=sc.nextInt(),a=sc.nextInt(),b=sc.nextInt();
				enter.add(new Data(a,m));
				leave.add(new Data(b,m));

			}
			Collections.sort(enter,new DataComparator());
			Collections.sort(leave,new DataComparator());
			if(solve(enter,leave,150)){
				System.out.println("OK");
			}
			else{
				System.out.println("NG");
			}
		}
		sc.close();
	}
	
	public static void main(String[] args) {
		new Main().io();
	}

}

Measured memory_bytes: 12000
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()

ans=[0]*N
i=0
while i<N:
    if i<K:
        if T[i]=='r':
            ans[i]=P
        elif T[i]=='s':
            ans[i]=R
        else:
            ans[i]=S
    else:
        if T[i]=='r':
            if T[i-K]=='r'and ans[i-K]==P:
                ans[i]=0
            else:
                ans[i]=P
        elif T[i]=='s':
            if T[i-K]=='s'and ans[i-K]==R:
                ans[i]=0
            else:
                ans[i]=R
        else:
            if T[i-K]=='p'and ans[i-K]==S:
                ans[i]=0
            else:
                ans[i]=S
    i+=1

print(sum(ans))

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

int main() {
  int N, K;
  //N = abcdefgh
  cin >> N >> K;
  int a = 1;
  for (int i = 0; i < N; i ++){
    if (a < K) a *= 2;
    else a += K;
  }
  cout << a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE

	// For getting input from input.txt file
	freopen("input1.txt", "r", stdin);

	// Printing the Output to output.txt file
	freopen("output1.txt", "w", stdout);

#endif
	/*Always stress test, for n=0, n=1, n=10^9,what if n<k and so on */
	/* Please remember 10^7 se bada array is not possible */
	/* Always use pen and paper, don't just look at the screen*/
	/* Try finding a pattern on pen and paper until y0u get it*/
	ll t = 1;
	// cin >> t;
	while (t--)
	{
		string x;
		ll n;
		cin >> n;
		map<string, ll>m;
		for (int i = 0; i < n; ++i)
		{
			cin >> x;
			m[x]++;
		}
		cout << "AC" << " x " << m["AC"] << endl;
		cout << "WA" << " x " << m["WA"] << endl;
		cout << "TLE" << " x " << m["TLE"] << endl;
		cout << "RE" << " x " << m["RE"] << endl;
	}
}



Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstring>
using namespace std;
const int N = 1e6+5;
string s;
int main(){
	cin >> s;
	for(int i = 1; i <= s.length();i++)
		cout << "x";
	cout << endl;
}


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

    using namespace std;

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        unsigned long long a,b;
        cin>>a>>b;
        unsigned long long c=a%b;
        unsigned long long d=b-c;
        cout<<min(c,d);
        return 0;
    }


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

int main(){
	bool osenbei[15][15000][2];
	int h,w,a,b,c,sum,MAXN,ura[10];
	int osenbei2;
	while(true){
		cin>>h>>w;
		if(h==0 && w==0){
			break;
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin>>osenbei2;
				if(osenbei2==1){
					osenbei[i][j][0]=true;
					osenbei[i][j][1]=true;
				}
				else{
					osenbei[i][j][0]=false;
					osenbei[i][j][1]=false;
				}
			}
		}
		a=1;
		for(int k=0;k<h;k++){
			a *= 2;
		}
		MAXN=0;
		for(int i=0;i<a;i++){
			sum=0;
			for(int j=0;j<h;j++){
				b=1;
				for(int k=0;k<j;k++){
					b *= 2;
				}
				ura[j]=(i/b)%2;
				if(ura[j]==1){
					for(int k=0;k<w;k++){
						if(osenbei[j][k][1]==false){
							osenbei[j][k][1]=true;
						}
						else{
							osenbei[j][k][1]=false;
						}
					}
				}
			}
			for(int j=0;j<w;j++){
				c=0;
				for(int k=0;k<h;k++){
					if(osenbei[k][j][1]==false){
						c++;
					}
				}
				sum += max(h-c,c);
			}
			MAXN=max(sum,MAXN);
			for(int j=0;j<h;j++){
				for(int k=0;k<w;k++){
					osenbei[j][k][1]=osenbei[j][k][0];
				}
			}
		}
		cout<<MAXN<<endl;
	}
	return 0;
}

Measured memory_bytes: 1388
# include <cstdio>
# include <algorithm>
# include <cstring>
# include <cmath>
# include <climits>
# include <iostream>
# include <string>
# include <queue>
# include <vector>
# include <set>
# include <map>
# include <cstdlib>
# include <stack>
# include <ctime>
using namespace std;

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define mct(a,b) memset(a,b,sizeof(a))
# define gc getchar()
typedef long long ll;
const int N=1e5+5;
const int inf=0x7fffffff;
const double eps=1e-7;
template <typename T> void read(T &x){
	x=0;int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
	x*=f;
}

int n,t;
int h[N];
int s[N];
int ans;

inline bool cmp(int x,int y){
	return x<y;	
}

int main()
{
	read(n);
	Rep(i,1,n)read(h[i]);
	sort(h+1,h+n+1,cmp);
	Rep(i,1,n)
		Rep(j,i+1,n){
			int x=h[i]+h[j];
			int y=h[j]-h[i];
			ans+=lower_bound(h+1,h+n+1,x)-h-j-1;	
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int a[101];
int main()
{
    int n,m,deal;
    int sum=0,num=0;
    scanf("%d%d",&n,&m);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d",a+i);
        sum+=a[i];
    }
    for (int i = 1; i <= n; i++)
    {
        if(4*a[i]*m>=sum)
        num++;
    }
    if(num>=m)
        printf("Yes");
    else
        printf("No");
    return 0;
}

Measured memory_bytes: 128
let () = Scanf.scanf "%d\n" @@ fun l ->
  let as_ = Array.init l @@ fun _ -> Scanf.scanf "%d\n" @@ fun a -> a in
  let dp1, dp2, dp3, dp4, dp5 =
    Array.fold_left (fun (dp1, dp2, dp3, dp4, dp5) a ->
      a + dp1,
      (if a < 2 then 2 - a else a mod 2) + min dp1 dp2,
      (if a < 1 then 1 else (a + 1) mod 2) + min dp1 (min dp2 dp3),
      (if a < 2 then 2 - a else a mod 2) + min dp1 (min dp2 (min dp3 dp4)),
      a + min dp1 (min dp2 (min dp3 (min dp4 dp5))))
    (0, 0, 0, 0, 0) as_ in
  Printf.printf "%d\n" @@ min dp1 (min dp2 (min dp3 (min dp4 dp5)))


Measured memory_bytes: 7168
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
struct Nums{
    long long n;
    vector<long long> kaijo;
    Nums(int N){
        n=N;
        kaijo.push_back(1);
        for(long long i=1;i<=n;i++){
            kaijo.push_back((kaijo[i-1]*i)%MOD);
        }
    }
    long myPow(long x, long n, long m){
        if(n == 0)
            return 1;
        if(n % 2 == 0)
            return myPow(x * x % m, n / 2, m);
        else
            return x * myPow(x, n - 1, m) % m;
    }
    long long modinv(long long a, long long m) {
        long long b = m, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }
    long long comb(long long N,long long K,long long rest){
        long long res=kaijo[N]*modinv(kaijo[K],rest)%rest;
        res*=modinv(kaijo[N-K],rest);
        res%=rest;
        return res;
    }
};

signed main(){
  int h,w,a,b;cin>>h>>w>>a>>b;
  int res=0;
  Nums lib(h+w+5);
  res+=lib.comb(h+w-2,h-1,MOD);
  rep(i,a){
    int buf=lib.comb(h-a+1+i+b-2,b-1,MOD);
    buf*=lib.comb(h+w-(h-a+1+i+b+1),w-(b+1),MOD);
    buf%=MOD;
    res+=MOD-buf;
    res%=MOD;
  }
  cout<<res<<"\n";
  return 0;
}


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

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

bool isN(double n) {
  return n == (int) n;
}

int main() {
  int n, d;
  cin >> n >> d;

  int x[20][20];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < d; ++j) {
      cin >> x[i][j];
    }
  }

  int count = 0;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      float sq = 0;
      for (int k = 0; k < d; ++k) {
        sq += pow(x[i][k] - x[j][k], 2);
      }
      if (isN(sqrt(sq))) {
        count++;
      }
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = 998244353;
const ll INF = 1LL << 50;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

ll dia = 0;
vector<bool> used(200010,false);
mat G(200010,vec(0));
ll dfs(ll v){
    used[v] = true;
    ll f, s;
    f = s = 0;
    for(ll to: G[v]){
        if(!used[to]){
            ll temp = dfs(to);
            if(temp >= f){
                s = f;
                f = temp;
            }else if(temp >= s){
                s = temp;
            }
        }
    }
    dia = max(dia, f + s);
    return f + 1;
}

int main() {
    cin>>N;
    rep(i,N - 1){
        cin>>A>>B;
        --A; --B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    dfs(0);
    cout<<(dia%3 == 1 ? "Second" : "First")<<endl;
    //cout<<dia<<endl;
}

Measured memory_bytes: 20224
#include <stdio.h>
#include <math.h>
#include <malloc.h>
#include <string.h>
#include<bits/stdc++.h>
#include <iostream>
#include<algorithm>
#include<list>
#include <functional>
#include <map>
#include <deque>
using namespace std;

#define pt(...) prllf(__VA_ARGS__)
#define sf(...) scanf(__VA_ARGS__)
#define fui(p,n,d) for(ll i = p;i <= n; i += d)
#define fut(p,n,d) for(ll t = p;t <= n; t += d)
#define fuj(p,n,d) for(ll j = p;j <= n; j += d)
#define fdi(n,p,d) for(ll i = n;i >= p; i -= d)
#define fdt(n,p,d) for(ll t = n;t >= p; t -= d)
#define fdj(n,p,d) for(ll j = n;j >= p; j -= d)
#define Conn(x,y) x##y
#define ToString(x) #x
#define ll long long
#define MOD 1000000007
#define p(a,b) pow((double)a, b)
#define me(a,b) memset(a,b,sizeof(a))
bool compare(ll a, ll b){return a>b;}

const ll MAX = 1e7+5;
string s;
ll q;
int t[MAX], f[MAX];
string c[MAX];

int main(){
    cin>>s>>q;
    int p = 0;
    fui(1,q,1){
        cin>>t[i];
        if(t[i] == 1 && p == 0){
            p = 1;
        }else if(t[i] == 1 && p == 1) p = 0;
        else{
            cin>>f[i]>>c[i];
            if((f[i] == 1 && p == 0) || (f[i] == 2 && p == 1)){
                s.insert(0,c[i]);
            }else{
                s.insert(s.size(),c[i]);
            }
        }
    }
    if(p == 1) reverse(s.begin(), s.end());
    cout<<s;

    return 0;
}



Measured memory_bytes: 92160
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import math
import itertools
gcd = math.gcd
n  = ni()
def f(cnt):
    ret  = 0
    for i in range(1,10**9):
        ret +=i
        if ret>cnt:
            return i-1
def factorize(n):
    b = 2
    fct = [(1,1)]
    while b * b <= n:
        cnt =0
        while n % b == 0:
            n //= b
            cnt +=1
        if cnt >=1:
            fct.append((b,cnt))
        b = b + 1
    if n > 1:
        fct.append((n,1))
    return fct
d = factorize(n)
ans = 0
for num,cnt in d:
    ans += f(cnt)
print(ans-1)


Measured memory_bytes: 67956
#include<iostream>

int main(){
	int a,b,c,d,i,n;

	while(std::cin>>n&&n){
		i=0;
		for(a=0;a<=9;a++){
			for(b=0;b<=9;b++){
				for(c=0;c<=9;c++){
					for(d=0;d<=9;d++){
						if(a+b+c+d==n){
							i++;
						}
					}
				}	
			}		
		}
		std::cout<<i<<std::endl;
	}
	

    return 0;
}

Measured memory_bytes: 1160
#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*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    string S;

    cin >> N;
    cin >> S;

    vector<ll> ans(N, 0);

    ll temp = 0;
    for(ll i=1; i<N; i++){
        if(S[i] == 'E') temp++;
    }
    ans[0] = temp;

    for(ll i=1; i<N; i++){
        ans[i] = ans[i-1];
        if(S[i-1] == 'W') ans[i]++;
        if(S[i] == 'E') ans[i]--;
    }
    
    auto minmax = minmax_element(ans.begin(), ans.end());

    cout << *minmax.first << endl;

    return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>

using namespace std;

using ll = long long;
using ui = unsigned int;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807;


//AtCoder Beginner Contest 045-C
int main() {
	char S[11];
	scanf("%s", S);
	int len = (int)strlen(S);

	ll result = 0;

	for (int i = 0; i < (1 << (len - 1)); i++) {
		ll keta = 1;

		for (int j = 0; j < len; j++) {
			result += (ll)(S[len - j - 1] - '0') * keta;
			if ((i & (1 << j)) == 0) {
				keta *= 10;
			}
			else {
				keta = 1;
			}
		}
	}


	printf("%lld\n", result);
}


//AtCoder Regular Contest 067-D
/*
int main() {
	ll N;
	scanf("%lld", &N);
	ll A;
	scanf("%lld", &A);
	ll B;
	scanf("%lld", &B);

	vector<ll> X(N);
	for (ll i = 0; i < N; i++) {
		scanf("%lld", &X[i]);
	}

	ll result = 0;

	for (ll i = 0; i < N - 1; i++) {
		ll dist = X[i + 1] - X[i];
		result += min(A * dist, B);
	}

	printf("%lld\n", result);
}
*/

Measured memory_bytes: 256
def main():
    N = int(input())
    wn = [input()]
    ans = True
    for i in range(1, N):
        w = input()
        if ans is False:
            continue
        if wn.count(w) > 0:
            ans = False
        if wn[i - 1][-1] != w[0]:
            ans = False
        wn.append(w)

    if ans is False:
        print('No')
    else:
        print('Yes')


main()


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



int main() {
int A, B;
cin >> A >> B;
string S;
cin >> S;
bool check = 1;
for(int i = 0; i < A+B+1; i++){
if(i != A && S[i] == '-') check = 0;
if(i == A && S[i] != '-') check = 0;


}
if(check == 0)cout << "No" << endl;
else cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <functional>
#include <algorithm>
#include <stack>
#include <list>
#include <queue>
//#include <iostream>
//#include <sstream>
using namespace std;
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define pf printf
#define sf scanf
#define fr(i, a, b) for(int i = a ; i < b ; i++)
#define frr(i, a, b) for(int i = a ; i >= b ; i--)
#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str()
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)
#define deb(x) cout << #x" = " << x << '\n'
#define debd(x) pf("%s = %d\n", #x, x)
#define debs(x) pf("%s = %s\n", #x, s)
#define debll(x) pf("%s = %lld\n", #x, x)
#define has(cont, x) ((cont).find((x)) != (cont).end())
#define sz(x) ((int)(x).size())
//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
//bitmask
int onbit(int x, int pos) {x |= (1 << pos); return pos;}
int offbit(int x, int pos) {x &= ~(1 << pos); return x;}
int test(int x, int pos) {return x & (1 << pos);}
int flip(int x, int pos) {x ^= (1 << pos); return x;}
int lsb(int x) {return x & (-x);}
int onbitall(int x, int pos) {x = (1 << pos)-1; return x;}
//constants
const double EPS = 1e-9;
const double PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
//moves
const int dx1[] = {0, 1, 0, -1};
const int dy1[] = {1, 0, -1, 0};
const int dx2[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy2[] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
//    freopen("input.in", "r", stdin);
	int a, b, c;
	sf("%d %d %d", &a, &b, &c);
	bool yes = ((c-b) == (b-a));
	puts(yes ? "YES" : "NO");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
	while (true){
		int i,S=0;
		char x[1000] = { 0 };
		cin >> x;
		for (i = 0; i < 1000; i++){
			if (x[i] == '\n'){ break; }
			switch (x[i]){
				case '0':S = S + 0;
					break;
				case '1':S = S + 1;
					break;
				case '2':S = S + 2;
					break;
				case '3':S = S + 3;
					break;
				case '4':S = S + 4;
					break;
				case '5':S = S + 5;
					break;
				case '6':S = S + 6;
					break;
				case '7':S = S + 7;
					break;
				case '8':S = S + 8;
					break;
				case '9':S = S + 9;
					break;
			}
		}
		if (S == 0){ break; }
		cout << S << endl;
	}
	return 0;
}

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

int main()
{
	char str[1000001];
	scanf("%s",str);
	int len = strlen(str);
	int i = 0;
	int level = 0;
	while(1)
	{
		if(i == len)
		{
			break;
		}
		else
		{
			if(str[i] == 'O')
			{
				int s = i;
				while(i < len && str[i] == 'O')i++;
				if(i == len)
					break;
				int olen = i-s;
				if(i+olen>len || olen > s)
					continue;
				else if(olen < level)
					continue;
				else
				{
					int j = s-olen;
					for(;j < s;j++)
					{
						if(str[j] != 'J')
							break;
					}
					if(j != s)
						continue;
					for(j = 0;j < olen;j++)
					{
						if(str[i+j] != 'I')
							break;
					}
					if(j != olen)
						continue;
					level = olen;
				}
			}
			else
			{
				i++;
			}
		}
	}
	printf("%d\n",level);
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
using namespace std;
const int N=2e5+5;
int n,m,K,ans;
struct node{
	int x,y;
	bool operator < (node t) const{return x!=t.x?x<t.x:y<t.y;}
}a[N];
int main(){
	scanf("%d%d%d",&n,&m,&K);
	ans=n;
	rep (i,1,K) scanf("%d%d",&a[i].x,&a[i].y);
	sort(a+1,a+1+K);
	int mx=0;
	rep (i,1,K){
		if (a[i].x-a[i].y>mx) return printf("%d\n",a[i].x-1),0;
		if (a[i].x-a[i].y==mx) mx++;
	}
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var S = Console.ReadLine();
            for (var i = 0; i < S.Length; i += 2)
            {
                Console.Write(S[i]);
            }
            Console.WriteLine();
        }
    }
}


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

int main(){ 
    int d,n;
    cin>>d>>n;
    if(d==0){
        if(n==100){
            cout<<101;
        }else{
            cout <<n;
        }
    }else if(d==1){
        if(n==100){
            cout<<10100;
        }else{
            cout<<100*n;
        }
    }else{
        if(n==100){
            cout<<1010000;
        }else{
            cout<<10000*n;
        }
    }
    return 0;
}


Measured memory_bytes: 256