akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
#define fors(i,a,b) for(int i=(a);i<=(b);++i)
typedef long long ll;
const int Size=1<<18;
inline char getch(){
    static char buf[Size],*p1=buf,*p2=buf;
    return p1==p2 && (p2=(p1=buf)+fread(buf,1,Size,stdin),p1==p2) ? EOF : *p1++;
}
int read(){
    int s=0,f=1;
    char c=getch();
    while(c>'9' || c<'0'){if(c=='-') f=-1; c=getch();}
    while(c<='9' && c>='0'){s=(s<<1)+(s<<3)+c-'0';c=getch();}
    return s*=f;
}// 本蒟蒻使用的最强读入~~（用来暴力卡时间）~~
int main(){//纯模拟
    int a=read(),wh[9],b=read(),e=read();
    fors(c,-100,200){
        wh[1]=a+b+c;
        if(wh[1]<a+e) continue;
        fors(i,-100,200){
            wh[7]=a+e+i;
            if(wh[7]!=wh[1]) continue;
            fors(f,-100,200)
            {
                wh[6]=c+f+i;
                if(wh[6]!=wh[7]) continue;
                fors(d,-100,200){
                    wh[2]=d+e+f;
                    if(wh[2]!=wh[6]) continue;
                    fors(g,-100,200)
                    {
                        wh[4]=g+d+a;
                        wh[8]=c+e+g;
                        if((wh[8]!=wh[4])) continue;
                        fors(h,-100,200){
                            wh[3]=g+h+i;
                            wh[5]=b+e+h;
                            if((wh[3]!=wh[5]) || (wh[3]!=wh[4]) || (wh[3]!=wh[8])) continue;
                                printf("%d %d %d\n",a,b,c);
                                printf("%d %d %d\n",d,e,f);
                                printf("%d %d %d\n",g,h,i);
                                return 0;
                        }
                    }       
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d%d",$n,$m);
if($m==0)exit("0");
while($n--) {
  fscanf(STDIN,"%d%d%d",$x,$y,$z);
  $sum[0][] = $x + $y + $z;
  $sum[1][] =-$x + $y + $z;
  $sum[2][] = $x - $y + $z;
  $sum[3][] = $x + $y - $z;
}
$M = 0;
foreach($sum as $s) {
  sort($s);
  $M = max($M, abs(array_sum(array_slice($s, 0, $m))));
  $M = max($M, abs(array_sum(array_slice($s, -$m))));
}
printf("%d", $M);


Measured memory_bytes: 4604
#include<iostream>
#include<cctype>
#include<stdio.h>

using namespace std;
int main(){
    int index=0;
    char moji;
    while((moji=getchar())!=EOF){
        if(isalpha(moji)&&islower(moji)){
            moji=toupper(moji);
        }else if(isalpha(moji)&&isupper(moji)){
            moji=tolower(moji);
        }
        cout<<moji;
    }
}


Measured memory_bytes: 3076
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
d = [-1, 0, 1]
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            total = 0
            for dy in d:
                for dx in d:
                    if 0<=i+dy<h and 0<=j+dx<w and s[i+dy][j+dx] == "#":
                        total += 1
            s[i][j] = str(total)
for i in range(h):
    print("".join(s[i]))


Measured memory_bytes: 3188
N, Y = [int(_) for _ in input().split()]

for x in range(0, Y//10000 + 1, 1):
    for y in range(0, Y//5000 + 1, 1):
        
        z = N - x - y
        
        if z < 0:
            continue
        
        if 10000 * x + 5000 * y + 1000 * z == Y:
            print(x, y, z)
            exit()
    
print("-1 -1 -1")

Measured memory_bytes: 9108
#include <bits/stdc++.h> 
#define int long long
#define deb(x) cout<<#x <<" = "<<x<<"\n";
using namespace std; 

signed main() 
{
	//freopen("input.txt", "r", stdin);
	
	int n; cin>>n;
	bool ok = true;
	for(int i=0; i<n; i++)
	{
		int x; cin>>x;
		if(x & 1) continue;
		ok &= ( (x %3 == 0 || x % 5 == 0)) ;
	}
	if(ok) cout << "APPROVED\n";
	else cout <<"DENIED\n";
	
	
	
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cmath>

#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i = a ; i < (int)n ; i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back
#define mp make_pair
#define eps 1e-14
#define INF 1e9
#define m0(x) memset(x, 0, sizeof(x))

using namespace std;

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

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

int h[100001];
ll n, a, b;

bool check(ll t){
  ll cnt = 0;

  rep(i, n){
    if(h[i] > b * t){
      cnt += (h[i] - b * t) / (a-b);
      if(((h[i] - b * t) % (a - b)) != 0) cnt++;
    }
  }
  return cnt <= t;
}

signed main(){

  scanf("%lld %lld %lld", &n, &a, &b);

  rep(i, n) scanf("%d", h+i);
    
  ll l, r, mid, ans;
  l = 0; r = 1e9;

  while(l <= r){
    mid = (l + r) / 2;
    
    if(check(mid)){
      ans = mid;
      r = mid - 1;
    }else{
      l = mid + 1;
    }
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 640
#include<stdio.h>

int main(void){
  char str[100001];
  scanf("%100000s",str);
  int array[]={-1,-1};
  int i,j;

  //文字列の長さ
  for(j=0;str[j]!='\0';j++){
  }

  for(i=0;i<j;i++){
    if(str[i]==str[i+1]){
      array[0]=i+1,array[1]=i+2;
      // printf("%d %d\n",array[0],array[1]);
      break;
    }else if(str[i]==str[i+2]){
      array[0]=i+1,array[1]=i+3;
      //printf("%d %d\n",array[0],array[1]);
      break;
    }
  }

  // printf("%d\n",j);
  printf("%d %d\n",array[0],array[1]);
    return 0;
  }


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

using namespace std;

long long Euclidean_Algorithm(long long a,long long b){
    if(b==0) return a;
    else return Euclidean_Algorithm(b,a%b); 
    }

int main(){
    int N;
    long long X;
    cin>>N>>X;

    vector<long long>x(N+1);
    for(int i=0;i<N;++i){
        cin>>x[i];
        x[i]=X-x[i];
    }
    long long D=abs(x[0]);
    for(int i=0;i<N;++i )D=Euclidean_Algorithm(D,abs(x[i]));
    cout<<D<<endl;

}

Measured memory_bytes: 1024
using System;

public class Hello{
    public static void Main(){
        // Your code here!
        
        
        string str1=Console.ReadLine();
        string str2=Console.ReadLine();
        
        str1+=str1;
        
        if(str1.IndexOf(str2)>=0)Console.WriteLine("Yes");
        else Console.WriteLine("No");
        
        /*
        int i=0;
        while(true)
        {
            
        }
        */
    }
}



Measured memory_bytes: 20352
#include <stdio.h>

char s[5001];
// char s[5001], t[6], c[5];
// int k, n, l[6], i, j, iM;
int main() {
  int k, n, l[6] = {};
  char c[5] = {}, t[6] = {};
  scanf("%s", s);
  scanf("%d", &k);
  n = 5000;
  int low = 0;
  while (n - low > 1) {
    int mid = (n + low) >> 1;
    (s[mid] ? low : n) = mid;
  }
  for (c[0] = 'a'; c[0] <= 'z'; ++c[0]) {
    t[0] = c[0];
    l[1 + 0] = -1;
    for (int i = l[0], iM = n - 0; i < iM; ++i) {
      if (s[i + 0] != t[0]) continue;
      l[1 + 0] = i;
      break;
    }
    if (l[1] < 0) continue;
    if (k == 1) {
      printf("%s\n", t);
      return 0;
    }
    --k;
    for (c[1] = 'a'; c[1] <= 'z'; ++c[1]) {
      t[1] = c[1];
      l[1 + 1] = -1;
      for (int i = l[1], iM = n - 1; i < iM; ++i) {
        if (s[i + 0] != t[0] || s[i + 1] != t[1]) continue;
        l[1 + 1] = i;
        break;
      }
      if (l[2] < 0) continue;
      if (k == 1) {
        printf("%s\n", t);
        return 0;
      }
      --k;
      for (c[2] = 'a'; c[2] <= 'z'; ++c[2]) {
        t[2] = c[2];
        l[1 + 2] = -1;
        for (int i = l[2], iM = n - 2; i < iM; ++i) {
          if (s[i + 0] != t[0] || s[i + 1] != t[1] || s[i + 2] != t[2]) continue;
          l[1 + 2] = i;
          break;
        }
        if (l[3] < 0) continue;
        if (k == 1) {
          printf("%s\n", t);
          return 0;
        }
        --k;
        for (c[3] = 'a'; c[3] <= 'z'; ++c[3]) {
          t[3] = c[3];
          l[1 + 3] = -1;
          for (int i = l[3], iM = n - 3; i < iM; ++i) {
            if (s[i + 0] != t[0] || s[i + 1] != t[1] || s[i + 2] != t[2] || s[i + 3] != t[3]) continue;
            l[1 + 3] = i;
            break;
          }
          if (l[4] < 0) continue;
          if (k == 1) {
            printf("%s\n", t);
            return 0;
          }
          --k;
          for (c[4] = 'a'; c[4] <= 'z'; ++c[4]) {
            t[4] = c[4];
            l[1 + 4] = -1;
            for (int i = l[4], iM = n - 4; i < iM; ++i) {
              if (s[i + 0] != t[0] || s[i + 1] != t[1] || s[i + 2] != t[2] || s[i + 3] != t[3] || s[i + 4] != t[4]) continue;
              l[1 + 4] = i;
              break;
            }
            if (l[5] < 0) continue;
            if (k == 1) {
              printf("%s\n", t);
              return 0;
            }
            --k;
          }
          t[4] = 0;
        }
        t[3] = 0;
      }
      t[2] = 0;
    }
    t[1] = 0;
  }
}


Measured memory_bytes: 1640
n, m = gets.chomp.split.map(&:to_i)
arr = []
m.times do |i|
  p, y = gets.chomp.split.map(&:to_i)
  arr.push([i, p, y, nil])
end
arr.sort_by! { |a| a[2] }

counts = Array.new(n, 1)
m.times do |i|
  arr[i][3] = counts[arr[i][1] - 1]
  counts[arr[i][1] - 1] += 1
end
arr.sort!

arr.each do |a|
  puts format('%06d', a[1]).concat(format('%06d', a[3]))
end


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

int main() {
    char a, b;
    cin >> a >> b;
    char ans = 'D';
    if (a == b) ans = 'H';
    cout << ans << endl;
}

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

using namespace std;

int main(){
	int n;
	while(cin >>n,n){
		vector<int> a(n);
		for(int i=0;i<n;i++){
			cin >> a[i];
		}
		sort(a.begin(),a.end());
		int mini = INT_MAX;
		int idx;
		for(int i=0;i<n-1;i++){
			mini = min(mini,abs(a[i]-a[i+1]));
		}
		cout << mini<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3084
c = [list(map(int, input().split())) for _ in range(3)]
def a(c):
    for j in range(2):
        if not ((c[0][j]-c[0][j+1]) == (c[1][j]-c[1][j+1]) and (c[1][j]-c[1][j+1]) == (c[2][j]-c[2][j+1])):
            return print('No')
        if not ((c[j][0]-c[j+1][0]) == (c[j][1]-c[j+1][1]) and (c[j][1]-c[j+1][1]) == (c[j][2]-c[j+1][2])):
            return print('No')
    return print('Yes')
a(c)

Measured memory_bytes: 3064
def printAns( A ):
    n = len(A)
    for i in range(1, n-1):
        print( str( A[i] ), end=" ")
    print( str( A[n-1] ) )

def main():
    n = int( input() )
    A = [0]
    list = [int(x) for x in input().split()]
    A.extend(list)
    B = []
    C = []
    k = max(A)

    for i in range(k + 1):
        C.append(0)

    for i in range(n+1):
        B.append(0)

    for j in range(1, n+1):
        C[ A[j] ] += 1

    for i in range(1, k+1):
        C[i] = C[i] + C[i-1]

    for j in reversed(range(n+1)):
        B[ C[ A[j] ] ] = A[j]
        C[ A[j] ] -= 1

    printAns(B)

if __name__ == "__main__":
    main()



Measured memory_bytes: 224232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n,k;
    cin>>n>>k;
    vector<ll>a(n);
    rep(0,i,n){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    ll K=min(n,k);
    ll ans=0;
    rep(0,i,n-K){
        ans+=a[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    static public void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = 1;
        while(true){
            int x = sc.nextInt();
            if(x != 0){
                System.out.printf("Case %d: %d\n", n, x);
                n++;
            }else{
                break;
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 61980
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int main()
{
	fastIO
	//inp_out();
	string s;
	cin>>s;
	deque<char> dq;
	ll n=s.size();
	for(ll i=0;i<n;++i)
		dq.push_back(s[i]);
	ll q;
	cin>>q;
	ll rev=0;
	while(q--)
	{
		ll val;
		cin>>val;
		if(val==1)
		{
			rev=1-rev;
		}
		else
		{
			ll v1;
			char ch;
			cin>>v1>>ch;
			--v1;
			//db(ch);
			if((v1^rev)==0)
			{
			//	db(ch);
				dq.push_front(ch);
			}
			else
			{
				dq.push_back(ch);
			}
		}
	}

	string ans="";
	while(!dq.empty())
	{
		ans+=dq.at(0);
		dq.pop_front();
	}

	if(rev==1)
		reverse(all(ans));
	cout<<ans;

	return 0;
}



Measured memory_bytes: 1368
#include<iostream>
#include<cctype>
#include<queue>
#include<cstdio>
#include<cmath>
#include<sstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<ctime>
#include<cstdlib>
#include<map>
#include<utility>
#include<iomanip>
#include<set>
#include<stack>
#include<deque>
using namespace std;
typedef long long ll;typedef pair<int,int> pii;
typedef pair<ll,ll> pll;typedef vector<string> vss;
typedef vector<int> vii;typedef vector<pii> vpi;
typedef vector<ll> vll;typedef vector<pll> vpl;
typedef unsigned long long ul;typedef queue<int> qii;typedef queue<pii> qpi;
ll k,dis[100005];
deque<ll> q;
int main()
{
	cin>>k;
	fill(dis,dis+k,1e9+7);
	q.push_back(1);dis[1]=1;
	while(q.size()){
		ll t=q.front();q.pop_front();
	//	cout<<dis[t]<<' '<<dis[(t*10)%k]<<'\n';
		if(dis[(t*10)%k]>dis[t]){
			dis[(t*10)%k]=dis[t];
			q.push_front((t*10)%k);
		}
		if(dis[(t+1)%k]>dis[t]+1){
			dis[(t+1)%k]=dis[t]+1;
			q.push_back((t+1)%k);
		}
	}
	cout<<dis[0]<<'\n';
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;
int a, b, c, i, j, s, n, mi,  d[10][10], cost[10];

void dic(int ans[]) {
  for(s = 0; s < 10; s++) {
    for(i = 0; i < 10;i++) cost[i] = 100000000;
    int sum = 0, f[10] = {};
    cost[s] = 0;
    mi = s;
    for(i = 0; i < 10; i++) {
      f[mi] = 1;
      for(j = 0; j < 10; j++)  if(!f[j] && cost[j] > cost[mi] + d[mi][j]) cost[j] = cost[mi] + d[mi][j];
      int min = 200000000;
      for(j = 0; j < 10; j++)  if(!f[j] && min > cost[j])  min = cost[mi = j];
    }
    for(i = 0; i < 10; i++)  if(cost[i] != 100000000) sum += cost[i];
    //    cout << sum << endl;
    if(ans[1] > sum && sum != 0){
      ans[0] = s;
      ans[1] = sum;
    }
  }
}


int main() {
  while(cin >> n, n != 0) {
    for(i = 0; i < 10; i++)
      for(j = 0; j < 10; j++)  d[i][j] = 100000000;
    while(n--) {
      cin >> a >> b >> c;
      d[a][b] = d[b][a] = c;
    }
    int ans[2] = {100000000, 100000000};
    dic(ans);
    cout << ans[0] << ' ' << ans[1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            int iM = int.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = (iN - 1) * (iM -1);

            //出力
            Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13268
#include<iostream>

int main(void){
    int x, y;
    std::cin >> x >> y;
    bool flag = 0;
    for(int i = 0; i <= x; i++){
	int j = x - i;
	if(2 * i + 4 * j == y){
	    flag = 1;
	    break;
	}
    }
    if(flag) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
}


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

int main() {
	int n;
	cin >> n ;
	vector <int> mount(n);
	int dekai;
	dekai = 0;
	int mireru = 0;

	for ( int i = 0 ; i < n ; i++){
	cin >> mount[i] ;
	}

	for ( int i = 0 ; i < n ; i ++ ){
		if(dekai <= mount[i] ){
		mireru ++;
		dekai = mount[i];
		}
		else {
		continue;
		}
		}
		cout << mireru <<endl;
	}
	

 


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


ll without_ijl(ll i, ll j, ll l) {
    i /= 2; j /= 2; l /= 2;
    return 2*i + 2*j + 2*l;
}
ll with_ijl(ll i, ll j, ll l) {
    if (i && j && l) {
        return 3 + without_ijl(i-1, j-1, l-1);
    } else {
        return 0;
    }
}
ll solve(vi& a) {
    ll I = a[0], O = a[1], J = a[3], L = a[4];
    return O + max(with_ijl(I,J,L), without_ijl(I,J,L));
}

int main() {
    vi a(7);
    rep(i,7) cin >> a[i];
    cout << solve(a) << endl;
    return 0;
}


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

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
	cin >> n;
	unordered_set<int> a;

	for(int i =0 ; i< n; ++i)
	{
		int x;
		cin >> x;
		if(a.count(x))
		{
			cout << "NO";
			return 0;
		}
		a.insert(x);
	}
	cout << "YES";
	
    return 0;
}

Measured memory_bytes: 8520
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {
	os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T,class U> ostream& operator<<(ostream &os, const tuple<S,T,U> &t) { return os<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class S, class T,class U,class V> ostream& operator<<(ostream &os, const tuple<S,T,U,V> &t) { return os<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<","<<get<3>(t)<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
#else
#define out
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
	int n;
	cin>>n;
	vector<ll> a(n);
	rep(i,n) cin>>a[i], a[i]-=i+1;
	sort(all(a));
	ll re=0;
	for(ll x:a) re+=abs(x-a[n/2]);
	cout<<re<<endl;
  return 0;
}


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

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    ll s = min({a*b,b*c,c*a});
    if(a%2 == 0 || b%2 == 0 || c%2 == 0) cout << 0 << endl;
    else cout << s << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define H 251

int main(void){
  int n,Node[H];
  int i;

  scanf(" %d",&n);
  for(i = 1; i < n+1; i++){
    scanf(" %d",&Node[i]);
  }

  for(i = 1; i < n+1; i++){
    printf("node %d: key = %d, ",i,Node[i]);
    if(i/2 >= 1) printf("parent key = %d, ",Node[i/2]);
    if(2*i <= n) printf("left key = %d, ",Node[2*i]);
    if(2*i+1 <= n) printf("right key = %d, ",Node[2*i+1]);
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2052
#include "iostream"
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int h,w;
  std::cin >> h >> w;
  string s[100];

  for(int i=0; i<h; i++) cin >> s[i];

  std::cout << string(w+2,'#') << '\n';

  for(int i=0; i<h; i++){
    std::cout << '#' << s[i] << '#' << '\n';
  }

  std::cout << string(w+2,'#') << '\n';
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	int heap[n + 1];

	for (int i = 1; i <= n; i++) {
		cin >> heap[i];
	}

	for (int i = 1; i <= n; i++) {
		cout << "node " << i << ": key = " << heap[i] << ", ";
		if (i != 1) {
			cout << "parent key = " << heap[i / 2] << ", ";
		}
		if (i * 2 <= n) {
			cout << "left key = " << heap[i * 2] << ", ";
		}
		if (i * 2  + 1 <= n) {
			cout << "right key = " << heap[i * 2 + 1] << ", ";
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3080
N,M,X=map(int,input().split())
ls=[list(map(int,input().split())) for i in range(N)]
ls_c=[]
for i in range(1,2**N):
  ls_al=[0]*M
  c=0
  for j in range(N):
    if (i>>j)&1==1:
      c+=ls[j][0]
      for k in range(M):
        ls_al[k]+=ls[j][k+1]
  if min(ls_al)>=X:
    ls_c.append(c)
    
if ls_c!=[]:
  print(min(ls_c))
else:
  print(-1)

Measured memory_bytes: 9300
#include <stdio.h>

int main(void) {

    int x;

    scanf("%d", &x);

    if(0<=x && x<=100){
        printf("%d\n",x*x*x);
    }
    else{
        printf("Integer x should be greater than 0, less than 100\n");
    }

    return 0;
}


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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int A, B, Q;
vec s, t;

signed main() {
  cin >> A >> B >> Q;
  s.pb(-INF);
  for (int i = 0; i < A; i++) {
    int tmp;
    cin >> tmp;
    s.pb(tmp);
  }
  s.pb(INF);
  t.pb(-INF);
  for (int i = 0; i < B; i++) {
    int tmp;
    cin >> tmp;
    t.pb(tmp);
  }
  t.pb(INF);

  for (int i = 0; i < Q; i++) {
    int x;
    cin >> x;

    int a[2], b[2];
    a[1] = lower_bound(ALL(s), x) - s.begin();
    a[0] = a[1] - 1;
    b[1] = lower_bound(ALL(t), x) - t.begin();
    b[0] = b[1] - 1;

    int ans = INF;
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        int fi, se;
        fi = abs(x - s[a[j]]) + abs(s[a[j]] - t[b[k]]);
        se = abs(x - t[b[k]]) + abs(s[a[j]] - t[b[k]]);
        chmin(ans, min(fi, se));
      }
    }

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


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

struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int N;
    cin >> N;
    int p[11];
    int ma = 0;
    int ans = 0;
    rep(i,N){
        cin >> p[i];
        ans += p[i];
        ma = max(ma,p[i]);
    }
    ans -= ma/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second

ll FastModExp(ll a,ll b,ll m)
{
// To compute a^b mod m
    ll res=1;
    while(b>0)
    {
        if(b&1)
        {
            res=(res*a)%m;
        }
        a=(a*a)%m;
        b=b>>1;
    }

    return res;
}
int main()
{
    string s;
    ll c=0,i,c1=0;
    cin>>s;
    for(i=0;i<s.length();i++)
    {
        if(i%2==0 && s[i]=='1') c++;
        if(i%2!=0 && s[i]=='0') c++;
        if(i%2!=0 && s[i]=='1') c1++;
        if(i%2==0 && s[i]=='0') c1++;
    }
   
    cout<<min(c,c1);
    return 0;
}





Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

/**
 * Lesson9C 太郎と花子がカードゲームをする。
 * 二人はそれぞれn枚のカードを持っており、nターンの勝負を行う。
 * 各ターンではそれぞれ１枚ずつカードを出す。
 * カードにはアルファベットからなる動物の名前が書かれており、
 * 辞書順で大きいものがそのターンの勝者となる。
 * 勝者には３ポイント、引き分けの場合にはそれぞれ１ポイントが加算される。
 * 太郎と花子の手持ちのカードの情報を読み込み、ゲーム終了後のそれぞれの得点を出力するプログラム
 *
 * @author Internship
 *
 */
public class Main{

	/**
	 * プログラムのエントリポイント
	 *
	 * @param args
	 */
	public static void main(String[] args) {



		// 答えの格納場所
		ArrayList<String> StringAry = new ArrayList<String>();

		// charを繋げてStringにする
		String StrFromChar = "";

		try {
			BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));



			//点数を格納する場所
			int[] intAnswer = new int[2];



				// 1行目読み込む
				String strLine = insBR.readLine();

				int intNum = Integer.parseInt(strLine);

				//動物の名前の格納場所

				String[][] strAnimal = new String[2][intNum];

				// 2行目以降を読み込む
				for (int i = 0; i < intNum; i++) {
					strLine = insBR.readLine();

					//文字列の分割:入力値を" "で分ける
					//分けた文字列はstrLineAry[0]とstrLineAry[1]とstrLineAry[2]に分けられる
					String[] strLineAry = strLine.split(" ");

					strAnimal[0][i] = strLineAry[0];

					strAnimal[1][i] = strLineAry[1];

					if (strAnimal[0][i].compareToIgnoreCase(strAnimal[1][i]) == 0) {
						intAnswer[0]++;
						intAnswer[1]++;
					}else if(strAnimal[0][i].compareToIgnoreCase(strAnimal[1][i]) < 0) {
						intAnswer[1] += 3;
					}else if(strAnimal[0][i].compareToIgnoreCase(strAnimal[1][i]) > 0) {
						intAnswer[0] += 3;
					}



				}


			// 出力
			for (int i = 0; i < intAnswer.length; i++) {
				if(i == 0) {
					System.out.print(intAnswer[i]);
				}else {
					System.out.print(" " + intAnswer[i]);
				}
			}

			System.out.println("");

		} catch (IOException e) {
			System.out.println(e);
		} catch (NumberFormatException e) {
			System.out.println("数字で入力して下さい");
		}
	}
}

Measured memory_bytes: 20036
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

ll rep_pow(ll a, ll b){//繰り返し2乗法
    if(b==0) return 1;
    else if(b%2==0){
        ll memo = rep_pow(a, b/2);
        return memo*memo%mod;
    }else{
        return rep_pow(a, b-1)*a%mod;
    }
}

ll nCr(ll n, ll r){//mod逆元使ったnCr
    ll ret=1;
    rep(i,r){
        ret *= n-i;//分子
        ret %= mod;
        ret *=rep_pow(r-i, mod-2);//mod逆元によりr!で割ると同値
        ret %= mod;
    }
    return ret;
}
ll gcd(ll a, ll b){ if(b==0) return a; return gcd(b, a%b);}



int main(){
    fast_io

    int n;
    cin>>n;
    ll a[n];
    rep(i,n) cin>>a[i];

    int ans=0;
    rep(i,n){
        int x=a[i];
        while(x%2==0){
            ans++;
            x/=2;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

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

const ll MOD = ll(1e9) + 7;
const ll INF = LLONG_MAX;
const ll MAX_N = 200005;
const double EPS = 10e-8;
const double PI = 3.14159265359;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

struct UF {
    int par[MAX_N];
    int rank[MAX_N];
    int siz[MAX_N];

    void init(int x) {
        REP(i, x) {
            par[i] = i;
            rank[i] = 1;
            siz[i] = 1;
        }
    }
    int find(int x) {
        if (par[x] != x) {
            par[x] = find(par[x]);
        }
        return par[x];
    }
    bool same(int x, int y) { return find(x) == find(y); }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) rank[x]++;
        siz[x] += siz[y];
        par[y] = x;
    }
};

map<P, int> g;

int main() {
    int n, k, l;
    cin >> n >> k >> l;
    UF a, b;
    a.init(n);
    b.init(n);
    REP(i, k) {
        int p, q;
        cin >> p >> q;
        p--;
        q--;
        a.unite(p, q);
    }
    REP(i, l) {
        int r, s;
        cin >> r >> s;
        r--;
        s--;
        b.unite(r, s);
    }
    REP(i, n) { g[{a.find(i), b.find(i)}]++; }
    REP(i, n) {
        if (i == 0) {
            cout << g[{a.find(i), b.find(i)}];
        } else {
            cout << " " << g[{a.find(i), b.find(i)}];
        }
    }
    cout << endl;
    return 0;
}

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

using ll = long long int;
using P = std::pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rag(con) std::begin(con), std::end(con)

int main()
{
    int h, w, m;

    std::cin >> h >> w >> m;

    std::vector<P> vec;
    std::map<int, int> mpX, mpY;

    rep(i, m)
    {
        int hi, wi;
        std::cin >> hi >> wi;
        vec.emplace_back(hi, wi);
        mpX[hi]++;
        mpY[wi]++;
    }

    int mx = 0, my = 0;

    for (auto p : mpX)
    {
        mx = std::max(mx, p.second);
    }

    std::set<int> sx;

    for (auto p : mpX)
    {
        if (mx == p.second)
        {
            sx.emplace(p.first);
        }
    }

    for (auto p : mpY)
    {
        my = std::max(my, p.second);
    }

    std::set<int> sy;

    for (auto p : mpY)
    {
        if (my == p.second)
        {
            sy.emplace(p.first);
        }
    }

    int ans = mx + my, cnt = 0;

    for (P p : vec)
    {
        if (sx.count(p.first) && sy.count(p.second))
            ++cnt;
    }

    if (cnt == (ll)sx.size() * (ll)sy.size())
        --ans;

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

    return 0;
}

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

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b.begin(), b.end());
    for (int i = 0; i < n; i++)
    {
        if (a[i] == b[n - 1])
        {
            cout << b[n - 2] << endl;
        }
        else
        {
            cout << b[n - 1] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4736
from operator import itemgetter
N = int(input())

lst =[]
for i in range(N):
    lst.append(list(map(int, input().split())))

lst.sort(key=itemgetter(1))

now = 0
flg = True
for item in lst:
    now += item[0]
    if now > item[1]:
        flg = False
        break

print('Yes' if flg else 'No')

Measured memory_bytes: 53720
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>

using namespace std;

const double eps=1e-10;

int main()
{
	int a[4],b[4];
	while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){

		int hit=0,blow=0;

		int c[10]={0};
		for(int i=0;i<4;i++){
			if(a[i]==b[i]) hit++;
			else{
				c[a[i]]++;
				c[b[i]]++;
			}
		}
		for(int i=0;i<10;i++)
			if(c[i]==2) blow++;

		cout<<hit<<" "<<blow<<endl;

	}

	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#define N 100

int BubbleSort(int a[], int n)
{
    int swap_times = 0;
    for (int i = 0; i < n-1; i ++)
    {
        for (int j = n-1; j >= i+1; j--)
        {
            if (a[j] < a[j-1])
            {
                int t = a[j];
                a[j] =  a[j-1];
                a[j-1] = t;
                swap_times++;
            }
        }
    }
    return swap_times;
}
int main()
{
    int n;
    int a[N];

    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    int t = BubbleSort(a, n);
    for (int i = 0; i < n; i++)
    {
        if (i > 0)
            printf(" ");
        printf("%d", a[i]);
    }
    printf("\n%d\n", t);

    return 0;
}



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

int com(int n, int r){
        int num = 1;
        for(int i = 1; i <= r; i++){
            num = num * (n - i + 1) / i;
        }
        return num;
    }

int main(){
    int n, m, ret = 0;
    cin >> n >> m;

    ret = com(n,2) + com(m,2);

    cout << ret << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxm=100000+10,maxn=300000+10;
int tree[maxm],ans[maxm];
int h[maxm],go[maxm*20],nxt[maxm*20],ask[maxm*20][3];
int h2[maxm],g2[maxn],n2[maxn];
int i,j,k,l,t,n,m,tot,top;
void add(int x,int y){
    go[++tot]=y;
    nxt[tot]=h[x];
    h[x]=tot;
}
void add2(int x,int y){
    g2[++tot]=y;
    n2[tot]=h2[x];
    h2[x]=tot;
}
int lowbit(int x){
    return x&-x;
}
void change(int x){
    while (x){
        tree[x]++;
        x-=lowbit(x);
    }
}
int query(int x){
    int t=0;
    while (x<=m){
        t+=tree[x];
        x+=lowbit(x);
    }
    return t;
}
int main(){
    scanf("%d%d",&n,&m);
    fo(i,1,n){
        scanf("%d%d",&j,&k);
        add2(k,j);
    }
    tot=0;
    fo(i,1,m) ans[i]=n;
    fo(i,1,m){
        fo(j,1,m/i){
            ask[++top][0]=i*(j-1);
            ask[top][1]=i*j;
            ask[top][2]=i;
            add(ask[top][1],top);
        }
        top++;
        ask[top][0]=(m/i)*i;
        ask[top][1]=m+1;
        ask[top][2]=i;
        add(m+1,top);
    }
    fo(i,0,m+1){
        t=h[i];
        while (t){
            j=go[t];
            ans[ask[j][2]]-=query(ask[j][0]+1);
            t=nxt[t];
        }
        t=h2[i];
        while (t){
            change(g2[t]);
            t=n2[t];
        }
    }
    fo(i,1,m) printf("%d\n",ans[i]);
}

Measured memory_bytes: 36864
eval'N,K,*A='+`dd`.split*?,
d=(0..255).map{[0]*-~N}
d[0][0]=1
A.map{|a|N.times{|j|256.times{d[_1^a][i=N-j]+=d[_1][i-1]*i}}}
p d[K].sum.%10**9+7

Measured memory_bytes: 21524
n, p = map(int, input().split())
i_dict = {}
ans = 1

while True:
    check = 0
    for i in range(2, 1 + int(p**0.5)):
        if p % i == 0:
            if i in i_dict:
                i_dict[i] += 1
            else:
                i_dict[i] = 1
            p = p // i
            check = 1
            break
    if check == 0:
        if p in i_dict:
            i_dict[p] += 1
        else:
            i_dict[p] = 1
        break

for k, v in i_dict.items():
    ans *= k ** (v // n)

print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
bool comp(pair<pair<string,int>,int>a,pair<pair<string,int>,int>b)
{
	if(a.first.first<b.first.first)
	{
		return true;
	}
	else if(a.first.first==b.first.first)
	{
		if(a.first.second>b.first.second)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	else
	{
		return false;
	}
}
int main()
{
	ll n,rat;
	string city;
	vector<pair<pair<string,int>,int> >r;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>city>>rat;
		r.push_back(make_pair(make_pair(city,rat),i+1));
	}
	sort(r.begin(),r.end(),comp);
	for(int i=0;i<n;i++)
	{
		cout<<r[i].second<<endl;
	}
}


Measured memory_bytes: 256
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)

const int M=1000000007;
const int MM=998244353;


 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(m<=1)return 0;
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=1e6+5;

ll sp[N];

void fill(){
  for(int i=1;i<N;i++)sp[i]=i;

    for(int i=2;i<N;i++){
      for(int j=i;j<N;j+=i){
        if(sp[j]==j)sp[j]=i;
      }
    }
}

//vl f(N);

bool prime(ll x){
  if(x<=3)return true;

  for(ll i=2;i*i<=x;i++)if(x%i==0)return false;

    return 1;
}


int main()
{ 

IOS;

fill();

ll a,b;cin>>a>>b;

ll mn=min(a,b);

ll c=0;

set<ll>s;

for(ll i=1;i*i<=a;i++){
  if(a%i==0){
    if(prime(i))s.insert(i);
    if(prime(a/i))s.insert(a/i);
  }
}

for(ll i=1;i*i<=b;i++){
if(b%i==0){
 if( prime(i)&&s.count(i))++c;
 if(i*i!=b&&prime(b/i)&&s.count(b/i))++c;

}

}

//for(auto d:s)cout<<d<<" ";

cout<<c;

return 0;
 
}


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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

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


const ll SIZE = 1e5+10;
ll a,b;

int main(){
    cin >> a >> b;
    if(a<=9 && b <= 9)  cout << a*b << endl;
    else
    {
        cout << "-1\n";
    }
    
}

Measured memory_bytes: 256
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    uint64_t N;
    std::cin >> N;

    size_t ma = 10000000000;

    for (uint64_t i = 1; i < sqrt(N) + 1; ++i) {
        if (N % i != 0) {
            continue;
        }
        auto r = N / i;

        auto mm = std::max(boost::lexical_cast<std::string>(i).size(),
                           boost::lexical_cast<std::string>(r).size());
        if (ma < mm) {
            std::cerr << i << " " << r << std::endl;
        }
        ma = std::min(ma, mm);
    }

    std::cout << ma << std::endl;

    return 0;
}


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

d = n // (a + b)
mod = n % (a + b)
# print(d, mod)

ans = a * d

# print(ans, a, mod)

if a >= mod:
    # print(a, mod)
    ans += mod
else:
    ans += a

print(ans)

Measured memory_bytes: 38384
#include <stdio.h>
int main(){
	int n,m,i,a,sum=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)scanf("%d",&a),sum+=a;
	if(n<sum)printf("-1\n");
	else printf("%d\n",n-sum);
	return 0;
}

Measured memory_bytes: 1724
n,k = map(int,input().split())
MOD = 998244353
hani = []
for _ in range(k):
    l,r = map(int,input().split())
    hani.append((l,r))

rui = [0] * (n+1)
cur = [0] * n
rui[1] = 1
cur[0] = 1

for i in range(1,n):
    for j in range(k):
        left = max(0,i-hani[j][0]+1)
        right = max(0,i-hani[j][1])
        
        cur[i] = (cur[i] + MOD + rui[left] - rui[right]) % MOD
        
    rui[i+1] = (rui[i] + cur[i]) % MOD
    
print(cur[n-1])

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

int main(){
  int N,k;
  cin>>N;
  vector<int> X(N);
  for(int i=0; i<N; i++){
    cin>>X.at(i);
  }
  sort(X.begin(),X.end());
  int mini=1000000000;
  for(int i=X.at(0); i<=X.at(N-1); i++){
    int c=0;
    for(int j=0; j<N; j++){
      k=pow(abs(i-X.at(j)),2);
      c+=k;
    }
    mini=min(mini,c);
  }
  cout<<mini<<endl;
}

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

using namespace std;

int n, m, g;

signed main() {
	cin >> n >> m;
    g = __gcd(n,m);
    int ans = 1;
    for(register int i = 2; i <= 1000000; i++) {
        if(g % i == 0) {
            while(g % i == 0) g /= i;
            ans++;
        }
    }
    if(g > 1) ans++;
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256