akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>

using namespace std;

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/
int main(){
    string s;
    cin >> s;
    int n = s.length();
    int c=0;
    for(int i = 0; i<(n/2)*2;i= i+2){
        if(s[i]!='0'){
            c++;
        }
        if(s[i+1]!='1'){
            c++;
        }
    }
    if(n%2==1){
        if(s[n-1]!='0'){
            c++;
            s[n-1]='0';
        }
    }
    cout<<min(c,n-c)<<'\n';
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main() {
	int n,m,l,r,ansL,ansR;
	scanf("%d%d", &n,&m);
	ansR=n;
	ansL=0;
	for (int i = 0; i < m; i++) {
		scanf("%d%d", &l,&r);
		if(ansL<l){
			ansL=l;
		}
		if(r<ansR){
			ansR=r;
		}
		if(r<ansL||ansR<l){
			printf("0\n");
			return 0;
		}
	}
	printf("%d\n", ansR-ansL+1);
	return 0;
}


Measured memory_bytes: 128
# ALDS1_4_C: Dictionary
n = int(input())
cmds = [input().split() for _ in range(n)]
dictionary = {}
for cmd in cmds:
    if cmd[0] == "insert":
        dictionary[cmd[1]] = None
    elif cmd[0] == "find":
        if cmd[1] in dictionary.keys():
            print("yes")
        else:
            print("no")


Measured memory_bytes: 303796
#include <algorithm>
#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <vector>
using namespace std;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    
    string ddd = "ABC";
    
    int result = 0;
    for (int i = 0; i < n; i++) {
        if (s.substr(i, 3) == ddd){
            result++;
        }
    }
    cout << result << endl;
   
   
    return 0;   
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    def main():

        N = int(input())
        A = list(map(int, input().split()))
        B = list(map(int, input().split()))
        pluslist = []
        minuscnt = 0
        cnt = 0

        for i in range(N):
            if A[i] < B[i]:
                minuscnt += B[i]-A[i]
                cnt += 1
            elif A[i] > B[i]:
                pluslist.append(A[i]-B[i])
        if minuscnt == 0:
            return 0
        pluslist.sort(reverse=True)
        val = 0
        i = 0
        while True:
            val += pluslist[i]
            i += 1
            if val >= minuscnt:
                return i+cnt
            elif i >= len(pluslist):
                return -1
        return i+1+cnt

    print(main())

resolve()

Measured memory_bytes: 76336
import java.util.*;

public class Main{
  static long cost = 0;
  private int a;
  private int b;

  Main(int a, int b){
    this.a = a;
    this.b = b;
  }
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int m = sc.nextInt();

    Main[] d = new Main[n];

    for(int i=0; i<n; i++){
      d[i] = new Main(sc.nextInt(),sc.nextInt());
    }
    //for(int i=0; i<n; i++){
      //System.out.println(d[i].a+","+d[i].b);
    //}
    Arrays.sort(d,new Comparator<Main>(){
      public int compare(Main o1,Main o2){
        return o1.a - o2.a;
      }
    });
    //for(int i=0; i<n; i++){
      //System.out.println(d[i].a+","+d[i].b);
    //}
    int j = 0;
    while(m>0){
      if(m-d[j].b>=0){
        cost += (long)d[j].a * (long)d[j].b;
        m -=  d[j].b;
      }else if(m-d[j].b<0){
        cost += (long)d[j].a * (long)m;
        m = 0;
      }
      j++;

    }
    System.out.println(cost);


  }

}

Measured memory_bytes: 90700
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


int main(){
  
  long long n;
  string s;
  cin>>n;
  cin>>s;
  long long cnt[26]={};
  int c;
  REP(i,n){
    c = s[i] - 'a';
    cnt[c]++;
  }
  
  long long ans=1;
  REP(i,26){
    if(cnt[i]){
      ans *= 1+cnt[i];
      ans = mod(ans);
    }
  }
  ans -= 1;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
import java.util.Stack;

//Strange Mathematical Expression
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String[] s = sc.nextLine().split(" ");
			Stack<Double> u = new Stack<Double>();
			for(String x:s){
				if(x.equals("+")){
					double b = u.pop();
					double a = u.pop();
					u.push(a+b);
				}
				else if(x.equals("-")){
					double b = u.pop();
					double a = u.pop();
					u.push(a-b);
				}
				else if(x.equals("*")){
					double b = u.pop();
					double a = u.pop();
					u.push(a*b);
				}
				else if(x.equals("/")){
					double b = u.pop();
					double a = u.pop();
					u.push(a/b);
				}
				else u.push(Double.parseDouble(x));
			}
			System.out.println(u.pop());
		}
	}
}

Measured memory_bytes: 17200
n = int(input())
count = [0]*n
base = 0
list = [int(i) for i in input().split()]

for i in list:
    count[i-1] += 1

for j in range(n):
    m = count[j]
    base += m*(m-1)//2

for k in list:
    print(base - count[k-1] + 1)


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

