akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
vector<vector<int> >v;
void f(int a,int b){
	int at=0;
	int h=0;
	for(int i=0;i<v.size();i++){
		for(int j=0;j<v[i].size();j++){
			if(a==v[i][j]){
				at=i;h=j;
			}
		}
	}
	for(int i=h+b;i<v[at].size();i++){
		v.push_back(vector<int>(1,v[at][i]));
	}
	int n=v[at].size()-h-b;
	for(int i=0;i<n;i++)v[at].pop_back();
}
vector<int>s;
int main(){
	int a;
	while(scanf("%d",&a),a){
		v.clear();
		for(int i=0;i<a;i++){
			v.push_back(vector<int>(1,i));
		}
		int p,q;
		while(scanf("%d%d",&p,&q),p){
			p--;q--;
			if(p==q)continue;
		//	for(vector<vector<int> >::iterator it=v.begin();it!=v.end();it++){
		//		if((*it).size()==0)v.erase(it);
		//	}
			if(q==-1){
				bool ok=false;
				for(int i=0;i<v.size();i++)if(v[i].size()&&v[i][0]==p)ok=true;
				if(!ok)f(p,0);
				continue;
			}
			int ap,aq;
			int hp,hq;
			for(int i=0;i<v.size();i++)for(int j=0;j<v[i].size();j++){
				if(p==v[i][j]){
					ap=i;hp=j;
				}
				if(q==v[i][j]){
					aq=i;hq=j;
				}
			}
			if(ap==aq){
				if(hp>hq)continue;
				f(p,0);
				int tp=0;
				int tq=0;
				for(int i=0;i<v.size();i++){
					if(v[i].size()&&v[i][0]==p){
						tp=i;
					}
					if(v[i].size()&&v[i][0]==q){
						tq=i;
					}
				}
				v[tp].clear();
				v[tq].push_back(p);
				continue;
			}
			f(p,1);
			v[ap].pop_back();
			v[aq].push_back(p);
		}
		s.clear();
		for(int i=0;i<v.size();i++)if(v[i].size())s.push_back(v[i].size());
		std::sort(s.begin(),s.end());
		for(int i=0;i<s.size();i++)printf("%d\n",s[i]);
		printf("end\n");
	}
}

Measured memory_bytes: 1084
N = int(input())
H = list(map(int, input().split()))

ans = 0

i = 0
j = 0
while i < len(H):
    j = i
    isOK = True
    while j >= 0:
        if H[i] < H[j]:
            isOK = False
            break
        j -= 1
    if isOK:
        ans += 1
    i += 1

print(ans)

