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

using namespace std;

struct Point {
    int x, y;
    Point() {}
    friend istream& operator>>(istream& in, Point& p) {
        in >> p.x >> p.y;
        return in;
    }
    bool operator<(const Point& o) const {
        return x < o.x;
    }
};

struct Fenwick {
    // Fenwick tree on 1, .., n. (1-indexed)
    int n;
    vector<int> xs;
    Fenwick(int n): n(n), xs(n+1, 0) {}
    void add(int i, int v) { // a[i] += v
        while (i <= n) {
            xs[i] += v;
            i += i & (-i);
        }
    }
    int get(int i) { // return a[1] + .. + a[i]
        int sum = 0;
        while (i > 0) {
            sum += xs[i];
            i -= i & (-i);
        }
        return sum;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long prime = 998244353;
    int n;
    cin >> n;
    vector<long long> pow2(n);
    pow2[0] = 1LL;
    for (int i = 1; i < n; ++i) {
        pow2[i] = (pow2[i-1] * 2) % prime;
    }
    vector<Point> points(n);
    vector<int> xs, ys;
    for (Point& point : points) {
        cin >> point;
        xs.push_back(point.x);
        ys.push_back(point.y);
    }
    map<int, int> f_x, f_y;
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());
    for (int i = 0; i < n; ++i) {
        f_x[xs[i]] = i;
        f_y[ys[i]] = i+1; // y coordinates are 1-indexed.
    }
    for (Point& point : points) {
        point.x = f_x[point.x];
        point.y = f_y[point.y];
    }
    sort(points.begin(), points.end());
    Fenwick visited(n);
    long long sum = 0;
    for (int i = 0; i < n; ++i) {
        Point& p = points[i];
        // we get a, b, c, d like this 
        // a | b
        // -----
        // c | d
        int c = visited.get(p.y);
        int a = i - c;
        // a + b == n - p.y
        int b = n - p.y - a;
        // c + d == p.y - 1
        int d = p.y - 1 - c;
        long long outside = (pow2[a+b]-1) + (pow2[b+d]-1) + (pow2[d+c]-1) + (pow2[c+a]-1) - (pow2[a]-1) - (pow2[b]-1) - (pow2[c]-1) - (pow2[d]-1);
        long long from_others = (pow2[n-1]-1) - outside;
        long long total = from_others + pow2[n-1];
        total = (total % prime + prime) % prime;
        sum = (sum + total) % prime;
        visited.add(p.y, 1);
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 24556
#include <stdio.h>


int main () {

    int a,b,c;



    scanf("%d %d %d", &a, &b, &c);

    if(a == b) printf("%d", c);
    if(b == c) printf("%d", a);
    if(c == a) printf("%d", b);
    
    return 0;
}

Measured memory_bytes: 128
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
var q=arr.shift()-0;
var str="";
var  set = new Map();
for(var i=0;i<q;i++){
   var [a,b]=arr[i].split(" ");
   if(a=="0"){
      set.set(b,0);
      str+=set.size+"\n";
   }else if(a=="1") {
      str+=((set.has(b))?1:0)+"\n";
   } else{
      set.delete(b);
   }
}
console.log(str.trim());


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

int compare_int(const void *a,const void *b){
  return *(long*)a-*(long*)b;
}

int main(void){
  long N;
  scanf("%ld",&N);
  long A[N];
  long ans[2];
  long past = -1;
  int flag = 0;

  for(int i = 0;i < N;i++) scanf("%ld",&A[i]);
  qsort(A,N,sizeof(long),compare_int);

  for(int i = N-1;i >= 0;i--){
    if(past == A[i]){
      if(flag){
        ans[1] = A[i];
        printf("%ld\n",ans[0]*ans[1]);
        return 0;
      }else{
        ans[0] = A[i];
        flag = 1;
      }
      past = -1;
    }else{
      past = A[i];
    }
  }

  printf("0\n");
  return 0;
}

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<map>
#include<utility>
#include<queue>
using namespace std;
 
char f[1001][1001];
int d[1001][1001];
int h , w , n , x , y , ans;
typedef pair<int,int> P;
int dx[] = {1,0,-1,0} , dy[] = {0,-1,0,1};
 
int bfs(int to){
  for( int i = 0 ; i < h ; i++)
    for( int j = 0 ; j < w ; j++)
      d[i][j] = 0;
  queue<P> q;
  q.push(make_pair(x,y));
  d[y][x]=1;
  while(!q.empty()){
    P p = q.front();
    q.pop();
    if(f[p.second][p.first] - '0' == to){
      x = p.first;
      y = p.second;
      break;
    }
    for(int i = 0 ; i < 4 ; i ++){
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if(nx >= 0 && nx < w && ny < h && ny >=0 && d[ny][nx] == 0 && f[ny][nx] != 'X'){
        d[ny][nx] = d[p.second][p.first] + 1;
        q.push(make_pair(nx,ny));
        
      }
    }
  }
  return d[y][x] - 1;
} 
 
int main(){
  while(cin >> h >> w >> n){
    ans = 0;
    for( int i = 0 ; i < h ; i++)
      cin >> f[i];
    for( int i = 0 ; i < h ; i++)
      { 
      for( int j = 0 ; j < w ; j++)
        {
          if(f[i][j]=='S')
            {
          x = j;
          y = i;
            }
        }       
      }
    for( int i = 1 ; i <= n ; i++ ) ans +=bfs(i) ; 
    cout << ans << endl;
  }     
}

Measured memory_bytes: 5776
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//<ここに一言>

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
template <typename T>
T gcd(T a,T b){
  if(a%b==0)return b;
  else return gcd(b,a%b);
}
template <typename T>
T lcm(T a,T b){
  return a/gcd(a,b)*b;
}
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int n;cin>>n;
	string m;cin>>m;
	int ans = 0;
	for(int i = 0; n > i; i++){
		string s;cin>>s;
		bool ok = false;
		for(int j = 1; s.size() >= (j*(m.size()-1));j++){//j文字おき
		//2 4 6 8
		//1 2 3 4
			for(int k = 0; s.size() > (j*(m.size()-1))+k; k++){
				for(int l = 0; m.size() > l; l++){
					if(s[k+(j*l)] != m[l]){
						break;
					}
					if(l+1==m.size()){
						ok = true;
					}
				}
			}
		}
		if(ok){
			ans++;
		}
	}
	cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  if (N==1) cout << 1;
  else {
	long long lm2 = 2;
	long long lm1 = 1;
	long long l = 3;   
    for(int i=2; i<N; i++){
		lm2 = lm1;
		lm1 = l;
		l = lm1 + lm2;
  	}
    cout << l;
  }
}


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

int main()
{
    int n ;
    int a[MX] ;
    int maxx ;
    int total ;
    while(cin >> n)
    {
        total = 0 ;
        maxx = 0 ;
        for(int i=0; i<n; i++)
        {
            cin >> a[i] ;
            if(a[i] >= maxx)
            {
                total++ ;
                maxx = a[i] ;
            }
        }
        cout << total << '\n' ;
    }
    return 0 ;
}


Measured memory_bytes: 256
import math
from collections import Counter
import itertools

def prime_factors(n):
  i = 2
  factors = []
  while i * i <= n:
    if n % i==0:
      n //= i
      factors.append(i)
    else:
      i += 1
  if n > 1:
    factors.append(n)
  return factors

n=int(input())
num=math.factorial(n)
factors=prime_factors(num)
es=list(Counter(factors).values())
m=len(es)
ans=0

for i in range(m):
  if es[i]>=74:
    ans+=1

for i in range(m):
  for j in range(m):
    if i!=j and es[i]>=24 and es[j]>=2:
      ans+=1

for i in range(m):
  for j in range(m):
    if i!=j and es[i]>=14 and es[j]>=4:
      ans+=1

for i in range(m):
  for j in range(i+1,m):
    for k in range(m):
      if i!=k and j!=k and es[i]>=4 and es[j]>=4 and es[k]>=2:
        ans+=1
print(ans)


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

int main(){
  string S1,S2,S3;
  cin >> S1 >> S2 >> S3;
  transform(S1.begin(),S1.end(),S1.begin(), ::toupper);
  transform(S2.begin(),S2.end(),S2.begin(), ::toupper);
  transform(S3.begin(),S3.end(),S3.begin(), ::toupper);
  
  cout << S1.at(0) << S2.at(0) << S3.at(0) << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int N;
  int t[100001];
  int x[100001];
  int y[100001];
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  cin >> N;
  for (int i = 1; i <= N ; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  bool is_ok = true;
  //cout << "-------------" << endl;
  for (int i = 0; i <= N - 1; i++) {
    //cout << t[i] << "," << x[i] << ',' << y[i] << endl;
    int z = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
    int t_diff = t[i+1] - t[i];
    //cout << "z:" << z << ",t_diff:" << t_diff << endl;
    if (z == t_diff) {
      //cout << i << ":OK" << endl;
    } else if (z < t_diff && (t_diff - z) % 2 == 0) {
      //cout << i << ":OK" << endl;
    } else {
      //cout << i << ":NG" << endl;
      is_ok = false;
    }
    if (!is_ok) {
      cout << "No" << endl;
      break;
    }
  }
  if (is_ok) {
    cout << "Yes" << endl;
  }
}


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

int main() {
  int N;
  cin >> N;
  LL out =1;
  const LL MX =1e18;
  bool ng = false;
  
  for (int i=0;i<N;i++){
    LL b;
    cin >> b;
    
    if (b ==0){
      cout<< 0 <<endl;
      return 0;
    }
    if (ng ||MX/out<b){
      ng = true;
    }
    
    out *= b;
  }
  if (ng) cout<< -1 << endl;
  else
    cout << out << endl;
  return 0;
}


Measured memory_bytes: 3592
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();

		// 計算
		int result = max(a+b, max(a-b, a*b));
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 22612
import java.util.*;
class Main
{
  public static void main(String [] args)
  {
    Scanner s = new Scanner(System.in);
    int count = 0;
    int n = 9;
    while(n != 0)
    {
      n = s.nextInt();
      count++;
    } 
    System.out.println(count);
  }
}

Measured memory_bytes: 35688
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


A = [[0 for _ in range(3)] for _ in range(3)]

for i in range(3):
    A[i] = list(map(int, input().split()))

n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == b:
                A[j][k] = - 1

for i in range(3):
    if A[i][0] == A[i][1] == A[i][2] == -1:
        print("Yes")
        exit()
for i in range(3):
    if A[0][i] == A[1][i] == A[2][i] == -1:
        print("Yes")
        exit()
if A[0][0] == A[1][1] == A[2][2] == -1:
    print("Yes")
    exit()

if A[0][2] == A[1][1] == A[2][0] == -1:
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 9424
#include <stdio.h>

int main(void) {
	int saikoro[6];
	int q,i;
	int top,front;
	int result;
	
	for(i=0;i<6;i++){
		scanf("%d",&saikoro[i]);
	}
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d %d",&top,&front);
		result = dice(saikoro,top,front);
		printf("%d\n",result);
	}
	return 0;
}
int dice(int saikoro[6],int top,int front){
	if(top == saikoro[0]){
		if(front == saikoro[1]) return saikoro[2];
		if(front == saikoro[2]) return saikoro[4];
		if(front == saikoro[3]) return saikoro[1];
		if(front == saikoro[4]) return saikoro[3];
	}
	if(top == saikoro[1]){
		if(front == saikoro[0]) return saikoro[3];
		if(front == saikoro[2]) return saikoro[0];
		if(front == saikoro[3]) return saikoro[5];
		if(front == saikoro[5]) return saikoro[2];
	}
	if(top == saikoro[2]){
		if(front == saikoro[0]) return saikoro[1];
		if(front == saikoro[1]) return saikoro[5];
		if(front == saikoro[4]) return saikoro[0];
		if(front == saikoro[5]) return saikoro[4];
	}
	if(top == saikoro[3]){
		if(front == saikoro[0]) return saikoro[4];
		if(front == saikoro[1]) return saikoro[0];
		if(front == saikoro[4]) return saikoro[5];
		if(front == saikoro[5]) return saikoro[1];
	}
	if(top == saikoro[4]){
		if(front == saikoro[0]) return saikoro[2];
		if(front == saikoro[2]) return saikoro[5];
		if(front == saikoro[3]) return saikoro[0];
		if(front == saikoro[5]) return saikoro[3];
	}
	if(top == saikoro[5]){
		if(front == saikoro[1]) return saikoro[3];
		if(front == saikoro[2]) return saikoro[1];
		if(front == saikoro[3]) return saikoro[4];
		if(front == saikoro[4]) return saikoro[2];
	}
	return 0;
}

Measured memory_bytes: 1788
// g++ -I ~/Documents/AtCoder -std=gnu++14 -o test ~/Documents/AtCoder/test.cpp && ./test && rm test
#include <bits/stdc++.h>
#define in ([]{int n; cin >> n; return n;}())
#define rep(i, n) for( lint i=0,i##_LEN_=(n); i<i##_LEN_; ++i )
#define all(v)    (v).begin(), (v).end()
using namespace std;
using lint = int64_t;
const char nl = '\n';

int main() { cin.tie(0); ios::sync_with_stdio(false);
    int N=in, M=in;

    vector<pair<int,int>> ABC(N+M);
    rep( i, N ) {
        ABC[i] = pair<int,int>({ 1, in });
    }
    for( int i=N; i<N+M; i++ ) {
        ABC[i] = pair<int,int>({ in,in });
    }

    sort( all(ABC), [](auto x, auto y){return x.second > y.second;} );

    lint sum = 0;
    int other = N;
    for( auto abc : ABC ) {
        int maisuu = min( other, abc.first );
        sum += (lint)abc.second * maisuu;
        other -= maisuu;
        if( other == 0 ) {
            cout << sum << nl;
            return 0;
        }
    }
}


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

int main (){
  int n,d,x;
  cin >> n >> d >> x;

  int ans = x;
  for (int i = 0; i < n; i++)
  {
    int a;
    cin >> a;
    for (int j = 1; j <= d; j+=a)
    {
      ans++;
    }
    
  }
  cout << ans << endl;
}

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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    int nA = (c+b-1)/b;
    int nB = (a+d-1)/d;

