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

struct P
{
    int x,y,z;

    bool operator<(const P &a)const{
              return z>a.z;
    }
};


vector<P> v[10];
//bitset<4001000> b;
int a,c,i,b,k,n,d,e,m;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int l[33];

int o[101];
int j[11];
int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={-1,0,1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};


long long x,y,mod=1000000007;
long long z[222222];

P u[120];
stack<int> s;
//queue<int> q,q1,q2;
//set<int> s;
queue<int> q;

//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<long long,int> p;
//list<int> l;
string r1,r;
//char r[22][2];
//deque<int> de;
bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}


int main()
{
    scanf("%d",&a);
    p[0]++;
    for(int t=1;t<=a;z[t]+=z[t-1],x+=p[z[t]],p[z[t]]++,t++)
    {
        scanf("%lld",&z[t]);
    }
    printf("%lld",x);
}


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

using namespace std;

int main(){
	int k;cin >> k;
	string s;
	cin >> s;
	int n = s.size();
	for(int i = 0; i < min(k,n); i++){
		cout << s[i];
	}
	if(n > k) cout << "..." << "\n";
	return 0;
}


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

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
//int a,b,c,d,e;
string H="HITACHI";
signed main(){
  int n;
  string s;cin>>s;
  n=(int)s.length();
  bool flag=false;bool ans=true;
  rep(i,n){
    if(s[i]!='h'&&i%2==0)ans=false;
    if(s[i]!='i'&&i%2==1)ans=false;
  }
  if(n%2==1)ans=false;
  if(ans){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

int main() {
  int n, d, x;
  std::cin >> n >> d >> x;
  std::vector<int> a(n);
  for (auto &i : a) {
    std::cin >> i;
  }

  int count = 0;

  for (int i = 0; i < n; i++) {
    int j = 1;
    while (j <= d) {
      j += a[i];
      count++;
    }
  }

  std::cout << count + x << std::endl;
  return 0;
}


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

using T = tuple<int,int,int>;
using P = pair<int,int>;

vector<P> G[2000];
bool visited[2000];
int dfs(int current, int pre, int start, int k, int len, int sum){
    visited[current]=true;
    int ret=-1;
    if(len==k)ret=sum;
    for(auto p:G[current]){
        int to,weight;
        tie(to,weight)=p;
        if(to==pre) continue;
        if(to==start&&len==k){
            ret=sum+weight;
            continue;
        }
        if(len<k){
            ret = max(ret,dfs(to,current,start,k,len+1,sum+weight));
        }
    }
    visited[current]=false;
    return ret;
}

int main(){
    int n,k,s;
    while(cin>>n>>k>>s,n){
        vector<T> V;
        for(int i=0;i<n;i++){
            int x,y,z;
            cin>>x>>y>>z;
            V.emplace_back(x,y,z);
        }
        for(auto &g:G) g.clear();
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                int ix,iy,iz,jx,jy,jz;
                tie(ix,iy,iz)=V[i];
                tie(jx,jy,jz)=V[j];
                int cx = max(0,s-abs(ix-jx));
                int cy = max(0,s-abs(iy-jy));
                int cz = max(0,s-abs(iz-jz));
                if(cx&&cy&&cz){
                    G[i].emplace_back(j,2*(cx*cy+cy*cz+cz*cx));
                    G[j].emplace_back(i,2*(cx*cy+cy*cz+cz*cx));
                }
            }
        }
        
        int ans = 0;
        for(int i=0;i<n;i++){
            fill(visited,visited+2000,false);
            ans = max(ans,dfs(i,-1,i,k,1,0));
        }
        if(k>1&&!ans) ans=-1;
        else ans = 6*s*s*k-ans;
        cout<<ans<<endl;
    }


    return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <string>
#include <stdlib.h>
#define MAX 2000000
#define MOD 2019
using namespace std;

typedef long long int ll; 

int DP[2][MOD];//={};

int main(void){
  string str;
  cin >> str;
  char c1 = str[0];
  int num1 = atoi(&c1);
  DP[0][num1] = 1;
  DP[1][num1]=1;
  ll sum = 0;
  for(int i=1;i<str.length();i++){
    //前にコピー
    char c = str[i];
    int num = atoi(&c);
    //cout << num << endl;
    for(int i=0;i<MOD;i++){
      DP[0][i] = DP[1][i];
      DP[1][i] = 0;
    }
    DP[1][num] = 1;
    for(int i=0;i<MOD;i++){
      DP[1][(10*i+num)%MOD] += DP[0][i];
    }
    sum = sum + DP[1][0];
  }
  cout << sum << endl;
  return 0; 
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int n; cin >> n;
	int t_s = 0;
	int h_s = 0;
	REP(i, n) {
		string t_c, h_c; cin >> t_c >> h_c;
		if (t_c > h_c) {
			t_s += 3;
		} else if (h_c > t_c) {
			h_s += 3;
		} else if (t_c == h_c) {
			t_s += 1;
			h_s += 1;
		}
	}
	printf("%d %d\n", t_s, h_s);
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



Measured memory_bytes: 3304
s=input()
n=len(s)+1
mountain=[0,0]
count=[0,0]
sum=0
for i in range(n-1):
    if s[i]=="<":
        mountain[1]+=1
    else:
        if mountain[1]>0:
            sum+=(mountain[0]*(mountain[0]-1)+mountain[1]*(mountain[1]+1))//2+max([0,mountain[0]-count[1]])
            count=mountain
            mountain=[1,0]
        else:
            mountain[0]+=1

sum+=(mountain[0]*(mountain[0]-1)+mountain[1]*(mountain[1]+1))//2+max([0,mountain[0]-count[1]])

print(sum)


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

int main(){

    ios::sync_with_stdio(0) ;
    int n ;
    int a, b, c ;
    cin >> n >> a >> b ;
    int ans = 0 ;
    for(int i = 2; i < n; i++){

        cin >> c ;
        if((a<b && b<c)||(a>b && b>c)){
            ans++ ;
        }
        a = b ;
        b = c ;

    }
    cout << ans ;

}


Measured memory_bytes: 256
/*
  AtCoder Regular Contest 100
  C - Linear Approximation
*/

#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int N;
int A[200000];

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

  sort(A, A+N);
  int med = A[(N/2)];
  
  unsigned long long result = 0;
  for (int i = 0; i < N; ++i) result += abs(A[i] - med);
  printf("%llu\n", result);
  return 0;
}

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

int main() {
  int a, b;
  
  cin >> a >> b;
  
  if ( a * b % 2 == 0) {
    cout << "Even" << endl;
  }
  
  else {
    cout << "Odd" << endl;
  }
  
}


Measured memory_bytes: 256
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

a,b,c,d = In.ints()

Out.int(max([a*c, a*d, b*c,b*d]))

######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

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

int main(){
  int N;
  cin >> N;
  vector<string> s(N);
  vector<string> W(N);
  vector<int> C(N);
  for(int i=0; i<N; i++){
    cin >> s[i];
    W[i]="##";
  }
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(W[j]=="##"){
        W[j]=s[i];
        C.at(j)++;
        break;
      }
      else if(W[j]==s[i]){
        C.at(j)++;
        break;
      }
    }
  }
  int M;
  cin >> M;
  for(int i=0; i<M; i++){
    string t;
    cin >> t;
    for(int j=0; j<N; j++){
      if(W[j]==t){
        C.at(j)--;
        break;
      }
    }
  }
  sort(C.begin(), C.end());
  cout << max(0, C.at(N-1)) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
   int n,a[210],sum=0;
   scanf("%d",&n);
   for (int i=1;i<=2*n;i++)
   scanf("%d",&a[i]);
   sort(a+1,a+1+2*n);
   for (int i=1;i<=2*n;i+=2)
      sum+=min(a[i],a[i+1]);
      printf("%d\n",sum);
   return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main()
{
	int count[26] = {0};
	char ch;
	while (true)
	{
		cin.get(ch);
		if (cin.fail())
			break;
		if (isupper(ch))
			ch = tolower(ch);
		if(islower(ch))
			count[ch - 'a']++;
	}
	for (int i = 0; i < 26; i++)
		cout << char('a' + i) << " : " << count[i] << endl;
}


Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
using namespace std;