██╗    ██╗██████╗ ██╗████████╗████████╗███████╗███╗   ██╗    ██████╗ ██╗   ██╗
██║    ██║██╔══██╗██║╚══██╔══╝╚══██╔══╝██╔════╝████╗  ██║    ██╔══██╗╚██╗ ██╔╝
██║ █╗ ██║██████╔╝██║   ██║      ██║   █████╗  ██╔██╗ ██║    ██████╔╝ ╚████╔╝
██║███╗██║██╔══██╗██║   ██║      ██║   ██╔══╝  ██║╚██╗██║    ██╔══██╗  ╚██╔╝
╚███╔███╔╝██║  ██║██║   ██║      ██║   ███████╗██║ ╚████║    ██████╔╝   ██║
 ╚══╝╚══╝ ╚═╝  ╚═╝╚═╝   ╚═╝      ╚═╝   ╚══════╝╚═╝  ╚═══╝    ╚═════╝    ╚═╝

     ███╗   ███╗   ██╗██████╗ ██████╗  █████╗ ██╗  ██╗██╗███╗   ███╗
     ████╗ ████║   ██║██╔══██╗██╔══██╗██╔══██╗██║  ██║██║████╗ ████║
     ██╔████╔██║   ██║██████╔╝██████╔╝███████║███████║██║██╔████╔██║
     ██║╚██╔╝██║   ██║██╔══██╗██╔══██╗██╔══██║██╔══██║██║██║╚██╔╝██║
     ██║ ╚═╝ ██║██╗██║██████╔╝██║  ██║██║  ██║██║  ██║██║██║ ╚═╝ ██║
     ╚═╝     ╚═╝╚═╝╚═╝╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝╚═╝     ╚═╝
*/
#define speed  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(n) for(int i=0;i<n;i++)
#define For(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define E "\n"
#define all(e) e.begin(),e.end()
#define F first
#define S second
#define pi (acos(-1))
#define rad(x) ((x*pi)/(ld)(180))
#define perc(x) fixed<<setprecision(x)
/*****
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define vec(a,b) ((b) - (a))
#define rot(p,angle) (p)*polar((double)(1),angle)
#define rot2(p,angle,a) ((p)-(a)) *(polar((ld)(1),angle)+ (a))
#define x real()
#define y imag()
*****/
typedef long long int ll; typedef unsigned long long ull; typedef long double ld;typedef complex<ld> point; typedef tuple<double,double,double> line;
ll gcd(ll x,ll y){if(!y)return x; return gcd(y,x%y);};   ll lcm(ll x,ll y){return (x*y)/__gcd(x,y);}

int main(){ speed;

int n; cin>>n;
int arr[n];

FOR(n)cin>>arr[i];

int ans[n];

ans[0]=0;

ans[1]= abs(arr[0]-arr[1]);

for(int i=2;i<n;i++)
{
    ans[i]=min(ans[i-1]+abs(arr[i]-arr[i-1]),ans[i-2]+abs(arr[i]-arr[i-2]));
}

cout<<ans[n-1];


return 0;}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
using namespace std;

#define abs(N) ((N>0)?N:-1*N)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

int main(int argc, char const *argv[])
{
  int a,b;
  cin >> a >> b;

  if( a > 8 || b > 8){
    println(":(");
  }
  else{
    println("Yay!");
  }

  return 0;
}


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

using namespace std;
const int maxn=2e5+5;
map<string,int>s;
struct node
{
   string s1;
   int num;
}a[maxn];
bool cmp(node a, node b)
{
    if(a.num<b.num)
        return a.num>b.num;
    if(a.num==b.num)
        return a.s1<b.s1;

}
int main()
{
   int n;
   string ss;
   cin>>n;
   for(int i=1;i<=n;i++){
    cin>>ss;
    s[ss]++;
   }
   int len=0;
   for (map<string,int>::iterator it=s.begin(); it!=s.end(); it++,len++){
    a[len].s1=it->first;
    a[len].num=it->second;
   }
   //printf("%d\n",len);
   sort(a,a+len,cmp);
   int maxm=a[0].num;
    cout<<a[0].s1<<endl;
   for(int i=1;i<len;i++){
    if(a[i].num==maxm)
        cout<<a[i].s1<<endl;
    else
        break;
   }
   return 0;
}


Measured memory_bytes: 28288
n, x, y = list(map(int, input().split()))

dists = [0] * (n-1)

for start in range(n):
    for end in range(start+1, n):
        dist = min(end-start, abs(((x-1)-start))+1+abs(end-(y-1)))
        dists[dist-1] += 1

for dist in dists:
    print(dist)

Measured memory_bytes: 9260
n,m=map(int, input().split())
H = list(map(int, input().split()))
es=[[] for i in range(n)]
for i in range(m):
    a,b=map(int, input().split())
    if H[a-1]<=H[b-1]:
        es[a-1].append(b-1)
    if H[b-1]<=H[a-1]:
        es[b-1].append(a-1)
cnt=0
for e in es:
    if e==[]:
        cnt+=1
print(cnt)

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

int k , a[100] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
	cin >> k;
	cout << a[k - 1];
	return 0;
} 

Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	a := nextInt(sc)
	b := nextInt(sc)

	fmt.Println(a*b, 2*(a+b))
}



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

