akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,k;
    cin >> n >> k;
    k -= 1;
    string s;
    cin >> s;
    if(s[k] == 'A') s[k] = 'a';
    if(s[k] == 'B') s[k] = 'b';
    if(s[k] == 'C') s[k] = 'c';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
# 問題C
n, m = map(int, input().split())

switch_list = []
for i in range(m):
    switch_list.append(list(map(int, input().split()))[1:])

ok_list = list(map(int, input().split()))
counter = 0
for i in range(2**n):
    tmp_counter = 0
    for light_num in range(len(switch_list)):
        light_status = ok_list[light_num]
        for switch in switch_list[light_num]:
            light_status += int(i&(1<<(switch-1))>0)
        if(light_status % 2 == 0):
            tmp_counter += 1
    if(tmp_counter == m):
        counter += 1
print(counter)


Measured memory_bytes: 3064
/*
CODED BY               
******
DARSHAN JAIN
darshanjain31
******
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define MOD 1000000007
using namespace std;

int main()
{
	fast;
	ll t;
	cin>>t;
	double mid=(double)2*3.14159*t;
	cout << std::setprecision(5) <<mid<<endl;  
}

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

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

    int r;
    cin >> r;
    if (r < 1200) {
        cout << "ABC";
    } else if (r < 2800) {
        cout << "ARC";
    } else {
        cout << "AGC";
    }
}

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

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

const int N = 2e5+10 , mod = 1e9+7;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n;
   cin >> n;
   int a[n];
   for(int i = 0 ; i < n ; i++)
      cin >> a[i];
   sort(a , a + n);
   int cur = 1;
   ll ans = a[n - 1];
   for(int i = n - 2 ; i >= 0 ; i--){
      if(n - 1 - cur >= 2){
         cur += 2;
         ans += 2 * a[i];
      }
      else if(n - 1 - cur == 1){
         cur++;
         ans += a[i];
      }
   }
   cout << ans;
   return 0;
}


Measured memory_bytes: 4444
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String... args) throws IOException {
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final StringBuilder sb = new StringBuilder();
        while (true) {
            final String[] lines = br.readLine().split(" ");
            final int x = Integer.parseInt(lines[0]);
            final int y = Integer.parseInt(lines[1]);
            if (x == 0 && y == 0) break;
            // do something
            for (int i = 0; i < x; i++) {
                for (int j = 0; j < y; j++) {
                    if ((i != 0 && i != x - 1) && (j != 0 && j != y - 1)) {
                        sb.append(".");
                    } else {
                        sb.append("#");
                    }
                }
                sb.append("\n");
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
}

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

class Main{
  static int n;
  static int[][] m;
  static int[] P;
  public static void main(String[] args){
    int i, j;
    int X[] = new int[2];
    try{
      BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
      String s;
      s = bf.readLine();
      n = Integer.parseInt(s);
      m = new int[n+1][n+1];
      P = new int[n+1];
      StringTokenizer S;
      for( i=1 ; i<=n ; i++){
        S = new StringTokenizer(bf.readLine());
        for(j=0 ; j<2 ; j++){
        X[j] = Integer.parseInt(S.nextToken());
        }
        if(i == 1){
          P[0] = X[0];
          P[1] = X[1];
        }
        else{P[i] = X[1];}
        }
    }
    catch(IOException e){
      System.out.println(e);
    }
    matrixChainOrder(P);
  }

  static void matrixChainOrder(int p[]){
    int i, j=0, k, l, q;
    n = p.length-1;
    for(i=1 ; i<=n ; i++){
      m[i][i] = 0;
    }
    for(l=2 ; l<=n ; l++){
      for(i=1 ; i<=n-l+1 ; i++){
        j = i+l-1;
        m[i][j] = 2147483647;
        for(k=i ; k<=j-1 ; k++){
          q = m[i][k] + m[k+1][j] +p[i-1]*p[k]*p[j];
          m[i][j] = min(m[i][j], q);
        }
      }
    }
    /*for(i=1;i<=6;i++){
      for(j=1;j<=6;j++){
      System.out.println(m[i][j]);
        }
  }*/

//System.out.println("i="+i+"j="+j);
    System.out.println(m[i-1][j]);
  }

  static int min(int m, int q){
    if(m < q)return m;
    else return q;
  }
}



Measured memory_bytes: 24588
n = int(input())
l = list(map(int,input().split()))

from collections import Counter
l1 = Counter(l[0::2])
mostl1 = l1.most_common()[0]
#semimostl1 = l1.most_common()[1]

l2 = Counter(l[1::2])
mostl2 = l2.most_common()[0]
#semimostl2 = l2.most_common()[1]

if mostl1[0] != mostl2[0]:
    print(n-mostl1[1]-mostl2[1])
elif len(l1.keys()) == 1 and len(l2.keys()) == 1:
    print(int(n/2))

else:
    semimostl1 = l1.most_common()[1]
    semimostl2 = l2.most_common()[1]
    print(min(n - mostl1[1] - semimostl2[1], n - semimostl1[1] - mostl2[1]))


#elif print(min(n-mostl1[1]-mostl2[1],n-mostl1[1]-mostl2[1]))