int main() {
  int K, S;
  cin >> K >> S;
  
  int num = 0;
  for (int x=0; x <= K; x++){
    for (int y=0; y <= K; y++){
        if ((x+y <= S)and(K>=S-x-y)) ++num;
    
    } 
  }
  cout << num << endl;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    int N;
    cin >> N;
    unordered_map<string, int> mp;
    string S;
    for (int i = 0; i < N; i++) {
        S.clear();
        cin >> S;
        ++mp[S];
    }

    int vmax = 0;
    for (const auto& p : mp) {
        vmax = max(vmax, p.second);
    }
    vector<string> anses;
    for (const auto& p : mp) {
        if (p.second == vmax) {
            anses.emplace_back(p.first);
        }
    }
    sort(anses.begin(), anses.end());

    for (const auto& ans : anses) {
        cout << ans << "\n";
    }

    return 0;
}

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

  using namespace std;
  vector<int> vi;
  int main(){
 	int A , B , K;
	scanf("%d%d%d",&A,&B,&K);
	for(int i  = A ; i < min(A + K , B +1) ; ++i){
		vi.push_back(i);
	}
	for(int i = B ; i > max(B-K , A-1) ; --i){
		vi.push_back(i);
	}
	sort(vi.begin() , vi.end());
	vector<int>::iterator it = unique(vi.begin() , vi.end());
	vi.resize(distance(vi.begin() ,it ));
	for(int i =0 ; i  < vi.size() ; ++i){
		printf("%d\n",vi[i]);
	}
  }

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

int main(){

int a,b,c,k;
cin >> a >> b >> c >> k;
int ans=0;
if(k<=a) ans=k;
else if(k<=a+b) ans=a;
else ans=a-(k-(a+b));
cout << ans << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int n,a[100005],b[100005],c[100005],dpa[100005],dpb[100005],dpc[100005],mn=1e9;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
	}
	dpa[1]=a[1];
	dpb[1]=b[1];
	dpc[1]=c[1];
	for(int i=2;i<=n;i++){
		dpa[i]=max(dpb[i-1]+a[i],dpc[i-1]+a[i]);
		dpb[i]=max(dpa[i-1]+b[i],dpc[i-1]+b[i]);
		dpc[i]=max(dpa[i-1]+c[i],dpb[i-1]+c[i]);
	}
	mn=max(dpa[n],dpb[n]);
	mn=max(mn,dpc[n]);
	cout << mn;
}