    if(nA <= nB){
        cout << "Yes\n";
    }else
    {
        cout << "No\n";
    }

    return 0;
}

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

ll game(ll *arr,int n){
    ll dp[n][n];
    for(int i= 0;i<n;i++)
        dp[i][i] = arr[i];
    
    for(int len = 2 ; len <= n;len++){
        for(int i= 0;i<=n-len;i++){
            int j= i+len-1;
            if(len == 2)
            {
                dp[i][j] = max(dp[i][i],dp[j][j]);
            }
            else{
                dp[i][j] = max(arr[i] + min(dp[i+1][j-1],dp[i+2][j]), arr[j] + min(dp[i+1][j-1],dp[i][j-2]));
            }
        }
    }
    return dp[0][n-1];
}

int main(){
    int n;
    scanf("%d" , &n);
  
    ll a[n];
    ll total = 0;
    for(int i = 0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        total += a[i];
    }
    
    ll x = game(a,n);
    ll y = total - x;
    ll ans = x - y;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 70272
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K; 
  int X = 1; 
  for (int i = 0; i < N; ++i) 
  {int s; 
  cin >> s;
  if(s != 1) X ++;
  if(s == 1) break;
  }
  int m = 0;
  if(1 <= X <= K || N-K+1 <=X <= N)
  cout << 1 + (N-2)/(K-1) << endl; 
  else
  {for (int j = 0; j < K; ++j)
  {int y = 1 + (X-j+K-1)/(K-1) + (N-X+j-1) / (K-1);
  m = min(m, y);
  }
cout << m << endl; 
}
}


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

