akhauriyash/Code-Regression huggingface dataset:
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = line[0];
    let k = line[1];

    if k > (n-1)*(n-2)/2 {
        println!("-1");
    } else {
        let m = (n-1)*(n-2)/2 - k;
        println!("{}", n-1+m);
        for i in 1..n {
            println!("1 {}",i+1);
        }
        let mut j = 2;
        let mut k = 3;
        for i in 0..m {
            println!("{} {}", j, k);
            k += 1;
            if k > n {
                j += 1;
                k = j + 1;
            }
        }
    }
}


Measured memory_bytes: 4352
#include <cstdio>
int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++)
    {
        if (i % 2 == 0)
            printf("%d %d\n", 1 + i / 2, m + 1 - i / 2);
        else
            printf("%d %d\n", m + 2 + i / 2, 2 * m + 1 - i / 2);
    }
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
//#define TEST
const ll MOD = 1e9+7;

ll powmod(ll a, ll n){
    ll rez = 1;
    while(n){
        if (n&1)
            rez = rez * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return rez;
}

ll inv(ll a){
    return powmod(a, MOD-2);
}

vector<ll> fact;
ll comb(ll n, ll k){
    return fact[n] * inv(fact[k] * fact[n-k] % MOD) % MOD;
}

int main(int argc, char** argv) {
    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\stdout", "w", stdout);
    }

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

    ll pa = a * inv(a+b) % MOD;
    ll pb = b * inv(a+b) % MOD;

    fact.resize(2*n+1);
    fact[0] = 1;
    FOR1(i, 2*n)
        fact[i] = fact[i-1] * i % MOD;

    vector<ll> pas(n+1), pbs(n+1);
    pas[0] = pbs[0] = 1;
    FOR1(i, n){
        pas[i] = pas[i-1] * pa % MOD;
        pbs[i] = pbs[i-1] * pb % MOD;
    }

    ll sol = 0;
    FOR(k, n){
        sol += (n+k) * pas[n] % MOD * pbs[k] % MOD * comb(n+k-1, k) % MOD;
        sol += (n+k) * pbs[n] % MOD * pas[k] % MOD * comb(n+k-1, k) % MOD;
    }
    sol %= MOD;
    sol = sol * 100 % MOD * inv(a+b) % MOD;
    cout << sol << '\n';

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int t = sc.nextInt();
 
		int ans = (n / x + (n % x == 0 ? 0 : 1)) * t;
		System.out.println(ans);
		
		sc.close();
	}
 
}

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