int main() {
    int N,M;
    cin >> N >> M;
    int ans=0;
    vector<int> digit(N,-1);
    int s,c;
    for (int i = 0; i < M; i++){
        cin >> s >> c ;
        if(N>1&&s==1&&c==0){
            cout << -1 << endl;
            return 0;
        }
        if(digit[s-1]==-1)digit[s-1]=c;
        else if (digit[s-1]!=c){
            cout << -1 << endl;
            return 0;
        }
    }
    if(N>1&&digit[0]==-1)ans+=pow(10,N-1);
    else if(digit[0]!=-1)ans+=digit[0]*pow(10,N-1);
    for (int i = 1; i < N; i++){
        if(digit[i]!=-1)ans+=digit[i]*pow(10,N-i-1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <iomanip>
#include <numeric>


using namespace std;

typedef long long LL;


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

	cin.tie(0);
	ios::sync_with_stdio(false);


	LL N, M;

	cin >> N >> M;

	vector<LL> X(M);

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

	sort(X.begin(), X.end());
	vector<int> dist(M - 1);

	for (int i = 0; i < M - 1; i++) dist.at(i) = X.at(i + 1) - X.at(i);

	sort(dist.begin(), dist.end(), greater<int>());

	int ans = 0;

	for (int i = N - 1; i < M - 1; i++) ans += dist.at(i);

    cout << ans << endl;

	return 0;
}

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

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

return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl

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

  vector<int> cnts;
  int bt = 1;
  int cnt = 0;
  rep(i, n) {
    if(s[i] != (char)(bt + '0')) {
      cnts.push_back(cnt);
      bt ^= 1;
      cnt = 1;
    } else {
      ++cnt;
    }
  }
  if(cnt != 0) cnts.push_back(cnt);
  if(!bt) cnts.push_back(0);

  int m = (int)cnts.size();
  vector<int> acc(m + 1);
  acc[0] = 0;
  rep(i, m) acc[i + 1] = acc[i] + cnts[i];
  int d = 2 * k + 1;
  int ans = 0;
  for(int i = 0; i < m; i += 2) {
    int left = i;
    int right = min(i + d, m);
    ans = max(ans, acc[right] - acc[left]);
  }
  cout << ans << endl;

  return 0;
}


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

typedef long long ll;

int main(){
	const int MOD = 2019;
	string S;
	cin >> S;
	reverse(S.begin(),S.end());

	ll ans = 0;
	vector<ll> cnt(2020);
	cnt[0] = 1;
	int p = 1; int t=0;
	for(char c : S ){
		int i = c-'0';
		t = (t + i * p) % MOD;
		ans += cnt[t];

		p = p*10;
		p %= MOD;
		cnt[t]++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3748
import java.math.BigInteger;
import java.util.*;

public class Main {
	int INF = 1 << 29;
	
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			String [] data = new String[3];
			for(int i = 0; i < 3; i++){
				data[i] = sc.next();
			}
			int count = 0;
			for(int i = 0; i < n; i++){
				int [] freq = new int[26];
				freq[data[0].charAt(i) - 'a']++;
				freq[data[1].charAt(i) - 'a']++;
				freq[data[2].charAt(i) - 'a']++;
				int res = Math.max(freq[data[0].charAt(i) - 'a'], Math.max(freq[data[1].charAt(i) - 'a'], freq[data[2].charAt(i) - 'a']));
				count += 3 - res;
			}
			System.out.println(count);
			
		}
	}


	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 22608
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

int n,m;
int graph[10][10];

int jud(int flag[])
{
    for(int i = 0; i < n; i++) if(flag[i] == 0) return 0;
    return 1;
}

int dfs(int now,int flag[])
{
    if(jud(flag)) return 1;
    int ret = 0;
    for(int i = 0; i < n; i++){
        if(graph[i][now] && flag[i] == 0){
            flag[i] = 1;
            ret += dfs(i,flag);
            flag[i] = 0;
        }
    }
    return ret;
}

int main()
{
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int a,b; cin >> a >> b;
        a--,b--;
        graph[a][b] = graph[b][a] = 1;
    }

    int flag[8] = {1};
    cout << dfs(0,flag) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <vector>
//#define ivorysi
#define MAXN 200005
#define eps 1e-7
#define mo 974711
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
const int64 MOD = 998244353;
int N;
char s[MAXN];
int64 dp[MAXN][3][3][2];
void inc(int64 &x,int64 y) {
    x = x + y;
    while(x >= MOD) x -= MOD;
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    scanf("%s",s + 1);
    N = strlen(s + 1);
    bool all_same = 1;
    for(int i = 1 ; i <= N ; ++i) {
	if(s[i] != s[1]) all_same = 0;
    }
    if(all_same) {puts("1");return 0;}
    if(N > 3) {
	for(int i = 0 ; i <= 2 ; ++i) dp[1][i][i][0] = 1;
	for(int i = 2 ; i <= N ; ++i) {
	    for(int s = 0 ; s <= 2 ; ++s) {
		for(int j = 0 ; j <= 2 ; ++j) {
		    for(int h = 0 ; h <= 2 ; ++h) {
			for(int l = 0 ; l <= 1 ; ++l) {
			    inc(dp[i][(s + h) % 3][h][l || h == j],dp[i - 1][s][j][l]);
			}
		    }
		}
	    }
	}
	bool flag = 1;
	int c = 0;
	for(int i = 1 ; i <= N ; ++i) {
	    c = (c + s[i] - 'a') % 3;
	}
	for(int i = 2 ; i <= N ; ++i) {
	    if(s[i] == s[i - 1]) {flag = 0;break;}
	}
	int64 ans = flag;
	for(int i = 0 ; i <= 2 ; ++i) ans += dp[N][c][i][1];
	ans %= MOD;
	printf("%lld\n",ans);
    }
    else {
	if(N == 3) {
	    if(s[1] != s[2] && s[2] != s[3] && s[1] != s[3]) puts("3");
	    else if(s[1] == s[2] || s[2] == s[3]) puts("6");
	    else puts("7");
	}
	else if(N == 2) {
	    puts("2");
	}
    }
    return 0;
}


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

#define rep(X,Y) for(int (X) = 0; (X) < (Y); ++(X))
typedef long long ll;
typedef pair<int, int> pii;

#define all(X) (X).begin(),(X).end()
#define pb push_back
#define eb emplace_back
#define rrep(X,Y) for(int (X)=(Y)-1; (X) >= 0; --(X))
#define X first
#define Y second
#define reps(X,Y,Z) for(int (X)=(Y); (X) <= (Z); ++(X))
#define sz size()
#define in(i,j,k) ((i) >= (j) && (j) <= (k))

#define UNIQUE(X) (X).erase(unique(all(X)), (X).end())

int main(){
    int n;
    while(cin >> n&&n){
        vector<pair<pii,pii > > v;
        rep(i,n){
            int id,u,a,p;
            cin >> id >> u >> a >> p;
            v.eb(pii(-a,p),pii(id,u));
        }
        sort(all(v));
        map<int,int> m;
        vector<int> ans;
        rep(i,n){
            if( ans.sz < 10 && m[v[i].Y.Y] < 3 ||
                ans.sz < 20 && m[v[i].Y.Y] < 2 ||
                ans.sz < 26 && m[v[i].Y.Y] < 1 )
            {
                m[v[i].Y.Y]++;
                ans.pb(v[i].Y.X);
            }
        }
        rep(i,ans.sz){
            cout << ans[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se  second
int main()
{
   int n,w;
   cin>>n>>w;
   ll wi[n+1],val[n+1];
   for(int i=1;i<=n;++i)
    cin>>wi[i]>>val[i];
   ll dp[n+1][w+1];
   for(int i=0;i<=n;++i)
   {
       for(int j=0;j<=w;++j)
       {
           if(i==0 || j==0)
            dp[i][j]=0;
           else if(wi[i]<=j)
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-wi[i]]+val[i]);
           else
            dp[i][j]=dp[i-1][j];
       }
   }
   cout<<dp[n][w]<<endl;
   return 0;
}


Measured memory_bytes: 79104
import sys
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3
#sys.setrecursionlimit(int(1e+6))
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
MOD = int(1e+9) + 7

def main():
    N, M, Q = i2nn()
    LR = ii2nnn(M)
    PQ = ii2nnn(Q)
    D = [[0] * (N+2) for i in range(N+2)]
    for l, r in LR:
        D[l][r] += 1
    for i in range(N, 0, -1):
        for j in range(1, N+1):
            D[i][j] += D[i+1][j] + D[i][j-1] - D[i+1][j-1]
    for p, q in PQ:
        print(D[p][q])

main()


Measured memory_bytes: 119632
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int n;
	cin >> n;
	if (n % 2 == 1)
		n = 2 * n;
	cout << n << endl;
} 

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

struct Range {
	long long int left, right;
};
int main() {
	int n; long long int l; std::cin >> n >> l;
	std::vector<Range> ranges(n); for (auto& r : ranges) std::cin >> r.left >> r.right;
	std::vector<long long int> values;
	for (const auto r : ranges) {
		values.push_back(r.left);
		values.push_back(r.right);
	}
	std::sort(values.begin(), values.end());
	values.erase(std::unique(values.begin(), values.end()), values.end());
	std::unordered_map<long long int, int> rank;
	for (auto i = 0; i < values.size(); ++i) {
		rank[values[i]] = i;
	}
	for (auto& r : ranges) {
		r.left = rank[r.left];
		r.right = rank[r.right];
	}
	std::sort(ranges.begin(), ranges.end(), [](const Range& a, const Range& b) {return a.left == b.left ? a.right < b.right : a.left < b.left; });
	std::vector<int> max_right(values.size(), 0);
	for (const auto& r : ranges) {
		max_right[r.left] = r.right;
	}
	for (auto i = 1; i < max_right.size(); ++i) {
		max_right[i] = std::max(max_right[i], max_right[i - 1]);
	}
	int x = 0;
	for (auto i = 0; i + 1 < max_right.size(); i = max_right[i]) {
		++x;
	}
	std::vector<int> count(values.size(), 0);
	for (const auto& r : ranges) {
		count[r.left]++;
		count[r.right]--;
	}
	for (auto i = 1; i < count.size(); ++i) {
		count[i] += count[i - 1];
	}
	count.pop_back();
	int y = 0;
	for (const auto c : count) {
		y = std::max(y, n - c + 1);
	}
	std::cout << x << ' ' << y << '\n';
}


Measured memory_bytes: 27788
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int ans = 0;
    rep(i, 0, s.size()) if(s[i] == '1') ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
let quick_sort (a : (int * char * int) array) cmp =
  let rec partition p r =
    let swap i j = let t = a.(i) in a.(i) <- a.(j); a.(j) <- t
    in
    let rec exchange i j =
      if j >= r then (swap (i + 1) r; i + 1)
      else if cmp a.(j) a.(r) <= 0 then (swap (i + 1) j; exchange (i + 1) (j + 1))
      else exchange i (j + 1)
    in exchange (p - 1) p
  and doit p r =
    if p < r then begin
      let q = partition p r in
      doit p (q - 1);
      doit q r
    end in
  doit 0 (Array.length a - 1)

let stable_p (a : (int * char * int) array) n =
  let rec doit i =
    if i = n - 1 then true
    else if (fun (xi, _, xd) (yi, _, yd) -> xd = yd && xi > yi) a.(i) a.(i+1) then false
    else doit (i + 1)
  in doit 0

let split str delim =
  let rec doit s acc =
    match
      try Some (String.rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        doit s1 (String.sub s (i + 1) (String.length s - String.length s1 - 1) :: acc)
  in doit str []

let () =
  let n = read_int () in
  let a = Array.init n (fun i ->
    match split (read_line ()) ' ' with
    | [c; d] -> (i, c.[0], int_of_string d)
    | _ -> exit 1
  ) in
  quick_sort a (fun (_, _, x) (_, _, y) -> compare x y);
  print_endline (if stable_p a n then "Stable" else "Not stable");
  Array.iter (fun (_, c, d) -> Printf.printf "%c %d\n" c d) a

Measured memory_bytes: 8796
#include <iostream>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1) a = 14;
	if (b == 1) b = 14;
	cout << (a != b ? (a < b ? "Bob" : "Alice") : "Draw") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
int main(){
    ll n,q;cin>>n>>q;
    vector<vector<ll>> vec(n);
    vector<ll> ans(n,0);
    For(i,n-1){
        ll a,b;cin>>a>>b;a--;b--;
        vec.at(a).push_back(b);
    }
    For(i,q){
        ll p,x;cin>>p>>x;p--;
        ans.at(p)+=x;
    }
    For(i,n){
        for(ll j=0;j<vec.at(i).size();j++){
            ans.at(vec.at(i).at(j))+=ans.at(i);
        }
    }
    For(i,n){
        cout<<ans.at(i)<<" ";
    }
}


Measured memory_bytes: 14848
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_169c
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            decimal firstnumber = decimal.Parse(input[0]);
            decimal secondnumber = decimal.Parse(input[1]);

            decimal res = firstnumber * secondnumber;

            Console.WriteLine(Math.Floor(res));

            Console.Read();


        }
    }
}


Measured memory_bytes: 27568
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
using namespace std;

int main(){
	long long n,m;
	cin >> n >> m;
	vector<pair<long long,string>> pa(m);
	vector<pair<bool,long long>> clear(n);
	long long sum_ac=0,sum_wa=0;
	
	//shokika
	for(long long i=0;i<n;i++){
			clear[i].first=false;
			clear[i].second=0;
	}
	
	//nyuryoku
	for(long long i=0;i<m;i++){
		cin >> pa[i].first >> pa[i].second;
	}
	
	//check
	for(long long i=0;i<m;i++){
		
		if(pa[i].second=="AC"){
			clear[pa[i].first-1].first=true;
			continue;
		}
		
		if(pa[i].second=="WA"){
			if(clear[pa[i].first-1].first==false){
				clear[pa[i].first-1].second++;
				continue;
			}
		}
		
	}
	
	//sum
	for(long long i=0;i<n;i++){
		if(clear[i].first==true){
			sum_ac++;
			sum_wa+=clear[i].second;
		}
	}
		
	//out
	cout << sum_ac << " " << sum_wa << endl;	
	
	return 0;
}


Measured memory_bytes: 8064
import sys
import math

ct= 0
def insertion_sort(a, n, g):
    global ct
    for j in range(0,n-g):
        v = a[j+g]
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j-g
            ct += 1
        a[j+g] = v

n = int(input())
a = list(map(int, sys.stdin.readlines()))

b = math.floor(2.25*701)
g = [x for x in [1,4,10,23,57,132,301,701] if x <= n]

while b<=n:
    g.append(b)
    b = math.floor(2.25*b)
g = g[::-1]

for i in g:
    insertion_sort(a, n, i)

print(len(g))
print(*g, sep=" ")
print(ct)
print(*a, sep="\n")

Measured memory_bytes: 118484
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
#define EPS (1e-10)

static const int COUNTER_CLOCKWISE=1;
static const int CLOCKWISE=-1;
static const int ONLINE_BACK=2;
static const int ONLINE_FRONT=-2;
static const int ON_SEGMENT=0;

struct Point { double x, y; };//点
struct Segment { Point p1, p2; };//線
double dot(Point a, Point b) {//内積
    return a.x * b.x + a.y * b.y;
}
double cross(Point a, Point b) {//外積
    return a.x * b.y - a.y * b.x;
}
double norm(Point a) {
    return a.x * a.x + a.y * a.y;
}
double absv(Point a) {
    return sqrt(norm(a));
}
Point project(Segment s, Point p) {
    Point base, q;
    Point ans;
    base.x = s.p2.x - s.p1.x;
    base.y = s.p2.y - s.p1.y;
    q.x = p.x - s.p1.x;
    q.y = p.y - s.p1.y;
    double r = dot(q, base) / norm(base);
    ans.x = s.p1.x + base.x * r;
    ans.y = s.p1.y + base.y * r;
    return ans;
}
Point reflect(Segment s, Point p) {
    Point ans;
    ans.x = p.x + (project(s, p).x - p.x) * 2.0;
    ans.y = p.y + (project(s, p).y - p.y) * 2.0;
    return ans;
}
/*double getPointDistance(Point a, Point b) {
    Point ans;
    ans.x = a.x - b.x;
    ans.y = a.y - b.y;
    absv(ans);
}
double getDistanceLP(Segment l, Point p) {
    Point tmp, tmp2, ans;
    tmp.x = l.p2.x - l.p1.x;
    tmp.y = l.p2.y - l.p1.y;
    tmp2.x = p.x - l.p1.x;
    tmp2.y = p.y - l.p1.y;
    return absv(cross(tmp, tmp2) / absv(tmp));
}
double getDistanceSP(Segment s, Point p) {
    Point t1, t2, t3, t4;
    t1.x = s.p2.x - s.p1.x;
    t1.y = s.p2.y - s.p1.y;
    t2.x = p.x - s.p1.x;
    t2.y = p.y - s.p1.y;
    t3.x = s.p1.x - s.p2.x;
    t3.y = s.p1.y - s.p2.y;
    t4.x = p.x - s.p2.x;
    t4.y = p.y - s.p2.y;
    if (dot(t1, t2) < 0.0)return absv(t2);
    if (dot(t3, t4) < 0.0)return absv(t4);
    return getDistanceLP(s, p);
}*/
int ccw(Point p0,Point p1,Point p2){
    Point a,b;
    a.x=p1.x-p0.x;
    a.y=p1.y-p0.y;
    b.x=p2.x-p0.x;
    b.y=p2.y-p0.y;
    if(cross(a,b)>EPS)return COUNTER_CLOCKWISE;
    if(cross(a,b)<(-EPS))return CLOCKWISE;
    if(dot(a,b)<(-EPS))return ONLINE_BACK;
    if(norm(a)<norm(b))return ONLINE_FRONT;
    
    return ON_SEGMENT;
}
bool intersect(Point p1,Point p2,Point p3,Point p4){
    return(ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 && ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}
bool intersectS(Segment s1,Segment s2){
    return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}
/*double getDistance(Segment s1,Segment s2){
    if(intersectS(s1,s2))return 0.0;
    return min(min(getDistanceSP(s1,s2.p1)),getDistanceSP(s1,s2.p2)),min(getDistanceSP(s2,s1.p1),getDistanceSP(s2,s1.p2)));
}*/

int main(void) {
    Point p0,p1,p2;
    cin >> p0.x >> p0.y >> p1.x >> p1.y;
    int n,ret;cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> p2.x >> p2.y;
        ret=ccw(p0,p1,p2);
        if(ret==1)cout<<"COUNTER_CLOCKWISE"<<endl;
        if(ret==0)cout<<"ON_SEGMENT"<<endl;
        if(ret==-1)cout<<"CLOCKWISE"<<endl;
        if(ret==2)cout<<"ONLINE_BACK"<<endl;
        if(ret==-2)cout<<"ONLINE_FRONT"<<endl;
        //cout << fixed << setprecision(10) <<  << " " << ans.y << endl;
    }
    return 0;
}



Measured memory_bytes: 3236
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define NUM 100000
#define INF 1000000000


int main(void){
    int n;
    int a[NUM];
    int length = 0;

    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }

    int A[NUM];
    for(int i = 0; i < n; i++){
        A[i] = INF;
    }

    for(int i = 0; i < n; i++){
        int* t = upper_bound(A, A + length, a[i] - 1);
        *t = a[i];
        if (A[length] != INF){
            length++;
        }
        /*
        for(int i = 0; i < length; i++){
            printf(" %d", A[i]);
        }
        printf("\n");
        */
            
    }
    
    printf("%d\n", length);
}



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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 105