Measured memory_bytes: 2560
import math
a,b,h,m=map(int, input().split())

s_1=h/12*360+m/60*30
s_2=m/60*360
s=s_1-s_2
ans=0
if abs(s)==180:
    print(a+b)
    exit()

if abs(s)<180:
    s=s
else:
    s=360-s

s=math.radians(s)
    
ans=a**2+b**2-2*a*b*math.cos(s)
ans=abs(ans**0.5)

print(ans)

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

int main(){
  int N;
  cin >> N;
  int x,y;
  int sum = 0;
  
  rep(i,N){
    cin >> x >> y;
    sum += y-x+1;
  }
  
  cout << sum << endl;
}   

Measured memory_bytes: 256
//
//  Print_Test_Cases.c
//  AOJ
//
//  Created by admin on 2014/07/12.
//
//

#include <stdio.h>

main()
{
    int x;
    int i=0;
    
    do{
        scanf("%d",&x);
        if(x==0){
            break;
        } else {
            printf("Case %d: %d\n",++i,x);
        }
    }while(1);
    
    return 0;
}

Measured memory_bytes: 600
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;
use std::cmp::min;

fn main() {
    let _n: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();
    let t: Vec<char> = read::<String>().chars().collect();

    let mut ans = s.len() + t.len();

    for i in 0..min(s.len(), t.len()) + 1 {
        if s[s.len() - i..] == t[..i] {
            ans = s.len() + t.len() - i;
        }
    }

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

int main()
{
    ll n;
    string s;
    cin >> n;
    do {
        n--;
        s += n % 26 + 97;
        n = n / 26;
    } while (n != 0);
    reverse(s.begin(), s.end());
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3592
a,b,k = map(int,(input().split()))
ans = []
for i in range(a,min(a+k,b)):
    ans.append(i)
for i in range(max(b+1-k,a),b+1):
    ans.append(i)
ans = list(set(ans))
ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define forsn(i,x,y) for(long long i = (x) ; i <= (y) ; ++i)
typedef long long ll;
typedef long double ld;

void show_pairs(pair<int,pair<int,int>> x) {
  cout << "ldif:" << x.first << " (" << x.second.first << "," << x.second.second << endl;
}
vector<int> a;
pair<int,pair<int,int>> finddif(int s, int e) { // (dif,(max,min))
  //cout << s << " " << e << endl;
  if(s == e) {
    return make_pair(0, make_pair(a[s],a[s]));
  }
  pair<int,pair<int,int>> x = finddif(s, (s+e)/2);
  pair<int,pair<int,int>> y = finddif((s+e)/2+1, e);
  int lmax = max(max(x.first,y.first),y.second.first - x.second.second);
  return make_pair(lmax, 
                   make_pair(max(x.second.first,y.second.first), 
                             min(x.second.second,y.second.second)));
}

pair<int, pair<int,int>> finddifcount(int s, int e, int dif) {
  if(s == e) {
    return make_pair(0, make_pair(a[s],a[s]));
  }
  pair<int,pair<int,int>> x = finddifcount(s, (s+e)/2, dif);
  pair<int,pair<int,int>> y = finddifcount((s+e)/2+1, e, dif);
  int intermax = y.second.first - x.second.second;
  int ldifcnt = x.first + y.first + (intermax==dif?1:0);
  return make_pair(ldifcnt,
                   make_pair(max(x.second.first,y.second.first), 
                             min(x.second.second,y.second.second)));
}

int main() {
  int n, t;
  cin >> n >> t;
  forn(i,n) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  pair<int,pair<int,int>> r = finddif(0,a.size()-1);
  int dif = r.first;
  pair<int,pair<int,int>> res = finddifcount(0,a.size()-1,dif);
  cout << res.first << endl;
  //cout << "dif:" << r.first << " (" << r.second.first << "," << r.second.second << ")" << endl;
  return 0;
}

Measured memory_bytes: 892
def main():
    N, C, K = map(int, input().split())
    T = [int(input()) for _ in range(N)]
    T.sort()
    ans = 0
    remain = 0
    first = 0
    for t in T:
        if remain <= 0 or first + K < t:
            remain = C
            first = t
            ans += 1
        remain -= 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 50520
#include<iostream>
#include<bits/stdc++.h>
#include<array>
using namespace std;
#define int long long
#define fast_cin ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define endl "\n"
#define with_tests int t; cin >> t; while(t--){ solve(); cout << endl; }
#define without_tests solve(); cout << endl;
#define CEIL(x, y) (ll)ceil((long double)(x)/(long double)(y))
#define epsilon 1e-9 
typedef long long ll;
const int mod = 1e9+7;
const int N = 1e5+1;

void solve(){
    
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i=0; i<n; i++){
        cin >> h[i];
    }
    vector<int> dp(n);
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=2; i<n; i++){
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
        // cout << i << " " << dp[i] << endl;
    }
    cout << dp[n-1]; 

}