void solve()
{	
	string s,p; cin >> s >> p;
	s += s;
	for (int i = 0; i + sz(p)-1 < sz(s); i++)
	{
		if(s.substr(i,sz(p))==p)
		{
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
	return;
}

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



Measured memory_bytes: 3216
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void){
  cout << std::fixed << std::setprecision(16);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  
  int a,b;
  cin>>a>>b;
  
  cout<<std::max(0,a-b*2)<<endl;
  



  return 0;
}


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

int main() {
  long a,b,c,x,y,ans;
  cin >> a >> b >> c >> x >> y;
  if(y>x) {
    swap(x,y);
    swap(a,b);
  }
  ans=y*min(a+b,c*2);
  ans+=(x-y)*min(a,c*2);
  cout << ans << endl;
}

Measured memory_bytes: 3564
#include <stdio.h>

int main(){
    int sec,h,m,s;
    
    scanf("%d", &sec);
    
    h = sec / 3600;
    m = (sec % 3600) / 60;
    s = (sec % 3600) % 60;
    
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;

void solve() {
	int n;
	cin >> n;
	n -= 400;
	cout << (8 - n / 200) << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}



Measured memory_bytes: 3644
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#define min(a,b) {a > b ? b:a}
using namespace std;

int  N = 1000000;
long long int segment[1000000 * 2];
int id[1000000 * 2];

void q99() {
	int n, q;
	cin >> n >> q;

	for (int i = 0; i < N; i++) {
		id[i + N] = i;
	}
	for (int i = 0; i < q; i++) {
		int a, v;
		cin >> a >> v;
		segment[N + a - 1] += v;
		for (int j = (N + a - 1) >> 1; j > 0; j = j >> 1) {
			if (segment[j * 2] == segment[j * 2 + 1]) {
				segment[j] = segment[j * 2];
				id[j] = min(id[j * 2], id[j * 2 + 1]);
			}
			else if (segment[j * 2] > segment[j * 2 + 1]) {
				segment[j] = segment[j * 2];
				id[j] = id[j * 2];
			}
			else {
				segment[j] = segment[j * 2 + 1];
				id[j] = id[j * 2 + 1];
			}
		}
		cout << id[1] + 1 << " " << segment[1] << endl;
	}

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

Measured memory_bytes: 26480
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

int main(){
	int x1, y1, x2, y2, x3, y3, x4, y4;
	int dx, dy;
	scanf("%d %d %d %d\n", &x1, &y1, &x2, &y2);
	dx = x2 - x1;
	dy = y2 - y1;
	x3 = x2 - dy;
	y3 = y2 + dx;
	x4 = x3 - dx;
	y4 = y3 - dy;
	printf("%d %d %d %d\n", x3, y3, x4, y4);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void)
{
    int m, f, b;
    scanf("%d %d %d", &m, &f, &b);
    if (b > m + f) 
    	puts("NA");
    else if (m >= b) 
    	puts("0");
    else 
    	printf("%d\n", b - m);
    return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    int A,B;
    cin >> A >> B;
    B+=pow(10,((int)log10(B)+1))*A;
   // cout << B << endl;
    
    if((int)sqrt(B)*(int)sqrt(B)==B){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int num[10][10];

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

   for(int i=1; i<=n; i++){
      int b=i%10, t;
      for(t=i; t/10!=0; t/=10);
      num[t][b]++;
   }

   // for(int a=1; a<=9; a++) for(int b=1; b<=9; b++){
   //    cout<<a<<","<<b<<"  "<<num[a][b]<<endl;
   // }

   ll ans=0;
   for(int a=1; a<=9; a++) for(int b=a; b<=9; b++){
      if(a==b) ans+= num[a][a]*num[a][a];
      else ans+=(ll)2*num[a][b]*num[b][a];
   }

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


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
 
signed main()
{
  string n; cin >> n;
  string a = n.substr(n.length() -1);
  if(a=="2"||a=="4"||a=="5"||a=="7"||a=="9") {cout << "hon";}
  if(a=="0"||a=="1"||a=="6"||a=="8") {cout << "pon";}
  if(a=="3") {cout << "bon";}
}

Measured memory_bytes: 3580
import fractions

A, B, C, D = map(int, input().split())
LCM = C * D // fractions.gcd(C, D)

R = (B - A) + 1
R1 = (A - 1) // C + (A - 1) // D - ((A-1) // LCM)
R2 = B // C + B // D - (B // LCM)

RR = R - (R2 - R1)

print(RR)


Measured memory_bytes: 5048
// #include C {
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<cmath>
// }

// #include C++ {
#include<functional>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<map>
#include<set>
// }

using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef DEBUG_MODE

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 505
#define MAX_M 100005
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

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

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
//  WF("output.txt");
	DF("err.txt");

	int x, y, z;
	scanf("%d %d %d", &x, &y, &z);

	printf("%d\n", int(1 + floor((x - y - 2 * z) / (y + z))));
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vll = V<ll>;
using VVll = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

const double PI = acos(-1);
const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

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

    Vi v(n);
    REP(i, n) {
        cin >> v[i];
    }

    sort(ALL(v), greater<int>());

    if (k >= n) {
        std::cout << 0 << '\n';
    } else {
        ll cnt = 0;
        REP2(i, k, n) {
            cnt += v[i];
        }
        std::cout << cnt << '\n';
    }

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <functional>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,f,t) for(int i=f;i<t;i++)
int main()
{
    string S; cin >> S;
    unsigned int bits = 0;
    for (char c : S) {
        int b = 1 << (c - 'a');
        if (b & bits) {
            cout << "no" << endl;
            return 0;
        }
        bits |= b;
    }
    cout << "yes" << endl;
    return 0;
}

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

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') cout << 3 << '\n';
	else if (s[0] == 'R' && s[1] == 'R') cout << 2 << '\n';
	else if (s[1] == 'R' && s[2] == 'R') cout << 2 << '\n';
	else if (s[0] == 'R') cout << 1 << '\n';
	else if (s[1] == 'R') cout << 1 << '\n';
	else if (s[2] == 'R') cout << 1 << '\n';
	else cout << 0 << '\n';
	return 0;
}

Measured memory_bytes: 3652
str = gets.chomp.split('')
q = gets.to_i
check = true
q.times do
  s, t, u = gets.chomp.split
  if s == "1"
    check = !check
  elsif s == "2"
    if check
      if t == "1"
        str.unshift(u)
      elsif t == "2"
        str.push(u)
      end
    else
      if t == "1"
        str.push(u)
      elsif t == "2"
        str.unshift(u)
      end
    end
  end
end
str.reverse! if !check
puts str.join('')

Measured memory_bytes: 28668
N = int(input())
L = list(map(int,input().split()))
count = 0
for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if L[i] != L[j] and L[j] != L[k] and L[i] != L[k] and L[i]+L[j]>L[k] and L[j]+L[k]>L[i] and L[k]+L[i]>L[j]:
        count += 1
print(count)

Measured memory_bytes: 9200
from collections import defaultdict
import math
n = int(input())
a = [int(x) for x in input().split()]
ans = []
tmp_sum = 0
m_dic,c_dic = defaultdict(int),defaultdict(int)
for x in a:
    m_dic[x] += 1

for value in m_dic.values():
    if value > 1:
        tmp_sum += math.factorial(value) // (math.factorial(value - 2) * math.factorial(2))

for x in a:
    print(tmp_sum-m_dic[x]+1)

Measured memory_bytes: 26780
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/

int main()
{
	//freopen("D:\\code\\text\\input.txt","r",stdin);
	//freopen("D:\\code\\text\\output.txt","w",stdout);
	ll h;
	cin >> h;
	ll ans = 0ll;
	ll cnt = 1ll;
	while (h)
	{
		if (h > 1)
		{
			ans += cnt;
			cnt <<= 1;
			h /= 2;
		} else {
			ans += cnt;
			h /= 2;
		}
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string s; cin >> s;
	int ans = 0, n = s.size();
	for (int i = 0; i < n; i++) {
		int j = -1;
		if (s[i] == 'O') {
			j = i;
			while (s[j + 1] == 'O')j++;
		}
		int l = j - i + 1;
		if (i - l >= 0 && j + l<n) {
			bool flag = true;
			for (int k = i - l; k < i; k++)
				if (s[k] != 'J')flag = false;
			for (int k = j + 1; k <= j + l; k++)
				if (s[k] != 'I')flag = false;
			if (flag)ans = max(ans, l);
		}
		if (j != -1)i = j + l;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
#define vll vector<long long int>
#define vvll vector<vector<long long int>>
#define all(v) (v).begin(),(v).end()
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string S; cin >> S; ll N = S.size();
  ll Q; cin >> Q;
  
  //main
  string left="", right="";
  
  bool rev = false;
  FOR(i,Q){
    ll T; cin >> T;
    if(T==1){//反転
      string tmp="";
      tmp = left; left = right; right = tmp;
      rev = !rev;
      //cout << left << " " << right << endl;
    }else{
      ll F; cin >> F; string C; cin >> C;
      if(F==1){//左側に追加
        if(!rev){//反転していない時
          left = C+left; 
        }else{
          left = left+C;
        }
      }else{//右側に追加
        if(!rev){//反転していない時
          right = right+C;
        }else{
          right = C+right;
        }
      }
      //cout << left << " " << right << endl;
    }
  }
  
  string ans = "";
  if(rev){
    reverse(left.begin(),left.end());
    reverse(S.begin(),S.end());
    reverse(right.begin(),right.end());
  }else{
    
  }
  
  // output
  ans = (left+S+right);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1404
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		
		int ans = K;
		for(int i = 1;i < N;++i)
			ans *= K-1;
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

#define ABS(a) ((a)>(0)?(a):-(a))

void run (void) {
  i32 n, l;
  scanf ("%" SCNi32 "%" SCNi32, &n, &l);
  i32 sum = 0;
  for (i32 i = 0; i < n; ++i) {
    sum += l + i;
  }
  i32 min = l;
  for (i32 i = 1; i < n; ++i) {
    if (ABS(min) > ABS(l + i)) {
      min = l + i;
    }
  }
  printf ("%" PRIi32 "\n", sum - min);
}

int main (void) {
  run();
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;
typedef long long ll;

int main(){
  int s, m = 1;
  map<int, int> mp;
  cin >> s;
  mp[s]++;
  while(1){
    if(s%2 == 0) s /= 2;
    else s = 3 * s + 1;
    m++;
    if(mp[s] > 0) break;
    else if(mp[s] == 0) mp[s]++;
  }
  cout << m << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s,t;
  cin>>s>>t;
  int x,y; cin>>x>>y;
  string u;
  cin>>u;
  if(u==s) cout<<x-1<<" "<<y;
  else cout<<x<<" "<<y-1;
}

Measured memory_bytes: 256
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 105
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;

int main() {
	go;
    cin >> N;
    fi(i, 0, N, 1) {
    	cin >> arr[i];
    }
    ll cnt = 0;
    fi(i, 0, N, 1) {
    	while(arr[i]) {
    		cnt++;
    		int j = i;
    		// trace1(arr[i]);
    		while(arr[j] >= 1 && j < N) {
    			arr[j]--;
    			j++;
    		}
    	}
    }
    cout << cnt << "\n";
    
	return 0;
}
/*
	Powered by Buggy Plugin
*/




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

int main(){
  int n; cin>>n;
  long double ans=0;
  vector<float> x(n);
  vector<string> u(n);
  
  for(int i=0;i<n;i++){
    cin>>x.at(i) >>u.at(i);
    if(u.at(i) == "JPY"){
      ans += x.at(i);
    }else{
      ans += x.at(i)*380000;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;




namespace aoj
{

public class program{
	static void Main(){
	TogglingCases tg = new  TogglingCases(Console.ReadLine());
	tg.toggle();
	Console.WriteLine();

}

}


class TogglingCases{
	string str;
	public TogglingCases(string s){
		str = s;
	}
	public void toggle(){
		foreach(char ch in str){
			if(char.IsLetter(ch)){
				Console.Write("{0}",char.IsUpper(ch) ? ch.ToString().ToLower() : ch.ToString().ToUpper());
			}else{
				Console.Write(ch);
			}
		}
	}
}

}

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

int main() {
  double l;
  cin >> l;
  long double len = l / 3;
  cout << fixed <<  pow(len, 3) << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;

int main(){
    ll l, r;
    cin >> l >> r;
    ll unko = 2019;
    if (r - l >= 2019)
    {
        cout << 0 << endl;
   }
   else{
       vector<ll> v;
       for (int i = l; i <= r; i++)
       {   
           v.push_back(i%unko);
        
       }

       ll ans = 2019;
       sort(v.begin(), v.end());
       for (int i = 0; i < v.size(); i++)
       {
           for (int j = i + 1; j < v.size(); j++)
           {    
               if(ans>(v[i]*v[j])%unko)
               ans = (v[i] * v[j]) % unko;
           }
   }
   
   ll q = (v[0] * v[1]) % unko;
   cout <<ans << endl;

   }

   return 0;
}

Measured memory_bytes: 256
fn main() {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let a: i64 = s.next().unwrap().parse().unwrap();
	let b: i64 = s.next().unwrap().parse().unwrap();
	println!("{}", a * b);
}


Measured memory_bytes: 2104
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    string s;cin>>s;
    vector<ll>imos(s.length()+1);imos[0]=0;
    for(ll i=0;i<s.length();++i)imos[i+1]=s[s.length()-1-i]-'0';
    ll p10=1;
    for(ll i=1;i<imos.size();++i){
        imos[i]=(imos[i]*p10+imos[i-1])%2019;
        p10=p10*10%2019;
    }
    map<ll,ll>cnt;for(auto i:imos)++cnt[i];
    ll ans=0;for(auto c:cnt)ans+=(c.second-1)*c.second/2;
    cout<<ans<<endl;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1



int main() {

    char s[51] = {},t[51] = {};
    Scs(s);
    Scs(t);

    int slen = strlen(s);
    int tlen = strlen(t);

    bool able = false;
    int wh = 0;

    Rep(i,slen-tlen+1){
        Rep(j,tlen+1){
            if( j == tlen ){
                able = true;
                wh = i;
            }
            if( !(t[j] == s[i+j] || s[i+j] == '?') ){
                break;
            }

        }


    }

    if( able ){
        Rep(i,slen){
            if( wh == i){
                Rep(j,tlen){
                    i++;
                    printf ("%c", t[j]);
                }
            }
            if( i >= slen ) break;
            if( s[i] == '?' ) s[i] = 'a';
            printf ("%c", s[i]);
        }
        printf ("\n");
    }else{
        printf ("UNRESTORABLE\n");
    }


    return 0;
}



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

using namespace std;

int main(){
    string s;
    char aux;
    int a,b, c ,parity = 0;
    deque<char> dq; 
    cin >> s >> a;
    for (int i = 0; i < s.size(); i++)
    {
        dq.push_back(s[i]);
    }
    
    while (a--){
       cin>> b;

        if(b == 1)
            parity++;
        if(b == 2){
            cin>>c >> aux;
            if((parity%2 == 0 && c == 1) || (parity%2 == 1 && c == 2))
                dq.push_front(aux);
            if((parity%2 == 0 && c == 2) || (parity%2 == 1 && c == 1))
                dq.push_back(aux);
        }
    }
    if(parity %2 == 1)
        reverse(dq.begin(),dq.end());

    for (int i = 0; i < dq.size(); i++)
    {
        cout<<dq[i];
    }
    
    cout<< "\n";

    
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
using namespace std;

const int INF = 1e8;
int d[45][45];

int main() {
    int n;
    while (cin >> n, n) {
        for (int i=0; i<45; ++i) {
            for (int j=0; j<45; ++j) {
                d[i][j] = (i == j ? 0 : INF);
            }
        }
        int a, b, c, vn = -1;
        for (int i=0; i<n; ++i) {
            cin >> a >> b >> c;
            d[a][b] = min(d[a][b], c);
            d[b][a] = min(d[b][a], c);
            vn = max(vn, max(a, b)+1);
        }
        for (int k=0; k<vn; ++k) {
            for (int i=0; i<vn; ++i) {
                for (int j=0; j<vn; ++j) {
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }
        int idx = -1, min_time = INF;
        for (int i=0; i<vn; ++i) {
            int time = 0;
            for (int j=0; j<vn; ++j) {
                time += d[i][j];
            }
            if (time < min_time) {
                idx = i;
                min_time = time;
            }
        }
        cout << idx << " " << min_time << endl;
    }
    return 0;
}

Measured memory_bytes: 1172
#include<cstdio>
#include<vector>
#include<iostream>
using namespace std;
typedef long long int LLD;
int main()
{
	int n;
	LLD cnt=0;
	vector<char> joi;
	LLD **dp;
	cin>>n;
	dp = new LLD *[n+1];
	for(int i=0;i<n+1;i++){
		dp[i]=new LLD [7];
		for(int j=0;j<7;j++){
			dp[i][j]=0;
		}
	}
	for(int i=0;i<n;i++)
	{
		char temp;
		cin>>temp;
		joi.push_back(temp);
	}
	dp[0][0]=1;
	for(int i=0;i<n;i++)
	{
		// 0 1 2 ３ ４ ５ ６
		// J O I JO OI JI JOI
		switch(joi[i]){
			case 'J':
				dp[i+1][0]+=(dp[i][0]+dp[i][3]+dp[i][5]+dp[i][6])%10007;
				dp[i+1][3]+=(dp[i][0]+dp[i][1]+dp[i][3]+dp[i][4]+dp[i][5]+dp[i][6])%10007;
				dp[i+1][5]+=(dp[i][0]+dp[i][2]+dp[i][3]+dp[i][4]+dp[i][5]+dp[i][6])%10007;
				dp[i+1][6]+=(dp[i][0]+dp[i][1]+dp[i][2]+dp[i][3]+dp[i][4]+dp[i][5]+dp[i][6])%10007;
				break;
			case 'O':
				dp[i+1][1]+=(dp[i][1]+dp[i][3]+dp[i][4]+dp[i][6])%10007;
				dp[i+1][3]+=(dp[i][0]+dp[i][1]+dp[i][3]+dp[i][4]+dp[i][5]+dp[i][6])%10007;
				dp[i+1][4]+=(dp[i][1]+dp[i][2]+dp[i][3]+dp[i][4]+dp[i][5]+dp[i][6])%10007;
				dp[i+1][6]+=(dp[i][0]+dp[i][1]+dp[i][2]+dp[i][3]+dp[i][4]+dp[i][5]+dp[i][6])%10007;
				break;
			case 'I':
				dp[i+1][2]+=(dp[i][2]+dp[i][4]+dp[i][5]+dp[i][6])%10007;
				dp[i+1][4]+=(dp[i][1]+dp[i][2]+dp[i][3]+dp[i][4]+dp[i][5]+dp[i][6])%10007;
				dp[i+1][5]+=(dp[i][0]+dp[i][2]+dp[i][3]+dp[i][4]+dp[i][5]+dp[i][6])%10007;
				dp[i+1][6]+=(dp[i][0]+dp[i][1]+dp[i][2]+dp[i][3]+dp[i][4]+dp[i][5]+dp[i][6])%10007;
				break;
		}
	}
	for(int i=0;i<7;i++){
		cnt+=dp[n][i];
	}
	printf("%lld\n",cnt%10007);
	return 0;
}

Measured memory_bytes: 1276
from collections import defaultdict
inf = float("INF")
binary = [1 << i for i in range(14)]

def main(n):

    s = [input() for _ in range(n)]
    delete = set()
    for i in range(n):
        for k in range(n):
            if i == k:
                continue
            if s[k] in s[i]:
                delete.add(k)
    n -= len(delete)
    for de in reversed(sorted(delete)):
        del s[de]

    mindist = [[inf] * n for _ in range(n)]
    lenlis = [len(s[i]) for i in range(n)]
    for i in range(n):
        mindisti = mindist[i]
        si = s[i]
        for k in range(n):
            if i == k:
                continue
            sk = s[k]
            lenk = lenlis[k]
            if sk in si:
                tmp = 0
            else:
                tmp = lenk
                for index_k in range(1, lenk + 1):
                    if sk[:index_k] == si[-index_k:]:
                        tmp = lenk - index_k
            mindisti[k] = tmp

    d = defaultdict(int)
    for i in range(n):
        d[(binary[i], i)] = len(s[i])

    for _ in range(n-1):
        nd = defaultdict(lambda: inf)
        for key, value in d.items():
            state, before = key
            mindistb = mindist[before]

            for i in range(n):
                if not (state >> i & 1):
                    if nd[(state ^ binary[i], i)] > value + mindistb[i]:
                        nd[(state ^ binary[i], i)] = value + mindistb[i]

        d = nd

    print(min(d.values()))


if __name__ == "__main__":
    while 1:
        n = int(input())
        if n:
            main(n)
        else:
            break


Measured memory_bytes: 15152
# -*- coding: utf-8 -*-

o = list(input())
e = list(input())
ans = []
while len(o) or len(e):
    if len(o):
        ans.append(o[0])
        del o[0]
    if len(e):
        ans.append(e[0])
        del e[0]
print(''.join(ans))


Measured memory_bytes: 2940
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	p := make([]int, n)
	for i := range p {
		fmt.Scan(&p[i])
		// 任意の数に+1して2で割るとその数の期待値になる。計算中を整数でやりたいので、+1しておいて最後に2で割る
		//(6+1)/2=3.5
		p[i]++
	}

	idx := make([]int, 0, k)
	var max, sum int
	for i := 0; i < n; i++ {
		sum += p[i]
		idx = append(idx, p[i])
		if len(idx) > k {
			sum -= idx[0]
			idx = idx[1:]
		}
		if len(idx) == k {
			if max < sum {
				max = sum
			}
		}
	}
	ans := float64(max)
	ans /= 2.0
	fmt.Printf("%.12f\n", ans)
}


Measured memory_bytes: 8832
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e18
typedef long long ll;
typedef pair<int,int> P;

set<int>ban,ban1,num;
int n,k;

void dfs(int nn,int digit){
    if(digit == 5){
        if(nn>n){
            num.insert(nn);
        }
        return;
    }
    for(auto itr = ban.begin();itr!=ban.end();++itr){
        int x = *itr;
        int add = (int)pow(10,digit);
        int y = nn+x*add;
        if(y>=n){
            num.insert(y);
        }
        else dfs(y,digit+1);
    }
}

int main(void){
    cin>>n>>k;
    for(int i=0;i<k;i++){
        int d;
        cin>>d;
        ban1.insert(d);
    }
    for(int i=0;i<10;i++){
        if(ban1.count(i)==0)ban.insert(i);
    }
    dfs(0,0);
    for(auto itr = num.begin();itr!=num.end();++itr){
        cout<<(*itr)<<endl;
        return 0;
    }
	return 0; 
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std ;
int main () {
  int N , K ;
  cin >> N >> K ;
  string s ;
  cin >> s ;
  s[K - 1] = char(s[K - 1]-'A' + 'a') ;
  cout<<s<<endl;
  return 0 ;
}

Measured memory_bytes: 256
program main
  implicit none
  integer :: N
  integer,allocatable :: A(:)
  integer,allocatable :: out(:)
  integer :: i
  read(*,*) N
  allocate(A(N))
  read(*,*) A(2:)
  allocate(out(N))
  out(:) = 0
  do i = 2,N
     out(A(i)) = out(A(i)) + 1
  end do
  do i = 1,N
     write(*,'(i0)') out(i)
  end do
end program main


Measured memory_bytes: 4608
#include<bits/stdc++.h>
    using namespace std;
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
     
    #define ff first
    #define ss second
    #define mp make_pair
     
    #define pb push_back
    #define endl "\n"
     
    #define int long long int
    #define double long double
     
    #define bp __builtin_popcountll
    #define inf 1e18
    const int N=1e5+6;
    const int MOD=1e9+7;
    vector<pair<int,int>> v[N];
    int dist[N];
    int col[N];
    
    void dfs(int x,int par)
    {
    	for(auto X:v[x])
    	{
    		if(X.ff!=par)
    		{
    			dist[X.ff]=dist[x]+X.ss;
    			if(dist[X.ff]%2)
    			col[X.ff]=1;
    			dfs(X.ff,x);
    			
    		}
    	}
    }
    void solve()
    {
    	int n;
    	cin>>n;
    	for(int i=1;i<=n-1;i++)
    	{
    		int t1,t2,w;
    		cin>>t1>>t2>>w;
    		v[t1].pb(mp(t2,w));
    		v[t2].pb(mp(t1,w));
    	}
    	dfs(1,0);
    	for(int i=1;i<=n;i++)
    	cout<<col[i]<<endl;
    }
	signed main()  
    {
        FAST
        int t=1;
        // cin>>t;
        while(t--)
        {
        	solve();
        }
    }

Measured memory_bytes: 10880
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<int, PP> PPP;
struct edge { int to; int to2; int cost; };
int cnt[30];
signed main() {
	int n; cin >> n; string s; cin >> s;
	rep(i, s.size()) {
		cnt[s[i] - 'a']++;
	}
	int ans = 1;
	rep(i, 26) {
		ans *= cnt[i] + 1;
		ans %= mod;

	}
	cout << ans -1<< endl;
}

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

int x[200001];
vector<int> prime;
bool num[200001];
int z = 1;
int n;
int dp[200001];
/*
void Prime(){
	for(int i = 2; i < 200001; i++){
		if(!num[i]){
			prime.push_back(i);
			for(int j = i+i; j < 200001; j += i) num[j] = true;
		}
	}
}

int func(int N, int st){
	if(dp[N] != -1) return dp[N];
	int ret = 1;
	for(int i = st; i < prime.size(); i++){
		int p = prime[i];
		if(N%p != 0) continue;
		if(N < p) break;
		bool flag = true;
		for(int j = 1; j < p; j++){
			for(int k = 0; k < N/p; k++){
				if(x[j*(n/p)+k] != x[k]){
					flag = false;
					break;
				}
			}
			if(!flag) break;
		}
		if(flag) ret = max(ret,p*func(N/p,i));
	}
	dp[N] = ret;
	return ret;
}

*/
int main(){
	rep(i,200001) dp[i] = -1;
	//Prime();
	scanf("%d",&n);
	rep(i,n) scanf("%d",x+i);
	//cout << func(n,0) << endl;
	int ans = 1;
	for(int i = 2; i <= n; i++){
		if(n%i != 0) continue;
		bool flag = true;
		for(int j = 1; j < i; j++){
			for(int k = 0; k < n/i; k++){
				if(x[j*(n/i)+k] != x[k]){
					flag = false;
					break;
				}
			}
			if(!flag) break;
		}
		if(flag) ans = i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2776
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

const long long MOD = 4294967291LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long mult_mod(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

long long cnt[200005];
vector<int> adj[200005];

void helper(int node, int prev = -1){
    for(int i : adj[node]){
        if(prev == i) continue;
        cnt[i] += cnt[node];
        helper(i, node);
    }
}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, q; cin >> n >> q;

    for(int a, b, i = 1; i < n; ++i){
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

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

    helper(1);

    for(int i = 1; i <= n; ++i)
        cout << cnt[i] << " ";

    return 0;
}


Measured memory_bytes: 21120
#include <cstdio>
using namespace std;
int main(){
  int m, f, r, s;
  m = 0;
  f = 0;
  r = 0;
  s = 0;
  while(1){
  scanf("%d %d %d", &m, &f, &r);
  s = m + f;
    if(m == -1 && f == -1 && r == -1)
      break;
    if(m == -1 || f == -1)
      printf("F\n");
    else if(s >= 80)
      printf("A\n");
    else if(s >= 65)
      printf("B\n");
    else if(s >= 50)
      printf("C\n");
    else if(s < 30)
      printf("F\n");
    else if(s >= 30 && s < 50 && r >= 50)
      printf("C\n");
    else
      printf("D\n");
  }
}

Measured memory_bytes: 1012
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define MOD 1000000007
int main()
{
	ll i,j,n,a,b,m,k,sum=0,ans;
	cin>>n>>a>>b;
	ll p=abs(b-a);
	ans=1e18;
	if(p%2==0)
	{
	ans=p/2;
	}
p=a-1;
ll q=b-p;
sum=p;
if((q-1)%2!=0)
{
	sum++;
	q--;
}
sum+=(q-1)/2;
ans=min(ans,sum);
p=n-b;
q=a+p;
sum=p;
if((n-q)%2!=0)
{
	sum++;
	q++;
}
sum+=(n-q)/2;
ans=min(ans,sum);
cout<<ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
class UnionFind {
    vector<int> p;//p[i]はiの属する組織
public:
    UnionFind(int n){
        p = vector<int>(n);
        for(int i = 0; i < n; i++){
            p[i] = i;
        }
        return;
    }

/* xの属する集合を返す */
    int find(int x) {
        if (p[x] == x) return x;
        return p[x] = find(p[x]);
    }

/* yにxを統合する */
    void unite(int x, int y) {
        p[find(x)] = p[find(y)];
    }

/* xとyが属する集合が同じかを判定する */
    bool same(int x, int y) {
        return find(x) == find(y);
    }

};

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

    int n,q;
    cin >> n >> q;
    UnionFind uf(n);
    while(q--){
        int cmd;
        cin >> cmd;
        if(!cmd){
            int x,y;
            cin >> x >> y;
            uf.unite(x,y);
        }else{
            int x,y;
            cin >> x >> y;

            cout << uf.same(x,y) << endl;
        }
    }


    return 0;
}



Measured memory_bytes: 3256
#include <cstdint>
#include <utility>

using namespace std;

#define PRIORITY_QUEUE_SIZE 2000000

static int64_t max_heap[PRIORITY_QUEUE_SIZE];
static uint64_t heap_size = 0;

static inline int64_t parent(int64_t i)
{
  if (i == 0) return -1;
  return (i - 1) / 2;
}

static inline uint32_t left(uint32_t index)
{
  return index * 2 + 1;
}

static inline uint32_t right(uint32_t index)
{
  return index * 2 + 2;
}

static void insert_at(uint64_t i, int64_t key)
{
  max_heap[i] = key;

  int64_t index = i;
  int64_t parent_index = parent(index);
  while ((parent_index >= 0) && (max_heap[parent_index] < max_heap[index])) {
    swap(max_heap[parent_index], max_heap[index]);
    index = parent_index;
    parent_index = parent(index);
  }
}

void priority_queue_insert(int64_t key)
{
  max_heap[heap_size] = INT64_MIN;
  heap_size++;
  insert_at(heap_size - 1, key);
}

static void heapify(uint32_t top)
{
  uint32_t max = top;

  if (left(top) < heap_size) {
    if (max_heap[max] < max_heap[left(top)]) {
      max = left(top);
    }
  }

  if (right(top) < heap_size) {
    if (max_heap[max] < max_heap[right(top)]) {
      max = right(top);
    }
  }

  if (max != top) {
    swap(max_heap[top], max_heap[max]);
    heapify(max);
  }
}

int64_t priority_queue_extract()
{
  int64_t ret = max_heap[0];
  heap_size--;
  max_heap[0] = max_heap[heap_size];

  heapify(0);

  return ret;
}

#include <cstdio>

int32_t main()
{
  while (true) {
    char command[10];
    scanf("%s", command);

    switch (command[0]) {
    case 'i':
      int64_t val;
      scanf("%ld", &val);
      priority_queue_insert(val);
      break;
    case 'e':
      if (command[1] == 'x') {
        printf("%ld\n", priority_queue_extract());
      } else {
        return 0;
      }
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 10480
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repeq(i,a,b) for(int i=a;i<=(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n>>m;
    vi par(n), nxt(n,-1), s(n,1);
    vector<ll> x(n,0);
    rep(i,0,n) par[i]=i;
    bool good=true;
    rep(i,0,m) {
        int l,r;
        ll d;
        cin >> l>>r>>d;
        --l, --r;
        if(par[l]==par[r]) {
            //rep(i,0,n) debug(x[i]);
            if(x[r]-x[l]!=d){
                good=false;
                break;
            }
        }
        else {
            d = x[r]-x[l]-d;
            if(s[par[l]]>s[par[r]]) {
                swap(l,r);
                d = -d;
            }
            l=par[l], r=par[r];
            int last=l;
            for(int j=l;j!=-1;j=nxt[j]) {
                par[j]=r;
                x[j]+=d;
                last = j;
            }
            s[r]+=s[l];
            nxt[last]=nxt[r];
            nxt[r] = l;
        }
    }
    if(good) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 2176
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    ll x, y;
    cin >> x >> y;
    ll cnt = 0;
    ll mul = x;
    while (x <= y) {
        x *= 2;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256