Measured memory_bytes: 3064
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (A, B, C, D): (i64, i64, i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let ans = if A + B > C + D {
        "Left"
    } else if A + B == C + D {
        "Balanced"
    } else {
        "Right"
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
import sys
def factorization(n):
    arr = []
    temp = n
    ele = 1
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp % i == 0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


if __name__ == "__main__":
    n = int(input())
    if n == 1:
        print(0)
        sys.exit(0)
    ar = factorization(n)
    ans = 0
    for ele in ar:
        cnt = ele[1]
        num = 1
        while True:
            if cnt - num < 0:
                break
            else:
                cnt -= num
                num += 1
        ans += num - 1
    print(ans)

Measured memory_bytes: 9496
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int  n;
int res[505][505];
void dfs(int start,int to,int index){
	if(to-start+1<=1) return;
for(int i=start;i<to;i++)
		for(int j=i+1;j<=to;j++) {res[i][j]=index;
		}
	int mid=(start+to)>>1;
dfs(start,mid,index+1),dfs(mid+1,to,index+1);
}
int main(){
	cin>>n;
dfs(1,n,1);
	for(int i=1;i<n;i++)
        for(int j=i+1;j<=n;j++)
	cout<<res[i][j]<<" ";
}

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

typedef long long ll;

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

int N;

int main() {
  scanf("%d", &N);
  if (N < 10) {
    printf("%d\n", N);
  } else if (N < 100) {
    printf("%d\n", 9);
  } else if (N < 1000) {
    printf("%d\n", 9+N-100+1);
  } else if (N < 10000) {
    printf("%d\n", 909);
  } else if (N < 100000) {
    printf("%d\n", 909 + N - 10000+1);
  } else {
    printf("%d\n", 90909);
  }
  
  return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Set<Character> set = new HashSet<>();
		set.add('A');
		set.add('C');
		set.add('G');
		set.add('T');
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int max = 0;
		for (int i = 0; i < S.length(); i++) {
			int tmp = 0;
			for (int j = i; j < S.length(); j++) {
				if (set.contains(S.charAt(j))) {
					tmp++;
				} else {
					break;
				}
			}
			max = Math.max(max, tmp);
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 21844
def abc144_e():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    F = list(map(int, input().split()))
    A.sort()
    F.sort(reverse=True)

    low = -1
    up = 10**12
    while up - low > 1:
        v = (up + low) // 2
        tk = K
        for i in range(N):
            tk -= max(0, A[i] - (v // F[i]))
            if tk < 0: break
        if tk < 0:
            low = v
        else:
            up = v
    print(up)

if __name__ == '__main__':
    abc144_e()

Measured memory_bytes: 113844
#include<stdio.h>
#include <stdlib.h>
typedef struct{
  int id,parent,depth,type; //type:0,root,1,internal node, 2,leaf
  int num; //nimber of data
  int *data;
}treenode;
int main(){
  int n,d,i,j,k,id;
  int cnt = 1;
  char ttype[3][20] = {"root","internal node","leaf"};
  treenode *a;
  scanf("%d",&n);
  a = (treenode *)malloc(sizeof(treenode)*n);
  for(i =0;i < n;i++){
    scanf("%d %d",&id,&j);
    a[id].id = id;
    a[id].num = j;
    a[id].data = malloc(sizeof(int)*j);
    a[id].depth = 0;
    a[id].parent = -1;
    for(k =0;k <j;k++){
       scanf("%d",&a[id].data[k]);
     }
  }
  while(cnt != 0){
    cnt = 0;
    for(i =0;i < n;i++){
      for(k =0;k < a[i].num;k++){
        a[a[i].data[k]].parent = a[i].id;
        if(a[a[i].data[k]].depth != a[i].depth + 1){
          a[a[i].data[k]].depth = a[i].depth + 1;
          cnt++;
        }
      }
    }
 }
  for(i =0;i < n;i++){
    if(a[i].parent == -1)  a[i].type = 0;
    else if(a[i].num == 0)  a[i].type = 2;
    else a[i].type = 1;
    printf("node %d: parent = %d, depth = %d, %s, [",a[i].id,a[i].parent,a[i].depth,ttype[a[i].type]);
    if(a[i].num != 0){
      for(j =0;j < a[i].num - 1;j++) printf("%d, ",a[i].data[j]);
      printf("%d]\n",a[i].data[j]);
    }else printf("]\n");
  }
  return 0;
}



Measured memory_bytes: 8348
use std::str::FromStr;
fn main() {
    let mut ab = String::new();
    std::io::stdin().read_line(&mut ab).ok();
    let mut it = ab.split_whitespace().map(|n| usize::from_str(n).unwrap());
    let (a,b) = (it.next().unwrap(),it.next().unwrap());
    if a + b == 15 {
        println!("+");
    } else if a * b == 15 {
        println!("*");
    } else {
        println!("x");
    }
}

Measured memory_bytes: 4352
<?php
define("MOD", 10**9+7);
fscanf(STDIN, "%d%d", $N, $M);

for($j = 2; $j <= $M; $j++){
    if($M%$j == 0){
        @$map[$j]++;
        $M/=$j;
        $j--;
    }
}
$product = 1;
foreach($map as $prime => $count){
    $product *= nCm($count + $N - 1, $count);
    $product %= MOD;
}
echo $product;

//足し算
function addm($a, $b){
    return ($a + $b) % MOD;
}
//引き算
function subm($a, $b){
    return ($a + MOD - $b) % MOD;
}
//掛け算
function mulm($a, $b){
    return ($a * $b) % MOD;
}
//割り算
function divm($a, $b){
    return mulm($a, powerm($b, MOD - 2));
}
//累乗
function powerm($a, $b){
    if($b == 0)return 1;
    if($b & 1)return (powerm($a, $b>>1)**2 % MOD) * $a % MOD;
    return powerm($a, $b>>1)**2 % MOD;
}
//階乗
function factorialm($a){
    if($a == 0)return 1;
    return factorialm($a - 1) * $a % MOD;
}
//順列
function nPm($n, $m){
    static $memo;
    if($m == 0)return 1;
    if(!isset($memo[$n][$m])){
        $memo[$n][$m] = nPm($n, $m - 1) * ($n - $m + 1) % MOD;
    }
    return $memo[$n][$m];
}
//組み合わせ
function nCm($n, $m){
    static $memo;
    if(!isset($memo[$n][$m])){
        $m = min($m, $n-$m);
        $memo[$n][$m] = divm(nPm($n, $m), factorialm($m));
    }
    return $memo[$n][$m];
}

Measured memory_bytes: 4604
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static private int sample = 0;
	static private InputStream in;
	static private PrintStream out;
	static private Scanner sc;
	static {
		if(sample == 0) {
			in = System.in;
			out = System.out;
		}else {
			try {
				in = new FileInputStream(new File("sample"+sample));
				out = new PrintStream("result"+sample);
			} catch (Exception e) {
				e.printStackTrace();
				System.exit(1);
			}
		}
		sc = new Scanner(in);
	}
	static public boolean fileCompare2(String fileA, String fileB) {
		boolean bRet = false;
		try {
			bRet = Arrays.equals(Files.readAllBytes(Paths.get(fileA)), Files.readAllBytes(Paths.get(fileB)));
		} catch (IOException e) {
		}
		return bRet;
	}
	static public void exit() {
		if(sample!=0) {
			out.close();
			String sam = "sample"+sample;
			String ans = "answer"+sample;
			String res = "result"+sample;
			if(fileCompare2(ans, res)) {
				System.out.println("AC");
			}else {
				System.out.println("WA");
				try {
					System.out.println(new String(Files.readAllBytes(Paths.get(ans))));
					System.out.println(new String(Files.readAllBytes(Paths.get(res))));
					System.out.println(new String(Files.readAllBytes(Paths.get(sam))));
				} catch (IOException e) {
				}
			}
		}
		sc.close();
	}
	static public void main(String ...strings ) {
		try {
			final int r = sc.nextInt();
			out.println(3*r*r);
		} finally {
			exit();
		}
	}
}


Measured memory_bytes: 24148
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>
using namespace std;

int main() {
	int a, b;
	cin >> a;
	cin >> b;

	if (b % a == 0) {
		cout << a + b << endl;
	}
	else {
		cout << b - a << endl;
	}

	return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, k, q, inp;
    map<ll, ll> mpl;
    cin >> n >> k >> q;
    for(ll i=0; i<q; i++){
        cin >> inp;
        mpl[inp] = mpl[inp] + 1;
    }
    for(ll i=0; i<n; i++){
        if(k - (q-mpl[i+1]) <= 0)
            cout << "No\n";
        else
            cout << "Yes\n";
    }
    return 0;
}

Measured memory_bytes: 6912
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod=1e9+7;
int pot(int a,int b){
  if(b==0)return 1;
  int x=pot(a,b/2);
  if(b%2)return x*x%mod*a%mod;
  return x*x%mod;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int N,K;
    cin>>N>>K;
    int p=1;
    vector<int> pos,neg;
    int togli=0;
    for(int i=0;i<N;i++){
      int x;
      cin>>x;
      if(x==0)togli++;
      else{
        p=p*x%mod;
        if(x>=0)pos.push_back(x);
        else neg.push_back(x);
      }
    }
    N-=togli;
    if(N<K){
      cout<<0;
      return 0;
    }
    sort(neg.begin(),neg.end());
    sort(pos.begin(),pos.end(),greater<int>());
    if(pos.size()==0 && K%2){
        reverse(neg.begin(),neg.end());
        if(togli){
          cout<<0;
          return 0;
        }
    }
    while(K!=N){
      if(neg.size()%2){
        p=p*pot(neg.back(),mod-2)%mod;
        neg.pop_back();
        N--;
        continue;
      }
      if((N-K)%2){
        if(pos.size()){
          p=p*pot(pos.back(),mod-2)%mod;
          pos.pop_back();
          N--;
          continue;
        }
        p=p*pot(neg.back(),mod-2)%mod;
        neg.pop_back();
        N--;
        continue;
      }
      if(pos.size()>1 && neg.size()>1){
        if(neg.back()*neg[neg.size()-2]<pos.back()*pos[pos.size()-2]){
          p=p*pot(neg.back(),mod-2)%mod;
          neg.pop_back();
          N--;
          p=p*pot(neg.back(),mod-2)%mod;
          neg.pop_back();
          N--;
          continue;
        }else{
          p=p*pot(pos.back(),mod-2)%mod;
          pos.pop_back();
          N--;
          p=p*pot(pos.back(),mod-2)%mod;
          pos.pop_back();
          N--;
          continue;
        }
      }
      if(pos.size()>1){
          p=p*pot(pos.back(),mod-2)%mod;
          pos.pop_back();
          N--;
          p=p*pot(pos.back(),mod-2)%mod;
          pos.pop_back();
          N--;
          continue;
      }
      p=p*pot(neg.back(),mod-2)%mod;
      neg.pop_back();
      N--;
      p=p*pot(neg.back(),mod-2)%mod;
      neg.pop_back();
      N--;
      continue;
    }
    cout<<(p+mod)%mod;
}

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

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

    int n;
    cin >> n;

    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0) {
            cout << ' ' << i;
        } else {
            int check = i;
            while (check) {
                if (check % 10 == 3) {
                    cout << ' ' << i;
                    break;
                }
                check /= 10;
            }
        }
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 3088
# -*- coding: utf-8 -*-

"""
二分探索
"""

from bisect import bisect_left

N = int(input())
sN = list(map(int, input().split()))
Q = int(input())
tQ = list(map(int, input().split()))

cnt = 0
for i in range(Q):
    idx = bisect_left(sN, tQ[i])
    # 探す要素が大きいとidxが範囲外にでるのでidx < N
    if idx < N and sN[idx] == tQ[i]:
        cnt += 1
print(cnt)



Measured memory_bytes: 16752
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
template<class T> inline bool chmax(int a, int b, T c, T d) { return c > d ? a : b; }
template<class T> inline bool chmin(int a, int b, T c, T d) { return c > d ? a : b; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<ppr, Vppr, greater<ppr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 3e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;
ut N, M, K, L, Q, D, H, W, R;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
LL maps[SIZE2][SIZE2];
//LL A[SIZE];
string n;
LL f(int x) {
	LL used = x * 9;
	LL next = 0;
	REP(i, n.size()) {
		LL c = n[i] - '0';
	//	cout << used << endl;
		if (used < c) return 0;
		used-=(10+used+next-c)%10;
		next = (used+next) / 10;
	}
	return true;
}
LL solve() {
	cin >> n;
	int s = 1,e = 600000;
	reverse(ALL(n));
	//cout << n << endl;
	while (s <= e) {
		int mid = (s + e) / 2;
	//	cout << mid << endl;
		if (f(mid)) {
			e = mid - 1;
		}
		else {
			s = mid + 1;
		}
	}
	cout << s << endl;
	return 0;
}




//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	solve();


	//cin >> N;
	return 0;

}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){

  while(x->left!=NIL){
    x=x->left;
  }

  return x;

}

Node treeSearch(Node u, int k){

  if(u==NIL || k==u->key) return u;
  if(k<u->key) return treeSearch(u->left,k);
    else return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){

  if (x->right!=NIL) return treeMinimum(x->right);
    
  /*y=x->parent;

  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
  */
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key) x=x->left;
    else x=x->right;
    z->parent=y;
  }

    if(y==NIL) root=z;
    else if (z->key<y->key)
		 y->left=z;
    else y->right=z;

}

void inorder(Node u){

  if(u!=NIL) {

    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);

  }

}
void preorder(Node u){

  if(u!=NIL){

  printf(" %d",u->key);
 preorder(u->left);
 preorder(u->right);

  }

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int sum = a + b;
			
			System.out.println(Integer.toString(sum).length());
		}
	}
}