int n , a , b , d;
int x[MAXX][MAXX];

int main()
{
    _FastIO;
    cin >> n >> d;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin >> x[i][j];
        }
    }
    vector<pii> v;
    for(int i = 0; i < n - 1; i++){
        for(int j = i + 1; j < n; j++){
            v.push_back({i , j});
        }
    }
    int ans = 0;
    for(int i = 0; i < v.size(); i++){
        a = v[i].first;
        b = v[i].second;
        int s = 0;
        for(int j = 0; j < d; j++){
            s += ((x[a][j] - x[b][j]) * (x[a][j] - x[b][j]));
        }
        int k = int(sqrt(s));
        if((k * k) == s)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
long long power(long long a,long long now) {
	long long ans = 1;
	while (now != 0) {
		if (now % 2 == 1) {
			ans *= a;
			ans %= MAX_MOD;
		}
		now /= 2;
		a *= a;
		a %= MAX_MOD;
	}
	return ans;
}
long long inv(long long a) {
	return power(a, MAX_MOD - 2);
}
long long Permutation(long long a, long long b) {
	long long ans = 1;
	for (long long i = 0; i < b; ++i) {
		ans *= (a - i);
		ans %= MAX_MOD;
	}
	return ans;
}
long long Combination(long long a, long long b) {
	long long ans = 1;
	for (long long i = 0; i < b; ++i) {
		ans *= (a - i);
		ans %= MAX_MOD;
		ans *= inv(i + 1);
		ans %= MAX_MOD;
	}
	return ans;
}
int main() {
	long long n, k;
	cin >> n >> k;
	cout << Combination(n + k - 1, n) << endl;
	return 0;
}



Measured memory_bytes: 3088
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

int main() {
  //
  ll n, a, b;
  cin >> n >> a >> b;
  cout << min(a * n, b) << endl;
  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
int main(){
    ll N;
    ll K;
    cin>>N>>K;
    vector<int>A(N);
    vector<int>B(N+1);
    bool flag1=true;
    set<int>list;
    int res=1;
    rep(i,N){
        cin>>A.at(i);
    }
    B.at(0)=1;
    for(int i=0;i<N;i++){
        B.at(i+1)=A.at(B.at(i)-1);
    }
    bool flag=true;
    ll s,t;
    rep(i,N+1){
        if(flag1){
            if(list.count(B[i])){
                res=B[i];
                t=i;
                flag1=false;
            }
            list.insert(B[i]);
        }
        if(flag1==false){
            break;
        }
    }
    rep(i,t){
        if(B[i]==res){
            s=i;
            break;
        }
    }
    if(K<=s){
        cout<<B[K]<<endl;
    }
    else{
        cout<<B[s+(K-s)%(t-s)]<<endl;
    }
}

Measured memory_bytes: 13844
#include <iostream>
using namespace std;
int main(){
	string A,B,C;
	cin >> A >> B >> C;
	if(A[A.size()-1]==B[0]&&B[B.size()-1]==C[0]){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
	}

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

int main() {
  string s, t;
  cin >> s >> t;

  string ret = t.substr(0, (int)s.size());
  if (s == ret) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}



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

int32_t main(){
  int n;
  cin>>n;
  int a[3][n];
  for(int i=0;i<n;i++){
    cin>>a[0][i]>>a[1][i]>>a[2][i];
  }
  int dp[3][n];
  dp[0][0]=a[0][0];
  dp[1][0]=a[1][0];
  dp[2][0]=a[2][0];
  for(int i=1;i<n;i++){
    dp[0][i]=max(dp[1][i-1],dp[2][i-1])+a[0][i];
    dp[1][i]=max(dp[2][i-1],dp[0][i-1])+a[1][i];
    dp[2][i]=max(dp[1][i-1],dp[0][i-1])+a[2][i];
  }
  cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
}


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

int main(){
	string s,res;
	int i,j=0;
	//for(i=0;i<sizeof(s);i++){
	cin>>s;
	//}
	for(i=0;i<s.size();i++){
		if(i%2==0){
			res+=s[i];
		}
	}
	//cout<<s.size()<<endl;
	//for(i=0;i<sizeof(res);i++){
	cout<<res;

	cout<<endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
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;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

int main(){
    ll N; cin>>N;
    ll sm = 0;
    ll counter = 1;
    while(1){
        if(sm+pow(26,counter)>=N){
            break;
        }else{
            sm += pow(26,counter);
            ++counter;
        }
    }
    char ans[counter];
    N -= (sm+1);
    REP(i,counter){
        ll x = N%26;
        ans[i] = (char)('a' + x);
        N /= 26;
    }
    REPR(i,counter-1){
        cout << ans[i];
    }
    cout << "\n";
}

Measured memory_bytes: 4028
// abc130c.cpp : Rectangle Cutting
#include <bits/stdc++.h>
using namespace std;
#define otf(f,x) printf(f,x)

int main(){
	double w,h,x,y;cin>>w>>h>>x>>y;
	// 中心を通る線が解につながる線になっている
	// 結局、四角形の半分の面積が解になる
	// (x,y)=(w/2,h/2) なら複数ある
	int f = (int)w%2==0 && w/2==x && (int)h%2==0 && h/2==y? 1:0;
	otf("%f ",w*h/2); otf("%d\n",f);
}

Measured memory_bytes: 256
def main():
    import sys
    #input = lambda: sys.stdin.buffer.readline().rstrip('\r\n')
    T = input()
    T = T.replace('?','D')
    # for i,t in enumerate(T):
    #     if t == '?':
    #         if i == 0:
    #             if T[i+1] == 'D' or T[i+1] == '?':
    #                 T[i] = 'P'
    #             else:
    #                 T[i] = 'D'
    #             continue
    #         if i == len(T)-1:
    #             T[i] = 'D'
    #             continue

    #         if T[i-1] == 'P':
    #             T[i] = 'D'
    #         else:
    #             if T[i+1] == 'D' or T[i+1] == '?':
    #                 T[i] = 'P'
    #             else:
    #                 T[i] = 'D'
    print(T)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9248
#include <iostream>
#include <cstring>

using namespace std;

int adja[101][101], dist[101];

void bfs() {
    int que[100], l = 0, d = 1;
    que[0] = 1;l++;
    while (l > 0) {
        int temp[100], m = 0;
        for (int i = 0; i < l; ++i) {
            int u = que[i];
            if (0 < dist[u] && dist[u] <= d)
                continue;
            dist[u] = d;
            for (int j = 0, v; (v = adja[u][j]) > 0; j++) {
                temp[m++] = v;
            }
        }
        memcpy(que, temp, sizeof(int) * m);
        l = m;
        d++;
    }
}

int main() {
    int n, k, u;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> u >> k;
        for (int j = 0; j < k; ++j) {
            cin >> adja[u][j];
        }
    }
    bfs();
    for (int i = 1; i <= n; ++i) {
        cout << i << " " << dist[i] - 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3160
import java.util.Scanner;

public class Main{

	public static void main(String args[]){
		new Main().mainrun();
	}

	private Scanner scan;
	private int N,x,y;
	private char[][] F;

	private void mainrun() {
		scan = new Scanner(System.in);

		N = scan.nextInt();
		F = new char[8][8];

		for(int i = 0;i < N;i++) {
			y = scan.nextInt();
			x = scan.nextInt();
			F[y][x] = 'Q';

			Xpoint(y,x);
		}

		loop(0);
		//System.out.print(check());
		scan.close();
	}

	private int[][] vector = {{-1,0},{-1,1},{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1}};

	private void loop(int n) {
		for(int i = 0;i < 8;i++) {
			if(F[n][i] == 'X') {
				continue;
			}else {
				if(F[n][i] != 'Q' ) {
					F[n][i] = 'Q';
				}

				if(n == 7) {
					if(check()) {
						print();
						break;
					}
				}else {
					loop(n+1);
				}
				F[n][i] = '\0';
			}
		}
	}

	private boolean check() {
		for(int i = 0;i < 8;i++) {
			for(int j = 0;j < 8;j++) {
				if(F[i][j] == 'Q') {

					for(int k = 0;k < 8;k++) {
						x = j;
						y = i;

						while(	0 <= y + vector[k][0] && y + vector[k][0] < 8 &&
								0 <= x + vector[k][1] && x + vector[k][1] < 8 ){

							y += vector[k][0];
							x += vector[k][1];

							if(F[y][x] == 'Q') {
								return false;
							}
						}
					}
					break;
				}
			}
		}

		return true;
	}


	private void Xpoint(int yy,int xx) {
		for(int i = 0;i < 8;i++) {
			x = xx;
			y = yy;

			while(	0 <= y + vector[i][0] && y + vector[i][0] < 8 &&
					0 <= x + vector[i][1] && x + vector[i][1] < 8 ){

				y += vector[i][0];
				x += vector[i][1];

				F[y][x] = 'X';
			}
		}
	}

	private void print() {
		for(int i = 0;i < 8;i++) {
			for(int j = 0;j < 8;j++) {
				if(F[i][j] == 'Q') {
					System.out.print('Q');
				}else {
					System.out.print('.');
				}
			}

			System.out.println();
		}
	}

}



Measured memory_bytes: 27580
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  vector<int> a(3);
  for (auto &i : a) cin >> i;
  sort(all(a));
  if ((a[1] == a[0] && a[1] != a[2]) || (a[1] == a[2] && a[1] != a[0])) {
    cout << "Yes" << '\n';
  }
  else {
    cout << "No" << '\n';
  }
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3556
import sys

def 解():
    iN,iM = [int(_) for _ in input().split()]
    aAB = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
    def addSpan(d,a,b):
        if a in d:
            d[a].add(b)
        else:
            d[a]={b}
    dT ={}
    for a,b in aAB:
        addSpan(dT,a,b)
        addSpan(dT,b,a)
    #とりあえずDFSで全検索だ
    iC = 0
    for a,b in aAB:
        iR = 1
        for i in dT[a] - {b}:
            aSt = [i]
            vP = {a}
            while aSt:
                iP = aSt.pop()
                vP.add(iP)
                if iP == b:
                    iR = 0
                    break
                else:
                    for nP in dT[iP] - vP:
                        aSt.append(nP)
            if iR == 0:
                break
        iC += iR
    print(iC)
解()


Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
  
  int a,b;
  scanf("%d",&a);
  scanf("%d",&b);
  
  if(a != 1 && b != 1){
    printf("1");
    return 0;
  }
    if(a != 2 && b != 2){
        printf("2");
    return 0;
  }
    if(a != 3 && b != 3){
        printf("3");
    return 0;
  }
  return 0;
}

Measured memory_bytes: 1616
N,A,B=map(int,input().split())
if (A-B)%2==0:
  print(abs(A-B)//2)
else:
  optionA=min(N-A,B-1)
  optionB=abs(A-B-1)//2+min(N-B,A-1)
  print(min(optionA,optionB))

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int cnt5 = 0;
    int cnt7 = 0;

    rep(i, 3){
        int tmp; cin >> tmp;
        if(tmp==5){
            cnt5++;
        }
        else if(tmp==7){
            cnt7++;
        }
    }

    if(cnt5==2 && cnt7==1){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict


def main():
    N = int(input())
    cnt = defaultdict(int)
    for _ in range(N):
        S = input()
        cnt[S] += 1
    for key in ['AC', 'WA', 'TLE', 'RE']:
        print(key, 'x', cnt[key])


if __name__ == "__main__":
    main()


Measured memory_bytes: 69916
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

int main(){
  int h1,h2,m1,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  cout << (h2-h1)*60 + m2-m1 -k;


return 0;
}

Measured memory_bytes: 3188
class unionfind:
  def __init__(self, n):
    self.data = [ -1 for i in range(n) ]
    
  def root(self, x):
    if self.data[x] < 0:
      return x
    else:
      self.data[x] = self.root(self.data[x])
      return self.data[x]
    
  def same(self, l, r):
    return self.root(l) == self.root(r)
  
  def join(self, l, r):
    l = self.root(l)
    r = self.root(r)
    if l == r:
      return False
    if self.data[l] > self.data[r]:
      l, r = r, l
    self.data[l] += self.data[r]
    self.data[r] = l
    return True
  
n,q,*l = map(int,open(0).read().split())
uf = unionfind(n)
for c,x,y in zip(*[iter(l)]*3):
  if c:
    print(int(uf.same(x,y)))
  else:
    uf.join(x,y)


Measured memory_bytes: 28916
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
#define int long long

signed main(){
        //int a;
        //while( scanf("%lld", &a) != EOF ){}

        int w;
        scanf("%lld",&w);
        vector<int> line(w);
        for(int i=0;i<w;i++){
                line[i] = i;
        }

        int n;
        scanf("%lld",&n);
        for(int i=0;i<n;i++){
        int a,b;
        scanf("%lld,%lld",&a,&b);
        int t = line[a-1];
        line[a-1] = line[b-1];
        line[b-1] = t;
        }

        for(int i=0;i<w;i++){
                cout << line[i] +1 << endl;
        }


        return 0;
}

Measured memory_bytes: 3148