int32_t main(){

    fast_cin;
    // with_tests;
    without_tests;

    return 0;
}


Measured memory_bytes: 4756
N,M=map(int,input().split())
list=[[] for i in range(3*N)]
for i in range(M):
  u,v=map(int,input().split())
  list[3*u-3].append(3*v-2)
  list[3*u-2].append(3*v-1)
  list[3*u-1].append(3*v-3)
s,t=map(int,input().split())
def bfs(a,b):
  visited=[-1 for i in range(3*N)]
  visited[a]=0
  h=[]
  h.append(a)
  while h:
    v=h.pop(0)
    for k in list[v]:
      if visited[k]==-1:
        visited[k]=visited[v]+1
        h.append(k)
  return visited[b]

print(bfs(3*s-3,3*t-3)//3) 

Measured memory_bytes: 61380
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;


public class Main {
	public static void main(String[] args) throws Exception {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			long[] a = new long[n];
			for(int i=0; i<n; i++) {
				a[i] = sc.nextLong();
			}
			Arrays.sort(a);
			Map<Integer, Integer> map = new TreeMap<>(Comparator.reverseOrder());
			for(int i=0; i<m; i++) {
				int s = sc.nextInt();
				int t = sc.nextInt();
				if(map.get(t)!=null)	s+=map.get(t);
				map.put(t, s);
			}
			long ans = 0;
			int now = 0;
			for(Integer key:map.keySet()) {
				int dis = Math.min(now+map.get(key), n);
				for(int i=now; i<dis; i++) {
					if(a[i]<key) {
						a[i] = key;
					}
				}
				now = dis;
			}
			for(int i=0; i<n; i++) {
				ans += a[i];
			}
			System.out.println(ans);
		}
	}

}

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

int n, p[10000], r[10000];

int findSet(int x) {
  if (p[x] != x) p[x] = findSet(p[x]);
  return p[x];
}
void unite(int x, int y) {
  x=findSet(x);
  y=findSet(y);
  if (r[x] < r[y]) {
    p[x] = p[y];
  } else {
    p[y] = p[x];
    if (r[x] == r[y]) r[x]++;
  }
}
int same(int x, int y) {
  if (findSet(x) == findSet(y)) return 1;
  return 0;
}
int main() {
  int q, com, x, y;

  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    p[i] = i;
    r[i] = 0;
  }
  for (int i = 0; i < q; i++) {
    cin >> com >> x >> y;
    if (com == 0)
      unite(x, y);
    else
      cout << same(x, y) << endl;
  }

  return 0;
}



