akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define ff first
#define mp make_pair
#define ss second
#define rep(i,a,b) for(int i = a; i < b; i++)
#define repp(i,a,b) for(int i = a; i <= b; i++)
#define endl '\n'
#define mod 1000000007
#define mod_in(a) bin(a, mod - 2)
#define fact(n) rep(i, 1, n+1) ft.pb((ft[i-1] * i) % mod)
#define ncr(n, r) (n >= r ? ((ft[n] * mod_in((ft[r] * ft[(n)-(r)]) % mod)) % mod) : 0LL)
#define pi 3.14159265358979323
#define INF 1e15
#define lb(v, a) lower_bound(v.begin(), v.end(), a)
#define ub(v, a) upper_bound(v.begin(), v.end(), a)

int power(int x, int n){
    int res=1;
    while(n>0){
        if(n&1)
            res=res*x;
        x*=x;
        n>>=1;
    }
    return res;
}

int bin(int x, int n){
    int res=1; x%=mod;
    while(n){
        if(n&1) res=(res*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return res;
}

bool prime(int n){
    if(n==3)return 1;
    repp(i,2,sqrt(n)){
        if(n%i==0)return 0;
    }
    return 1;
}

set<int> v[26];
int flag=0;
int vis[26]={0}, par[200001]={0}, top[500001], a[200006], b[200006];

void dfs(int n){
    vis[n] = 1;
    cout<<char(n + 'a');
    for(auto i: v[n]){
        if(!vis[i]) dfs(i);
    }
}

// vector<int> adj[2000005];
// vector<int> pr(2000005, 1), xx[2000005];
// void sieve(int n){ 
//     for(int p=2; p<n; p++){ 
//         if(pr[p]){ 
//             for(int i=p; i<n; i += p){
//                 pr[i]=0;
//                 xx[i].pb(p);
//             }
//         } 
//     } 
// }  
// vector<int> ft(40);

void solve(){
    int n, d, x, y, ans=0; cin>>n>>d;
    while(n--){
        cin>>x>>y;
        ans += (sqrt(power(x, 2) + power(y, 2)) <=d);
    }
    cout<<ans<<endl;
}

signed main(){
    fast
    int t=1;
    // cin>>t;
    while(t--) solve();
}

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

class Program {
    const int mod = 1000000007;

    static void Main() {
#if DEBUG
        var exStdIn = new System.IO.StreamReader("./../../TestStdin.txt");
        Console.SetIn(exStdIn);
#endif
        var N = int.Parse(Console.ReadLine());
        var ints = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        var maxValue = ints.Max();
        var maxIndex = Array.IndexOf(ints, maxValue);
        var total = 0;
        for (int i = 0; i < N; i++) {
            if (i != maxIndex) {
                total += ints[i];
            }

            if (total > maxValue) {
                Console.WriteLine("Yes");
                return;
            }
        }

        Console.WriteLine("No");
    }
}

Measured memory_bytes: 13152
#coding: utf-8
S = input()
enki = ["A", "T", "G", "C"]
a = []
ans = ""
max_ = 0
for i in range(len(S)):
    if S[i] in enki:
        ans += S[i]
    else:
        ans = ""
    a.append(ans)
    max_ = max(max_, len(ans))
print(max_)

Measured memory_bytes: 3064
#include <algorithm>
#include <ctype.h>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define ENDL '\n'
#define FOR(i, n) for (int i = 0; i < n; i++)
#define FOR_EACH(i, v) for (auto&& i : v)

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

	int A;
	int B;
	int C;
	int D;
	cin >> A >> B >> C >> D;

	int ans = min(B, D) - max(A, C);
	if (ans < 0) {
		ans = 0;
	}

	cout << ans << ENDL;

	return 0;
}

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

const int maxN = 1 << 17;

bool A[maxN];

int main() {
	vector<int> P;
	for(int i = 2; i < maxN; i++) if(!A[i]) {
		P.push_back(i);
		for(int j = i; j < maxN; j += i)
			A[j] = 1;
	}
	int n; cin >> n;
	cout << *lower_bound(P.begin(), P.end(), n);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
std::vector<int> A['   '];
int N, M, S['   '], B, L, R, I;
int U(int z, int u) {
  while (z <= N)
    S[z] += u, z += z & -z;
}
main() {
  scanf("%d%d", &M, &N);
  for (; ~scanf("%d%d", &L, &R);)
    A[R - L + 1].push_back(L);
  for (L = 1; L <= N; L++) {
    for (B = M, I = L; I <= N; I += L) {
      
      for (R = I;R;)
        B += S[R], R -= R & -R;
    }
    for (int u : A[L])
      U(u, 1), U(u + L, -1), M--;
    printf("%d\n", B);
  }
}

Measured memory_bytes: 53760
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	sumTime := 0
	minFirstDigitValue := 10

	for i := 0; i < 5; i++ {
		input, _ := strconv.Atoi(scanNextLine(scanner))
		minFirstDigitValue = compareFirstDigit(minFirstDigitValue, input)
		sumTime += roundUpFirstDigit(input)
	}

	sumTime -= 10 - minFirstDigitValue

	fmt.Print(sumTime)
}


func scanNextLine(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func roundUpFirstDigit(value int) int {
	return int(math.Ceil(float64(value) * 0.1) * 10.0)
}

func compareFirstDigit(minFirstDigitValue int, value int) int {
	firstDigit := value % 10
	if firstDigit < minFirstDigitValue && firstDigit > 0 {
		minFirstDigitValue = firstDigit
	}
	return minFirstDigitValue
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;

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

  vector<ll> X(N), Y(N);
  rep (i, N) cin >> X[i] >> Y[i];

  int parity = abs(X[0] + Y[0]) % 2;
  rep (i, N) {
    if (parity != abs(X[i] + Y[i]) % 2) {
      cout << "-1" << endl;
      return 0;
    }
  }

  vector<ll> d;
  for (int i = 30; i >= 0; i--) d.eb(1LL << i);
  if (parity == 0) d.eb(1);

  cout << sz(d) << endl;
  rep (i, sz(d)) cout << (i == 0 ? "" : " ") << d[i];
  cout << endl;

  rep (i, N) {
    string w = "";
    rep (j, sz(d)) {
      if (abs(X[i]) < abs(Y[i])) {
        if (Y[i] > 0) {
          Y[i] -= d[j];
          w += 'U';
        } else {
          Y[i] += d[j];
          w += 'D';
        }
      } else {
        if (X[i] > 0) {
          X[i] -= d[j];
          w += 'R';
        } else {
          X[i] += d[j];
          w += 'L';
        }
      }
    }
    cout << w << endl;
  }
}


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

public class Main{
	public static void main(String[] args) throws Exception{
		PrintWriter pw=new PrintWriter(System.out);
		MScanner sc = new MScanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
		pw.println(c+" "+a+" "+b);
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		static void shuffle(int[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				int tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		static void shuffle(long[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				long tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void addX(int[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
	static void addX(long[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
}

Measured memory_bytes: 22100
#include <iostream>
#include <vector>
#include <list>

using namespace std;

const int MAX = 8009 * 2, ORIGIN = 8009;
int b[MAX][MAX], x, y;
vector<int> sy, sx, d;

bool valid(int p);
list<vector<int>> dp(const vector<int> &iv, const vector<int> &sv);

bool valid(int p) {
	return (0 <= p && p < MAX);
}

void printv(const vector<int> &v) {
	for (int i = ORIGIN - 10; i < ORIGIN + 10; i++) {
		cerr << v[i] << ' ';
	}
	cout << '\n';
}

void debug(const vector<int> &v) {
	for (auto ch : v) {
		cout << ch << ' ';
	}
	cout << '\n';
}

list<vector<int>> dp(const vector<int> &iv, const vector<int> &sv) {
	list<vector<int>> l;
	l.push_back(iv);
	for (int i = 0; i < sv.size(); i++) {
		vector<int> newv(MAX);
		for (int j = 0; j < MAX; j++) {
			 if (valid(j - sv[i]) && l.front()[j - sv[i]] == 1) {
			 	newv[j] = 1;
			 } else if (valid(j + sv[i]) && l.front()[j + sv[i]] == 1) {
			 	newv[j] = 1;
			 }
		}
		l.push_back(newv);
//		printv(newv);
		l.pop_front();
	}
	return l;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	string s;
	cin >> s >> x >> y;
	int dist = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'T') break;
		dist++;
	}
	int dir = -1, start = dist;
	dist = 0;
	for (int i = start + 1; i < s.size(); i++) {
		if (s[i] == 'F') dist++;
		else {
			if (dist != 0) d.push_back(dir * dist);
			dir *= -1;
			dist = 0;
		}
	}
	if (dist != 0) d.push_back(dir * dist);
	for (int i = 0; i < d.size(); i++) {
		if (d[i] < 0) sy.push_back(abs(d[i]));
		else sx.push_back(abs(d[i]));
	}
//	debug(sx);
//	debug(sy);
	vector<int> ix(MAX), iy(MAX);
	ix[ORIGIN + start] = iy[ORIGIN] = 1;
	vector<int> dy = dp(iy, sy).front(), dx = dp(ix, sx).front();
	if (dy[ORIGIN + y] && dx[ORIGIN + x]) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

// 二次元累積和
int sum[10000][10000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; ++i){
        int x, y;
        char c;
        cin >> x >> y >> c;
        
        // すべて(c='B')にして、([0, 2k), [0, 2k))に圧縮
        if(c == 'W'){
            y += k;
        }
        x %= 2 * k;
        y %= 2 * k;
        
        ++sum[x + 1][y + 1];
    }
    
    // 二次元累積和
    // 横方向の累積和
    for(int i = 0; i <= 2 * k; ++i){
        for(int j = 0; j <= 2 * k; ++j){
            sum[i][j+1] += sum[i][j];
        }
    }
    // 縦方向の累積和
    for(int i = 0; i <= 2 * k; ++i){
        for(int j = 0; j <= 2 * k; ++j){
            sum[i+1][j] += sum[i][j];
        }
    }
    
    int res = 0;
    // (0, 0) ~ (2k-1, 2k-1)
    for(int tx = 0; tx < 2 * k; ++tx){
        for(int ty = 0; ty < 2 * k; ++ty){
                int temp = 0;
                
                // ([0, 2k], [0, 2k])内の5つの黒に塗る部分に関して、点の数を足し合わせる
                if(tx <= k && ty <= k){
                    temp += sum[tx][ty];
                    temp += sum[tx+k][ty+k] - sum[tx+k][ty] - sum[tx][ty+k] + sum[tx][ty];
                    temp += sum[2*k][ty] - sum[tx+k][ty];
                    temp += sum[tx][2*k] - sum[tx][ty+k];
                    temp += sum[2*k][2*k] - sum[2*k][ty+k] - sum[tx+k][2*k] + sum[tx+k][ty+k];
                }
                else if(tx > k && ty > k){
                    temp += sum[tx-k][ty-k];
                    temp += sum[tx][ty] - sum[tx][ty-k] - sum[tx-k][ty] + sum[tx-k][ty-k];
                    temp += sum[2*k][ty-k] - sum[tx][ty-k];
                    temp += sum[tx-k][2*k] - sum[tx-k][ty];
                    temp += sum[2*k][2*k] - sum[2*k][ty] - sum[tx][2*k] + sum[tx][ty];
                }
                else if(tx <= k){
                    temp += sum[tx][ty] - sum[tx][ty-k];
                    temp += sum[tx+k][ty-k] - sum[tx][ty-k];
                    temp += sum[tx+k][2*k] - sum[tx][2*k] - sum[tx+k][ty] + sum[tx][ty];
                    temp += sum[2*k][ty] -sum[tx+k][ty] - sum[2*k][ty-k] + sum[tx+k][ty-k];
                }
                else{   // ty <= k
                    temp += sum[tx][ty] - sum[tx-k][ty];
                    temp += sum[tx-k][ty+k] - sum[tx-k][ty];
                    temp += sum[2*k][ty+k] - sum[2*k][ty] - sum[tx][ty+k] + sum[tx][ty];
                    temp += sum[tx][2*k] - sum[tx][ty+k] - sum[tx-k][2*k] + sum[tx-k][ty+k];
                }
                
                res = max(res, temp);
        }
    }
    
    cout << res << endl;
}

Measured memory_bytes: 78720
n = int(input())
a = list(map(int,input().split()))


s = 0
for i in a:
    s = 2*i - s
x = s//2

ans = []
ans.append(str(x))
for i in range(len(a)-1):
    x = 2*a[i]-x
    ans.append(str(x))
print(' '.join(ans))


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

int main()
{
    int n;
     char s[1000];
     char s2[1000];

     char s3[1000];

     cin>>n;
     scanf("%s%s",s,s2);


     int j=0,k=1;
     for(int i=0;i<n;i++)
     {
         s3[j]=s[i];
         j+=2;
         s3[k]=s2[i];
         k+=2;
     }
     s3[k]='\0';


       for(int i=0;i<n*2;i++){
        cout<<s3[i];
       }



    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#define NMAX 100000
#define LMAX 10
// ノードを表す構造体
struct Node {
  int data ;
  char name[LMAX];
  struct Node * next ;
} ;

typedef struct Node Node ;

// 新しいノードのメモリを確保する
Node *create_node(int new_data, char name[]) {
  Node *new_node = (Node *) malloc(sizeof(Node));
  if (!new_node) {
    fprintf(stderr, "could not allocate a node.\n");
    exit(1);
  }
  new_node->data = new_data;
  strcpy(new_node->name, name);
  new_node->next = NULL;
  return new_node;
}

// リストのメモリを解放する
void clear_list(Node * head) {
  while (head) {
    Node * target = head ;
    head = head->next ;
    free(target) ;
  }
}


//リストが空か否か判定する
int is_empty(Node *head){
  if(head == NULL){
    return 1;
  }
  return 0;
}

//リストの最後尾にノードを追加する
void push_back(Node **head, Node **tail, int new_data, char new_name[]){
  Node *new_node = create_node(new_data, new_name);
  if(is_empty(*head)){
    *head = new_node;
    *tail = new_node;
    return;
  }
  (*tail)->next = new_node;
  (*tail) = (*tail)->next;
}


//リストの先頭からノードを削除する
Node pop_front(Node **head){
  Node c = **head;
  Node *tmp = *head;
  *head = (*head)->next;
  free(tmp);
  return c;
}


// リストの要素を先頭から順に出力する
void print_list(const Node * head) {
  while(head) {
    printf("| %d |-> ", head->data);
    head = head->next;
  }
  printf("NULL\n");
}

int main(void) {
  int n, q;
  char name[LMAX];
  int time;
  Node * head = NULL , *tail = NULL;
  
  scanf("%d%d", &n, &q);
  for(int i = 0; i < n; ++i){
    scanf("%s%d", name, &time);
    push_back(&head, &tail, time, name);
  }
  //print_list(head);

  Node tmp;
  int t = 0;
  while(!is_empty(head)){
    tmp = pop_front(&head);
    if(tmp.data <= q){
      t += tmp.data;
      printf("%s %d\n", tmp.name, t);
    }
    else{
      tmp.data -= q;
      push_back(&head, &tail, tmp.data, tmp.name);
      t += q;
    }
  }
  

  
  clear_list(head) ;
  return 0 ;
}



Measured memory_bytes: 3368
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M, DP[int(1e5 + 5)];
char S[int(1e5 + 5)];

int main(){
  scanf("%d%d", &N, &M);
  scanf("%s", S);

  fill(DP, DP + N + 1, 1e9);
  DP[0] = 0;
  priority_queue <int> que; que.push(0);

  while (!que.empty() && DP[N] == 1e9){
    int Q = que.top(); que.pop();
    for (int i = 1; i <= M; i++){
      int next = Q + i;
      if (next > N) continue;
      if (S[next] == '1') continue;
      if (DP[next] != 1e9) continue;
      que.push(next);
      DP[next] = DP[Q] + 1;
    }
  }

  if (DP[N] == 1e9){
    printf("-1\n"); return 0;
  }

  vector <int> ans;
  int now = N;
  while (now > 0){
    for (int i = M; i >= 1; i--){
      if (now - i < 0) continue;
      if (DP[now] == DP[now - i] + 1){
        now -= i;
        ans.push_back(i);
        break;
      }
    }
  }

  printf("%d", ans[ans.size() - 1]);
  for (int i = ans.size() - 2; i >= 0; i--){
    printf(" %d", ans[i]);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 1404
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		double sum = 0;
		for(int i = 0; i < N; i++) {
			sum += (double)1 / A[i];
		}
		System.out.println(1 / sum);
		sc.close();
	}

}
/*
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□■■□□
■■■■■■□□□■□■■■□□□
□□□□□■□□□■■■□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□□□■□□□■□□□□□□□
□□□■■■□□□■□□□□□□□
□■■■□■□□□■□□□□□■□
■■□□□■□□□■■□□□■■□
□□□□□■□□□□■■■■■□□
□□□□□■□□□□□□□□□□□
□□□□□□□■□□□□□□□□□
□□□□□□□■□□□□□□□□□
□□□□□□□■□□□□□□□□□
□□□□□□□■□□□□□□□□□
□□□□□□□■□□□□□□□□□
■■■■■■■■■■■■■■■■□
□□□□□□□■□□□□□□□□□
□□□□□□■■■□□□□□□□□
□□□□□□■□■□□□□□□□□
□□□□□□■□■■□□□□□□□
□□□□□■■□□■□□□□□□□
□□□□□■□□□■■□□□□□□
□□□□■■□□□□■■□□□□□
□□□■■□□□□□□■■□□□□
□□■■□□□□□□□□■■□□□
■■■□□□□□□□□□□■■■□
*/


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

class DSU {
  private:
    vector<int> p, rank;
  public:

    DSU(int n) {
      p.assign(n, -1);
      rank.assign(n, 0);
    }

    int root(int x) {
      if (p[x] < 0) {
        return x;
      }
      return (p[x] = root(p[x]));
    }

    int sameSet(int x, int y) {
      return (root(x) == root(y));
    }

    void connect(int x, int y) {
      x = root(x);
      y = root(y);
      if (x != y) {
        if (rank[x] > rank[y]) {
          p[y] = x;
        } else {
          p[x] = y;
          if (rank[x] == rank[y]) {
            rank[y]++;
          }
        }
      }
    }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  DSU dsu(n + 1);
  for (int i = 0; i < m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    dsu.connect(x, y);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (dsu.root(i) == i) {
      ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1024
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	N, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	M, _ := strconv.Atoi(sc.Text())

	total := 0.0
	a := make([]float64, N)
	for i := range a {
		sc.Scan()
		num, _ := strconv.Atoi(sc.Text())
		a[i] = float64(num)
		total = total + float64(a[i])
	}
	min := total / (4.0 * float64(M))

	for _, a := range a {
		if a >= min {
			M = M - 1
		}
	}

	if M <= 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
   int table[200][200] = {{0}};
   int c,r; //colum,row
   cin >> r >> c;
   for(int i=0; i<r; i++){
       for(int j=0; j<c; j++){
           cin >> table[i][j];
       }
   }

   //横計算する
   for(int i=0; i<r; i++){
       int sum = 0;
       for(int j=0; j<c; j++){
           sum += table[i][j];
       }
       table[i][c] = sum;
   }

   //縦計算する
   int sum=0;
   for(int i=0; i<r; i++){
       for(int j=0; j<c; j++){
           sum += table[i][j];
       }
       table[r][c] = sum;
   }

   //縦計算する
   for(int j=0; j<c; j++){
       int sum=0;
       for(int i=0; i<r; i++){
           sum += table[i][j];
       }
       table[r][j] = sum;
   }

   //出力を作る
   for(int i=0; i<=r; i++){
       for(int j=0; j<c; j++){
           cout << table[i][j] << " ";
       }
       cout << table[i][c];
       cout << endl;
   }
}


Measured memory_bytes: 3256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split(' ')))

aa = list(map(lambda x: abs(x), A))
c = len(list(filter(lambda x: x < 0, A)))
s = sum(aa)
if c % 2 == 1:
    s -= min(aa) * 2
print(s)


Measured memory_bytes: 14412
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<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 dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    bool ok=true;
    int d,t,s;
    cin>>d>>t>>s;
    if(d>t*s) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
int c(const void *v1,const void *v2){
    return *(int *)v2-*(int *)v1;
}
int main(void){
    int n,m,i,o,count,num,line[100],line1[100];
    for(;count=0,memset(line,0,sizeof(line)),scanf("%d %d",&n,&m),m;){
        for(i=0;i<n;i++)
            for(o=0;o<m;o++){
                scanf("%d",&num);
                line[o]+=num;
            }
        memcpy(line1,line,4*m);
        qsort(line,m,4,c);
        for(i=0;i<m;i++)
            for(o=0;o<m;o++)
                if(line[i] == line1[o]){
                    printf("%d%s",o+1,(count==m-1)?"\n":" ");
                    line1[o]=-1;
                    count++;
                }
    }
    return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define MAX 200000

int n, k[2];
vector<int> e[2][MAX];
int c[2][MAX];

void dfs(int i, int s, int cnt){
	c[i][s]=cnt;
	for(int j=0; j<e[i][s].size(); j++){
		if(c[i][e[i][s][j]]==0){
			dfs(i, e[i][s][j], cnt);
		}
	}
	return;
}

int main(){
	cin >> n >> k[0] >> k[1];
	for(int i=0; i<2; i++){
		for(int j=0; j<k[i]; j++){
			int p, q;
			cin >> p >> q;
			p--; q--;
			e[i][p].push_back(q);
			e[i][q].push_back(p);
		}
	}

	for(int i=0; i<2; i++){
		int cnt=1;
		for(int j=0; j<n; j++){
			if(c[i][j]==0){
				dfs(i, j, cnt);
				cnt++;
			}
		}
	}

	pair<int, int> p[n];
	map<pair<int, int>, int> cnt;
	for(int i=0; i<n; i++){
		p[i]=make_pair(c[0][i], c[1][i]);
		cnt[p[i]]++;
	}

	for(int i=0; i<n; i++){
		cout << cnt[p[i]] << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 29440
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<set> 
#include<map>
long long combi(long long a) {

    return a*(a-1)*(a-2) / 6;
}

int main() {
   int n; std::cin >> n;
   std::vector<std::string> s(n);
   std::map<char, long long> t;

   long long ans = 0;
   long long sum = 0;
   t.insert(std::make_pair('M', 0));
   t.insert(std::make_pair('A', 0));
   t.insert(std::make_pair('R', 0));
   t.insert(std::make_pair('C', 0));
   t.insert(std::make_pair('H', 0));
   for(int i = 0; i < n; i++) {
       std::cin >> s[i];
       if (s[i][0] == 'M' || s[i][0] == 'A' || s[i][0] == 'R' || s[i][0] == 'C' || s[i][0] == 'H') {
           t[s[i][0]]++;
       }
   }

   ans += t['M'] * t['A'] * t['R'];
   ans += t['M'] * t['A'] * t['C'];
   ans += t['M'] * t['A'] * t['H'];
   ans += t['M'] * t['R'] * t['C'];
   ans += t['M'] * t['R'] * t['H'];
   ans += t['M'] * t['C'] * t['H'];
   ans += t['A'] * t['R'] * t['C'];
   ans += t['A'] * t['R'] * t['H'];
   ans += t['A'] * t['C'] * t['H'];
   ans += t['R'] * t['C'] * t['H'];

   std::cout << ans << "\n";
}

Measured memory_bytes: 6424
#include <iostream>
#include <vector>

using namespace std;


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

    for (int i = 0; i < n.size(); i++)
        if (n[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }

    cout << "No" << endl;

    return 0;
}

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

int main()
{

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;

using namespace std;

int N;
vector<int> as, answers, table;
vector<vector<int>> tree;

void DFS(int u, int p) {
    // tableを二分探索
    int i = lower_bound(begin(table), end(table), as[u]) - begin(table);
    int old_value = table[i];

    table[i] = as[u];
    answers[u] = lower_bound(begin(table), end(table), (1 << 30)) - begin(table);

    for (int c : tree[u]) {
        if (c == p) continue;
        DFS(c, u);
    }

    table[i] = old_value;
}

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

    cin >> N;
    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
    }

    tree.resize(N);
    for (int i = 0; i < N - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }

    answers.resize(N);
    table.resize(N, (1 << 30));
    DFS(0, -1);

    for (int i = 0; i < N; i++) {
        cout << answers[i] << '\n';
    }
    cout << flush;

    return 0;
}



Measured memory_bytes: 27568
#pragma GCC optimize("O3")
#pragma GCC target("tune=native")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
using ll = long long;
template <typename Functor>
struct fix_type
{
    Functor functor;
    template <typename... Args>
    decltype(auto) operator()(Args&&... args) const& { return functor(functor, std::forward<Args>(args)...); }
};
template <typename Functor>
fix_type<typename std::decay<Functor>::type> fix(Functor&& functor) { return {std::forward<Functor>(functor)}; }

int main()
{
    int N;
    ll X, D;
    cin >> N >> X >> D;
    vector<ll> m(N);
    cin >> m[0];
    vector<vector<int>> edge(N);
    for (int i = 1; i < N; i++) {
        cin >> m[i];
        int p;
        cin >> p;
        edge[p - 1].push_back(i);
    }
    auto mrec = fix([&](auto&& self, const int s) -> ll {
        ll sum = m[s];
        for (const int to : edge[s]) { sum += self(self, to); }
        return m[s] = sum;
    });
    vector<ll> s(N, 0);
    auto srec = fix([&](auto&& self, const int i) -> ll {
        ll sum = 1;
        for (const int to : edge[i]) { sum += self(self, to); }
        return s[i] = sum;
    });
    mrec(0);
    srec(0);
    using P = pair<ll, ll>;
    vector<P> obj;
    for (int i = 0; i < N; i++) {
        ll num = i == 0 ? X : D;
        ll n = 1;
        for (; (n << 1) - 1 <= num; n <<= 1) {
            if ((double)m[i] * n <= X) { obj.push_back({m[i] * n, s[i] * n}); }
        }
        const ll res = num - (n - 1);
        if (res > 0 and (double) m[i] * res <= X) { obj.push_back({m[i] * res, s[i] * res}); }
    }
    auto comp = [](const P& p1, const P& p2) {
        const ll x = p1.first * p2.second - p1.second * p2.first;
        return x != 0 ? x < 0 : p1.first > p2.first;
    };
    const int size = (int)obj.size();
    sort(obj.begin(), obj.end(), comp);
    ll ans = 0;
    auto rec = fix([&, size](auto&& self, const int ind, const ll value, const ll rest) {
        if (ind == size) {
            ans = max(ans, value);
            return;
        }
        if (rest >= obj[ind].first) {
            ll greedy = value + obj[ind].second;
            ll res = rest - obj[ind].first;
            for (int i = ind + 1; i < size; i++) {
                if (res > obj[i].first) {
                    greedy += obj[i].second, res -= obj[i].first;
                } else if (res > 0) {
                    greedy += obj[i].second * res / obj[i].first;
                    break;
                }
            }
            if (greedy > ans) { self(self, ind + 1, value + obj[ind].second, rest - obj[ind].first); }
        }
        ll greedy = value;
        ll res = rest;
        for (int i = ind; i < size; i++) {
            if (res > obj[i].first) {
                greedy += obj[i].second, res -= obj[i].first;
            } else if (res > 0) {
                greedy += obj[i].second * res / obj[i].first;
                break;
            }
        }
        if (greedy > ans) { self(self, ind + 1, value, rest); }
    });
    rec(0, 0, X);
    cout << ans << endl;
    return 0;
}


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

li = []

ans = 'APPROVED'

for a in A:
  if a % 2 == 0:
    li.append(a)

for i in li:
  if i % 3 != 0 and i % 5 != 0:
    ans = 'DENIED'

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  string a[]={"Sunny","Cloudy","Rainy"};
  if(s=="Sunny") cout<<a[1]<<endl;
  else if(s=="Cloudy") cout<<a[2]<<endl;
  else cout<<a[0]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9

using namespace std;
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}
int n;
ll sum, ans;
int main()
{
	n = read();
	rep(i, 1, n)
	{
		int x = read();
		if(x == 0)
		{
			ans += sum / 2;
			sum = 0;
		}
		sum += x;
	}
	ans += sum / 2;
	cout << ans;
	return 0;
} 


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; } /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; } /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b)
{
  return *(char *)a - *(char *)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b)
{
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)

int main(void)
{
  int w, h, x, y;
  scanf("%d %d %d %d", &w, &h, &x, &y);

  printf("%lf %d\n", (double)w * (double)h / 2.0, 2 * x == w && 2 * y == h);
  return 0;
}


Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

dim = [0]*4

for _ in range(3):
	a, b = MAP()
	dim[a-1] += 1
	dim[b-1] += 1

c = Counter(dim)
if c[1] == 2 and c[2] == 2:
	print("YES")
else:
	print("NO")


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

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

int main() {
  int N;
  cin >> N;
  string D;
  REP(i, N) {
    int Di;
    cin >> Di;
    D.push_back('0' + Di);
  }
  int ans = 0;
  while (true) {
    if (D.find(to_string(ans)) == string::npos) {
      cout << ans << endl;
      return 0;
    }
    ++ans;
  }
}

Measured memory_bytes: 3292
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"YES"<<'\n';
#define no cout<<"NO"<<'\n';
using namespace std;

int main()
{
    godspeed
    ll  i,j,k,l,x,y,z;
    string a,b;
    cin>>x>>y>>z;
    x-=z;
    cout<<max(0LL,x/(y+z))<<endl;
       return 0;
}





Measured memory_bytes: 3612
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        var grid = new int[3][];
        for (int i = 0; i < 3; i++)
        {
            grid[i] = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        }

        var min = grid.Select(x => x.Min()).Min();
        grid = grid.Select(x => x.Select(y => y - min).ToArray()).ToArray();

        var a = new int[3];
        var b = new int[3];

        //全探索
        for (int i = 0; i <= 100; i++)
        {
            a[0] = i;
            for (int j = 0; j < 3; j++)
            {
                b[j] = grid[0][j] - a[0];
            }

            for (int j = 1; j < 3; j++)
            {
                a[j] = grid[j][0] - b[0];
            }

            var flag = true;
            for (int row = 0; row < 3; row++)
            {
                for (int col = 0; col < 3; col++)
                {
                    if (grid[row][col] != a[row]+b[col])
                    {
                        flag = false;
                        break;
                    }
                }
            }

            if (flag)
            {
                Console.WriteLine("Yes");
                return;
            }
        }

        Console.WriteLine("No");
    }
}

Measured memory_bytes: 13524
//package atCoder;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		//int m = sc.nextInt();
		int i,j;
				
		Rest[] rests = new Rest[n];
		
		for(i=0;i<n;i++) {
			Rest target = new Rest(sc.next(),sc.nextInt(),i+1);
			for(j=i;j>0;j--) {
				int eval =target.city.compareTo(rests[j-1].city);
				if(eval<0)
					rests[j]=rests[j-1];
				else if(eval==0 && target.point > rests[j-1].point)
					rests[j]=rests[j-1];
				else {
					rests[j] = target;
					break;
				}
			}
			if(j==0)
				rests[0]=target;
		}
		sc.close();
		
		for(i=0;i<n;i++)
			System.out.println(rests[i].index);
	}
}

class Rest{
	String city;
	int point;
	int index;
	
	Rest(String city,int point,int index){
		this.city = city;
		this.point = point;
		this.index = index;
	}
}
/*
 * xor
 */

Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> a(n); for(int & i : a) cin >> i;
  int mx = 0, q = 0;
  for(int i = 0; i < n; i++){
    mx = max(mx, a[i]);
    q += a[i] >= mx;
  }
  cout << q << endl;
  return 0;
}
  

Measured memory_bytes: 256
using System;

    class Program
    {
        static void Main()
        {
            int[,,] hause = new int[4,3,10];
            int inputnum = int.Parse(Console.ReadLine());
            for (int i = 0; i < inputnum; i++)
            {
                int[] line = TypeConverter.arrayStrToInt(Console.ReadLine().Split(' '));
                hause[line[0] - 1, line[1] - 1, line[2] - 1] += line[3];
            }

            for (int b = 0; b < 4; b++)
            {
                for (int f = 0; f < 3; f++)
                {
                    for (int r = 0; r < 10; r++)
                    {
                        Console.Write(" " + hause[b, f, r].ToString());
                    }
                    Console.Write("\n");
                }
                if(b < 3) Console.Write("####################\n");
            }
        }
    }

    class TypeConverter
    {
        static public int[] arrayStrToInt(string[] str)
        {
            return Array.ConvertAll<string, int>(str,
                delegate(string value)
                {
                    return int.Parse(value);
                }
            );
        }

        static public string[] arrayIntToStr(int[] x)
        {
            return Array.ConvertAll<int, string>(x,
                delegate(int value)
                {
                    return value.ToString();
                }
            );
        }
    }

Measured memory_bytes: 17956
import sys
from itertools import accumulate
from bisect import bisect_right

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

N, M, K = MAP()
A = LIST()
B = LIST()

acc1 = [0] + list(accumulate(A))
acc2 = [0] + list(accumulate(B))
ans = 0
for i in range(N+1):
    cur = K - acc1[i]
    if cur < 0:
        break
    j = bisect_right(acc2, cur) - 1
    ans = max(ans, i+j)
print(ans)


Measured memory_bytes: 133244
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

#include <cmath>
#include <cstdlib>
#include <climits>

//#include <stdio.h>
//#include <stdlib.h>


using namespace std;

#define debug false

int main(int argc, char *argv[]){

  int N, tmp;
  vector< pair<int, int> > odd, even;
  // <count, value>
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> tmp;

    if(i % 2 == 0){
      int l = odd.size();
      bool flag = false;
      for(int j = 0; j < l; j++){
        if(odd[j].second == tmp){
          odd[j].first++;
          flag = true;
          break;
        }
      }
      if(! flag){
        odd.push_back(make_pair(1, tmp));
      }
    }else{
      int l = even.size();
      bool flag = false;
      for(int j = 0; j < l; j++){
        if(even[j].second == tmp){
          even[j].first++;
          flag = true;
          break;
        }
      }
      if(! flag){
        even.push_back(make_pair(1, tmp));
      }
    }

  }
  sort(odd.begin(), odd.end());
  reverse(odd.begin(), odd.end());

  sort(even.begin(), even.end());
  reverse(even.begin(), even.end());

  //printf("max : %d, %d回\n", odd[0].second, odd[0].first);
  //printf("max : %d, %d回\n", even[0].second, even[0].first);

  int shuffle, n = N / 2;
  // 最頻値の値が異なる場合。
  if(odd[0].second != even[0].second){
    shuffle = N - odd[0].first - even[0].first;
  }else{
    // 最頻値が同じ場合。
    int tmp1 = N - odd[1].first - even[0].first;
    int tmp2 = N - odd[0].first - even[1].first;
    if(tmp1 < tmp2) shuffle = tmp1;
    else            shuffle = tmp2;
  }

  cout << shuffle << endl;


  return 0;
}


Measured memory_bytes: 1276
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var Pi = Sarray();
            var min = N + 1;
            var ans = 0;
            for(var i=0;i<N;++i)
            {
                if (Pi[i] < min)
                    ++ans;
                min = Min(min, Pi[i]);
            }
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 36420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=(ll)(1e9+21);
ll run();
int main() {
#ifdef home
    freopen("i", "r", stdin);
    freopen("d", "w", stderr);
#endif
    cout.precision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    run();
    return 0;
}

void max_self(ll &a, ll b){
    a= max(a,b);
}

void min_self(ll &a, ll b){
    a=min(a,b);
}

ll run() {

    int n,w;
    cin>>n>>w;
    vector<ll> dp(w+1);

    for(int item=0;item<n;item++){
        int wt,v;
        cin>>wt>>v;
        for(int wt_already = w-wt;wt_already>=0;wt_already--){
            max_self(dp[wt_already+wt],dp[wt_already]+v);
        }
    }

    ll ans =0;
    for(int i=0;i<=w;i++){
        max_self(ans,dp[i]);
    }
    cout<<ans;
}


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

int k, m, n;
string s = "1122", t = "";
vector<int> v(4);

int main()
{
    for (int i = 0; i < 6; i++)
    {
        cin >> m;
        v[m - 1]++;
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < 4; i++)
    {
        t = t + to_string(v[i]);
    }
    if (s == t)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
	string a,b;
	cin>>a;
	b+=a.at(0)+to_string(a.size()-2)+a.at(a.size()-1);
	cout<<b<<endl;
}

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

using namespace std;

using ll = long long;

const long long MOD = 1e9 + 7;
const int INF = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    ll cnt = 0;
    ll sub_sum = a[0];
    if (sub_sum == 0) sub_sum = -1, ++cnt;
    for (int i = 1; i < n; ++i) {
        ll sum = sub_sum + a[i];
        ll sgn = sub_sum / abs(sub_sum) * sum;
        if (sgn >= 0) {
            ll b = -1 * sub_sum / abs(sub_sum);
            sum = b;
            cnt += abs(b - sub_sum - a[i]);
        }
        sub_sum = sum;
    }
    ll ans = cnt;
    cnt = abs(a[0]) + 1;
    sub_sum = (a[0] > 0 ? -1 : 1);
    for (int i = 1; i < n; ++i) {
        ll sum = sub_sum + a[i];
        ll sgn = sub_sum / abs(sub_sum) * sum;
        if (sgn >= 0) {
            ll b = -1 * sub_sum / abs(sub_sum);
            sum = b;
            cnt += abs(b - sub_sum - a[i]);
        }
        sub_sum = sum;
    }
    ans = min(ans, cnt);
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		int as = 0, bs = 0;
		for (int i = 0; i < N; ++i) {
			int a, b; cin >> a >> b;
			if (a > b) {
				as += a + b;

			}
			else if (b > a) {
				bs += a + b;
			}
			else {
				as += a;
				bs += b;
			}

		}
		cout << as << " " << bs << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3056
import java.util.Scanner;

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

        char C = scanner.next().charAt(0);

        /* int m = scanner.nextInt(); */

        char[] alpha = new char[26];
        for (int i = 0; i < 26; i++) {
            alpha[i] = (char) (97 + i);
        }

        int j;
        for (j = 0; j < alpha.length; j++) {
            if (C == alpha[j]) {
                System.out.println(alpha[j + 1]);
                return;
            }

        }

    }
}


Measured memory_bytes: 21844
#include <stdio.h>

int main(void){
    int a,b,c;
    int reslut=0;
    scanf("%d %d %d\n",&a,&b,&c);
    for (int x=a; x<=b; x++){
        if(c%x==0){
            reslut++;
        }
    }
    printf("%d\n",reslut);
}


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

double n, m, k;

double dfs(int num, int c){
    double sum=0;
    if(c==n) return (num-k)<=1 ? 1/pow(m, n) : (num-k)/pow(m, n);
    for(int i=1; i<=m; i++){
        sum+=dfs(i+num, c+1);
    }
    return sum;
}
int main(void){
    while(true){
        cin >> n >> m >> k;
        if(n+m+k==0) break;
        printf("%.8f\n", dfs(0, 0));
        
    }
    
    return 0;
}


Measured memory_bytes: 3272
n = int(input())
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))

temp = 0.006
min_t = abs(a - (t - h[0] * temp))
min = 0

for i in range(n):
    tmp = abs(a - (t - h[i] * temp))
    if tmp < min_t:
        min_t = tmp
        min = i

print(min + 1)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

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

Measured memory_bytes: 3520