int main() {
int N;
  cin>>N;
  int i,s,t,u;
  vector<int> vec(N);
  for(i=0;i<N;i++){
    cin>>vec.at(i);}
  int k=0;
  for(s=0;s<N;s++){
    for(t=0;t<N;t++){
      for(u=0;u<N;u++){
        if(vec.at(s)!=vec.at(t)&&vec.at(t)!=vec.at(u)&&vec.at(s)!=vec.at(u)&&vec.at(s)+vec.at(t)>vec.at(u)&&vec.at(s)+vec.at(u)>vec.at(t)&&vec.at(t)+vec.at(u)>vec.at(s)){
          k=k+1;}
      }}}
        cout<<k/6<<endl;}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll f(ll n){
    return (n*n + 4) / 8;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H,W;
    cin >> H >> W;
    ll dx[8] = {1,1,1,0,0,-1,-1,-1};
    ll dy[8] = {1,0,-1,1,-1,1,0,-1};
    string S[55];
    rep(i,0,H) cin >> S[i];
    rep(i,0,H){
        rep(j,0,W){
            if(S[i][j] == '#'){
                cout << '#';
                continue;
            }
            ll cnt = 0;
            rep(k,0,8){
                if(i+dy[k] < 0 || i+dy[k] >= H || j+dx[k] < 0 || j + dx[k] >= W) continue;
                if(S[i+dy[k]][j+dx[k]] == '#') cnt++;
            }
            cout << cnt;

        }
        cout << endl;
    }

}

