akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int n;
Int s[108000];
Int ss[108000];
Int ans = 0;
int main(){
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> s[i];
    }

    for(int d = 1;d < n;d++){
        Int tmp = 0;
        for(int kd = 0;kd < n-1;kd += d){
            int op = n-1 - kd;
            if(op <= kd && op % d == 0)break;
            tmp += s[kd] + s[op];
            if(op > d)
                ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (N, M) = (input[0], input[1])
let student = (0..<N).map{_ in readLine()!.characters.split(" ").map{Int(String($0))!}}
let checkpoint = (0..<M).map{_ in readLine()!.characters.split(" ").map{Int(String($0))!}}
for i in 0..<N {
    var ans = 1
    var minDist = abs(student[i][0] - checkpoint[0][0]) + abs(student[i][1] - checkpoint[0][1])
    for j in 1..<M {
        let dist = abs(student[i][0] - checkpoint[j][0]) + abs(student[i][1] - checkpoint[j][1])
        if dist < minDist {
            minDist = dist
            ans = j + 1
        }
    }
    print(ans)
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  int t[N],x[N],y[N];
  for (int i = 0; i <N; i++) cin >> t[i] >> x[i] >> y[i];
  bool can = true;
  int time = 0;
  int nx = 0;
  int ny = 0;
  for (int i = 0; i < N; i++) {
    int diff = abs(x[i] - nx) + abs(y[i] - ny);
    if (diff <= t[i] - time && diff % 2 == (t[i] - time) % 2) {
      time = t[i];
      nx = x[i];
      ny = y[i];
    } else {
      can = false;
      break;
    }
  }
  if (can) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 4808
def main
  xs = gets.split.map(&:to_i)
  puts show solve xs
end

def solve(xs)
  cands = xs.concat([xs[0] + xs[1]])
  cands.find do |x|
    x % 3 == 0
  end
end

def show(x)
  if x then 'Possible'
  else 'Impossible'
  end
end

main


Measured memory_bytes: 1788
x, y = map(int, raw_input().split())
if x == 1:
    s = 300000
elif x == 2:
    s = 200000
elif x == 3:
    s = 100000
else:
    s = 0
if y == 1:
    s += 300000
elif y == 2:
    s += 200000
elif y == 3:
    s += 100000
if (x, y) == (1, 1):
    s += 400000
print s

Measured memory_bytes: 2572
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n, x, t;
  cin >> n >> x >> t;
  ll ans = 0;
  while(1) {
    ans += t;
    n -= x;
    if (n <= 0) {
      cout << ans << '\n';
      return 0;
    }
  }

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int arr[n];
  for(int i=0;i<n;i++)
    cin>>arr[i];
  sort(arr,arr+n);
  int sum=0;
  for(int i=0;i<k;i++)
    sum+=arr[i];
  cout<<sum<<endl;
}

Measured memory_bytes: 3672
N = int(input())
a = []
b = []
for i in range(N):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)
a.sort()
b.sort()
if N % 2 == 0:
    x = a[N//2]+a[N//2-1]
    y = b[N//2]+b[N//2-1]
    print(y-x+1)

else:
    x = a[N//2]
    y = b[N//2]
    print(y-x+1)

Measured memory_bytes: 25504
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <limits.h>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll N,A,B,D,L[10];
ll ANS=LINF;

void dfs(ll P,ll i,ll C[10]){
  if(i==N){
    ll a=0,b=0,c=0,AL=0,BL=0,CL=0;
    rep(j,N){
      if(C[j]==1){
        a++;
        AL+=L[j];
      }
      if(C[j]==2){
        b++;
        BL+=L[j];
      }
      if(C[j]==3){
        c++;
        CL+=L[j];
      }
    }
    if(a==0 || (b==0  || c==0) ){
      return;
    }
    ll SUM=((a+b+c)-3)*10;
    SUM+=abs(AL-A)+abs(BL-B)+abs(CL-D);
    ANS=min(ANS,SUM);
    return;
  }
  else{
    rep(j,4){
      C[i]=j;
      dfs(P,i+1,C);
    }
  }
}

int main(){
  cin >> N >> A >> B >> D;
  rep(i,N){
    cin >> L[i];
  }
  ll C[10];
  rep(i,9){
    C[i]=0;
  }
  dfs(0,0,C);
  cout << ANS  << endl;
} 


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

struct mint {
  ll x;
  mint(ll x = 0): x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
  mint& operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct cominit {
  vector<mint> fact, ifact;
  cominit(int n): fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; i--) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int r) {
    if (n < r or r < 0) return 0;
    return fact[n] * ifact[r] * ifact[n - r];
  }
};

int main() {
  int k;
  string s;
  cin >> k >> s;
  int ss = s.size();
  cominit nCr(k + ss);
  mint ans = 0;
  for (int i = ss; i <= k + ss; i++) {
    mint res = nCr(i - 1, ss - 1);
    res *= mint(25).pow(i - ss);
    res *= mint(26).pow(k + ss - i);
    ans += res;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 35536
program main;
var
  n, i : LongInt;
  sum : Int64; 
begin
  readln(n);

  sum := 0;
  for i := 1 to n do
    if not ((i mod 3 = 0) or (i mod 5 = 0)) then
      sum := sum + i;

  writeln(sum);
end.

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


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

    int N, A, B, C, D;
    string S;
    cin >> N >> A >> B >> C >> D;
    cin >> S;
    A--;
    B--;
    C--;
    D--; //0-indexに直す

    if(D > C){//この場合は、AとBそれぞれが目的地に到達できるか判断すればよい
        //Aについて
        bool en_through = true;
        bool pre_x = false;
        for(int i = A+1; i < C; i++){
            if(S[i] == '#'){
                if(pre_x == true){
                    en_through = false;
                }
                pre_x = true;
            }else{
                pre_x = false;
            }
        }
        pre_x = false;
        for(int i = B+1; i < D; i++){
            if(S[i] == '#'){
                if(pre_x == true){
                    en_through = false;
                }
                pre_x = true;
            }else{
                pre_x = false;
            }
        }

        if(en_through){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        bool en_through = true;
        bool pre_x = false;
        for(int i = A+1; i < C; i++){
            if(S[i] == '#'){
                if(pre_x == true){
                    en_through = false;
                }
                pre_x = true;
            }else{
                pre_x = false;
            }
        }
        pre_x = false;
        for(int i = B+1; i < D; i++){
            if(S[i] == '#'){
                if(pre_x == true){
                    en_through = false;
                }
                pre_x = true;
            }else{
                pre_x = false;
            }
        }

        // これに更に、...が３つ続いたところが、Bの位置からDの位置までにないといけない
        bool exist_broad = false;
        int cnt_broad = 0;
        for(int i = B-1; i <= D+1; ++i){
            if(S[i] == '.'){
                cnt_broad++;
                if(cnt_broad==3){
                    exist_broad = true;
                }
            }else{
                cnt_broad = 0;
            }
        }

        if(en_through && exist_broad){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 592
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>

int digit(int v){
	int cnt = 1;
	while ((v /= 10) != 0)
		cnt++;
	return cnt;
}

int main(){
	int a, b;
	while (scanf("%d%d", &a, &b) != EOF)
		printf("%d\n", digit(a + b));

	return 0;
}

Measured memory_bytes: 1188
n = int(input())

dicN = {}
nList = []
for i in range(n):
  nList.append(input())

for i in nList:
  if not(i in dicN):
    dicN[i]=1
  else:
    dicN[i] += 1

maxN = max(dicN.values())

result = []
for i in list(dicN.items()):
  if i[1] == maxN:
    result.append(i[0])
  #else:
  #  break

for i in sorted(result):
  print(i)



Measured memory_bytes: 44684
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        self.all_group_member=defaultdict(list)
        for i in range(self.n):
            self.all_group_member[self.find(i)].append(i)
        return self.all_group_member

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    h, w = map(int, input().split())
    s = [list(input()) for i in range(h)]
    uf = UnionFind(h*w)
    for i in range(h):
        for j in range(w):
            if i != h-1:
                if s[i][j] != s[i+1][j]:
                    uf.union((i*w)+j, (i*w)+j+w)
            if j != w-1:
                if s[i][j] != s[i][j+1]:
                    uf.union((i*w)+j, (i*w)+j+1)
    ans=0
    for item in uf.all_group_members().values():
        A=0
        B=0
        for grid in item:
            i,j=divmod(grid,w)
            if s[i][j]=='.':
                A+=1
            else:
                B+=1
        ans+=A*B
    print(ans)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 34264
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

bool isprime(int p) {
  if (p==1) return false;
    FOR(i,2,p) {
      if (p%i==0) return false;
    }
  return true;
}

int main(){
  int x,t,m;
  cin >> x;
  t=0;
  m=0;
  FOR(i,1,10){
    FOR(j,2,10){
      t=pow(i,j);
      if (t<=x&&m<t) m=t;
    }
  }
  FOR(i,10,33){
    FOR(j,2,5){
      t=pow(i,j);
      if (t<=x&&m<t) m=t;
    }
  }
  cout << m;
  return 0;
}

Measured memory_bytes: 640
from fractions import gcd

a, b, c, d = map(int, input().split())

A = (a-1) // c + (a-1) // d - (a-1) // ((c * d) // gcd(c, d))
B = b // c + b // d - b // ((c * d ) // gcd(c, d))

print (b - B - (a - 1 - A))

Measured memory_bytes: 5688
N = int(input())
A = list(map(int,input().split()))

def solve(A):
  res = []
  while len(A) > 0:
    k = -1
    i = 0
    while i < len(A):
      if A[i] == (i+1):
        k = i
      i += 1
    if k == -1:
      return -1
    res.append(k+1)
    A = A[:k] + A[k+1:]
  return res[::-1]

res = solve(A)
if res == -1:
  print(res)
else:
  print("\n".join(map(str,res)))


Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<cassert>
using namespace std;
int main() {
	long long s; cin >> s;
	vector<long long> a(1000,0);
	a[s-1]++;
	for (long long i = 1; i <= 1000100; i++) {
		if (s % 2 == 0) {
			s = s / 2;
		}
		else {
			s = s * 3 + 1;
		}
		a[s-1]++;
		if (a[s - 1] > 1) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	assert(false);
}

Measured memory_bytes: 256
### constant

MAX_INT = 1 << 30

### main

m, n = gets.strip.split(' ').map(&:to_i)

pis = m.times.map{gets.strip.to_i}.sort{|a, b| b <=> a}
#p pis

psums = [0]
for i in (0...m)
  psums[i + 1] = psums[i] + pis[i]
end
#p psums

cis = []
eis = []

n.times do
  ci, ei = gets.strip.split(' ').map(&:to_i)
  cis << ci
  eis << ei
end
#p cis
#p eis

maxs = (m + 1).times.map{MAX_INT}

bps = maxs.clone
bps[0] = 0

for i in (1..n)
  pbps = bps
  bps = maxs.clone

  ci = cis[i - 1]
  ei = eis[i - 1]
  for j in (0..m)
    j0 = [j - ci, 0].max
    bps[j] = [pbps[j], pbps[j0] + ei].min
  end
end
#p bps[n]

bnmax = 0

for j in (0..m)
  bn = psums[j] - bps[j]
  bnmax = bn if bnmax < bn
end

puts bnmax

Measured memory_bytes: 6796
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int dp[1005][10005];

int main(){
  int h, n;
  cin >> h >> n;
  vector<int> a(n);
  vector<int> b(n);
  rep(i, n){
    cin >> a[i] >> b[i];
  }
  rep(i, n+1)rep(j, 10005){
    dp[i][j]=INF;
  }
  dp[0][0]=0;
  rep(i, n){
    rep(j, 10005){
      if(j-a[i]<0){
        dp[i+1][j]=min(dp[i+1][0]+b[i], dp[i][j]);
      } else {
        dp[i+1][j]=min(dp[i+1][j-a[i]]+b[i], dp[i][j]);
      }
    }
  }
  cout << dp[n][h] << endl;
  return 0;
}


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

// sample test
int main() {
  int n, c[500], s[500], f[500];
  cin >> n;
  for(int i = 0; i < n-1; i++)
  cin >> c[i] >> s[i] >> f[i];
  for(int i = 0; i < n; i++){
    int t = 0;
    for(int j = i; j < n-1; j++){
      if(t < s[j]) t = s[j];
      else if(t % f[j] == 0);
      else t = t + f[j] - t % f[j];
      t += c[j];
    }
    cout << t << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}

int  main(){
  int a,b,c,ans=0,memo;
  cin>>a>>b>>c;
  memo=c;
  while(1){
    if(c<=a){
      ans+=c;
      break;
    }
    else{
      ans+=a;
      c-=a;
      if(c<0) c+=60;
    }
    c-=b;
    ans+=b;
    if(c<0) c+=60;
    
    if(memo==c){
      ans=-1;
      break;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}



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

int main(){
  int A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0;
  cin >> N;
  char st1[N];
  for(int i=0;i<N;i++){
    cin >> st1[i];
  }
  if(N%2==1){
    cout <<"No" << endl;
  }
  else{
    for(int i=0;i<N/2;i++){
      if(st1[i]!=st1[i+N/2]){
        F=1;
      }
    }
    if(F==1){
      cout <<"No" << endl;
    }
    else{
      cout <<"Yes" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int mxN = 2e5+7;
vector<int> adj[mxN];
vector<int> vis(mxN,false);
int nv, ne;

int dfs(int v)
{
	if(vis[v])
		return 0;
	vis[v] = true;
	int ans = 1;
	for(int u: adj[v])
		if(!vis[u])
		ans += dfs(u);
	return ans;
}

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	cin >> nv >> ne;
	for(int i = 0, x, y;i < ne;i++)
	{
		cin >> x >> y, x--, y--;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	int ans = INT_MIN;
	for(int i = 0;i < nv;i++)
	{
		if(!vis[i])
			ans = max(ans,dfs(i));
	}
	cout << ans;
}


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

const int M=105;
char s[M];

int main()
{
	int k;
	scanf("%d%s",&k,s);
	int n=strlen(s);
	if(n<=k)
		printf("%s\n",s);
	else
	{
		s[k]=s[k+1]=s[k+2]='.';
		s[k+3]='\0';
		printf("%s\n",s);
	}
	return 0;
}

Measured memory_bytes: 3768
using System.Collections.Generic;
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var hs = new HashSet<int>();
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var c = int.Parse(line[0]);
            var c2 = int.Parse(line[1]);
            if (c == 0)
            {
                hs.Add(c2);
                Console.WriteLine(hs.Count());
            }
            else Console.WriteLine(hs.Contains(c2) ? 1 : 0);
        }
    }
}




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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n; scanf("%d",&n);
    vector<int> a(n);
    rep(i,0,n)scanf("%d",&a[i]);
    reverse(ALL(a));
    int ans=0,cnt=0;
    rep(i,0,n-1){
        if(a[i]<=a[i+1])cnt++;
        else{
            chmax(ans,cnt); cnt=0;
        }
    }
    chmax(ans,cnt);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main()
{
	int N;
	char input[16];

	scanf("%s", input);

	int i;
	int win = 0;

	for (i = 0; input[i]; ++i)
	{
		if (input[i] == 'o') ++win;
	}

	if (win + 15 - i >= 8) printf("YES\n");
	else printf("NO\n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
    long long a, b, c, cnt=0, tmpa, tmpb, tmpc;
    cin >> a >> b >> c;
    if(a==b && b==c && a%2==0) cnt=-1;
    else if(a==b && b==c && a%2!=0) cnt=0;
    else while(1){
         if(a%2!=0 || b%2!=0 || c%2!=0) break;
         else{
            tmpa=a;tmpb=b;tmpc=c;
            a=tmpb/2+tmpc/2;
            b=tmpa/2+tmpc/2;
            c=tmpa/2+tmpb/2;
            cnt++;
        }
    }
    cout << cnt <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <utility>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>

using namespace std;

#define init() ios::sync_with_stdio(false); cin.tie();
#define for0(i, n) for (int i=0; i<n; i++)
#define for1(i, n) for (int i=1; i<=n; i++)
#define for2(i, a, b) for (int i=a; i<=b; i++)
#define bac0(i, n) for (int i=n-1; i>=0; i--)
#define bac1(i, n) for (int i=n; i>0; i--)
#define bac2(i, a, b) for (int i=a; i>=b; i--)
#define PB push_back
#define MOD 1000000009
#define S second
#define F first

#define xL ((x<<1)+1)
#define xR ((x<<1)+2)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, char> ic;

const int N = (int) (4e5 + 5);

int a, b, c, k;

int main() {
    init()

    cin >> a >> b >> c >> k;
    cout << a + b + c - max(a, max(b, c)) + (max(a, max(b, c)) << k) << endl;

    return 0;
}

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

public class Main {

  private static void solve() {
    char[] s = next().toCharArray();
    char[] t = next().toCharArray();

    int n = s.length;
    int m = t.length;

    int[][] dp = new int[n][m];
    int[][][] bt = new int[n][m][2];

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        Arrays.fill(bt[i][j], -1);
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (s[i] == t[j]) {
          if (i - 1 >= 0 && j - 1 >= 0) {
            dp[i][j] = dp[i - 1][j - 1] + 1;
            bt[i][j][0] = i - 1;
            bt[i][j][1] = j - 1;
          } else {
            dp[i][j] = 1;
          }
        } else {
          if (i - 1 >= 0) {
            if (dp[i][j] < dp[i - 1][j]) {
              dp[i][j] = dp[i - 1][j];
              bt[i][j][0] = i - 1;
              bt[i][j][1] = j;
            }
          }

          if (j - 1 >= 0) {
            if (dp[i][j] < dp[i][j - 1]) {
              dp[i][j] = dp[i][j - 1];
              bt[i][j][0] = i;
              bt[i][j][1] = j - 1;
            }
          }
        }
      }
    }

    int curX = n - 1;
    int curY = m - 1;
    StringBuilder sb = new StringBuilder();
    while (curX != -1 && curY != -1) {
      if (s[curX] == t[curY]) {
        sb.append(s[curX]);
      }
      int oldX = curX;
      int oldY = curY;
      curX = bt[oldX][oldY][0];
      curY = bt[oldX][oldY][1];
    }

    System.out.println(sb.reverse().toString());
  }

  private static void run() {
    br = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out);

    solve();

    out.close();
  }

  private static StringTokenizer st;
  private static BufferedReader br;
  private static PrintWriter out;

  private static String next() {
    while (st == null || !st.hasMoreElements()) {
      String s;
      try {
        s = br.readLine();
      } catch (IOException e) {
        return null;
      }
      st = new StringTokenizer(s);
    }
    return st.nextToken();
  }

  private static int nextInt() {
    return Integer.parseInt(next());
  }

  private static long nextLong() {
    return Long.parseLong(next());
  }

  public static void main(String[] args) {
    run();
  }
}

Measured memory_bytes: 386260
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		String t = sc.next();
		int r = 0;
		for (int i = 0; i < 3; i++) {
			if (s.charAt(i) == t.charAt(i)) {
				r++;
			}
		}
		System.out.println(r);
		sc.close();
	}
}


Measured memory_bytes: 23508
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    c = LI()
    c.sort(reverse = True)
    dp = [0]*n
    dp[0] = c[0]
    p = 1
    for i in range(n-1):
        ni = i+1
        dp[ni] = (2*dp[i]+p*(2+ni)*c[ni])%mod
        p *= 2
        p %= mod
    p *= 2
    p %= mod
    print(p*dp[n-1]%mod)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 95408
#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)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N;
    cin >> N;
    vector<int> A1(N + 1), A2(N + 1);
    rep(i, 0, N) {
        cin >> A1[i + 1];
    }
    rep(i, 0, N) {
        cin >> A2[i + 1];
    }

    rep(i, 0, N) {
        A1[i + 1] += A1[i];
    }
    rep(i, 0, N) {
        A2[i + 1] += A2[i];
    }
    int ans = 0;
    rep(i, 1, N + 1) {
        ans = max(ans, A1[i] - A1[0] + A2[N] - A2[i - 1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int N, A, B; cin >> N >> A >> B;

    int total = 0;
    for (int i = 1; i<= N; i++) {
      int s = i%10+(i/10)%10+(i/100)%10+(i/1000)%10+(i/10000)%10;
        if (A <= s && s <= B) {
	  total += i;
        }
    }

    cout << total << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N, W;
    cin >> N >> W;
    vector <ll> weights(N+1), values(N+1);
    loop(i,1,N+1) cin >> weights[i] >> values[i];
    vector <ll> dp(W+1, -1);
    dp[0]=0;
    // dp[i] = maximum value possible with items weighing exactly i
    for (int i=1; i<=N; ++i)
    {
        for (int j=W-weights[i]; j>=0; --j)
        {
            if (dp[j]!=-1) {
                dp[j+weights[i]] = max(dp[j+weights[i]], dp[j]+values[i]);
            }
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

ll sqr(ll x){
    ll LA=x, SM=1;
    while(LA>SM+1){
        ll MID=(LA+SM)/2;
        if(MID*MID<=x) SM=MID;
        else LA=MID;
    }
    return SM;
}

ll dp[90000][101];
int main(){
    ll N,K; cin>>N>>K;
    

    ll S=sqr(N);

    
    
    for(int i=1;i<=S;i++) dp[i][0]=1;
    for(int i=1;i<=S;i++){
        ll a=N/i, b=N/(i+1);
        if(N<S*(S+1)) {if(i==S) break; dp[2*S-i][0]=a-b;}
        else dp[2*S+1-i][0]=a-b;
    }

    for(int i=1;i<=2*S;i++){
        if(N<S*(S+1) && i==2*S) break;
        dp[i][1]=dp[i-1][1]+dp[i][0];
    }

    for(int j=2;j<=K;j++){
        if(N<S*(S+1)) for(int i=1;i<2*S;i++) dp[i][j]=(dp[i-1][j]+dp[2*S-i][j-1]*dp[i][0])%mod;
        else for(int i=1;i<=2*S;i++) dp[i][j]=(dp[i-1][j]+dp[2*S+1-i][j-1]*dp[i][0])%mod;
    }

    /*for(int j=0;j<=K;j++) {
        for(int i=1;i<=2*S;i++) cout<<dp[i][j]<<' ';
        cout<<endl;
    }*/

    if(N<S*(S+1)) cout<<dp[2*S-1][K]<<endl;
    else cout<<dp[2*S][K]<<endl;

    


    

}

Measured memory_bytes: 51456
while True:
    x = input()
    if x == '-' :
        break
    m = int(input())
    
    for i in range(m):
        h = int(input())
        y = x[0:h]
        z = x[h:len(x)+1]
        x = list(z+y)
    x = ''.join(x)
    print(x)


Measured memory_bytes: 5592
#include <iostream>
#include <algorithm>
 
using namespace std;
 
#define MAX 500
typedef long long ll;
 
int main(){
    int n, arr[MAX];
 
    cin >> n;
    for(int i = 0 ; i < n ; i++){
	cin >> arr[i];
    }
    sort(arr, arr+n, greater<int>());
    ll ans = 0;
    for(int i = 0 ; i < n ; i++){
	if(arr[i]-i/4 > 0){
	    ans += arr[i]-i/4;
	}
    }
    cout << ++ans << endl;
 
    return 0;
}

Measured memory_bytes: 3148
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main(){
    string sdata,tdata,s,t;
    lli cnt=0;
    string alf="abcdefghijklmnopqrstuvwxyz";
    map<char,lli> smap,tmap;
    lli i,j;
    cin>>s>>t;
    rep(i,0,s.size()){
        if(smap[s[i]]==0){
            smap[s[i]]=smap.size();
        }
    }
    rep(i,0,t.size()){
        if(tmap[t[i]]==0){
            tmap[t[i]]=tmap.size();
        }
    }
//    for(auto itr=smap.begin();itr!=smap.end();itr++){
//        cout<<itr->first<<"を"<<alf[itr->second-1]<<"に変換する"<<endl;
//    }
//    for(auto itr=tmap.begin();itr!=tmap.end();itr++){
//        cout<<itr->first<<"を"<<alf[itr->second-1]<<"に変換する"<<endl;
//    }
    rep(i,0,s.size()){
        sdata+=alf[smap[s[i]]-1];
    }
    rep(i,0,t.size()){
        tdata+=alf[tmap[t[i]]-1];
    }
//    cout<<sdata<<endl<<tdata<<endl;
    if(sdata==tdata){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 1168
#include<iostream>
using namespace std;
int main()
{
    int ans, operand;
    char op;
    cin>>ans;
    while(cin>>op>>operand, op!='=') {
        switch(op) {
            case '+':
                ans += operand;
                break;
            case '-':
                ans -= operand;
                break;
            case '*':
                ans *= operand;
                break;
            case '/':
                ans /= operand;
                break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,n) for(int i=a;i<n;i++)
int main()
{
	int no_of_stones, no_of_steps;
    cin >> no_of_stones >> no_of_steps;

    vector <int> height(no_of_stones + 1, 0);
    for(int i = 1; i <= no_of_stones; i++)
        cin >> height[i];

    const int oo = 1e9;
    vector <int> minimum_cost(no_of_stones + 1, oo);
    minimum_cost[1] = 0;

    for(int i = 2; i <= no_of_stones; i++)
    {
        for(int j = i - 1; j >= max(1, i - no_of_steps); j--)
        {
            minimum_cost[i] = min(minimum_cost[i], minimum_cost[j] + abs(height[i] - height[j]));
        }
    }

    cout << minimum_cost[no_of_stones];
    return 0;
}


Measured memory_bytes: 4040
a,b,k = map(int,input().split())
c = 0
for i in range(k):
    a = int(a//2)
    b += a
    c += 1
    if c==k: print(a,b)
    b = int(b//2)
    a += b
    c += 1
    if c==k: print(a,b)

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

int main() {
    ll N, M; cin >> N >> M;
    vector<ll> A(N);
    ll sum = 0;
    ll cnt = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
    }
    ll sh = (sum+4*M-1)/(4*M);
    for (int i = 0; i < N; i++)
    {
        if(sh<=A[i]) cnt++;
    }
    if(cnt >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast","inline")
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=a;i<=b;i++)
#define Fod(i,b,a) for (int i=b;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define _SEED_ ('C'+'L'+'Y'+'A'+'K'+'I'+'O'+'I')
#define outval(x) printf(#x" = %d\n",x)
#define outvec(x) printf("vec "#x" = ");for (auto _v : x)printf("%d ",_v);puts("")
#define outtag(x) puts("----------"#x"----------")
#define outarr(a,L,R) printf(#a"[%d...%d] = ",L,R);\
						For(_v2,L,R)printf("%d ",a[_v2]);puts("");
using namespace std;
typedef long long LL;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=200005,mod=1e9+7;
int n,lim=200000;
int t[N],Next[N],a[N];
int dp[N];
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
int main(){
	n=read();
	For(i,1,n)
		a[i]=read();
	For(i,1,lim)
		t[i]=n+1;
	Fod(i,n,1){
		Next[i]=t[a[i]];
		t[a[i]]=i;
	}
	dp[1]=dp[2]=1;
	For(i,2,n){
		if (Next[i-1]>i)
			Add(dp[Next[i-1]],dp[i-1]);
		Add(dp[i+1],dp[i]);
	}
//	outarr(dp,1,n);
	cout<<dp[n]<<endl;
	return 0;
}

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

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

fn main() {
    let n: usize = read();
    let mut a: Vec<Vec<i64>> = vec![vec![]; n];
    let mut b: Vec<Vec<i64>> = vec![vec![]; n];

    for i in 0..n {
        for _ in 0..10 {
            let item = read();
            a[i].push(item);
        }
    }
    for i in 0..n {
        for _ in 0..11 {
            let item = read();
            b[i].push(item);
        }
    }
    let mut maxv: i64 = std::i64::MIN;
    // for i in 0..b.len() {
    //     println!("{:?}", b[i]);
    // }

    for i in 1..1 << 10 {
        let mut ans = 0;
        for j in 0..n {
            let mut pc = 0;
            for k in 0..10 {
                if i & (1 << k) != 0 && a[j][k] == 1 {
                    pc += 1;
                }
            }
            ans += b[j][pc];
        }
        if maxv < ans {
            maxv = ans
        }
    }
    println!("{}", maxv);
}


Measured memory_bytes: 4352
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	string ans = "";
	int tmp;
	string o, e;
	cin >> o >> e;
	REP(i, o.size()){
		ans += o[i];
		if(i < e.size()) ans+= e[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main (void) {
    int A, B, X;

    cin >> A >> B >> X;

    if (A > X) {
        cout << "NO" << endl;
    }

    else {
        if (A + B < X) {
            cout << "NO" << endl;
        }

        else {
            cout << "YES" << endl;
        }
    }

    return 0;
}

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

using namespace std;

typedef long long ll;

#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < ll(b); i++)
#define FORD(i, a, b) for (ll i = b - 1; i >= ll(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] ={ 1, 0, -1, 0 };
int dy[4] ={ 0, 1, 0, -1 };

int main()
{
    string s, t;
    cin>>s>>t;
    int ans=0;
    REP(i, s.length())
        if (s[i]!=t[i])
            ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 3836
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]){
  int i,j,m,n;
  int **matrix,*b;
  int tmp;
  /* - - - get data - - -*/
  //for matrix
  scanf("%d %d", &n, &m);
  matrix=(int **)malloc(sizeof(int *)*n);
  for(i=0; i<n; i++){
    matrix[i]=(int *)malloc(sizeof(int)*m);
    for(j=0; j<m; j++){
      scanf("%d", &matrix[i][j]);
    }
  }
  //for vector
  b=(int *)malloc(sizeof(int)*m);
  for(i=0; i<m; i++)
    scanf("%d", &b[i]);
  /* - - - calc - - -*/
  for(i=0; i<n; i++){
    tmp=0;
    for(j=0; j<m; j++)
      tmp+=matrix[i][j]*b[j];
    printf("%d\n", tmp);
  }
  //show
  return(0);
}



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

using namespace std;

int main()
{
    double x,y,w,h;
    long long c=0;

    cin>>w>>h>>x>>y;

//    d=w/2;

    if(x==w/2 && y==h/2)
    {

        c++;
        //printf("%.6f %d",a,c);

    }
     double a=(w/2)*1.0*h;
    printf("%.6lf %lld",a,c);
   /* else
    {
        float a=y*x*1.0;

        c=abs(d-x);
         printf("%.6f %d",a,c);

    }*/
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
const char key4[9][9]={
"aacd",
"bbcd",
"ghee",
"ghff"
};
const char key5[9][9]={
"aaccd",
"b.eed",
"bf..j",
"gf..j",
"ghhii"
};
int n,ans[1000][1000];
int main(){
	scanf("%d",&n);
	if(n==2)return 0*puts("-1");
	if(n%3==0){
	  for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)
		  if(i/3==j/3&&(i%3==0&&j%3==0||i%3==0&&j%3==1))putchar('a');
		  else if(i/3==j/3&&(i%3==1&&j%3==2||i%3==2&&j%3==2))putchar('b');
		  else putchar('.');
		puts("");
	  }
	  return 0;
	}
	if(n==7){
	  puts("a.aa.aa");
	  puts("abb.cc.");
	  puts("...edda");
	  puts("a..e..a");
	  puts("afg....");
	  puts(".fg...a");
	  puts("aa.aa.a");
	  return 0;
	}
	if(n==11){
	  puts("a.aa.aa....");
	  puts("abb.cc.....");
	  puts("...edda....");
	  puts("a..e..a....");
	  puts("afg........");
	  puts(".fg...a....");
	  puts("aa.aa.a....");
	  puts(".......aacd");
	  puts(".......bbcd");
	  puts(".......ghee");
	  puts(".......ghff");
	  return 0;
	}
	for(int i=0;i<n;i++)
	  for(int j=0;j<n;j++)ans[i][j]='.';
	for(int i=0;i*4<=n;i++)
	  for(int j=0;j*5<=n;j++)if(i*4+j*5==n){
		for(int k=0;k<i;k++)
		  for(int p=0;p<4;p++)
			for(int q=0;q<4;q++)
			  ans[k*4+p][k*4+q]=key4[p][q];
		for(int l=0;l<j;l++)
		  for(int p=0;p<5;p++)
			for(int q=0;q<5;q++)
			  ans[i*4+l*5+p][i*4+l*5+q]=key5[p][q];
		for(int i=0;i<n;i++){
		  for(int j=0;j<n;j++)putchar(ans[i][j]);
		  puts("");
		}
		return 0;
	  }
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x; cin >> x;
    x/=200;
    cout << 10-x << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
using namespace std; 
typedef long long ll; 
ll ans, fact[25]; 
int arr[25]; 
inline void chk(int len)
{
	ll res = 9 - my_abs(arr[0]); 
	for (int i = 1; i <= len - 1 >> 1; i++)
		res *= 10 - my_abs(arr[i]); 
	ans += res; 
}
void dfs(int cur, int len, ll rem)
{
	if (cur == len >> 1)
	{
		if (!rem)
		{
			arr[cur] = 0; 
			chk(len); 
		}
		return; 
	}
	ll diff = fact[len - cur - 1] - fact[cur]; 
	ll r = ceil((double)rem / diff), l = floor((double)rem / diff); 
	if (-9 <= r && r <= 9)
	{
		arr[cur] = r; 
		dfs(cur + 1, len, rem - diff * r); 
	}
	if (l != r && -9 <= l && l <= 9)
	{
		arr[cur] = l; 
		dfs(cur + 1, len, rem - diff * l); 
	}
}
int main()
{
	// freopen("ARC075-F.in", "r", stdin); 
	ll d;
	scanf("%lld", &d); 
	fact[0] = 1; 
	for (int i = 1; i <= 18; i++)
		fact[i] = fact[i - 1] * 10; 
	for (int cnt = 1; cnt <= 18; cnt++)
	{
		memset(arr, 0, sizeof(arr)); 
		dfs(0, cnt, d);
	}
	printf("%lld\n", ans);
	return 0; 
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
long long a,b,c,i,j,k;
int main(){
	cin>>a;
	for(i=1;i<=a;i++){
		if((i+1)*i/2>=a){
			cout<<i<<endl;
			return 0;
		} 
	}
} 

Measured memory_bytes: 256
a,b=map(int,input().split())

def xor(n):
    ret=0
    i=1
    while True:
        div,mod=divmod(n,i)
        flg=i*(div//2)
        if div%2==1:
            flg+=(mod+1)
        if flg%2==1:
            ret+=i
        i*=2
        if i>n:
            break
    return ret
print(xor(a-1)^xor(b))


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

typedef long long ll;

int N;
vector<int> G[100010];

ll dp[100010];

ll DFS(int v,int p)
{
    ll AND = 0,OR = 0;
    if(G[v].size() == 1 && G[v][0] == p)return dp[v] = 1;
    for(int i = 0; i < G[v].size(); i++)
    {
        int ne = G[v][i];
        if(ne == p)continue;
        ll now = DFS(ne,v);
        AND |= (now & OR);
        OR |= now;
    }
    int id = 0;
    while(AND >= (1 << id))id++;
    while((OR >> id) & 1)id++;
    return dp[v] = (OR + (1 << id)) & (~((1 << id) - 1));
}

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N - 1; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        G[a].push_back(b);
        G[b].push_back(a);
    }

    ll res = DFS(1,-1);

    for(int i = 0; res >> i; i++)
    {
        if(res >> i + 1 == 0)
        {
            printf("%d\n",i);
            return 0;
        }
    }
}


Measured memory_bytes: 12160
#include<bits/stdc++.h>
#define INF (1e9)
#define N 105
using namespace std;
int n,dp[N],c,f;
string s[N],t[N];
map<string,int> m;
int e[N];

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s[i];
    if(s[i]=="goto"){
      cin>>t[i];
      t[i][t[i].size()-1]=':';
    }
    else m[s[i]]=i;
  }
  for(int i=0;i<n;i++){
    if(s[i]=="goto")e[i]=m[t[i]];
    else e[i]=i+1;
  }
  for(int i=0;i<n;i++)dp[i]=INF;
  dp[n]=c=0,f=1;
  while(f){
    f=0;
    for(int i=n-1;i>=0;i--){
      if(dp[i]>dp[e[i]])
	dp[i]=dp[e[i]],f=1;
      if(dp[i]>dp[i+1]+1)
	dp[i]=dp[i+1]+1,f=1;
    }
  }
  cout<<dp[0]<<endl;
  return 0;
}

Measured memory_bytes: 1228
#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;

void solve()
{	
	string s;cin >> s;
	int n; cin >> n;
	vector<string> commands(n);
	vector<string> subst(n);
	vector<int> a(n),b(n);
	rep(i, n)
	{
		cin >> commands[i] >> a[i] >> b[i];
		if(commands[i] == "replace")cin >> subst[i];
	}
	rep(i, n)
	{
		if(commands[i] == "replace")
		{
			rep(j,sz(subst[i]))
			{
				s[a[i]+j] = subst[i][j];
			}
		}
		else if(commands[i] == "reverse")
		{
			reverse(s.begin()+a[i],s.begin()+b[i]+1);
		}
		else
		{
			cout << s.substr(a[i],b[i]-a[i]+1) << endl;
		}
	}
	return;
}

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



Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define MAX_N 100000
using namespace std;

int par[MAX_N + 1], ds[MAX_N + 1];

void init(int n) {
    for (int i = 1; i <= n; i++) {
        par[i] = i;
        ds[i] = 0;
    }
}

int find(int x) {
    if (par[x] == x)
        return x;
    int px = par[x];
    par[x] = find(par[x]);
    ds[x] += ds[px];
    return par[x];
}

bool unite(int _x, int _y, int d) {
    int x = find(_x), y = find(_y);
    if (x == y) {
        if (ds[_y] - ds[_x] != d)
            return false;
    } else {
        par[y] = x;
        ds[y] = d - ds[_y] + ds[_x];
    }
    return true;
}

int main() {
    int n, m;
    cin >> n >> m;
    init(n);
    for (int i = 0; i < m; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        if (!unite(l, r, d)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 1024
# coding: utf-8

all_sec = int(input().rstrip())

hour = all_sec // (60 * 60)
all_sec %= (60 * 60)

minite = all_sec // 60
all_sec %= 60

second = all_sec

print(str(hour) + ":" + str(minite) + ":" + str(second))


# <?php

# $all_sec = trim(fgets(STDIN));

# $hour = floor($all_sec / (60 * 60));
# $all_sec %=  (60 * 60);

# $minite = floor($all_sec / 60);
# $all_sec %=  60;

# $second = $all_sec;

# echo $hour . ":" . $minite . ":" . $second . PHP_EOL;

# ?>


Measured memory_bytes: 5592