Measured memory_bytes: 20448
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		int[][] result = new int[1000][];
		int index = 0;
		
		while( a != 0 || b != 0 || c != 0 ){
			int N = stdIn.nextInt();
			int[][] check = new int[N][4];
			for(int i = 0; i < N; i++){
				for(int j = 0; j < 4; j++){
					check[i][j] = stdIn.nextInt();
				}
			}
			result[index] = new int[a+b+c];
			for(int i = 0; i < N; i++){
				if( check[i][3] == 1 ){
					for(int j = 0; j < 3; j++){
						result[index][check[i][j]-1] = -1;
					}
				}
			}
			for(int i = 0; i < N; i++){
				if( check[i][3] == 0 ){
					int count = 0;
					int key = -1;
					for(int j = 0; j < 3; j++){
						if( result[index][check[i][j]-1] == -1 ){
							count++;
						} else {
							key = j;
						}
					}
					if( count == 2 ){
						result[index][check[i][key]-1] = -2;
					}
				}
			}
			index++;
			a = stdIn.nextInt();
			b = stdIn.nextInt();
			c = stdIn.nextInt();
		}
		
		for(int i = 0; i < index; i++){
			for(int j = 0; j < result[i].length; j++){
				System.out.println(result[i][j]+2);
			}
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;




int main(){
	ll x; cin>>x;

	for(ll a=-150;a<150;a++){
		for(ll b=-150;b<150;b++){
			ll a5=pow(a,5);
			ll b5=pow(b,5);
			if((a5-b5)==x){
				cout<<a<<" "<<b<<endl;
				return 0;
			}
		}
	}
}


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

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
const int  p=31,po=1,N=50001, M=(ll)1e9+1 ;
const int mod = (ll)1e9 +7;
// struct node{
//   ll prefixsum,suffixsum,bettersum,totalsum;
//   void create(ll val){
//     prefixsum=suffixsum=bettersum=val;
//   }
//   void Merge(node& a,node &b){
//     prefixsum=max(a.prefixsum,a.totalsum+b.prefixsum);
//     suffixsum=max(b.suffixsum,a.suffixsum+b.sum);
//     totalsum=a.totalsum+b.totalsum;
    
//   }
// }
//ll dp[2][100];
vl compute(string s){
        vl has(s.length());
        ll i;

        for(i=0;i<s.length();i++){
            if(i==0){
                has[i]=((s[i]-'a'+1))%mod;
            }
            else
                has[i]=(has[i-1]*p + (s[i]-'a'+1))%mod;
        }
        return has;
}


int main(){
 ios_base::sync_with_stdio(0);
  ll i,n,j,k;
  cin >> n >> k;
  vl h(n+1),ans(n+1,INT_MAX);
  for(i=1;i<=n;i++)
    cin >> h[i];
  ans[1]=0,ans[0]=INT_MAX;
  for(i=2;i<=n;i++){
    for(j=1;j<=k;j++){
      if(i-j==0)
        break;
    ans[i]=min(ans[i-j]+abs(h[i]-h[i-j]),ans[i]);
    }
  }
    cout << ans[n];
    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int main(){
    iostream::sync_with_stdio(false);

    int K,S;
    cin >> K >> S;
    long long ans = 0;
    for(int i=0; i<=K; i++){
        for(int j=0; j<=K; j++){
            if(i+j <= S && S-i-j <= K) ans++;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int selectSort(int [], int);
int main() {
	int n;
	int A[100];
	cin >> n;
	for(int i=0; i<n; i++)
		cin >> A[i];
	cout << selectSort(A, n) << endl;
	return 0;
}
int selectSort(int A[], int n){
	int sw = 0;
	for(int i=0; i<n; i++){
		int minj = i;
		for(int j=i; j<n; j++){
			if(A[j] < A[minj]){
				minj = j;
			}
		}
		if(minj != i){
			int t = A[i];
			A[i] = A[minj];
			A[minj] = t;
			sw ++;
		}
	}
	for(int i=0; i<n-1; i++){
		cout << A[i] << ' ';
	}
	cout << A[n-1] << endl;
	return sw;
}

Measured memory_bytes: 3096
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int LEN = 100005;

typedef struct pp{ //typedefを使うことでPの宣言でstruct pp {~}の宣言になる
  char name[100];
  int t;
} P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){ // キューの末尾に要素ｘを追加する
    Q[tail] = x;
    tail = (tail + 1) % LEN; //LENを超えたときに0に戻る（わっかみたいになる）

}

P dequeue(){ // キューの先頭から要素を取り出す
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail = n + 1;
  while(head != tail){
      u = dequeue();
      c = min(q, u.t);
      u.t -= c;
      elaps += c;
      if (u.t > 0) enqueue(u);
      else
      {
          printf("%s %d\n", u.name, elaps);
      }
      
  }
  return 0;
}


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

const int maxn = 1e5+10;

int f[maxn];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n = 0;
	int k = 0;
	cin >> n >> k;

	long double res = 0;
	int t = 1;
	int cnt = 0;
	while (t < k) {
		t *= 2;
		cnt++;
	}
	cerr <<cnt << endl;
	for(int i=1;i<=n;i++) {
		int cnt = 0;
		int t = i;
		while (t < k) {
			t <<= 1;
			cnt++;
		}
		f[cnt]++;
	}

	for(int i=0;i<50;i++) {
		res += pow(2, -(i)) * f[i];
	}
	cerr << res << endl;
	res /= n;

	cout << fixed << setprecision(12) << res;
	return 0;
	
}


Measured memory_bytes: 256
A,B,C,D  = map(int, input().split())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#Cの倍数
if A % C ==0:
    C_start = A // C
else:
    C_start = (A//C)+1

C_end = B//C
C_count =-C_start+C_end+1

#Dの倍数
if A % D ==0:
    D_start = A // D
else:
    D_start = (A//D)+1

D_end = B//D
D_count =-D_start+D_end+1

#CとDの倍数
CD=C*D//gcd(C, D)
if A % CD ==0:
    CD_start = A // CD
else:
    CD_start = (A//CD)+1

CD_end = B//CD
CD_count =-CD_start+CD_end+1

count = (B-A+1)-(C_count +D_count -CD_count)
print(count)

Measured memory_bytes: 3064
l = [0,0,0,0]
for i in range(3):
    a,b = map(int,input().split())
    l[a-1] += 1
    l[b-1] += 1

if (max(l) == 3)or(min(l) == 0):
    print("NO")
else:
    print("YES")



Measured memory_bytes: 2940
n=int(input())
ans=0
i=0
if n%2==0:
  while n%2==0:
    i+=1
    n//=2
def judge(n):
  s=0
  i=0
  while s<=n:
    i+=1
    s=i*(i+1)//2
  return i-1
ans+=judge(i)
for i in range(3,int(n**0.5),2):
  if n%i==0:
    cnt=0
    while n%i==0:
      n//=i
      cnt+=1
    ans+=judge(cnt)
if n!=1:
  ans+=1
print(ans)

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

grid=[["#"for i in range(100)]for j in range(50)]+[["."for i in range(100)]for j in range(50)]
#print(grid)

print(100,100)
a-=1  #下半分がその色だから
for i in range(1,49):
    for j in range(1,99):
        if all([ grid[i+x][j+y]=="#" for x,y in ((0,0),(0,1),(1,0),(-1,0),(0,-1),(1,1),(-1,1),(1,-1),(-1,-1))]):
            if a==0:
                break
            grid[i][j]="."
            a-=1

            
    if a==0:
        break
b-=1
for i in range(51,99):
    for j in range(1,99):
        if all([ grid[i+x][j+y]=="." for x,y in ((0,0),(0,1),(1,0),(-1,0),(0,-1),(1,1),(-1,1),(1,-1),(-1,-1))]):
            if b==0:
                break
            grid[i][j]="#"
            b-=1

            
    if b==0:
        break
for i in grid:
    print("".join(i))

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

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

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

int main(){
  int n;
  cin>>n;
  unordered_map<int,int> ma,mb;
  rep(i,n){
    int t;
    cin >> t;
    if(i%2==0) ma[t]++;
    if(i%2==1) mb[t]++;
  }
  vector<pair<int,int>> va,vb;
  for(auto x:ma){
    va.push_back(make_pair(x.second,x.first));
  }
  for(auto x:mb){
    vb.push_back(make_pair(x.second,x.first));
  }
  sort(va.begin(),va.end());
  reverse(va.begin(),va.end());
  sort(vb.begin(),vb.end());
  reverse(vb.begin(),vb.end());
  va.push_back(make_pair(0,-1));
  vb.push_back(make_pair(0,-1));
  int ans = 0;
  if(va[0].second!=vb[0].second)ans = n-va[0].first-vb[0].first;
  else {
    int t = max(va[0].first+vb[1].first,va[1].first+vb[0].first);
    ans = n - t;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5524
from sys import stdin, stdout

def checkDocs(numbers):
  for a in numbers:
    if a%2:
      continue
    
    if a%3 and a%5:
      return False
  return True

N = int(stdin.readline().strip())
nums = list(map(int, stdin.readline().strip().split()))

if checkDocs(nums):
  stdout.write("APPROVED")
else:
  stdout.write("DENIED")

Measured memory_bytes: 3060
#include<stdio.h>
int n;
void dfs(char* s,int now){
    char max='a';for(int i=0;i<now;i++)if(s[i]>max)max=s[i];
    for(char i='a';i<=max+1;i++){
        s[now]=i;
        now!=n-1?dfs(s,now+1):printf("%s\n",s);
    }
}
int main(){
    scanf("%d",&n);
    char s[20]="";
    s[0]='a';s[n]='\0';
    n==1?printf("%s\n",s):dfs(s,1);
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k;
    cin >> n >> k;
    ll ans = n;
    if (n == k) {
        ans = 0;
    }
    else {
        if (n % k == 0) n = k;
        else n = n % k;
        ans = min(ans, n);
        rep(i, 10) {
            n = abs(n - k);
            ans = min(ans, n);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  S+='R';
  int L=S.size();
  vector<int> C(L-1);
  int rcnt=0; int lcnt=0; int spot=0;
  for(int i=0; i<L-1; i++){
    if(S[i]=='R' && S[i+1]=='R'){
      C[i]=0;
      rcnt++;
    }
    if(S[i]=='L' && S[i+1]=='L'){
      C[i]=0;
      lcnt++;
    }
    if(S[i]=='R' && S[i+1]=='L'){
      spot=i;
      rcnt++;
    }
    if(S[i]=='L' && S[i+1]=='R'){
      lcnt++;
      if((rcnt+lcnt)%2==0){
        C[spot]=(rcnt+lcnt)/2;
        C[spot+1]=(rcnt+lcnt)/2;
      }
      else if(rcnt%2!=0){
        C[spot]=(rcnt+lcnt)/2+1;
        C[spot+1]=(rcnt+lcnt)/2;
      }
      else{
        C[spot]=(rcnt+lcnt)/2;
        C[spot+1]=(rcnt+lcnt)/2+1;
      }
      rcnt=0;
      lcnt=0;
    }
  }
  for(int i=0; i<L-1; i++) cout << C[i] << ' ';
  cout << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iomanip> 
using namespace std; 
#define rep(i,a,b)		for(long int i=a;i<=b;i++)
#define MOD 1e9+7

int ans = 0,n,d,x,a[102],k;
int main() 
{ 
	ios::sync_with_stdio(false);
    cin.tie(NULL);  
   
	cin>>n>>d>>x;
	ans = x+n;
	rep(i,1,n)
	{
		cin>>a[i];
		k=1;
		while(((k++)*a[i]+1)<=d)
			ans++;
	}
	cout<<ans;
}
	

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;
const int inf = 1e9;

struct info{
	int n,d,e;
	info(int n, int d, int e):n(n),d(d),e(e){}
};
namespace std{
	bool operator < (const info &a, const info &b){
		return b.e < a.e;
	}
}
int main(){
	while(1){
		int n,m,l;
		cin >> n >> m >> l;
		if(n==0) break;
		
		vector<vector<info> > adj(n+1);
		for(int i=0; i<m; i++){
			int a,b,d,e;
			cin >> a >> b >> d >> e;
			adj[a].push_back(info(b,d,e));
			adj[b].push_back(info(a,d,e));
		}
		
		priority_queue<info> wait;
		wait.push(info(1,l,0));
		vector<vector<int> > mincost(n+1, vector<int>(l+1, inf));
		mincost[1][l] = 0;
		while(!wait.empty()){
			int cur = wait.top().n;
			int money = wait.top().d;
			int cost = wait.top().e;
			wait.pop();
			if(cost > mincost[cur][money]) continue;
			for(int i=0; i<(int)adj[cur].size(); i++){
				info next = adj[cur][i];
				if(cost + next.e < mincost[next.n][money]){
					mincost[next.n][money] = cost+next.e;
					wait.push(info(next.n, money, cost+next.e));
				}
				if(money >= next.d && cost < mincost[next.n][money-next.d]){
					mincost[next.n][money-next.d] = cost;
					wait.push(info(next.n, money-next.d, cost));
				}
			}
		}
		
		int ans = inf;
		for(int i=0; i<=l; i++){
			ans = min(ans, mincost[n][i]);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3392
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define range_for(i, b, e) for(int i=(b), i##_len=(e); i<=i##_len; ++i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define pb push_back
# define len(x) ((int)(x).size())
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
# define LINT_MAX (LONG_LONG_MAX)
# define cauto const auto
using namespace std;
using lint = long long;
template <class Type> inline constexpr bool InRange(const Type& x, const Type& i, const Type& a) { return (i <= x) && (x <= a); }
template<class Integer>bool chmax(Integer &a, const Integer &b) { if (a<b) { a=b; return 1; } return 0; }
template<class Integer>bool chmin(Integer &a, const Integer &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Integer>bool IsOdd(Integer &n) { return n & 1; }
template<class Integer>bool IsEven(Integer &n) { return !(n & 1); }
int ctoi(const char c) { return ('0' <= c && c <= '9') ? (c - '0') : -1; }
string YesNo(bool b) { return b ? "Yes" : "No"; }
string YESNO(bool b) { return b ? "YES" : "NO"; }
string yesno(bool b) { return b ? "yes" : "no"; }
static const lint MOD9 = (lint)1e9+7;
int dy[4] = {0, 1, 0, -1};
int dx[4] = {1, 0, -1, 0};

// 整数の桁数を返す ( log(N) )
template <class Integer> Integer GetDigit(Integer n) {
    Integer d = 0;
    while (n) {
        n /= 10;
        d++;
    }
    return d;
}

// 素数かどうかを返す ( O(sqrt(N)) )
template <class Integer>
constexpr bool IsPrime(const Integer n) noexcept {
    if (n < 4) return n == 2 || n == 3;
    if (n % 2 == 0 || n % 3 == 0 || (n % 6 != 1 && n % 6 != 5)) return false;
    for (Integer i = 5; i * i <= n; i += 6) if (n % i == 0 || n % (i + 2) == 0) return false;
    return true;
}


int main()
{
    string N; cin >> N;
    cout << YesNo(count(ALL(N), '7')) << endl;


    return 0;
}



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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

//-----------------------------------------------------------------------

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

    int n;
    while(cin>>n,n){
        vector<int> v(n);
        REP(i,n){
            string s; cin>>s;
            v[i]=s.size();
        }

        REP(i,n){
            int pos=i;
            int j,A[]={5,7,5,7,7};
            for(j=0;j<5;j++){
                int cnt=0;
                while(pos<n && cnt<A[j]) cnt+=v[pos++];
                if(cnt!=A[j]) break;
            }
            if(j==5){
                cout<<i+1<<endl; break;
            }
        }
    }
}



Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}

int main()
{
   ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
ll n,k; cin>>n>>k;
ll a[n];
ll dp[n+25];
for(ll i=0;i<n;i++)
{
	cin>>a[i];
}
for(ll i=0;i<=n;i++){
	dp[i]=1e12;
}
dp[0]=0;
for(ll i=1;i<n;i++)
{
for(ll j=1;j<=k;j++)
{
	if(j<=i)
	{
		dp[i]=min(dp[i],dp[i-j]+abs(a[i-j]-a[i]));
	}
}
}
cout<<dp[n-1]<<endl;
}

 


Measured memory_bytes: 5192
=begin
a = gets.to_i
s = gets

if a < 3200
  puts "red"
else
  puts s
end
=end

b = gets.to_i
a = gets.split(" ").map{|x| x.to_f}
sum = 0.0
b.times do |i|
  sum += 1/a[i]
end
p 1 / sum


Measured memory_bytes: 1788
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int X = sc.nextInt();
    int[] C = new int[N];
    int[][] A = new int[N][M];
    int ans = 0;
    for(int i=0;i<N;i++){
      C[i] = sc.nextInt();
      ans+=C[i];
      for(int j=0;j<M;j++){
        A[i][j] = sc.nextInt();
      }
    }
    boolean anscheck = false;
    for(int i=0;i<Math.pow(2,N);i++){
      int cost = 0;
      boolean levelcheck = true;
      int[] level = new int[M];
      for(int j=0;j<N;j++){
        if((1&i>>j)==1){
          cost+=C[j];
          for(int k=0;k<M;k++){
            level[k]+=A[j][k];
          }
        }
      }
      for(int l=0;l<M;l++){
        if(!(level[l]>=X)){
          levelcheck = false;
          break;
        }
      }
      if(levelcheck==true){
        ans = Math.min(ans,cost);
        anscheck = true;
      }
    } 
    if(anscheck){
      System.out.println(ans);
    }else{
      System.out.println(-1);
    }
  }
}


Measured memory_bytes: 37688
n,m = gets.split().map(&:to_i)
l = []
r = []
y = 0
m.times do
  x = gets.split().map(&:to_i)
  l << x[0]
  r << x[1]
  if x[0] == x[1]
    y = 1
  end
end
min = l.sort.reverse.first
max = r.sort.first
if max < min
  ans = 0
elsif max == min
  ans = 1
else
  ans = max - min + 1
end
if y == 0
  puts ans
elsif ans != 0
  puts 1
else
  puts ans
end



Measured memory_bytes: 6440
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n + 1); ++i)
using namespace std;
using ll = long long;
const int INF = +100100100;
typedef pair<int,int> P;


int main(){
    int n;
    cin >> n;
    int MAX = 10500;
    vector<int> a(n),b(n),c(n);
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        cin>>b[i];
    }
    rep(i,n){
        cin>>c[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll ans =0;
    rep(i,n){
        // cout << "original " << distance(a.begin(),lower_bound(a.begin(),a.end(),b[i]))<<endl;
        // int a_long =  lower_bound(a.begin(),a.end(),b[i])-a.begin();
        ll a_long = distance(a.begin(),lower_bound(a.begin(),a.end(),b[i]));
        // int c_long =  c.end() - lower_bound(c.begin(),c.end(),b[i]);
        ll c_long = distance(upper_bound(c.begin(),c.end(),b[i]),c.end());
        ans+=a_long*c_long;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,a[1000000],c=1,ans=0;
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int i=0;i<n;i++){
    if(a[i]==c)
      c++;
    else
      ans++;
  }
  if(ans==n)
    cout<<"-1"<<endl;
  else
    cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
const ll MOD=1e9+7;

struct segtree{
    vector<ll> dat;
    int size;
    segtree(int n):dat(2*n-1,(1LL<<31)-1),size(n){};
    void update(int i,ll a){
        i+=this->size-1;
        dat[i]=a;
        while(i>0){
            i=(i-1)/2;
            dat[i]=min(dat[i+2+1],dat[i*2+2]);
        }
    }
    ll query(int a,int b){
        return querysub(a,b,0,0,this->size);
    }
    ll querysub(int a,int b,int k,int l,int r){
        if(r<=a||b<=l) return (1LL<<31)-1;
        else if(a<=l&&r<=b) return dat[k];
        else{
            ll vl=querysub(a,b,k*2+1,l,(l+r)/2);
            ll vr=querysub(a,b,k*2+2,(l+r)/2,r);
            return min(vl,vr);
        }
    }
};
int main(){
    int n;cin>>n;
    string s;cin>>s;
    int c=0;
    for(int i=0;i<n;++i)if(s[i]=='R') c++;
    int ans=0;
    for(int i=0;i<c;++i)if(s[i]=='W') ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define int long long
using namespace std;

int power(int a, int n) {
	if (n == 0) return 1;
	if (n % 2 == 0) return power(a * a, n / 2);
	return a * power(a, n - 1);
}

int n, p;

signed main() {
	cin >> n >> p;
	
	int t = p, ans = 1;
	for (int i = 2; i * i <= t; i++) {
		int cnt = 0;
		while (t % i == 0) {
			t /= i;
			cnt++;
		}
		ans *= power(i, (cnt / n));
	}
	if (t > 1) ans *= power(t, 1 / n);
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[]
b=[]
c=0
for i in range(10):
    for j in range(10):
        a.append(0)
    b.append(a)
    a=[]
for i in range(n):
    b[int(str(i+1)[0])][int(str(i+1)[-1])]+=1
for i in range(10):
    for j in range(10):
        c+=b[i][j]*b[j][i]
print(c)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    // 累積和、答えを決め打って二分探索
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) {
        int x;
        cin >> x;
        A[--x]++;
    }
    sort(A.begin(), A.end()); // 0はそのまま無視
    vector<int> Acum(N+1);
    rep(i, N) Acum[i+1] = Acum[i] + A[i];
    for (int k = 1; k <= N; k++) {
        ll ok = 0; ll ng = N+1;
        while (abs(ng - ok) > 1) {
            ll mid = (ok + ng) / 2;
            bool bl = [&] {
                auto ind = lower_bound(A.begin(), A.end(), mid) - A.begin();
                int temp = Acum[ind] + mid * (N - ind);
                return (temp >= mid * k);
            }();
            if (bl) ok = mid;
            else ng = mid;
        }
        printf("%d\n", ok);
    }
    return 0;
}


Measured memory_bytes: 5612
//In The Name Of The God

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define F first
#define S second
#define X first.first
#define Y first .second
#define A second.first
#define B second.second
#define mp make_pair
#define pb push_back
#define pf push_front
#define P push
#define pob pop_back
#define pof pop_front
#define PO pop
#define rep(i,j,k) for(int i = j ; i <= k ; ++ i)
#define rrep(i,j,k) for(int i = j ; i>=k ; --i)
#define FR(i,j,k) for(int i = j ; i < k ; ++ i )
#define rFR(i,j,k) for(int i = j ; i > k ; -- i )
#define lb(x) x&-x;
#define SZ size()
#define LB lower_bound
#define UB upper_bound
#define IT iterator
#define RIT reverse_iterator
#define E end()
#define BE begin()
#define RE rend()
#define RBE rbegin()
#define UN unsigned

typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll ;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<int,pll> pipl;
typedef pair<pll,int> ppli ;
typedef pair<pll,pll> plpl ;
typedef pair<ll,pii> lpip;
typedef pair<pii,ll> lppi;
typedef pair<pii,pii> lppp;
typedef pair<ll,pll> lpipl;
typedef pair<pll,ll> lppli ;
typedef pair<pll,pll> lplpl ;
typedef vector<int> vi ;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii > stpi;
typedef set<pll> stpl;
typedef vi::IT vit;
typedef vl::IT vlt;
typedef vpi::IT vpit;
typedef vpl::IT vplt;
typedef sti::IT stit;
typedef stl::IT stlt;
typedef stpi::IT stpit;
typedef stpl::IT stplt;
typedef vpi::RIT rvpit;
typedef vpl::RIT rvplt;
typedef sti::RIT rstit;
typedef stl::RIT rstlt;
typedef stpi::RIT rstpit;
typedef stpl::RIT rstplt;

const int MAXN = 500000;
const int SUPERN = 5000000;
const int MD = 1e9+7;
//......Structures.......

//......Variables........
ll a,b,n,mn,mx;
//......Funcs............

//......Code.............
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>a>>b;
    mn=a*(n-1)+b;
    mx=b*(n-1)+a;
    if(a>b||(n==1&&a!=b))
    {
        cout<<0;
        return 0;
    }
    cout<<mx-mn+1;
    return 0;
}


Measured memory_bytes: 256
S = input()
T = input()
ans = float('inf')
d = len(S) - len(T) + 1

for i in range(d):
  cnt = 0
  
  for j in range(len(T)):
    if S[i + j] != T[j]:
      cnt += 1
      
  ans = min(ans, cnt)

print(ans)

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	ll a,b,c,x,y;

	cin >> a >> b >> c >> x >> y;

	ll ans = 1e10;
	for(ll u = 0; u <= 2 * max(x, y); u += 2){
		ll s = max(x - u / 2, 0LL);
		ll t = max(y - u / 2, 0LL);
		ll v = a * s + b * t + c * u;
		ans = min(ans, v);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
ll C(int c) {
    ll r=1;
    for (int i=2; i<=c; i++) r*=i;
    return r;
}
int main() {
    string s; cin>>s;
    map<char, int> cnt;
    for (int i=0; i<s.length(); i++) {
        if (cnt.find(s[i])!=cnt.end()) {
            cnt[s[i]]++;
        } else {
            cnt[s[i]]=1;
        }
    }
    int c=0, odd=0;
    for (map<char, int>::iterator it=cnt.begin(); it!=cnt.end(); it++) {
        if ((*it).second%2!=0) {
            odd++;
        }
    }
    if (odd>1) {
        puts("0");
    } else {
        ll res=C(s.length()/2);
        for (map<char, int>::iterator it=cnt.begin(); it!=cnt.end(); it++) {
            res/=C((*it).second/2);
        }
        printf("%lld\n",res);
    }
}

Measured memory_bytes: 0
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ct = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            total = 500*a + 100*b + 50*c
            if total == X:
                ct+=1
print(ct)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    int x;
    cin >> x;

    string ans="NO";
    if(x==3||x==5||x==7) ans="YES";

    cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256