Measured memory_bytes: 256
import java.util.Scanner;

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

        String α = scan.next();

        if (α.matches("[A-Z]")) {
            System.out.println("A");
        } else {
            System.out.println("a");
        }
    }
}


Measured memory_bytes: 35568
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

bool comp_greater(PIL& l, PIL& r){
  if(l.second == r.second) return l.first > r.first;
  return l.second > r.second;
}

int main(void){
  int N,M;cin >> N >> M;
  vector<ll> A(N);
  vector<PIL> v(M);
  int i;REP(i,N) cin >> A[i];
  sort(A.begin(),A.end());
  REP(i,M)cin >> v[i].first >> v[i].second;
  sort(v.begin(),v.end(),comp_greater);
  int index = 0;
  REP(i,M){
    if(A[index] > v[i].second) break;
    while(v[i].first-- && A[index] < v[i].second){
      A[index] = v[i].second;
      index++;
      if(index>=N) break;
    }
    if(index>=N)break;
  }
  ll sum = 0;
  REP(i,N) sum+=A[i];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 2560
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	k := iScan()
	q := iScan()
	x := make([]int, n)
	for i := 0; i < q; i++ {
		x[iScan()-1]++
	}
	for _, v := range x {
		if q-v < k {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 3216
import pprint

N, C = map(int, input().split())
stc = []

max_time = 0
for _ in range(N):
    tmp = list(map(int,input().split()))
    max_time = max(max_time,tmp[1])
    stc.append(tmp)

stc.sort(key=lambda x: (x[0]))
# pprint.pprint(stc,width=20)
# print(max_time)

ongoings = []

ans = 0

for prog in stc:
    # print("prog:",prog)
    flag = False
    for og in ongoings:
        if og[2] == prog[2]:
            og[1] = prog[1]
            flag = True
            break
        elif og[1] < prog[0]:
            og[1] = prog[1]
            og[2] = prog[2]
            flag = True
            break
    if not flag:
        ongoings.append(prog)
    # print("ogs:",ongoings)
    ans = max(ans,len(ongoings))

print(ans)

Measured memory_bytes: 29728
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void){
    // 入力
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    //黒と白の数を調べて配列に入れる
    vector<int> black(N);
    vector<int> white(N);
    for (int i = 0; i < N; i++){
        if (S[i] == '#') black[i]++;
        else white[i]++;
    }
    
    //黒の配列の先頭と、白の配列の末尾に０を追加する
    black.insert(black.begin(), 0);
    white.push_back(0);
    
    //黒の数と白の数の累積和を作る
    vector<int> black_ruisekiwa(N + 1);
    vector<int> white_ruisekiwa(N + 1);
    for (int i = 0; i < N; i++){
        black_ruisekiwa[i + 1] = black_ruisekiwa[i] + black[i + 1];
    }
    for (int i = N; i > 0; i--){
        white_ruisekiwa[i - 1] = white_ruisekiwa[i] + white[i - 1];
    }
    
    //出力
    int ans = 9999999;
    for (int i = 0; i < N + 1; i++){
        ans = min(ans, black_ruisekiwa[i] + white_ruisekiwa[i]);
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int w,h,n;
  cin>>w>>h>>n;
  vector<vi> m(h,vi(w,0));
  REP(_,n){
    int x,y,a;
    cin>>x>>y>>a;
    if(a==1){
      REP(i,h)REP(j,w)if(j<x)m[i][j]++;
    }else if(a==2){
      REP(i,h)REP(j,w)if(j>=x)m[i][j]++;
    }else if(a==3){
      REP(i,h)REP(j,w)if(i<y)m[i][j]++;
    }else{
      REP(i,h)REP(j,w)if(i>=y)m[i][j]++;
    }
  }
  int ans = 0;
  REP(i,h)ans+=count(ALL(m[i]),0);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;

bool prime(int n){
    for(int i = 2 ; i <= sqrt(n) ; ++i){
        if(n % i == 0) {
            return 0 ; 
        }
    }

    return 1 ; 
}

int main() {
    ll n ; 
    cin >> n ; 
    int a[n] ; 
    map<int,int> cnt ; 

    ll sum = 0 ;
    for(int i = 0 ;i < n ; ++i){
        cin >> a[i] ; 
        cnt[a[i]] ++ ;
        sum += a[i] ; 
    }
    int q ; 
    cin >> q  ;
    
    for(int i = 0 ;  i< q; ++i) {
        int b , c ; 
        cin >> b >>c ;
        if(cnt[b] > 0 ) {
            sum -= (ll)b * cnt[b] ; 
            sum += (ll)c * cnt[b] ; 
            cnt[c] += cnt[b] ;
            cnt[b] = 0 ; 
        }
        cout << sum << endl;
    }
    return 0 ; 
}

Measured memory_bytes: 8412
//2701 青木沙采 問２
import java.util.Scanner;
public class Main{
	
	public void solve(){
		Scanner sc = new Scanner(System.in);
		int ninzu,k;
		int ban;
		for(int i=0;i<4;i++){
			ban = sc.nextInt();
			if(ban == 1){
				k = 6000;
			}else if(ban == 2){
				k = 4000;
			}else if(ban == 3){
				k = 3000;
			}else{
				k = 2000;
			}
			ninzu = sc.nextInt();
			int uriage = k * ninzu;
			System.out.println(uriage);
		}
	}
	public static void main(String[] args){
		Main obj = new Main();
		obj.solve();
	}
}

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

typedef long long lint;

lint X[200010],S[200010];
int a[200010],n;

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	for(int i=0;i<n;i++){
		X[i+1]=X[i]^a[i];
		S[i+1]=S[i]+a[i];
	}
	lint ans=0;
	for(int start=0;start<n;start++){
		int low=start+1,high=n+1;
		while(high-low>1){
			int mid=(low+high)/2;
			int sum1=S[mid]-S[start];
			int sum2=X[mid]^X[start];
			if(sum1==sum2) low=mid;
			else high=mid;
		}
		ans+=low-start;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4096
#include <stdio.h>
#include <string.h>

#define M 1000001
#define NIL -1

int T[M];
char Q[M];
int tail = 0;

int h1(int k)
{
	return k % M;
}

int h2(int k)
{
	return (1 + (k % (M-1)));
}

int h(int k, int i)
{
	return (h1(k) + i * h2(k)) % M;
}

int insert(int key)
{
	int i = 0, p;
	while (1) {
		if (i >= M)
			return NIL;
		p = h(key, i++);
		if (NIL == T[p]) {
			T[p] = key;
			return p;
		}
	}
}

int find(int key)
{
	int i = 0, p;
	while (1) {
		if (i >= M)
			return NIL;
		p = h(key, i++);
		if (key == T[p]) {
			return p;
		} else if (NIL == T[p]) {
			return NIL;
		}
	}
}

int get_char(char ch)
{
	switch (ch) {
	case 'A': return 1;
	case 'C': return 2;
	case 'G': return 3;
	case 'T': return 4;
	default: return 0;
	}
}

int get_key(char *cargs)
{
	int key = 0, p = 1;
	while (*cargs != 0) {
		key += p * get_char(*cargs);
		p *= 5;
		cargs++;
	}
	return key;
}

int main(int argc, char *argv[])
{
	int i, n, key;
	char cmd[10], cargs[12];
	memset(T, NIL, sizeof(T));

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %s", cmd, cargs);
		key = get_key(cargs);

		if (!strcmp(cmd, "insert")) {
			insert(key);
		} else if (!strcmp(cmd, "find")) {
			if (NIL != find(key)) {
				//printf("yes\n");
				Q[tail++] = 1;
			} else {
				//printf("no\n");
				Q[tail++] = 0;
			}
		}
	}

#if 1
	for (i = 0; i < tail; i++) {
		if (Q[i]) {
			printf("yes\n");
		} else {
			printf("no\n");
		}
	}
#endif

	return 0;
}



Measured memory_bytes: 6036
/* 
 * Project: AtCoder Beginners Contest 165 B - 1%
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/05/02
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cmath>
using namespace std;

long x;

void solve() {
    long money = 100;
    long year = 0;

    while (money < x) {
        money = money*0.01 + money;
        year++;
    }
    printf("%ld\n", year);
}

int main() {

    scanf("%ld", &x);

    solve();

}

Measured memory_bytes: 1728
#include<stdio.h>
int main(void)
{
	int a,s,d,i,max,f,flg;
	flg=0;
	while(1){
	max=0;
		for(i=1;i<=5;i++){
		scanf("%d %d",&a,&s);
		if(a==0 && s==0){
			flg=1;
			break;
		}
			d=a+s;
			if(max<d){
				max=d;
				f=i;
			}
		}
		if(flg==1){
			break;
		}
	if(f==1){
		printf("A %d\n",max);
	}
	if(f==2){
		printf("B %d\n",max);
	}
	if(f==3){
		printf("C %d\n",max);
	}
	if(f==4){
		printf("D %d\n",max);
	}
	if(f==5){
		printf("E %d\n",max);
	}
	}
	return 0;
}

Measured memory_bytes: 1028
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        int k = sc.nextInt();
        long[] a = new long[x];
        long[] b = new long[y];
        long[] c = new long[z];
        for (int i = 0; i < x; i++) a[i] = sc.nextLong();
        for (int i = 0; i < y; i++) b[i] = sc.nextLong();
        for (int i = 0; i < z; i++) c[i] = sc.nextLong();
        Arrays.sort(a);
        Arrays.sort(b);
        Arrays.sort(c);
        long[] sum = new long[110000];
        int cnt = 0;
        for (int i = 0; i < x; i++) {
            for (int j = 0; j < y; j++) {
                for (int l = 0; l < z; l++) {
                    if((i+1)*(j+1)*(l+1) >k) break;
                    sum[cnt++] = a[x-1-i] + b[y-1-j] + c[z-1-l];
                }
            }
        }
        Arrays.sort(sum);
        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < k; i++) {
            ans.append(sum[sum.length -1 - i] + "\n");
        }

        System.out.println(ans);
        sc.close();
    }

}


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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

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



// Main Code
int main()
{
	ll n, a, b, c, d, e;
	cin>>n>>a>>b>>c>>d>>e;
	ll minn = min({a, b, c, d, e});
	ll grp = n / minn;
	if(n%minn != 0) grp++;
	ll ans = 5 + grp - 1;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	N := nextInt()
	as := make([]int, N)
	for i := 0; i < N; i++ {
		as[i] = nextInt()
	}
	sort.Ints(as)
	var ans, before int
	for i, a := range as {
		if i == 0 {
			before = a
			continue
		}
		ans += a - before
		before = a
	}
	fmt.Println(ans)
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
n=int(input())
count=[]
for a in range(1,n) :
  b=n-a
  la=list(str(a));lb=list(str(b))
  suma=0;sumb=0
  for sa in la :
    suma+=int(sa)
  for sb in lb :
    sumb+=int(sb)
  count.append(suma+sumb)
print(min(count))


Measured memory_bytes: 3864
using System;
class ProgramB
    {
        static void Main(string[] args)
        {
            
            //入力
            int[,] bingo = new int[3,3];
            int[,] hit = new int[3,3];

            for(int i = 0; i < 3;i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                bingo[0,i] = int.Parse(input[0]);
                bingo[1,i] = int.Parse(input[1]);
                bingo[2,i] = int.Parse(input[2]);
            }
            
            int n = int.Parse(Console.ReadLine());

            for(int i = 0;i < n ;i++)
            {
                int num = int.Parse(Console.ReadLine());
                for(int k = 0;k < 3;k++)
                    for(int j = 0;j < 3;j++)
                    {
                        if(bingo[k,j] == num)
                        {
                            hit[k,j] = 1;
                            break;
                        }
                    }
            }

            for(int i = 0;i < 3;i++)
            {
                if(hit[i,0] == 1 && hit[i,1] == 1 && hit[i,2] == 1)
                {
                    Console.WriteLine("Yes");
                    return;
                }

                if(hit[0,i] == 1 && hit[1,i] == 1 && hit[2,i] == 1)
                {
                    Console.WriteLine("Yes");
                    return;
                }
                    
            }

            if(hit[0,0] == 1 && hit[1,1] == 1 && hit[2,2] == 1)
            {
                Console.WriteLine("Yes");
                return;
            }

            if(hit[2,0] == 1 && hit[1,1] == 1 && hit[0,2] == 1)
            {
                Console.WriteLine("Yes");
                return;
            }
            
            Console.WriteLine("No");
    
        }
    }

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

using namespace std;
using ll = long long;

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

ll dp[105][4][4][4];
const int mod = 1e9 + 7;

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

  dp[0][3][3][3] = 1;
  rep(i, n) rep(j, 4) rep(k, 4) rep(l, 4) {
    rep(m, 4) {
      if (j == 0 && l == 2 && m == 1) continue; // A?GC
      if (j == 0 && k == 2 && m == 1) continue; // AG?C
      if (k == 0 && l == 2 && m == 1) continue; // AGC
      if (k == 2 && l == 0 && m == 1) continue; // GAC
      if (k == 0 && l == 1 && m == 2) continue; // ACG

      dp[i + 1][k][l][m] += dp[i][j][k][l];
      dp[i + 1][k][l][m] %= mod;
    }
  }

  ll ans = 0;
  rep(j, 4) rep(k, 4) rep(l, 4) {
    ans += dp[n][j][k][l];
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    if ((r*100 + g*10 + b) % 4 == 0) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
/*  ex5_3
    person_A  */
#include<stdio.h>
#include<math.h>

int main(void){
    int height,width,i,j,judge01;
    //マス目の高さと幅の入力
    scanf("%d %d",&height,&width);

    //マス目の配列の宣言、三次元目の数が0のmatrixは入力されたマス目、1のmatrixは行と列の削除の判定に使う
    char matrix[height][width][2];
    //マス目の配色の入力を受け取りながら、三次元目の数が1のmatrixを全て'o'で初期化
    for(i=0;i<height;i++){
        for(j=0;j<width;j++){
            scanf(" %c",&matrix[i][j][0]);
            matrix[i][j][1]='o';
        }
    }

    //もし、i行目が全て白色であれば、三次元目の数が1のmatrixのi行目を全て'x'で埋める
    for(i=0;i<height;i++){
        judge01=1;
        for(j=0;j<width;j++){
            if(matrix[i][j][0]=='#'){
                judge01=0;
                break;
            }
        }
        if(judge01==1){
            for(j=0;j<width;j++){
                matrix[i][j][1]='x';
            }
        }
    }
    //もし、j列目が全て白色であれば、三次元目の数が1のmatrixのj列目を全て'x'で埋める
    for(j=0;j<width;j++){
        judge01=1;
        for(i=0;i<height;i++){
            if(matrix[i][j][0]=='#'){
                judge01=0;
                break;
            }
        }
        if(judge01==1){
            for(i=0;i<height;i++){
                matrix[i][j][1]='x';
            }
        }
    }
    //matrix[i][j][1]が'o'の時だけ、matrix[i][j][0]を出力
    for(i=0;i<height;i++){
        judge01=0;
        for(j=0;j<width;j++){
            if(matrix[i][j][1]=='o'){
                printf("%c",matrix[i][j][0]);
                judge01=1;
            }
        }
        if(judge01==1){
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 128
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(__,v.size()){rep(_,v[__].size())cout<<" "<<v[__][_];cout<<endl;}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

signed main(){
	int n;
	cin>>n;
	if(n==1){
		cout<<1<<endl;
		return 0;
	}
	int out=0,MOD=1000000007;
	vi dp(1000010);
	dp[1]=n;
	dp[2]=(n+n*n)%MOD;
	loop(i,3,n+1){
		int t=(dp[i-1]-dp[i-2]+MOD)%MOD;
		(t+=(n-1)*(n-1))%=MOD;
		(t+=dp[i-3]+n-i+2)%=MOD;
		
		(dp[i]+=t+dp[i-1])%=MOD;
	}

	cout<<(dp[n]-dp[n-1]+MOD)%MOD<<endl;
}















Measured memory_bytes: 8064
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n,m = map(int, input().split())
v = [list(map(int, input().split())) for _ in range(m)]

for i in range(1000):
    flag = True
    num = str(i)
    for sc in v:
        if len(num) >= sc[0] and str(sc[1]) == num[sc[0] - 1]:
            continue
        else:
            flag = False
            break
    if flag and len(num) == n:
        print(i)
        exit()
print(-1)


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

int main()
{
    int n,k;
    while(~scanf("%d%d",&k,&n))
    {

        for(int i=k-1;i>=1;i--)
            printf("%d ",n-i);
        printf("%d ",n);
        for(int i=1;i<k;i++)
            printf("%d ",n+i);
        printf("\n");
    }
    return 0;
}


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

int main() {
	int a, b, c;

	cin >> a ;
	b = a / 100;
	c = a - (a / 100) * 100;

	if ((1 <= b && b <= 12) && (1 <= c && c <= 12))
	{
		cout << "AMBIGUOUS" << endl;
		return 0;
	}
	else if (1 <= b && b <= 12)
	{
		cout << "MMYY" << endl;
		return 0;
	}
	else if (1 <= c && c <= 12)
	{
		cout << "YYMM" << endl;
		return 0;
	}
	else
	{
		cout << "NA" << endl;
		return 0;
	}

	return 0;
}

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

int main()
{
   int N;
   cin >> N;
   vector<int> vec(N);
   for (int i = 0; i < N; i++)
   {
      cin >> vec.at(i);
   }
   sort(vec.begin(), vec.end());
   reverse(vec.begin(), vec.end());

   int alice   = 0;
   int bob     = 0;
   for (int i = 0; i < N; i++)
   {
      if (i%2==0) alice += vec.at(i);
      if (i%2!=0) bob   += vec.at(i);
   }
   cout << alice - bob << endl;
}

Measured memory_bytes: 256
function Main(input) {
    var N = parseInt(input[0], 10);
    var K = parseInt(input[1], 10);
    var Q = parseInt(input[2], 10);
    var A = input.slice(3).map(n => parseInt(n));

    var winCounter = new Array(N);
    winCounter.fill(0);

    for (var i = 0; i < Q; i++) {
        winCounter[A[i] - 1]++;
    }

    for (var i = 0; i < N; i++) {
        if (K - (Q - winCounter[i]) >= 1) {
            console.log('Yes');
        } else {
            console.log('No');
        }
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 29140
#include <stdio.h>

int main()
{
  int S, h, m, s;    

  scanf("%d", &S);

  h = S / 3600;
  m = (S - h * 3600) / 60;
  s = (S - h * 3600) % 60;

  printf("%d:%d:%d\n", h, m, s);

  return 0;
}

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

void solve(){
	int n, q;
	cin >> n;
	vector<int> a(n + 1), d(n + 1);
	unordered_map<int, int> m;
	long long s = 0;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		m[a[i]]++;
		s += a[i];
	}
	cin >> q;
	for(int i = 0; i < q; i++){
		int c, b;
		cin >> b >> c;
		if(m.count(b) > 0){
			s = s - (long long) m[b] * b + (long long) m[b] * c;
			m[c] += m[b];
			m[b] = 0;
		}
		cout << s << '\n';
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--) solve();
}

Measured memory_bytes: 7612
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int A,B,K;
  cin>>K>>A>>B;
  int ans=false;
  FOR(i,A,B+1){
    if(i%K==0)ans=true;
  }
  if(ans){
    cout<<"OK"<<endl;
  }else{
    cout<<"NG"<<endl;
  }

}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = 0;
		if (a + b >= 24) System.out.println(a + b - 24);
		else System.out.println(a + b);
	}
} 

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll a[255555];
ll b[255555];

ll sa[255555];
ll sb[255555];

ll suma(int l, int r)
{
	if(l>r) return 0;
	if(l==0) return sa[r];
	else return sa[r]-sa[l-1];
}

ll sumb(int l, int r)
{
	if(l>r) return 0;
	if(l==0) return sb[r];
	else return sb[r]-sb[l-1];
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll L, n; cin>>L>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];b[i]=L-a[i];
	}
	for(int i=0;i<n;i++)
	{
		sa[i]=a[i]; sb[i]=b[i];
		if(i>0) 
		{
			sa[i]+=sa[i-1]; sb[i]+=sb[i-1];
		}
	}
	ll ans = max(a[n-1], b[0]);
	for(int i=0;i<n-1;i++)
	{
		//L for a[0],a[1],...,a[i] and R for a[i+1],...,a[n-1]
		int l = i+1; int r = n-(i+1);
		//left first
		{
			ll res = 0;
			if(l>r)
			{
				res = 2LL*(suma(i-r,i)+sumb(i+1,i+r)) - a[i];
				res = max(res, 2LL*(suma(i-r+1,i)+sumb(i+1,i+r)) - b[i+1]);
			}
			else
			{
				res = 2LL*(suma(i-l+1,i)+sumb(i+1,i+l)) - b[i+1];
				res = max(res, 2LL*(suma(i-l+1,i)+sumb(i+1,i+l-1)) - a[i]);
			}
			ans = max(ans, res);
			
		}
		//right first
		{
			ll res = 0;
			if(r>l)
			{
				res = 2LL*(suma(i-l+1,i)+sumb(i+1,i+l+1)) - b[i+1];
				res = max(res, 2LL*(suma(i-l+1,i)+sumb(i+1,i+l)) - a[i]);
			}
			else
			{
				res = 2LL*(suma(i-r+1,i)+sumb(i+1,i+r)) - a[i];
				res = max(res, 2LL*(suma(i-r+2,i)+sumb(i+1,i+r)) - b[i+1]);
			}
			ans = max(ans, res);
		}
		//cerr<<i<<' '<<res-a[i]<<' '<<res-b[i+1]<<'\n';
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 7424
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  ll N ;
  cin >> N;
  cout << N/3 << endl;

  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 768
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=500000+10;

int n; char s[N];
int prenxt[N],sufnxt[N];

inline void getnext() {
    for (re int i=2,j=prenxt[1]=0;i<=n;++i) {
        while (j&&s[j+1]!=s[i]) j=prenxt[j];
        if (s[j+1]==s[i]) ++j;
        prenxt[i]=j;
    }
    reverse(s+1,s+n+1);
    for (re int i=2,j=sufnxt[n]=0;i<=n;++i) {
        while (j&&s[j+1]!=s[i]) j=sufnxt[j];
        if (s[j+1]==s[i]) ++j;
        sufnxt[i]=j;
    }
}

inline int checkpre(int i) { return !prenxt[i]||i%(i-prenxt[i]); }
inline int checksuf(int i) { return !sufnxt[i]||i%(i-sufnxt[i]); }

int main() {
    scanf("%s",s+1); n=strlen(s+1); getnext();
    if (checkpre(n)) { puts("1\n1"); return 0; }
    if (n-prenxt[n]==1) { printf("%d\n1\n",n); return 0; }
    int ans=0;
    for (re int i=1;i<=n;++i)
        if (checkpre(i)&&checksuf(n-i)) ++ans;
    printf("2\n%d\n",ans);
    return 0;
}
//qwq

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

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


Measured memory_bytes: 256