Measured memory_bytes: 18784
#include <cstdio>
#include <cmath>
int n;
double x[1005], y[1005], X, Y, d, e;
double dist(double a, double b) {
  return a*a + b*b;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lf%lf", &x[i], &y[i]);
    X += x[i]; Y += y[i];
  }
  X /= n; Y /= n;
  double P = 0.1;
  for (int i = 0; i < 30000; i++) {
    int f = 0;
    d = dist(X - x[0], Y - y[0]);
    for (int j = 1; j < n; j++) {
      e = dist(X - x[j], Y - y[j]);
      if (d < e) { d = e; f = j; }
    }
    X += (x[f] - X)*P;
    Y += (y[f] - Y)*P;
    P *= 0.999;
  }
  printf("%.9lf\n", sqrt(d));
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int L = sc.nextInt();
      	int R = sc.nextInt();
      	int d = sc.nextInt();
      	int count = 0;
      	for(int i = L; i <= R; i++){
        	if(i%d==0) count++; 
        }
      	System.out.println(count);
    }
}

Measured memory_bytes: 35604
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=1e6+3;
int n,q,x,d;
LL fac[2000010],ans,inv[2000010];
LL pw(LL x,LL y){
	LL t=1;
	for (;y;y>>=1){
		if (y&1) t=t*x%MO;
		x=x*x%MO;
	}
	return t;
}
int main(){
	fac[0]=1;
	FOR(i,1,1000002) fac[i]=fac[i-1]*i%MO;
	inv[1000002]=pw(fac[1000002],MO-2);
	FORD(i,1000001,0) inv[i]=inv[i+1]*(i+1)%MO;
	cin>>q;
	while (q--){
		cin>>x>>d>>n;
		if (d==0){
			ans=pw(x,n);
		}
		else{
			x=1ll*x*pw(d,MO-2)%MO;
			x=(x%MO+MO)%MO;
			if (x+n-1>=1000003 || x==0) ans=0;
			else{
				ans=fac[x+n-1]*inv[x-1]%MO;
				ans=ans*pw(d,n)%MO;
			}
		}
		ans=(ans%MO+MO)%MO;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 19328
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

template <typename T, typename Container=vector<T>> vector<pair<T,int>> group(const Container &v){
  vector<pair<T,int>> ret;

  for(auto &x : v){
    if(ret.empty()) ret.push_back({x,1});
    else if(ret.back().fst == x) ++ret.back().snd;
    else ret.push_back({x,1});
  }

  return ret;
}


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

  int n;
  while(cin >> n){
    vector<vector<int>> cnt(n, vector<int>(26));

    REP(i,n){
      string s; cin >> s;

      for(auto c : s){
        cnt[i][c-'a'] += 1;
      }
    }

    sort(ALL(cnt));

    auto g = group<vector<int>>(cnt);

    LLI ans = 0;

    for(auto &p : g){
      LLI t = p.snd;
      ans += t * (t-1) / 2;
    }


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


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

int main(){
    string S;
    cin >> S;
    int count=0;
    int ans=0;
    for(int i=0;i<S.size();i++){
        if(S[i]=='A'||S[i]=='G'||S[i]=='C'||S[i]=='T'){
            count++;
        }else{
            count=0;
        }
        ans=max(ans,count);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,ans=1; cin>>n;
    vi a(n);
    for (int &i: a) cin>>i ; 
    bool in=false,de=false ; 
    for (int i=1;i<n;i++){
        if (a[i]<a[i-1]) {
            if (in) ans++,in=false,de=false;
            else de=true;
        }
        else if (a[i]>a[i-1]){
            if (de) ans++,de=false,in=false;
            else in=true;
        }
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3976
#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
char str[1100][1100];
int rem[1100][1100];
int dx[]={1,1,1,0,0,-1,-1,-1};
int dy[]={1,0,-1,1,-1,1,0,-1};
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%s",str[i]);
	queue<pair<int,pair<int,int> > >Q;
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			if(str[i][j]=='.'){
				Q.push(make_pair(0,make_pair(i,j)));
				rem[i][j]=-1;
			}else rem[i][j]=str[i][j]-'0';
		}
	}
	int ret=0;
	while(Q.size()){
		int cost=Q.front().first;
		int row=Q.front().second.first;
		int col=Q.front().second.second;
		Q.pop();
		ret=max(ret,cost);
		for(int i=0;i<8;i++){
			int tr=row+dx[i];
			int tc=col+dy[i];
			if(tr<0||tc<0||tr>=a||tc>=b||rem[tr][tc]<=0)continue;
			rem[tr][tc]--;
			if(rem[tr][tc]==0){
				Q.push(make_pair(cost+1,make_pair(tr,tc)));
			}
		}
	}
	printf("%d\n",ret);
}

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

int main () {
	ll int k=0,x,ans=0,i=0;

	cin >> x;
	if(x<0){
		x = x*(-1);
	}

	while(1){
		i++;
		k += i;
		if(k>=x){
			break;
		}
	}

	cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	printf("%d\n",max(a,max(b,c))-min(a,min(b,c)));
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<sstream>
#include<cassert>
#include<queue>
#include<stack>

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define pb         push_back
#define mp         make_pair
#define vint       vector<int>
#define FOR(it,o)  for(__typeof((o).begin()) it=(o).begin(); it!=(o).end(); ++it)
#define lli	    long long int
#define ld	    long double
using namespace std;

int p,q,a,n;

//total:ツ個サツ催敖づ個債計ツづ個閉ェツ子,product:ツ個サツ催敖づ個債計ツづ個閉ェツ陛ェ
int solve(int i,int last,int prod,int total,int product){

	int cnt=0;
	int y;

	if(q*total==p*product)
		return 1;
	if(i>=n)
		return 0;
	for(y=last;y*prod<=a;y++){
		if(q*(y*total+product)<=p*y*product){
			//cout<<"a"<<endl;
			cnt+=solve(i+1,y,y*prod,y*total+product,y*product);
		}
	}
	return cnt;
} 
int main(void){
	while(cin>>p>>q>>a>>n,(p||q||a||n)){
	cout<<solve(0,1,1,0,1)<<endl;		
	}
	return 0;
}

Measured memory_bytes: 868
#include<stdio.h>
#define INFINITY 2000000000

int count;

int merge(int s[], int left, int mid, int right, int n){

    int n1, n2, i, j, k;
    int L[300000];
    int R[300000];

    n1 = mid - left;
    n2 = right - mid;

    for(i = 0; i < n1; i++) L[i] = s[left + i];
    for(i = 0; i < n2; i++) R[i] = s[mid + i];

    L[n1] = INFINITY;
    R[n2] = INFINITY;
    i = 0;
    j = 0;

    for(k = left; k < right; k++){

        count++;

        if(L[i] <= R[j]){

            s[k] = L[i];
            i++;

        }
        else{

            s[k] = R[j];
            j++;

       }
    }
}
int mergeSort(int s[], int left, int right){

    int mid;
    int n = right;

    if(left+1 < right){

        mid = (left + right) /2;
        mergeSort(s, left, mid);
        mergeSort(s, mid, right);
        merge(s, left, mid ,right, n);

    }

}
int main()
{
    int i, n;
    int s[500000];
    count = 0;

    scanf("%d", &n);

    for(i = 0; i < n; i++){

        scanf("%d", &s[i]);
    }

    mergeSort(s, 0, n);

    for(i = 0; i < n; i++){

        if(i > 0) printf(" ");

        printf("%d", s[i]);
    }
    printf("\n");

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

    return 0;
}


Measured memory_bytes: 5584
from sys import stdin
input = stdin.readline

n, a, b, c = map(int, input().split())
s = []
f = []
d = dict()
d['A'] = a
d['B'] = b
d['C'] = c
flag = 1

for _ in range(n):
    f.append(input().rstrip())

for x in range(n):
    e = f[x]

    if d[e[0]] == d[e[1]] == 1 and x < n - 1:
        if e[0] in f[x + 1] and e[1] not in f[x + 1]:
            s.append(e[0])
            d[e[1]] -= 1
            d[e[0]] += 1
        else:
            s.append(e[1])
            d[e[0]] -= 1
            d[e[1]] += 1

    elif d[e[0]] >= d[e[1]]:
        s.append(e[1])
        d[e[0]] -= 1
        d[e[1]] += 1
    else:
        s.append(e[0])
        d[e[1]] -= 1
        d[e[0]] += 1

    if d[e[0]] < 0 or d[e[1]] < 0:
        flag = 0
        break

if flag == 0:
    print("No")
else:
    print("Yes")
    print("\n".join(s))

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

    //居合を終え、青い絵を覆う

int main() {
  char c ;
  cin >> c ;
  
  if ( c == 'a' || c == 'i' || c == 'u' || c == 'e' || c== 'o' ){
      cout << "vowel" << endl;
  }
  else {
      cout << "consonant" << endl;
  }
}



Measured memory_bytes: 3672
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
using namespace std;

int search(void);

int dx[4] = { 1, 0,-1, 0};
int dy[4] = { 0, 1, 0,-1};
int h, w;
int s[50][50];


int main()
{
    int i, j, bl = 0, wh = 0, ans;
    char save;
    
    cin >> h >> w;
    
    for(i = 0; i < h; i++) {
        for(j = 0; j < w; j++) {
            cin >> save;
            
            if(save == '.') {
                s[i][j] = 0;
                wh++;
            } else {
                s[i][j] = -1;
                bl++;
            }
        }
    }
    
    ans = search();
    
    if(ans != 0) {
        cout << (h*w)-ans-bl << endl;
    } else {
        cout << "-1\n";
    }
    
    return 0;
}

int search(void)
{
    int x, y, nx, ny;
    int ans = 0, k;
    int count = 0;
    
    queue<int> qx, qy;
    
    qx.push(0);
    qy.push(0);
    s[0][0] = 1;
    
    while((qx.empty() == 0)&&(ans == 0)) {
        
        x = qx.front(); qx.pop();
        y = qy.front(); qy.pop();
        
        for(k = 0; k < 4; k++) {
            nx = x + dx[k];
            ny = y + dy[k];
            
            if((0 <= nx)&&(nx < w)&&(0 <= ny)&&(ny < h)) {
                
                if(s[ny][nx] == 0) {
                    
                    s[ny][nx] = s[y][x] + 1;
                    
                    /*cout << x << " " << y << " " << s[y][x] << endl;
                    cout << nx << " " << ny << " " << s[ny][nx] << endl << endl;*/
                    
                    if((nx == w-1)&&(ny == h-1)) {
                        ans = s[ny][nx];
                    } else {
                        qx.push(nx);
                        qy.push(ny);
                    }
                }
            }
        }
    }
    
    return ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#include<vector>
using namespace std;
inline void read(int &x)
{
    int s=0,w=1;
    char c=getchar();
    while(!isdigit(c)){if(c=='-')w=-1;c=getchar();}
    while(isdigit(c)){s=(s<<3)+(s<<1)+c-'0',c=getchar();}
    x=s*w;
}
const int N=200010;
typedef long long ll;
#define rg register int
#define pb emplace_back
struct data
{
    ll x,y;
    data(){};
    data(ll _x,ll _y):x(_x),y(_y){}
};
inline bool cmpx(const data &A,const data &B){return A.x<B.x;}
inline bool cmpy(const data &A,const data &B){return A.y<B.y;}
vector<data>f[N];
ll d[N],mn[N];
inline void solve(vector<data>a,vector<data>b,vector<data>&c,ll e,ll mid)
{
    if(!a.size()||!b.size())return ;
    if(a.size()>b.size())
        swap(a,b);
    sort(a.begin(),a.end(),cmpy),sort(b.begin(),b.end(),cmpx);
    int sb=b.size();
    for(rg i=0;i<sb;i++)
        if(!i)mn[i]=b[i].y;
        else mn[i]=min(mn[i-1],b[i].y);
    for(rg i=0,j=sb-1;i<a.size();i++)
    {
        while(j>=0&&a[i].y+b[j].x-2*e>mid)j--;
        if(~j)c.pb(data(a[i].x,mn[j]));
    }
    sort(a.begin(),a.end(),cmpx),sort(b.begin(),b.end(),cmpy);
    for(rg i=0;i<sb;i++)
        if(!i)mn[i]=b[i].x;
        else mn[i]=min(mn[i-1],b[i].x);
    for(rg i=0,j=sb-1;i<a.size();i++)
    {
        while(j>=0&&a[i].x+b[j].y-2*e>mid)j--;
        if(~j)
            c.pb(data(mn[j],a[i].y));
    }
}
int ls[N],rs[N];
bool cao;
inline void dfs(int u,ll mid)
{
    f[u].clear();
    if(!ls[u])
    {
        f[u].pb(data(d[u],d[u]));
        return ;
    }
    if(cao)return ;
    dfs(ls[u],mid),dfs(rs[u],mid);
    if(cao)return ;
    solve(f[ls[u]],f[rs[u]],f[u],d[u],mid);
    f[ls[u]].clear(),f[rs[u]].clear();
    if(!f[u].size())cao=1;
}
int n;
ll L,R,ans;
int main()
{
    //freopen("cc.in","r",stdin);
    //freopen("cc.out","w",stdout);
    read(n);
    for(rg i=2,x,y;i<=n;i++)
    {
        read(x),read(y);
        d[i]=d[x]+y,R=max(R,d[i]);
        if(ls[x])rs[x]=i;
        else ls[x]=i;
    }
    R<<=1;
    while(L<=R)
    {
        ll mid=(L+R)>>1;
        cao=0;
        dfs(1,mid);
        if(!cao)ans=mid,R=mid-1;
        else L=mid+1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 30440
#include<stdio.h>

  int main() {
   int n,i,m,k;
   scanf("%d",&n);
   int s=0;
   k=n;
   
   for(i=0;n>0;i++){
    m=n%10;
    n=n/10;
    s+=m;
    }
    if(k%s==0)
      printf("Yes\n");
      else
    	printf("No\n");
    	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;


int main() {
	int n, m; cin >> n >> m;
	string s; cin >> s;
	vector<int> ans;
	while (n > 0) {
		int now = 0;
		for (int i = 1; i <= m; ++i) {
			if (n - i < 0) break;
			if (s[n - i] == '0') now = i;
		}
		if (now == 0) {
			cout << -1 << endl;
			return 0;
		}
		ans.push_back(now);
		n -= now;
	}
	reverse(ans.begin(), ans.end());
	for (int i = 0; i < ans.size(); ++i)
		cout << (i ? " " : "") << ans[i];
	cout << endl;

	return 0;
}

Measured memory_bytes: 1144
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<iostream>
using namespace std;
#define ll long long
int s[100005];
int n;
ll a=0,b=0,c;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&s[i]);
    }
    sort(s,s+n);
    for(int i=n-1;i>0;)
    {
        if(a==0&&s[i]==s[i-1])
        {
            a=s[i];
            i=i-2;
        }
        if(a!=0&&s[i]==s[i-1])
        {
            b=s[i];
            break;
        }
        else
            i--;
        if(a!=0&&b!=0)
            break;
     }
    c=(ll)a*b;
    printf("%lld\n",c);
    return 0;
}


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

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

  vector<int> dp(n+1,100000);
  dp[0]=0;

  for (int i = 1; i <= n; i++)
  {
    int power = 1;
    while(power<=i){
      dp[i]=min(dp[i],dp[i-power]+1);
      power*=6;
    }
    power=9;
    while(power<=i){
      dp[i]=min(dp[i],dp[i-power]+1);
      power*=9;
    }
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 640
import itertools

n = int(input())
p = ''.join(input().split())
q = ''.join(input().split())
a = 0
b = 0
cnt = 0

for iter in itertools.permutations(list(map(str, range(1, n+1)))):
    cnt += 1
    if(''.join(iter) == p): a = cnt
    if(''.join(iter) == q): b = cnt
    
    if(a*b): break
print(abs(a-b))

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

int main()
{
string s; int z=1; cin>>s;
for(char i='a';i<='z';i++)
{
    if((s.find(i))== std::string::npos) {cout<<i;  z=0; break;}
}
if(z==1) cout<<"None";
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
int c[5][5];
int main(){
    for(int i=1;i<=3;i++)
    for(int j=1;j<=3;j++)
    cin>>c[i][j];
    int b11,b12,b13,b21,b22,b23,b31,b32,b33;
    for(int a1=0;a1<=100;a1++)
    {
        b11=c[1][1]-a1;
        b21=c[1][2]-a1;
        b31=c[1][3]-a1;
        for(int a2=0;a2<=100;a2++)
        {
            b12=c[2][1]-a2;
            b22=c[2][2]-a2;
            b32=c[2][3]-a2;
            if(b11!=b12 || b21!=b22 || b31!=b32)
            continue;   
            for(int a3=0;a3<=100;a3++)
            {
            b13=c[3][1]-a3;
            b23=c[3][2]-a3;
            b33=c[3][3]-a3;
            if(b11==b13 && b21==b23 && b31==b33)
            {
            cout<<"Yes";
            return 0;
            }
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rg register
#define il inline
#define cn const
#define gc getchar()
#define fp(i,a,b) for(rg int i=(a),ed=(b);i<=ed;++i)
using namespace std;
typedef cn int cint;
cint inf=0x3f3f3f3f,maxn=2010,mod=924844033;

int n,k,f[maxn<<1][maxn][2],vis[maxn<<1],g[maxn],cnt;
int fac[maxn],p[maxn],ans;

il void dp(cint &s){
	for(rg int i=s,u=s;i<=n+(s>n)*n;i+=k,u=(u+n)%(n<<1)+k){
		vis[u]=1,++cnt,f[cnt][0][0]=f[cnt-1][0][0];
//		printf("%d\n",u);
		fp(j,1,n){
			f[cnt][j][0]=(f[cnt-1][j][0]+f[cnt-1][j][1])%mod;
			if(u^s)f[cnt][j][1]=f[cnt-1][j-1][0];
		}
	}
}

int main(){
//    freopen("sample.in","r",stdin);
	scanf("%d %d",&n,&k);
	f[0][0][0]=1;
	fp(i,1,n){
		if(!vis[i])dp(i);
		if(!vis[i+n])dp(i+n);
	}
	fp(i,0,n)g[i]=(f[n<<1][i][0]+f[n<<1][i][1])%mod;
	fac[0]=1; fp(i,1,n)fac[i]=1ll*fac[i-1]*i%mod;
	p[0]=1; fp(i,1,n)p[i]=(mod-p[i-1])%mod;
	fp(i,0,n)ans=(ans+1ll*p[i]*fac[n-i]%mod *g[i]%mod)%mod;
	printf("%d\n",ans);
//	printf("%d\n",f[3][1][0]);
//	fp(i,0,n)printf("%d ",g[i]);puts("");
	return 0;
}

Measured memory_bytes: 63104
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ct = (a%d) ? (a / d) + 1 : (a / d);
  int ca = (c%b) ? (c / b) + 1 : (c / b);
  if (ct >= ca){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3588
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn comb(m: usize, n: usize) -> usize {
    if m < n {
        return 0;
    }
    let mut ret = 1;
    for i in 0..m {
        ret *= i + 1;
    }
    for i in 0..n {
        ret /= i + 1
    }
    for i in 0..(m - n) {
        ret /= i + 1
    }
    ret
}

fn combmodlucas(m: usize, n: usize, p: usize) -> usize {
    let mut m = m;
    let mut n = n;
    if m < n {
        return 0;
    }
    let mut ret = 1;
    loop {
        ret *= comb(m % p, n % p);
        if m == 0 {
            break;
        }
        m /= p;
        n /= p;
    }
    ret
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let mut n: usize = parse!(it);
    let a: Vec<usize> = it
        .next()
        .unwrap()
        .chars()
        .map(|i| i.to_digit(10).unwrap() as usize - 1)
        .collect();
    if a.iter().any(|&i| i == 1) {
        let i = a.iter().enumerate().fold(0, |s, (i, &x)| {
            (s + combmodlucas(n - 1, i, 2) * ((x == 1) as usize)) % 2
        });
        if i == 1 {
            println!("{}", 1);
        } else {
            println!("{}", 0);
        }
    } else {
        let i = a.iter().enumerate().fold(0, |s, (i, &x)| {
            (s + combmodlucas(n - 1, i, 2) * ((x == 2) as usize)) % 2
        });
        if i == 1 {
            println!("{}", 2);
        } else {
            println!("{}", 0);
        }
    }
}

fn test() {
    let mut f = fs::File::open("foo.txt").unwrap();
    let mut s = String::new();
    f.read_to_string(&mut s).unwrap();
    solve(&s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_main() {
        test();
    }
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 14588
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int[] a = new int[N];
		int[] b = new int[N];
		int sum = 0;
		
		for(int i = 0; i < N; i++) {
			a[i] = stdIn.nextInt();
			if(i > N/2 - 1) {
				b[i] = a[i];
				sum += b[i];
			}
		}
		
		for(int i = N/2 - 1; i >= 0; i--) {
			int count = 0;
			for(int j = 2*i+1; j < N; j += i+1) {
				count += b[j];
			}
			if(count%2 == a[i]) {
				b[i] = 0;
			}
			else {
				b[i] = 1;
			}
			sum += b[i];
		}
		
		System.out.println(sum);
		for(int i = 0; i < N; i++) {
			if(b[i] == 1) {
				System.out.println(i+1);
			}
		}

	}

}

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

int main() {
    int X, N;
    cin >> X >> N;
    vector<int> A(101, 1);

    if(N == 0){
        cout << X << endl;
        return 0;
    }

    int q;
    for(int i = 0; i < N; i++){
        cin >> q;
        A[q] = 0;
    }

    for(int i = 0; i < 101; i++){
        if(X - i > 0){
            if(A[X - i] == 1){
                cout << X - i << endl;
                return 0;
            }
        }else if(X - i == 0){
            cout << 0;
            return 0;
        }
        if(X + i < 101){
            if(A[X + i] == 1){
                cout << X + i << endl;
                return 0;
            } 
        }else if(X + i == 101){
            cout << 101 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;

int main()
{
    int a, b;
    
    cin >> a >> b;
    
    cout << a * b + 1 - a - b << endl;
    
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    int now=1;
    while(n--){
        int ne1=now*2,ne2=now+k;
        now=min(ne1,ne2);
    }
    cout<<now<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const ll INF = 1e15;
const double eps = 1e-6;
const ll MOD = 1000000007;

int main() {
	ll N;
	cin >> N;
	vector<ll> v(N);
	for (int i = 0;i < N;i++)
		cin >> v[i];
	sort(v.begin(), v.end());
	ll base = v.back();
	ll ans = -1;
	ll point = INF;
	for (int i = 0;i < v.size() - 1;i++) {
		ll dist = min(abs(v[i] - base/2), abs(v[i] - (base - base/2)));
		if (dist < point) {
			point = dist;
			ans = v[i];
		}
	}
	cout << base << " " << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.*

fun main(args:Array<String>?): Unit {
    while(true){
        val (n, m) = readLine()!!.trim().split(' ').map(String::toInt)
        if (n == 0 && m == 0) return
        val union = UnionFind(n)
        val edges = Array(m){
            val (s, t, c) = readLine()!!.trim().split(' ').map(String::toInt)
            Triple(s - 1, t - 1, c)
        }.sortedBy(Triple<Int, Int, Int>::third)
        val used = Stack<Int>()
        for ((s, t, c) in edges){
            if (!union.isSame(s, t)) {
                used.push(c)
                union.merge(s, t)
            }
        }
        used.sort()
        println(
                used[used.size / 2]
        )
    }
}
class UnionFind(val size: Int){
    private val array = IntArray(size){-1}
    private fun find(a: Int): Int {
        val root = root(a)
        setRoot(a, root)
        return root
    }
    private tailrec fun root(a: Int): Int {
        return if (array[a] < 0) a else root(array[a])
    }
    private fun setRoot(a: Int, root: Int) {
        if (a != root) {
            setRoot(array[a], root)
            array[a] = root
        }
    }
    fun isSame(u: Int, v: Int): Boolean {
        return find(u) == find(v)
    }
    fun merge(u: Int, v: Int) {
        val ur = find(u)
        val vr = find(v)
        if (ur != vr){
            if (array[ur] < array[vr]){
                array[ur] += array[vr]
                array[vr] = ur
            }else {
                array[vr] += array[ur]
                array[ur] = vr
            }
        }
    }
}


Measured memory_bytes: 82832
def combs_mod(n,k,mod):
  #nC0からnCkまで
  inv = [1]*(k+1)
  for i in range(1,k+1):
    inv[i] = pow(i,mod-2,mod)
  ans = [1]*(k+1)
  for i in range(1,k+1):
    ans[i] = ans[i-1]*(n+1-i)*inv[i]%mod
  return ans
def solve():
  mod = 998244353
  N, A, B, K = map(int, input().split())
  com = combs_mod(N,N,mod)
  ans = 0
  for x in range(N+1):
    if (K-A*x)%B==0:
      y = (K-A*x)//B
      if y>=0 and y<=N:
        ans += com[x]*com[y]
        ans %= mod
  return ans
print(solve())

Measured memory_bytes: 106484
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define pb push_back
    #define printV(v) for(int i=0;i<v.size();i++){cout << v[i] << " ";} cout << endl
    #define printRev(v) for(int i=v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
    #define sortV(v) sort(v.begin(),v.end())
    #define revV(v) reverse(v.begin(),v.end())
    ll a,b,c,d,e,f,g,n,m,k,t,p,x;
 
    ll mod = 998244353;
 
   
    bool isPal(string &str){
        for(int i=0;i<str.size();i++){
            if(str[i] != str[str.size()-1-i]) return false;
        }
        return true;
    }

    void solve(){
        string str; cin >> str;
        int size = str.size();
        string beg  = str.substr(0,(size-1)/2);
        if(isPal(str) && isPal(beg)){
            cout << "Yes\n";
        }else cout << "No\n";
    }
 
 
 
    int main(){
        ios_base::sync_with_stdio(false);
      
        int cases = 1; 
        //cin >> cases;

        while(cases--){
            solve();
        }
        return 0;
 
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i,ans;
  vector<int> a(3);
  for(i=0;i<3;i++) cin>>a.at(i);
  sort(a.begin(),a.end());
  ans=(a.at(1)-a.at(0))/2;
  a.at(0)+=2*ans;
  if(a.at(0)<a.at(1)){
    a.at(0)++;
    a.at(2)++;
    ans++;
  }
  ans+=a.at(2)-a.at(1);
  cout<<ans<<endl;
}

Measured memory_bytes: 3588
N = int(input())
As = [0]+list(map(int, input().split()))+[0]
ldp = [0]*(N+1)
rdp = [0]*(N+2)
for i in range(1, N+1):
    ldp[i] = ldp[i-1] + abs(As[i]-As[i-1])
    rdp[-(i+1)] = rdp[-i]+abs(As[-(i+1)]-As[-i])
for i in range(1, N+1):
    ans = ldp[i-1] + rdp[i+1] + abs(As[i+1]-As[i-1])
    print(ans)

Measured memory_bytes: 16276
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

S=input()
if S=='RSR':
    print(1)
else:
    print(S.count('R'))

Measured memory_bytes: 61652
#include<bits/stdc++.h>
#define N 200005
#define debug(x) cout<<#x<<":"<<x<<endl;
using namespace std;
int n,A[N],mx1,mx2,B[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&A[i]);
		B[A[i]]++;
		if(A[i]>=mx1)mx2=mx1,mx1=A[i];
		else if(A[i]>=mx2)mx2=A[i];
	}
	for(int i=1;i<=n;i++){
		B[A[i]]--;
		if(B[A[i]]==0&&A[i]==mx1)printf("%d\n",mx2);
		else printf("%d\n",mx1);
		B[A[i]]++;
	}
//	printf("%d",mx1);
	return 0;
}


Measured memory_bytes: 3072
s = int(input())
i = 0
min=0
num=0
for n in range(0,len(str(s))-2):
	num = int(str(s)[i:i+3])
	if abs (min -753) > abs (num -753):
		min = num
	i=i+1
	
print(abs (min -753))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dbg puts("It's Just Begining.Wait For The End!!!!!\n")
#define CHECK(x) cout << (#x) << " is " << (x) <<"\n";
#define endl printf("\n")
typedef pair<ll,ll> pii;
#define pb push_back
#define ms(a,b) memset(a, b, sizeof(a))
#define in(x) scanf("%lld",&x)
#define out(x) printf("%lld",x)
#define sps printf(" ");
#define X first
#define Y second
#define dou(x) cout<<fixed<<setprecision(6)<<x
#define MAX 100005
#define mod 1000000007
int main()
{
    ll i,j,k,l,n,m;
    in(n);
    ll arr[n];
    bool ok=true;
    for(i=0;i<n;i++)
    {
        in(arr[i]);
        if(arr[i]%3==0||arr[i]%5==0)continue;
        else if(arr[i]%2==0)ok=false;
    }
    if(!ok)puts("DENIED");
    else puts("APPROVED");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int N; cin >> N;
    string s[N]; rep(i, N) cin >> s[i];
    int cntA = 0, cntB = 0, cntAB = 0, ans = 0;
    rep(i, N) {
        rep(j, s[i].size() - 1) {
            if(s[i][j] == 'A' && s[i][j + 1] == 'B')
                ++ans;
        }
    }
    vector<bool> isAB(N, false);
    rep(i, N) {
        if(s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A') {
            cntAB++;
            isAB[i] = true;
        }else if(s[i][0] == 'B') {
            cntB++;
        }else if(s[i][s[i].size() - 1] == 'A') {
            cntA++;
        }
    }
    if(cntAB > 0) {
        ans += cntAB - 1;
        cntAB = 1;
    }
    if(cntAB == 1) {
        if(cntA > 0) ++ans, --cntA;
        if(cntB > 0) ++ans, --cntB;
    }
    cout << ans + min(cntB, cntA) << endl;
}


Measured memory_bytes: 768
#include<iostream>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)
#define ll long long

ll INF = 10e17;
ll n, t;
ll a[100000];

int main(){
    cin >> n >> t;
    REP(i, n) cin >> a[i];

    ll tmin = INF;
    ll p = 0;
    REP(i, n){
        tmin = min(tmin, a[i]);
        p = max(p, a[i] - tmin);
    }

    ll tmin2 = INF;
    ll c = 0;
    REP(i, n){
        tmin2 = min(tmin2, a[i]);
        if(a[i] - tmin2 == p){
            c += 1;
        }
    }
    cout << c << endl;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main() {
    int n; cin >> n;
    long long a[n];
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
    string a;  
bool v[2]={0};
    cin>>a; 
    for(int i=0;i<a.length();i++)
{ 
        if(a[i]=='C') v[0]=1; 
        if(a[i]=='F'&&v[0])
v[1]=1;
    }
    if(v[1]) cout<<"Yes";
    else cout<<"No"; 
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{

    class Program
    {

        static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());
            string input = Console.ReadLine();

            if (input.Length > k)
            {
                Console.WriteLine("{0}{1}", input.Substring(0, k), "...");
            }
            else
            {
                Console.WriteLine(input);
            }
        }

    }
}



Measured memory_bytes: 27484
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;
  Int sum = (0 + N-1) * N / 2;
  cout<<sum<<endl;
  return 0;
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair



int miny(int K, vi& ys) {
    int m = ys.size();
    if (m < K) return -1;
    int best = 0x7fffffff;
    for (int i=0; i<=m-K; ++i) {
        for (int j=i+K-1; j<m; ++j) {
            int d = ys[j] - ys[i];
            best = min(best, d);
        }
    }
    return best;
}

ll solve(int N,int K,vi& x,vi& y) {
    vector<ii> xy(N);

    rep(i,N) xy[i] = ii(x[i], y[i]);
    sort(ALL(xy));

    ll best = 0x7fffffffffffffffLL;
    repC2(i,j,N) {
        int x0 = xy[i].first, x1 = xy[j].first, dx = x1 - x0;
        vi ys;
        for (int u=i; u<=j; ++u) ys.pb(xy[u].second);
        sort(ALL(ys));

        int dy = miny(K, ys);
#ifdef DEBUG
        fprintf(stderr, "(%d,%d): %d-%d=%d; ", i,j, x0,x1,dx);
        cerr << ys << ",K=" << K << " -> " << dy << endl;
#endif
        if (dy < 0) continue;

        ll area = (ll)dx * dy;
        best = min(best, area);
    }
    return best;
}

int main() {
    int N,K;cin >>N>>K;
    vi x(N),y(N);
    rep(i,N) cin >> x[i] >> y[i];
    cout << solve(N,K,x,y) << endl;
    // cout << (solve(N,a) ? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9,N=1000,dx[]={0,0,1,-1},dy[]={1,-1,0,0};
int n,m,k,x,y;
char c[N][N];
bool vis[N][N];
int main()
{
	//freopen("qc.in","r",stdin);
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<n;i++)
	{
		scanf("%s",&c[i]);
		for(int j=0;j<m;j++)if(c[i][j]=='S')x=i,y=j;
	}
	int ans=min(min(x,y),min(n-x-1,m-y-1));
	vis[x][y]=1;
	if(ans%k==0)ans=ans/k;
	else ans=ans/k+1;
	int minv=ans+1;
	queue<pair<int,pair<int,int> > >q;
	q.push(make_pair(0,make_pair(x,y)));
	while(!q.empty())
	{
		pair<int,pair<int,int> >t=q.front();
		q.pop();
		if(t.first>=k)continue;
		for(int w=0;w<4;w++)
		{
			int nx=t.second.first+dx[w],ny=t.second.second+dy[w];
			if(nx<0||nx>=n||ny<0||ny>=m)continue;
			if(vis[nx][ny])continue;
			if(c[nx][ny]=='#')continue;
			vis[nx][ny]=true;
			int res=min(min(nx,ny),min(n-nx-1,m-ny-1));
			if(res%k==0)res=res/k;
			else res=res/k+1;
			minv=min(minv,res+1);
			q.push(make_pair(t.first+1,make_pair(nx,ny)));
		}
	}
	printf("%d\n",minv);
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a<b&&b<c) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 1968
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = n; i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 3; i <= n; i += 2) {
		int cnt = 0;
		for (int j = 1; j <= i; j++) {
			if (i % j == 0) cnt++;
		}
		if (cnt == 8) ans++;
	} 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<vector>

int main() {
    int h, w;
    std::cin >> h >> w;
    std::vector<std::vector<char>> a(h, std::vector<char>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            std::cin >> a[i][j];
        }
    }
        for (int i = -1; i < h + 1; i++)
        {
            for (int j = -1; j < w + 1; j++)
            {
                if (i >= 0 && i < h && j >= 0 && j < w)
                {
                    std::cout << a[i][j];
                }
                else
                {
                    std::cout << '#';
                }
            }
            std::cout << "\n";
        }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);

    int n,k;
    cin>>n>>k;
    
    vector<long long> score(n+1);
    
    for(int i=1; i<=n; i++){
        cin>>score[i];
        if(i>k){
            if(score[i]>score[i-k]){
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4744