Measured memory_bytes: 3192
#include <iostream>
#include <set>
using namespace std;
int main(void){
    int N,next,min = 1000000000,c;
    set<int> A;
    cin >> N;
    for(int i=0; i<N;i++){
        cin >> c;
        if(min > c)min = c;
        A.insert(c);
    }
    if(A.size() != N){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main(){
	int x , y , a , b , c;
	cin>>x>>y>>a>>b>>c;
	vector<int> aa(a) , bb(b) , cc(c);
	for(int i = 0 ; i < a ; i++) cin>>aa[i];
	for(int i = 0 ; i < b ; i++) cin>>bb[i];
	for(int i = 0 ; i < c ; i++) cin>>cc[i];
	sort(aa.begin() , aa.end());
	sort(bb.begin() , bb.end());
	for(int i = a - 1 ; i >= max(a - x, 0LL) ; i--) cc.push_back(aa[i]);
	for(int i = b - 1 ; i >= max(b - y, 0LL) ; i--) cc.push_back(bb[i]);
	sort(cc.begin() , cc.end());
	int ans = 0;
	for(int i = cc.size() - 1 ; i >= cc.size() - (x + y) ; i--)
		ans += cc[i];
	cout << ans << endl;
}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl
#define YORN(f) cout<<((f)?"YES":"NO")<<endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    YORN(b - a == c - b);
    return 0;
}

Measured memory_bytes: 3572
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>


int main(void)
{
	char str[11], ring[100][11];
	int number, str_len;

	scanf("%s", str);
	str_len = strlen(str);
	scanf("%d", &number);
	for (int i = 0; i < number; i++) {
		scanf("%s", ring[i]);
	}

	int ring_count = 0, ring_len;
	for (int i = 0; i < number; i++) {
		ring_len = strlen(ring[i]);
		for (int j = 0; j < ring_len; j++) {
			if (ring[i][j] == str[0]) {
				bool success = true;
				int point = 0;
				for (int k = 1; k < str_len; k++) {
					if (j + k < ring_len) {
						if (ring[i][j + k] != str[k]) {
							success = false;
							break;
						}
					}
					else {
						if (ring[i][point] != str[k]) {
							success = false;
							break;
						}
						point++;
					}
					
				}

				if (success == true) {
					ring_count++;
					break;
				}
			}
		}
	}

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

	return 0;
}

Measured memory_bytes: 1036
use proconio::input;

fn main() {
    input! {
        n: usize,
        p: usize,
        a: [usize; n],
    }
    let mut even = 0;
    let mut odd = 0;

    for &na in &a {
        if na % 2 == 0 {
            even += 1;
        } else {
            odd += 1;
        }
    }

    let ans;
    if p == 1 {
        if odd > 0 {
            ans = 2usize.pow(even) * 2usize.pow(odd-1);
        } else {
            ans = 0;
        }
    } else {
        if odd > 0 {
            ans = 2usize.pow(even) * 2usize.pow(odd-1);
        } else {
            ans = 2usize.pow(even);
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2172
import java.util.Arrays;
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    // 準備
    int ac = 0;
    int pena = 0;
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] p = new int[m];
    String[] s = new String[m];

    int[] submit = new int[n+1];
    int[] wa = new int[n+1];
    Arrays.fill(submit, 0);
    Arrays.fill(wa, 0);

    for(int i=0; i<m; ++i) {
      p[i] = sc.nextInt();
      s[i] = sc.next();
    }

    for(int i=0; i<m; ++i) {
      if(submit[p[i]] == 0 && s[i].equals("WA")) {
        ++wa[p[i]];
      }

      if(submit[p[i]] == 0 && s[i].equals("AC")) {
        submit[p[i]] = 1;
        ++ac;
        pena += wa[p[i]];
      }
    }
    System.out.println(ac +" "+pena);

  }
}

Measured memory_bytes: 69608
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>
 
 
 
int main(){
  
  long long int N, A_max, i_max, A_max2, i_max2, A_tmp;
  A_max = 0;
  A_max2 = 0;
  
  scanf("%lld", &N);
  for(int i = 1; i <= N; i++){
    // read A
    scanf("%lld", &A_tmp);
    // update max
    if(A_tmp >= A_max){
      i_max2 = i_max;
      A_max2 = A_max;
      i_max = i;
      A_max = A_tmp;
    }
    // update second max
    else if(A_tmp >= A_max2){
      i_max2 = i;
      A_max2 = A_tmp;
    }
  }
  
  std::cerr << "Answer: " << std::endl;
  for(int i = 1; i <= N; i++){
    if(i == i_max){
      std::cout << A_max2 << std::endl;
    }
    else{
      std::cout << A_max << std::endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
#include<string.h>
int main(){
    char s[100];
    scanf("%s",s);
    int f, l;
    l = strlen(s);
    int count = 0;
    for(int i = 0; i < l; i++)
        if(s[i] == s[l - i - 1])
            count ++;
    if(count != l){
        printf("No\n");
        return 0;
    }
    count = 0;
    for(int i = 0; i < (l - 1) / 2; i++)
        if(s[i] == s[(l - 1) / 2 - i - 1])
            count ++;
    if(count == (l - 1) / 2)
        printf("Yes\n");
    else   
        printf("No\n");
    return 0;
}

Measured memory_bytes: 128
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;

int n,c[1010],box[1010],q,t,x,d;

int main(){
    I(n);
    REP(i,n) I(c[i+1]);
    I(q);
    REP(i,q){
        I(t); I(x); I(d);
        if (t==1){
            box[x] += d;
            if (box[x] > c[x]){
                cout << x << endl;
                return 0;
            }
        } else {
            box[x] -= d;
            if (box[x] < 0){
                cout << x << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
}



Measured memory_bytes: 3244
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
long long ans,n,k;
long long maxx(long long a,long long b)
{
	if(a>b)  return a;
	else     return b;
}
int main()
{
	cin>>n>>k;
	n++;
	for(long long i=k+1;i<n;i++)//1---n-1
	{
		long long x=i-k;
		ans+=n/i*x+maxx(0,n-n/i*i-k);
	} 
	printf("%lld\n",ans-(!k)*(n-1));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
typedef pair<int,int> P;
typedef pair<int,P> PP; 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1e9+7;

signed main(){
  double w,h,x,y;
  cin>>w>>h>>x>>y;
  printf("%.10lf",w*h/2.);
  cout<<" "<<(int)(x*2==w&&y*2==h)<<endl;
  return 0;
}


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

#define S size()
#define E end()
#define B begin()
#define L length()
 
#define endl "\n"
#define cnt count
#define in insert
#define er erase
#define fi first
#define se second
#define fl float
#define ld long double
#define ll long long

#define gcd __gcd
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define all(v) v.B,v.E
#define acc(v) accumulate(all(v), 0)
#define psum partial_sum
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define np next_permutation
#define maxe *max_element
#define mine *min_element
 
#define forl(i,n) for(ll i = 0; i < n; i++)
#define fore(i,m,n) for (ll i = m; i <= n; i++)
#define rforl(i,n) for (ll i = n - 1; i >= 0; i--)
#define rfore(i,m,n) for (ll i = m; i >=n; i--)    
#define iter(s) for(auto it:s)
 

#define prec(n) fixed<<setprecision(n)
#define popcnt(n) __builtin_popcountll(n)
#define parity(n) __builtin_parityll(n)
#define clz(n) __builtin_clzll(n)
#define ctz(n) __builtin_ctzll(n)

#define sll set<ll>
#define sc set<char>
#define mll map<ll,ll>
#define vll vector<ll>
#define vc vector<char>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define msll multiset<ll>
#define msc multiset<char>
#define vvll vector<vector<ll>>
#define rev reverse

#define tc ll q;cin>>q;while(q--)
#define pat ll n;cin>>n;
#define pat1 vll a(n);forl(i,n)cin>>a[i];
#define pat2 ll n,k;cin>>n>>k;vll a;forl(i,n) cin>>a[i];
#define pats string s;cin>>s;
#define yesno if(flag)cout<<"YES\n";else cout<<"NO\n";
#define loop forl(i,n)

#define p0(a) cout << a << " ";
#define p1(a) cout << a << endl;
#define p2(a,b) cout << a << " " << b << endl;
#define p3(a,b,c) cout << a << " " << b << " " << c << endl;
#define p4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
 
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define mod1 1000000007
#define mod2 998244353
#define PI 3.1415926535897932384626433832

//**********************************
 
int main(){
    ll a,b;
    cin>>a>>b;
    p1(a*b)
    
}

Measured memory_bytes: 3632
#include <stdio.h>
int main(void){
    char x[0];
    scanf("%s",x);
    if(x[0]=='A'){
        printf("T");
    }
    else if(x[0]=='C'){
        printf("G");
    }
    else if(x[0]=='G'){
        printf("C");
    }
    else if(x[0]=='T'){
        printf("A");
    }
}


Measured memory_bytes: 128
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
#include<stack>
using namespace std;
#define ul unsigned long long

#define rep(a, b) for(int i = a; i < b; i++)



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

	int sp = 0;
	int leftBrace = 0;
	int rightBrace = 0;
	for (int i = 0; i < n; i++) {
		char c = s[i];
		if (c =='(') {
			sp++;
		}
		else {
			if (sp <= 0) {
				leftBrace++;
			}
			else {
				sp--;
			}
		}
		
	}
	if (sp > 0) {
		rightBrace = sp;
	}
	//else if(sp<0) {
	//	leftBrace += sp;
	//}
	string l = "";
	rep(0, leftBrace) {
		l += "(";
	}
	string r = "";
	rep(0, rightBrace) {
		r += ")";
	}
	cout << l + s + r << endl;

	return 0;
}





Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.text.*;
//Solution Credits: Taranpreet Singh
public class Main{
    //SOLUTION BEGIN
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        int n = ni();
        long[] h = new long[1+n], dp = new long[1+n];
        for(int i = 1; i<= n; i++)h[i] = nl();
        Arrays.fill(dp, IINF);
        dp[1] = 0;
        for(int i = 1; i<= n; i++){
            if(i+1<=n)dp[i+1] = Math.min(dp[i+1], dp[i]+Math.abs(h[i+1]-h[i]));
            if(i+2<=n)dp[i+2] = Math.min(dp[i+2], dp[i]+Math.abs(h[i+2]-h[i]));
        }
        pn(dp[n]);
    }
    //SOLUTION END
    void hold()throws Exception{throw new Exception("Hold right there, Sparky!");}
    long mod = (long)1e9+7, IINF = (long)4e18;
    final int INF = (int)2e9, MX = (int)1e6+1;
    DecimalFormat df = new DecimalFormat("0.000000000000000");
    double PI = 3.1415926535897932384626433832792884197169399375105820974944, eps = 1e-8;
    static boolean multipleTC = false, memory = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        int T = (multipleTC)?ni():1;
        //Solution Credits: Taranpreet Singh
        pre();for(int i = 1; i<= T; i++)solve(i);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

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

        String nextLine(){
            String str = "";
            try{   
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }  
            return str;
        }
    }
}    

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

int main(int argc, char** argv){
	cin >> n;
	ans = n * n * n;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) (v.begin(), v.end())
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll n, m;
    cin >> n >> m;
    
    ll ans = 0;
    if (n >= m) {
        ans = m / 2;
    } else if (m >= 2 * n) {
        ans = n + (m - 2 * n) / 4;
    } else {
        ans = m / 2;
    }

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


Measured memory_bytes: 256
h, w, k = map(int, input().split())

choco = [[0] * w for _ in range(h)]

for i in range(h):
    s = input()
    for j in range(w):
        choco[i][j] = int(s[j])

ans = float("inf")
for bit in range(1 << (h - 1)):
    idx = [0] * h
    group = 0
    for i in range(h):
        idx[i] = group
        if (bit >> i) & 1:
            group += 1
    group += 1
    array = [[0] * w for _ in range(group)]
    for j in range(w):
        for i in range(h):
            array[idx[i]][j] += choco[i][j]

    cnt = group - 1
    cum = [0] * group
    canAdd = True
    for i in range(w):
        for j in range(group):
            if cum[j] > k:
                canAdd = False

        if ans <= cnt:
            canAdd = False

        if canAdd is False:
            break

        for j in range(group):
            tmp = cum[j] + array[j][i]
            if tmp > k:
                cnt += 1
                for l in range(group):
                    cum[l] = array[l][i]
                break
            cum[j] += array[j][i]

    if canAdd:
        ans = min(ans, cnt)

print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
    using namespace std;
    #define fi first
    #define se second
    #define countof(array) (sizeof(array) / sizeof(array[0]))
    #define rep(i,n) for(int i = 0; i < (n); ++i)
    #define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
    #define srep(i,n,s) for(int i = s; i < (n); ++i)
    #define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
    #define all(a) (a).begin(),(a).end()
    #define rall(a) (a).rbegin(),(a).rend()
    #define aall(a) (a), (a)+countof(a)//for array sorting
    #define raall(a) (a), (a)+countof(a), greater<>()
    #define show(x) cout<<#x<<" = "<<x<<endl;
    #define vfind(v, a) find(all(v), a) != v.end()
    #define yn(f) { if (f) puts("YES"); else puts("NO"); }
    #define yns(f) { if (f) puts("Yes"); else puts("No"); }
    #define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
    #define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
    #define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
    #define argmax(v) distance((v).begin(), max_element(all(v)))
    #define argmin(v) distance((v).begin(), min_element(all(v)))
    #define vmax(v) *max_element(all(v))
    #define vmin(v) *min_element(all(v))
    typedef long long int ll;
    typedef pair<ll, int> P;
    typedef vector<P> vpair;
    typedef vector<int> vint;
    typedef vector<ll> vll;
    typedef vector<double> vdouble;
    typedef vector<string> vstr;
    typedef vector<bool> vbool;
    typedef vector<vint> vvint;
    typedef vector<vll> vvll;
    typedef vector<vstr> vvstr;
    typedef vector<vbool> vvbool;
    const ll LINF = 2000000000000000000ll;
    const int INF = 1000000100;
    const ll MOD = 1e9+7;
     
     
    vector<pair<int, ll>> edges[100005];
    vll d(100005, LINF);
     
    void dijkstra(int s) {
        priority_queue<P, vector<P>, greater<P>> que;
        d[s] = 0;
        que.push(P(0, s));
     
        while (que.size()) {
            P p = que.top();
            que.pop();
            int v = p.se;
            if (d[v] < p.fi) continue;
            for (auto e : edges[v]) {
                if (d[e.fi] > d[v] + e.se) {
                    d[e.fi] = d[v] + e.se;
                    que.push(P(d[e.fi], e.fi));
                }
            }
        }
    }
     
    int main() {
        int n;
        cin >> n;
        int a, b, c;
        rep(i, n-1) {
            cin >> a >> b >> c;
            --a;
            --b;
            edges[a].emplace_back(b, c);
            edges[b].emplace_back(a, c);
        }
     
        int q, k;
        cin >> q >> k;
        --k;
     
        dijkstra(k);
     
        int x, y;
        rep(i, q) {    
            cin >> x >> y;
            --x;
            --y;
            ll ans = d[x] + d[y];
            cout << ans << endl;
        }
     
        return 0;
    }

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

int main(){
    int A,B,C,X;
    cin >> A >> B >> C >> X;
    int total = 0;
    int result = 0;

    for (int a = 0; a <= A; a++){
        for (int b = 0; b <= B; b ++){
            for (int c = 0; c <= C; c ++){
                total = 500*a + 100 *b + 50*c;
                if (total == X){
                    result ++;
                }

            }
        }
    }
    cout << result << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main() {
   int n,m,ans=0;
   
   cin>>n;
   vll a(n);
   rep(i,n)cin>>a.at(i);
   
   cin>>m;
   vll b(m);
   rep(i,m)cin>>b.at(i);
   
   rep(i,m){
      if(binary_search(a.begin(), a.end(), b.at(i)) )ans++;
   }
   
   cout<<ans<<endl;
}



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

int main(){
  int N, M; cin >> N >> M;
  vector<vector<int>> vec(M);
  vector<int> p(M);
  for(int i = 0; i < M; i++){
    int k; cin >> k;
    vec[i].resize(k);
    for(int j = 0; j < k; j++){
      cin >> vec[i][j];
      vec[i][j]--;
    }
  }
  for(int i = 0; i < M; i++){
    cin >> p[i];
  }
  int ans = 0;
  for(int i = 0; i < (1 << N); i++){
    bool ok = true;
    bitset<11> bit(i);
    for(int j = 0; j < M; j++){
      int c = 0;
      for(int k = 0; k < vec[j].size(); k++){
        if(bit[vec[j][k]]){
          c++;
        }
      }
      if(c%2 != p[j]){
        ok = false;
      }
    }
    if(ok) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;
const ll N = 1000;
ll a[1001];
ll ans = 1;
void clac(ll n){
	ll k=2,nn=n;
	while(n!=1){
		while(n%k==0){
			a[k]++;
			n/=k;
		}
		k++;
	}
	if(nn==1) return;
	clac(nn-1);
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	clac(n);
	FOR(i,0,1001){
		ans *= a[i]+1;
		ans %= MOD;
	}
	cout<<ans<<endl;
}

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

int main() {
  int a,b,c,n;
  cin >> a >> b >> c >> n;
  int ans=0;
  for(int i=0;i<n/a+1;i++){
    int x=(n-i*a)/b;
    for(int j=0;j<x+1;j++){
      if((n-i*a-j*b)%c==0)
        ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <string.h>
using namespace std;
int main()
{
    int n,m;
    int i,j;
    scanf("%d",&n);
    getchar();
    char s[n][100];
    for(i=0;i<n;i++)
    {
        scanf("%s",s[i]);
    }
    scanf("%d",&m);
    getchar();
    char t[m][100];
    for(i=0;i<m;i++)
    {
        scanf("%s",t[i]);
    }
    int num[n];
    for(i=0;i<n;i++)
    {
        num[i]= 0;
    }
    for(i=0; i<n; i++)
    {
        for(j=0; j<n;j++)
        {
            if(strcmp(s[i],s[j])==0)
            {
                num[i]++;
            }
        }
    }
    for(i=0; i<n; i++)
    {
        for(j=0; j<m; j++)
        {
            if(strcmp(s[i],t[j])==0)
            {
                num[i]--;
            }
        }
    }
    sort(num,num+n);
    if(num[n-1]>0)
        printf("%d\n",num[n-1]);
    else
        printf("0\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int r,g,b,n;cin>>r>>g>>b>>n;
  int ans=0;
  for(int i=0;i<=n;i+=r){
    for(int j=0;j<=n;j+=g){
      if(n-i-j>=0 && (n-i-j)%b==0)ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import math
N = int(input())
a_list = [0] + list(map(int, input().split()))
result = True
answer_box = [0] * (N+1)
inboxes = []
for i in range(N, 0, -1):
    last_i = i * (N // i)
    count = 0
    for j in range(last_i, i-1, -i):
        count += answer_box[j]
    if (count % 2) != a_list[i]:
        answer_box[i] = 1
        inboxes.append(i)

if(result):
    print(len(inboxes))
    if(len(inboxes) > 0):
        print(" ".join(str(e) for e in inboxes))
else:
    print(-1)


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

using namespace std;


int main() {
    int d = 0;
    cin >> d;

    switch (d) {
        case 22:
            cout << "Christmas Eve Eve Eve" << endl;
            break;
        case 23:
            cout << "Christmas Eve Eve" << endl;
            break;
        case 24:
            cout << "Christmas Eve" << endl;
            break;
        case 25:
            cout << "Christmas" << endl;
            break;
        default:
            break;
    }
}

Measured memory_bytes: 3532
#include <iostream>

using namespace std;

int main()
{
	int a, b;
	
	cin >> a >> b;
	
	if (a == 1) {
		a += 13;
	}
	if (b == 1) {
		b += 13;
	}
	
	if (a > b) {
		cout << "Alice" << endl;
	}
	else if (a < b) {
		cout << "Bob" << endl;
	}
	else {
		cout << "Draw" << endl;
	}
	
	return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

#define rep(i, N) for(int i = 0;i < N;++i)

using namespace std;

int main() {
	int d[101];
	int N = 0;
	int ans = 1;
	cin >> N;
	rep(i, N) {
		cin >> d[i];
	}
	sort(d, d + N);
	rep(i, N - 1) {
		if (d[i] != d[i + 1]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

idx2alpha = {idx:s for idx,s in enumerate('abcdefghijklmnopqrstuvwxyz .\n')}
alpha2idx = {s:idx for idx,s in enumerate('abcdefghijklmnopqrstuvwxyz .\n')}

def rotate(s):
    idx = [next_w(alpha2idx.get(w)) for w in s]
    new_s = [idx2alpha.get(i) for i in idx]
    return ''.join(new_s)

def next_w(w_idx):
    if 25 < w_idx:
        return w_idx
    w_idx += 1
    return w_idx % 26

def decrypt(s):
    for _ in range(26):
        if 'the' in s or 'this' in s or 'that' in s:
            return s
        else:
            s = rotate(s)
    return 'Failed to decript!'

def run():
    for line in sys.stdin:
        print(decrypt(line.strip()))

if __name__ == '__main__':
    run()




Measured memory_bytes: 5568
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
//#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

struct Person{
	int id;
	int parent;
	std::vector<int> connects;
};

Person p[200010];
int n;


int main()
{
	scanf("%d", &n);
	p[1].parent = -1;
	for (int i = 2 ; i <= n ; i++) {
		scanf("%d", &(p[i].parent));
		int pp = p[i].parent;
		p[pp].connects.push_back(i);
	}
	
	for (int i = 1 ; i <= n ; i++) {
		printf("%d\n", p[i].connects.size());
	}
	
	
	return 0;
}

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

using namespace std;

//#define FILE_IO

int N;
bool go(int t, int x, int y, int tt, int xx, int yy)
{
    int dst = abs(xx - x) + abs(yy - y);
    int tim = tt - t;
    if(dst > tim)   return false;
    return (dst % 2) == (tim % 2);
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    int xx, yy, tt;
    xx = yy = tt = 0;
    for(int i = 1; i <= N; i++)
    {
        int t, x, y;
        scanf("%d%d%d", &t, &x, &y);
        if( !go(tt, xx, yy, t, x, y) )
        {
            printf("No\n");
            exit(0);
        }
        tt = t, xx = x, yy = y;
    }
    printf("Yes\n");

    return 0;
}


Measured memory_bytes: 256