akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

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

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int popcnt(int x) {
    x = (x & 0x55555555) + ((x >>  1) & 0x55555555);
    x = (x & 0x33333333) + ((x >>  2) & 0x33333333);
    x = (x & 0x0F0F0F0F) + ((x >>  4) & 0x0F0F0F0F);
    x = (x & 0x00FF00FF) + ((x >>  8) & 0x00FF00FF);
    x = (x & 0x0000FFFF) + ((x >> 16) & 0x0000FFFF);
    return x;
}

int ntz(int x) {
    int n = 1;
    if ((x & 0x0000FFFF) == 0) { n += 16; x >>= 16; }
    if ((x & 0x000000FF) == 0) { n +=  8; x >>=  8; }
    if ((x & 0x0000000F) == 0) { n +=  4; x >>=  4; }
    if ((x & 0x00000003) == 0) { n +=  2; x >>=  2; } 
    return n - (x & 1);
}

unsigned int low_bit(unsigned int x, int k) {
    return x & ((1 << k) - 1);
}

unsigned int high_bit(unsigned int x, int k) {
    return x & (~((1 << k) - 1));
}


vector<int> f(int N, int A, int B) {
    vector<int> P(1 << N);
    if (N == 1) {
        P[0] = A;
        P[1] = B;
        return P;
    }
    int x = ntz(A ^ B);
    int A0 = (high_bit(A, x + 1) >> 1) ^ low_bit(A, x);
    int B0 = (high_bit(B, x + 1) >> 1) ^ low_bit(B, x);
    int C;
    if (A0 & 1) {
        C = A0 - 1;
    } else {
        C = A0 + 1;
    }
    vector<int> Q = f(N - 1, A0, C);
    vector<int> R = f(N - 1, C, B0);
    REP(i, 1 << (N - 1)) {
        P[i]                  = (high_bit(Q[i], x) << 1) ^ (A & (1 << x)) ^ low_bit(Q[i], x);
        P[(1 << (N - 1)) + i] = (high_bit(R[i], x) << 1) ^ (B & (1 << x)) ^ low_bit(R[i], x);
    }
    return P;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, A, B;
    cin >> N >> A >> B;
    
    if (abs(popcnt(A) - popcnt(B)) % 2 == 0) {
        cout << "NO\n";
    } else {
        cout << "YES\n";
        vector<int> P = f(N, A, B);
        REP(i, (1 << N)) {
            if (i != 0) {
                cout << " ";
            }
            cout << P[i];
        }
        cout << "\n";
    }
    cout << flush;
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  int K = nextInt();
  int k = 0;
  for (int i = 1; i <= N; i += 2) k++;
  if (k >= K) cout << "YES" << endl; else cout << "NO" << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

int main(){
    int flg[30] = {0};
    int N, M;
    int ans;
    cin >> N >> M;
    int nAns;
    for(int i=0; i<N; i++){
        cin >> nAns;
        for(int j=0; j<nAns; j++){
            cin >> ans;
            flg[ans-1] += 1;
        }
    }
    int cnt = 0;
    for(int i=0; i<M; i++){
        if(flg[i]==N){
            cnt += 1;
        }
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
use strict;
use warnings;

my ($n, $l) = split /\s/, <>;

my $s = $l;
my $e = $l + $n - 1;

my $sum = ($s + $e) * $n / 2;

if ($s < 0) {
	if ($e < 0) {
		$sum = $sum - $e;
	}
} else {
	if ($e > 0) {
		$sum = $sum - $s;
	}
}

print $sum, "\n";



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

int main()
{
    int n,k,i,j;
    int vect[100000];
    long long int dp[100000];
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
        cin>>vect[i];
        dp[i]=INT32_MAX;
    }
    dp[0]=0;
    for(i=0;i<n;i++)
    {
        for(j=i-1;j>=max(0,i-k);j--)
        {
            dp[i]=min(dp[i],abs(vect[i]-vect[j])+dp[j]);
            
        }
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  rep(i,sz(s)){
    if(s[i]=='?') cout << "D" ;
    else cout << s[i] ;
  }
  cout  << endl;
  return 0;
}

Measured memory_bytes: 3752
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;

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

const int mod=1e9+7;

int main(){
    ll n,ans=0;
    cin >> n;
    vector<ll> a;
    for(int i=1;i<=n/i;i++){
        if(n%i==0){
            a.push_back(i-1);
            a.push_back(n/i-1);
        }
    }
    a.erase(unique(a.begin(),a.end()),a.end());
    for(int i=0;i<a.size();i++){
        if(a[i]==0) continue;
        if(n%a[i]!=0&&n/(a[i]+1)<a[i])   ans+=a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<unordered_set>
#include<map>
#include<cmath>
#include <iterator>
#include<stack>
#include<queue>
#include <iomanip>
#include<math.h>
#include <limits.h>
#include <numeric>
#include <functional>
#include<fstream>
#include <bitset>
#include <cstring>
using namespace std;

#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
ll a[(int)1e5 + 9], dp[(int)1e5 + 9];
int x, k;
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> x >> k;
	for (int i = 1; i <= x; i++)
		cin >> a[i];
	for (int i=2;i<=x;i++)
		dp[i]=1000000000;
	for (int i = 1; i <= x; i++) {
		for (int j = 1; j <= k; j++) {
			if (i + j <= x) {
				dp[i + j] = min(dp[i + j],dp[i]+abs(a[i + j] - a[i]));
			}
		}
	}
	cout << dp[x];
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    double r;
    cin >> r;
    cout << r * 3.14 * 2 << endl;
}

Measured memory_bytes: 3756
<?php


fscanf(STDIN, "%d", $n);

fscanf(STDIN, "%s", $slimes);
$array = str_split($slimes);

$ans = 0;
$buff = "";
foreach($array as $item){
    if($buff != $item){
        $buff = $item;
        $ans++;
    }
}
echo $ans;

Measured memory_bytes: 11000
def solve():
    s = input()
    s_set = set(s)
    s_set_l = list(s_set)
    if len(s_set) == 2:
        if s.count(s_set_l[0]) == 2 and s.count(s_set_l[1]) == 2:
            print('Yes')
            exit()
    print('No')


if __name__ == '__main__':
    solve()

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

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

    vector<string> s(10);
    s[0] = "pon";
    s[1] = "pon";
    s[2] = "hon";
    s[3] = "bon";
    s[4] = "hon";
    s[5] = "hon";
    s[6] = "pon";
    s[7] = "hon";
    s[8] = "pon";
    s[9] = "hon";
    cout << s[n % 10] << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main() {
    long long n, m;
    cin >> n >> m;
    if (n == 1 && m == 1) cout << 1 << endl;
    else if (n == 1 || m == 1) cout << max(n, m) - 2 << endl;
    else cout << (n - 2) * (m - 2) << endl;
}

Measured memory_bytes: 256
n = int(input())
for i in range(1, n+1):
  x = i
  if x%3 == 0:
    print("", i, end = "")
  else:
    while(x > 0):
      if x%10 == 3:
        print("", i, end = "")
        break
      else:
        x = x//10
print()



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

int main() {
  int N;
  string S;
  cin >> N >> S;
  if (N % 2 == 0) {
    string sliced_S = S.substr(N/2);
    if (S == sliced_S + sliced_S) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    cout << "No" << endl;
  }
}

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

int main() {
  string a,b;
  cin >> a >> b;
  int ans=0;
  for(int i=0;i<a.size();i++){
    if(a.at(i) != b.at(i) )
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3916
#include <stdio.h>
int main(void){
    int n,x,y,i,cnt=0;
    scanf("%d%d",&n,&x);
    int a[n+1];
    a[0]=0;
    for(i=0;i<n;i++){
        scanf("%d",&y);
        a[i+1]=a[i]+y;
    }
    for(i=0;i<=n;i++){
        if(x>=a[i]) cnt++;
    }
    printf("%d",cnt);
}

Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, X = MAP()
print("YES" if A <= X <= A+B else "NO")

Measured memory_bytes: 5148
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

ll c(ll a,ll b){
  if(a*b==0)return 1;
  ll res=1;
  rep(i,b){
    res=res*(a-i)/(i+1);
  }
  return res;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  double ok=0,ng=1e16;
  ll n;cin>>n;
  ll a,b;
  cin>>a>>b;
  vector<double>v(n);
  rep(i,n)cin>>v[i];
  auto check=[&](double k){
    auto tv=v;
    rep(i,n)tv[i]-=k;
    sort(all(tv),greater<double>());
    double su=0LL;
    rep(i,a){
      su+=tv[i];
    }
    rep(j,b+1){
      if(tv[j+a]>0)su+=tv[j+a];
    }
    if(su<0)return 0;
    return 1;
  };
  rep(i,500){
    double nn=(ng+ok)/2;
    if(check(nn))ok=nn;
    else ng=nn;
  }

  cout<<fixed<<setprecision(7)<<ok<<endl;
  double e=1e-2;
  auto tv=v;
  rep(i,n)tv[i]-=ok;
  sort(all(tv),greater<double>());
  //ll sum=0;
  if(abs(tv[a-1])<e){
    double d=tv[a-1];
    ll cnt=0,cnt2=0;
    rep(i,n)cnt+=(abs(tv[i]-d)<e);
    rep(i,a)cnt2+=(abs(tv[i]-d)<e);
    ll res=0LL;
    repi(i,cnt2,min(b-a,cnt-cnt2)+cnt2+1)res+=c(cnt,i);
    //cout<<d<<endl;
    //cout<<cnt<<cnt2<<endl;;
    //cout<<(1LL<<50)<<endl;
    cout<<res<<endl;
  }else {
    double d=tv[a-1];
    ll cnt=0,cnt2=0;
    rep(i,n)cnt+=(abs(tv[i]-d)<e);
    rep(i,a)cnt2+=(abs(tv[i]-d)<e);
    ll res=c(cnt,cnt2);
    //repi(i,cnt2,min(b-a,cnt-cnt2)+cnt2+1)res+=c(cnt,i);
    //cout<<d<<endl;
    //cout<<cnt<<cnt2<<endl;;
    //cout<<(1LL<<50)<<endl;
    cout<<res<<endl;

  }



  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 10e9
#define INFL 10e18;
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modinv(ll a){
	return powm(a,mod-2)%mod;
}
//cout<< fixed << setprecision(10)
int vis[100005];
vector<int>g[100005];
int lev[100005];
void edge(int u,int v)
{
    g[v].pb(u);
    g[u].pb(v);

}

void bfs(int s)
{
	queue<int>q;
	q.push(s);
	vis[s]=1;
	lev[s]=0;
	
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		for(int i=0;i<g[x].size();i++)
		{
			
			
			if(vis[g[x][i]]==0)
			{
				lev[g[x][i]]=x;
				vis[g[x][i]]=1;
				q.push(g[x][i]);
			}
			
		}
		
	}
}

int main(){

    fast;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        int n,m,i,j;
        cin>>n>>m;
        for(i=0;i<m;i++)
        {
        	int u,v;
        	cin>>u>>v;
        	edge(u,v);
		}
	    mem(vis,0);
	    mem(lev,0);
	    bfs(1);
	    for(i=2;i<=n;i++)
	    {
	    	if(lev[i]==0)
	    	{
	    		cout<<"No";
	    		return 0;
			}
		}
		cout<<"Yes\n";
		for(i=2;i<=n;i++)
		cout<<lev[i]<<"\n";
        
        
        
	}

}

Measured memory_bytes: 10964
import java.util.*;

public class Main{
  
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    String S = sc.next();
    
    char[] RB = S.toCharArray();
    int redCount = 0;
    int blueCount = 0;
    for(int i = 0 ; i < N ; i++){
      char rb = RB[i];
      if(rb == 'R'){
        redCount++;
      }else{
        blueCount++;
      }
    }
    
    if(redCount > blueCount){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }

  }  
}

Measured memory_bytes: 35736
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int N, K;

double solve()
{
	double result = 0;
	for (double num = 1; num <= N; num++)
	{
		double q;
		for(q = 0; ; q++)
			if(pow(2, q) >= (double)K/num) break;
		result += pow(0.5, q);
	}
	return result * (1/(double)N);
}

int main()
{
	cin >> N >> K;
	printf("%.12lf\n", solve());
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int main() {
    int N; cin>>N;
    vector<ll> p(N);
    for (int i = 0; i < N; ++i) {
        cin>>p[i]; --p[i];
    }

    vector<ll> a(N),b(N);
    for (int i = 0; i < N; ++i) {
        a[i]=40000ll*(i+1);
        b[i]=40000ll*(N-i);
    }

    for (int i = 0; i < N; ++i) {
        a[p[i]]+=(ll)i;
    }

    for (int i = 0; i <N-1; ++i) {
        cout<<a[i]<<" ";
    }
    cout<<a[N-1]<<endl;

    for (int i = 0; i <N-1; ++i) {
        cout<<b[i]<<" ";
    }
    cout<<b[N-1]<<endl;

    return 0;
}


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

signed main() {
  int n,k,q;
  cin>>n>>k>>q;
  int p[n]={},a;
  for(int i=0;i<q;i++){
    cin>>a;
    p[a-1]++;
  }
  for(int i=0;i<n;i++){
    if(k-q+p[i]>0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    string a;
    cin >> a;
    a[3]='8';
    cout << a << endl;
}


Measured memory_bytes: 256
import sys

def main():
    N = int(sys.stdin.readline())
    X = list(map(int, sys.stdin.readline().rstrip().split()))
    
    x_asc = sorted(X)
    m1, m2 = x_asc[N//2-1], x_asc[N//2]
    for x in X:
        if x <= m1:
            print(m2)
        else:
            print(m1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 26772
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
const int w=5e5+5;
const ll mod=998244353;
int n,m;
char a[w];
int b[w];
int main()
{
    int i,j;
    int k;
    cin>>n>>k;
    int r,s,p;
    cin>>r>>s>>p;
    scanf("%s",a+1);
    ll ans=0;
    for(i=1;i<=n;i++)
    {
        if(i>k&&a[i-k]==a[i]&&b[i-k]==0)
            b[i]=1;
        else
        {
            if(a[i]=='r')
                ans+=p;
            else if(a[i]=='s')
                ans+=r;
            else if(a[i]=='p')
                ans+=s;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int num = scan.nextInt();
			
			int b = num%1000/100;;
			int s = num%1000%100/10;
			int g = num%1000%100%10;
			
			if(num == g*100+s*10+b){
				System.out.println("Yes");
				System.out.println();
			}
			else{
				System.out.println("No");
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define rep(i, x, n) for(int i = x; i < n; i++)
#define repr(i, x, n) for(int i = x; i > n; i--)
#define pii pair<int,int>
#define ll long long
#define pb push_back
#define yes puts("YES")
#define no puts("NO")
#define PI 3.141592653589793238462643383279
const long long iinf = INT64_MAX - 1;
const int inf = INT32_MAX - 1;
const int MOD = (1e6+3);
int dir4[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};
int dir8[8][2] = {{1,0},{-1,0},{0,1},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};
int knight[8][2] = {{2,1},{2,-1},{-2,1},{-2,-1},{1,2},{-1,2},{1,-2},{-1,-2}};
using namespace std;

void solve()
{
    int n; cin >> n;
    string s;
    set<string> ans;
    for(int i = 0; i < n; i++){
        cin >> s;
        ans.insert(s);
    }
    cout << ans.size();

}
#define testcases 0             // 0 -> no test case. 1 -> test case
int main()
{
	int t = 1;

    if(testcases) cin >> t;

	// int i = 1;
	while(t--){
	// cout << "Case #" << i++ << ": \n";
	solve();
	// if(t)printf("\n");
	}
	return 0;
}

Measured memory_bytes: 19084
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(){
  int N,A,B;
  scanf("%d %d %d",&N,&A,&B);

  if(N*A<B)printf("%d\n",N*A);
  else printf("%d\n",B);

  return 0;
}


Measured memory_bytes: 128
using System;

namespace _0538
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0)
                {
                    break;
                }
                int m = int.Parse(Console.ReadLine());
                string s = Console.ReadLine();
                string IOI = "I";
                for (int i = 0; i < n; i++)
                {
                    IOI = IOI + "OI";
                }
                int x = 0;
                int flag = 1;
                for (int i = 1; i < m; i++)
                {
                    if (s[i - 1] != s[i])
                    {
                        flag++;
                        if (flag >= IOI.Length && s[i] == 'I')
                        {
                            x++;
                        }
                    }
                    else
                    {
                        flag = 1;
                    }
                }
                Console.WriteLine(x);
            }
        }
    }
}

Measured memory_bytes: 15432
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int w[10],k[10];
  for(int i=0;i<10;i++)scanf("%d",&w[i]);
  for(int i=0;i<10;i++)scanf("%d",&k[i]);
  sort(w,w+10);
  sort(k,k+10);
  printf("%d %d\n",w[9]+w[8]+w[7],k[9]+k[8]+k[7]);
}

Measured memory_bytes: 1204
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  int N, M; readf("%d %d\n", &N, &M);
  writeln(N == M ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dbg(x) cerr << #x << " : " << x << endl;
const ll mod=1e9+7;
int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for(ll i=0;i<n;i++) cin >> a[i];
    ll inv=0;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            inv+=(a[i]>a[j]);
        }
    }
    ll ans=inv*k;
    vector<ll> cnt(2002,0);
    for(ll x:a) cnt[x]++;
    vector<ll> cnt1=cnt;
    for(ll i=2000;i>=0;i--){
        cnt1[i]+=cnt1[i+1];
    }
    ll sthg=0;
    for(ll i=0;i<=2000;i++){
        sthg+=cnt[i]*cnt1[i+1];
    }
    sthg = sthg*k%mod*(k-1)%mod*(mod+1)/2%mod;
    ans = (ans + sthg)%mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

int main() {
	ll N, M;
	cin >> N >> M;
	auto graph = make_vec_nd((ll)0, N, 0);
	pair<ll, ll> some_edge;
	for (ll i = 0; i < M; i++) {
		ll A, B;
		cin >> A >> B;
		A--;
		B--;
		graph[A].push_back(B);
		graph[B].push_back(A);
		if (i == 0) {
			some_edge = {A, B};
		}
	}
	vector<bool> used(N);
	used[some_edge.first] = true;
	used[some_edge.second] = true;
	deque<ll> path;
	path.push_front(some_edge.first);
	path.push_back(some_edge.second);
	while (true) {
		bool found = false;
		for (ll v : graph[path.front()]) {
			if (!used[v]) {
				path.push_front(v);
				found = true;
				used[v] = true;
				break;
			}
		}
		if (!found) {
			break;
		}
	}
	while (true) {
		bool found = false;
		for (ll v : graph[path.back()]) {
			if (!used[v]) {
				path.push_back(v);
				found = true;
				used[v] = true;
				break;
			}
		}
		if (!found) {
			break;
		}
	}
	cout << path.size() << endl;
	for (ll i = 0; i < path.size(); i++) {
		cout << path[i] + 1;
		if (i < path.size() - 1) {
			cout << " ";
		}
	}
	cout << endl;
}


Measured memory_bytes: 7168
S = input().strip()
b = "R"
r = 1
xs = []
for c in S[1:]:
    if c == b:
        r += 1
    else:
        xs.append(r)
        r = 1
    b = c
xs.append(r)
rs = []
for i in range(len(xs)//2):
    l, r = xs[2*i], xs[2*i+1]
    rs += [0] * (l-1)
    rs += [l//2+l%2+r//2, l//2+r//2+r%2]
    rs += [0] * (r-1)
print(*rs)


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

int main() {
  char S[4];
  char T[4];
  for (int i = 0; i < 3; i++) cin >> S[i];
  for (int i = 0; i < 3; i++) cin >> T[i];
  
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    if (S[i] == T[i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	xs := make([]int, n+1)
	for i := range xs {
		xs[i] = 1
	}
	var (
		sc = bufio.NewScanner(os.Stdin)
		a  int
	)
	for i := 0; i < m; i++ {
		sc.Scan()
		a, _ = strconv.Atoi(sc.Text())
		xs[a] = 0
	}
	var (
		f2     = 1
		f1, f0 = xs[1], xs[0]
	)
	for i := 2; i <= n; i++ {
		f2 = (f1*xs[i-1] + f0*xs[i-2]) % 1000000007
		f1, f0 = f2, f1
	}
	fmt.Println(f2)
}


Measured memory_bytes: 1920
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()


n = ni()
a = na()

dp = [[-99999999] * (n+1) for _ in range(n+1)]
dp[a[0]][a[1]] = 0

dprow = [-99999999] * (n+1)
dprow[a[0]] = 0
dprow[a[1]] = 0

margin = 0
for i in range(2, 3*n-2, 3):
    if a[i] == a[i+1] and a[i+1] == a[i+2]:
        margin += 1
    else:
        q = []
        for jj in range(i, i+3):
            if dp[a[jj]][a[jj]] < 0:
                continue
            if jj == i:
                q.append((a[i+1], a[i+2], dp[a[jj]][a[jj]] + 1))
            if jj == i+1:
                q.append((a[i], a[i+2], dp[a[jj]][a[jj]] + 1))
            if jj == i+2:
                q.append((a[i], a[i+1], dp[a[jj]][a[jj]] + 1))

        for jj in range(i, i+3):
            for kk in range(jj+1, i+3):
                if a[jj] == a[kk]:
                    rem = i+i+1+i+2-jj-kk
                    for t in range(n+1):
                        if dp[a[jj]][t] >= 0:
                            q.append((t, a[rem], dp[a[jj]][t] + 1))
                        if dp[t][a[jj]] >= 0:
                            q.append((t, a[rem], dp[t][a[jj]] + 1))
        for j in range(n+1):
            if dprow[j] >= 0:
                for k in (a[i], a[i + 1], a[i + 2]):
                    q.append((j, k, dprow[j]))
        mx = max(dprow)
        for jj in range(i, i+3):
            for kk in range(jj+1, i+3):
                q.append((a[jj], a[kk], mx))
        for u in q:
            dp[u[0]][u[1]] = max(dp[u[0]][u[1]], u[2])
            dprow[u[0]] = max(dprow[u[0]], u[2])
            dprow[u[1]] = max(dprow[u[1]], u[2])
        # print(i)
        # for row in dp:
        #     print(row)
        # print(dprow)
        # print(dpcol)

ans = max(*dprow, dp[a[-1]][a[-1]] + 1)

print(ans+margin)


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

int main() {
  int K;
  cin >> K;
  if (K % 7 == 0) {
    K /= 7;
  }
  int M = 1;
  for (int i = 0; i < K; i++) {
    M = M % K;
    if (M == 0) {
      cout << i + 1 << endl;
      break;
    }
    else if (i == K - 1) {
      cout << -1 << endl;
      break;
    }
    M = M * 10 + 1;
  }
}

Measured memory_bytes: 3672
#include<iostream>
#include<string>
#include <vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	int n, l;
	cin >> n >> l;
	vs s(n);
	rep(i, n) cin >> s[i];
	vsort(s);
	rep(i, n) cout << s[i];
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define MAX_V 310

ll d[MAX_V][MAX_V];
int V, E, L;

void warshall_floyd() {
    for(int k=0; k<V; k++)
        for(int i=0; i<V; i++)
            for(int j=0; j<V; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}


int main(){
    cin >> V >> E >> L;
    rep(i, V){
        rep(j, V){
            d[i][j] = INF;
        }
    }
    rep(i, E){
        int a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        d[a][b] = c;
        d[b][a] = c;
    }

    warshall_floyd();

    // rep(i, V){
    //     rep(j, V){
    //         printf("%d %d %d\n", i, j, d[i][j]);
    //     }
    //     cout << endl;
    // }


    rep(i, V){
        rep(j, V){
            if(d[i][j] <= L){
                d[i][j] = 1;
            }else{
                d[i][j] = INF;
            }
        }
    }

    warshall_floyd();

    // rep(i, V){
    //     rep(j, V){
    //         printf("%d %d %d\n", i, j, d[i][j]);
    //     }
    // }

    int q;
    cin >> q;
    rep(i, q){
        int s, t;
        cin >> s >> t;
        --s;
        --t;
        if(d[s][t]==INF) {
            cout << -1 << endl;
        } else{
            cout << d[s][t]-1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1280
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};
bool use[100010];


vector<edge> te[100010];
vector<edge> fe[100010];
int d[100100];
ll rec(int num) {
	if (num == 0) return 0;
	return rec(num - 1) + num;
}
ll gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll calc(ll b,ll n){
	if (n < b) return n;
	return calc(b, n / b) + n % b;
}

void Solve() {

	ll n,p;
	cin >> n >> p;
	if (n == 1) {
		cout << p << endl;
		return;
	}
	ll res = 1;
	for (ll i = 2; i * i <= p; i++)
	{
		ll c = 0;
		while (p % i == 0)
		{
			p /= i;
			c++;
		}
		res *= pow(i,(c / n));
	}

	cout << res << endl;
}


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



Measured memory_bytes: 6016
from enum import Enum
import sys
import math
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
class Info:
    def __init__(self,arg_start,arg_end,arg_S):
        self.start = arg_start
        self.end = arg_end
        self.S = arg_S
 
 
LOC = []
POOL = []
 
line = input()
loc = 0
sum_S = 0
 
for ch in line:
 
    if ch == '\\':
 
        LOC.append(loc)
 
    elif ch == '/':
 
        if len(LOC) == 0:
            continue
 
        tmp_start = int(LOC.pop())
        tmp_end = loc
        tmp_S = tmp_end-tmp_start;
        sum_S += tmp_S;
 
        #既に突っ込まれている池の断片が、今回の断片の部分区間になるなら統合する
        while len(POOL) > 0:
            if POOL[-1].start > tmp_start and POOL[-1].end < tmp_end:
                tmp_S += POOL[-1].S
                POOL.pop()
            else:
                break
 
        POOL.append(Info(tmp_start,tmp_end,tmp_S))
 
    else:
        pass
 
    loc += 1
 
print("%d"%(sum_S))
print("%d"%(len(POOL)),end = "")
 
while len(POOL) > 0:
    print(" %d"%(POOL[0].S),end = "") #先頭から
    POOL.pop(0)
 
print()


Measured memory_bytes: 7528
def d_make_them_even(H, W, A):
    from itertools import product
    # グリッドを -1 の壁で包む
    wall = [[-1] * (W + 2)]
    grid = wall + [[-1] + row + [-1] for row in A] + wall

    ans_tmp = []
    for h, w in product(range(1, H + 1), range(1, W + 1)):
        if grid[h][w] % 2 == 1:
            # コイン1枚をグリッドの右か下に押し付ける
            for dh, dw in zip((0, 1), (1, 0)):
                nh, nw = h + dh, w + dw
                if grid[nh][nw] != -1:
                    grid[nh][nw] += 1
                    grid[h][w] -= 1
                    ans_tmp.append('{0} {1} {2} {3}'.format(h, w, nh, nw))
                    break
    # ans = '\n'.join([str(len(ans_tmp)), *ans_tmp]) # Python3.5 より前だとこの書き方ができない
    ans = str(len(ans_tmp)) + '\n' + '\n'.join(ans_tmp)
    return ans

H, W = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for j in range(H)]
print(d_make_them_even(H, W, A))

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

void solve(long long N, long long A, long long B, vector<long long> P) {
  int c[3] = {};
  for(int i = 0 ; i < P.size() ; i++){
    if( P[i] <= A ) c[0]++;
    else if( P[i] >= B+1) c[1]++;
    else c[2]++;
  }
  cout << min({c[0], c[1], c[2]}) << endl;
}

int main() {

  long long N;
  scanf("%lld", &N);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  vector<long long> P(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &P[i]);
  }
  solve(N, A, B, P);
  return 0;
}


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

int main() {
	string s; cin >> s;
	int gx, gy; cin >> gx >> gy;

	int xx, mode = 0, cnt = 0, spe = 1;
	vector<int>idx, idy;
	for (int i = 0; i <= s.size(); i++) {
		if (s[i] == 'T' || i == s.size()) {
			if (spe)xx = cnt, spe = 0;
			else if (mode == 0)idx.push_back(cnt);
			else idy.push_back(cnt);
			mode ^= 1; cnt = 0;
		}
		else cnt++;
	}

	set<int>canX = { 0 }, canY = { 0 };
	for (auto&& sx : idx) {
		set<int>res(canX);
		canX.clear();
		for (auto&& x : res) {
			canX.insert(x + sx); canX.insert(x - sx);
		}
	}
	for (auto&& sy : idy) {
		set<int>res(canY);
		canY.clear();
		for (auto&& y : res) {
			canY.insert(y + sy); canY.insert(y - sy);
		}
	}
	if (canX.count(gx - xx) && canY.count(gy))cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

using lli = long long int;
using ulli = unsigned long long int;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

lli A, B, N;
lli ans;

int main(){
	cin >> N >> A >> B;
	ans = (N-2)*(B-A) + 1;
	if (ans < 0) ans = 0;
	cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc170/abc170_c.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int X, N;
  cin >> X >> N;
  
  if (N == 0) {
    cout << X << endl;
    return 0;
  }

  map<int, int> m;
  rep(i, N) {
    int p;
    cin >> p;
    m[p]++;
  }

  ll ans = X;
  int MAX = 101;
  for (int i = X; i <= 101; i++) {
    if (!m[i]) {
      MAX = i;
      break;
    }
  }

  int MIN = -1;
  for (int i = X - 1; i > -1; i--) {
    if (!m[i]) {
      MIN = i;
      break;
    }
  }

  if (abs(X - MIN) > abs(X - MAX)) {
    ans = MAX;
  } else {
    ans = MIN;
  }

  cout << ans << endl;
}

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

using namespace std;

const int MN = 123456;
int n, k;
int a[MN], dp[MN];

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

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

    fill(dp + 1, dp + n, numeric_limits<int>::max());
    for (int i = 0; i < n - 1; i++) {
        for (int j = 1; j <= k; j++) {
            if (i + j >= n) break;
            dp[i + j] = min(dp[i + j], dp[i] + abs(a[i] - a[i + j]));
        }
    }
    cout << dp[n - 1] << '\n';
    return 0;
}

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

typedef long long ll;


int main()
{
	string s;

	cin >> s;

	ll num = 0;

	for(int i = 0; i < s.size(); i++){
		num += s[i] - '0';
	}

	if(num % 9 == 0)
		cout << "Yes\n";
	
	else
		cout << "No\n";

}

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


int main() {
    int n;
    int num;
    char mark;
    bool cards[4][13] = {false};
    cin >> n;
    for (int i=0; i<n; ++i) {
        cin >> mark >> num;
        switch(mark) {
        case 'S':
            cards[0][num-1] = true;
            break;
        case 'H':
            cards[1][num-1] = true;
            break;
        case 'C':
            cards[2][num-1] = true;
            break;
        case 'D':
            cards[3][num-1] = true;
            break;
        default:
            break;
        }
    }
    
    for (int i=0; i<4; ++i) {
        for (int j=0; j<13; ++j) {
            if (cards[i][j] == false) {
                if (i == 0) {
                    cout << 'S' << ' ' << j+1 << endl; 
                }else if (i == 1) {
                    cout << 'H' << ' ' << j+1 << endl;
                }else if (i == 2) {
                    cout << 'C' << ' ' << j+1 << endl;
                }else{
                    cout << 'D' << ' ' << j+1 << endl;
                }
            }
        }
    }
    return 0;
}




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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

  int n,k; cin >> n >> k;
  vector<int> a(n);
  int sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
  }

  vector<int> ans;
  for(int i = 1; i <= sqrt(sum); i++){
    if(sum%i == 0){
      ans.push_back(i);
      ans.push_back(sum/i);
    }
  }

  int res = 0;
  for(int p : ans){
    vector<int> v = a;
    for(int i = 0; i < n; i++){
      v[i] = a[i]%p;
    }
    sort(v.begin(),v.end());

    vector<int> small(n),large(n);
    for(int i = 0; i < n; i++){
      if(i == 0) small[i] = v[i], large[i] = p - v[i];
      else {
        small[i] = small[i-1] + v[i];
        large[i] = large[i-1] + p - v[i];
      }
    }

    // +1 + -1 == 0 より、(Σa)%ans == 0, ansの候補はΣaの約数
    // -方向の操作の和から+方向の操作の==0の必要があるが、一つの変更で
    // 変化量はansであり、それぞれの操作の和はansで割り切れることに変わりはない
    // -方向の操作の和 * 方向の操作 == d * d
    for(int i = 0; i < n; i++){
      int t = max(small[i],large[n-1] - large[i]);
      if(t <= k) res = max(res,p);
    }
  }
  cout << res << endl;

  return 0;
}


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

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll k, a, b,ans = 0;

int main(){
	cin >> k >> a >> b;
	if (a < b and k > a) {
		ans = a;
		ll s = k - a + 1;
		ans += s % 2 + (b - a) * (s / 2);
	}
	ans = max(ans, k + 1);
	cout << ans << endl;
}


Measured memory_bytes: 256
N,A,B = map( int, input().split() )
C = B - A
if C % 2 == 0:
    print( C // 2 )
else:
    start = A - 1
    position_start = B - start - 1
    D = ( position_start - 1 ) // 2 + start + 1 
    
    last = N - B
    position_last = A + last + 1
    E = ( N - position_last ) // 2 + last + 1
    
    print(min(D,E))

Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>

template <class T>
T gcd(T n, T m) {
    if (n < 0) n = -n;
    if (m < 0) m = -m;
    while (m != 0) {
        n %= m;
        std::swap(n, m);
    }
    return n;
}

using lint = long long;

lint pow(lint b, lint n, lint m) {
    lint x = 1;
    b %= m;

    while (n > 0) {
        if (n & 1) (x *= b) %= m;
        n >>= 1;
        (b *= b) %= m;
    }
    return x;
}

lint totient(lint n) {
    lint m = n;

    for (lint p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;

        m = m / p * (p - 1);
        while (n % p == 0) n /= p;
    }

    if (n > 1) m = m / n * (n - 1);

    return m;
}

void solve() {
    lint n;
    std::cin >> n;

    lint l = 1;
    {
        auto nn = n;
        for (lint p = 2; p * p <= nn; ++p) {
            if (nn % p != 0) continue;

            l *= (p - 1) / gcd(l, p - 1);

            if (nn % (p * p) == 0) {
                std::cout << -1 << std::endl;
                return;
            }
            nn /= p;
        }

        if (nn > 1) {
            auto p = nn;
            l *= (p - 1) / gcd(l, p - 1);
        }
    }

    if (gcd(n, l) != 1) {
        std::cout << -1 << std::endl;
        return;
    }

    auto m = totient(l);

    auto ans = m;
    for (lint p = 1; p * p <= m; ++p) {
        if (m % p != 0) continue;

        if (pow(n, p, l) == 1) ans = std::min(ans, p);
        if (pow(n, m / p, l) == 1) ans = std::min(ans, m / p);
    }

    std::cout << ans << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}



Measured memory_bytes: 3204
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

int n;
int[] a;

void main() {
    scan(n);
    a = readln.split.to!(int[]);

    auto b = DList!int();

    foreach (i ; 0 .. n) {
        if (i & 1) {
            b.insertBack(a[i]);
        }
        else {
            b.insertFront(a[i]);
        }
    }

    if (n & 1) {
        foreach (i ; 0 .. n) {
            writef("%d%c", b.front, i < n - 1 ? ' ' : '\n');
            b.removeFront();
        }
    }
    else {
        foreach (i ; 0 .. n) {
            writef("%d%c", b.back, i < n - 1 ? ' ' : '\n');
            b.removeBack();
        }
    }
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 20080
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    for(ll i=k; i<n; i++) (a[i] > a[i-k]) ? Yes() : No();
}

Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 N;
  cin >> N;
  vector<i64> A(N);
  rep(i,0,N) cin >> A[i];
  map<i64, i64> mp;
  i64 era = 0;
  rep(i,0,N) {
    mp[A[i]]++;
    if(mp[A[i]] > 1) {
      era++;
    }
  }
  if(era % 2 == 1) {
    cout << mp.size() - 1 << endl;
  }
  else {
    cout << mp.size() << endl;
  }
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long int
#define db double
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define endl "\n"
#define mp make_pair
#define f first
#define se second
#define pi 3.14159265358979
//ll string_inp() {cin.get(); for(int i =0;i<n;i++){ getline(cin,s[i]);}}
ll gcd(ll a, ll b){ if (a == 0) return b;  return gcd(b % a, a);  }
ll power(ll x, ll y, ll mod = 2e18) {ll ans = 1;x %= mod;while(y){if(y&1) ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
ll modInverse(ll a, ll m) { ll m0 = m; ll y = 0, x = 1; if (m == 1) return 0; while (a > 1) { ll q = a / m; ll t = m; m = a % m,a = t; t = y; y = x - q * y; x = t; } if(x < 0) x += m0;return x;}
int takemod(int a, int mod = MOD){a%=mod;if(a<0)a+=mod;return a;}
ll binsearch(std::vector<ll>& nums, ll target) {ll n = nums.size();ll l = 0;ll r = n-1;while(l<=r){ll mid = l+ (r-l)/2;if(nums[mid]==target)return mid;else if(nums[mid]>target)r = mid-1;else l = mid+1;}return -1;}
bool isPowerOfTwo (int x) {return x && (!(x&(x-1))); }

using namespace std;

int main()
{
   fastio
   ll t,y;
   cin>>t>>y;
   cout<<t*y<<endl;


}




Measured memory_bytes: 3648
#include <stdio.h>

int main(int argc, char const *argv[]){
  long long a, b, c, answer, n;
  
  scanf("%lld %lld %lld %lld", &a, &b, &c, &n);
  
  answer = ((n%2==0) ? 1 :-1) * (a - b);

  printf("%lld", answer);
  
  return 0;
}

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

const int maxn=2e5+7;
int a[maxn],n,k;
long long ans;

int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;++i) scanf("%d",a+i);
	sort(a+1,a+n+1);
	for(int i=1;i<=n-k;++i) {
		ans+=a[i];
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<list>
#include<map>
#include<iomanip>
#include<iostream>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
#include<memory.h>
using namespace std;
int i,n,a[52];
long long x;
string s,t;
int main(){
	memset(a,0,sizeof(a));
	cin>>n;
	cin>>s;
	cin>>t;
	if(s[0]==s[1]){
		i=2;
		x=6;
	}
	else{
		i=1;
		x=3;
	}
	for(;i<s.size();){
    	if(s[i]==s[i+1]){
			if(s[i-2]==s[i-1])
				x=x*3%1000000007;
			else 
				x=x*2%1000000007;
			i+=2;
    	}
	    else if(s[i-1]==t[i-1]){
	    	x=x*2%1000000007;
			i++;
		}
	    else 
			i++;
	}
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys

n = int(sys.stdin.readline().rstrip()) 
s, t = [], []
for _ in range(n):
    si, ti = sys.stdin.readline().split()
    s.append(si); t.append(int(ti))
x = sys.stdin.readline().rstrip()

def main():
    cum_t = t[1:n] + [0]
    for i in range(n-1, 0, -1):
        cum_t[i-1] += cum_t[i]
    
    return cum_t[s.index(x)]

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3064