akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	static char[][]field;
	static char[]a={'o','x'};
	static int[]v1={-1,0,1,-1,1,-1,0,1};
	static int[]v2={-1,-1,-1,0,0,1,1,1};
	static int  turn;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		field=new char[8][];
		turn=0;
		for(int i=0;i<8;i++){
			field[i]=sc.next().toCharArray();
		}
		int pass=0;
		for(;;){
			
			int x=0,y=0,max=0;
			if(turn==0){
				max=0;
			}
			else{
				max=1;
			}
			boolean isPass=true;;
			for(int i=0;i<8;i++){
				for(int j=0;j<8;j++){
					int[] put =putCount(i,j,a[turn]);

					if(put==null)continue;
					if(turn==0){
						if(max<put[0]){
							max=put[0];
							x=i;
							y=j;
							isPass=false;
						}						
					}
					else{
						if(max<=put[0]){
							max=put[0];
							x=i;
							y=j;
							isPass=false;
						}
					}

				}
			}
			if(!isPass){
				put(x,y,a[turn]);
				pass=0;
			}
			else{
				pass++;
				if(pass==2){
					break;
				}
			}
			turn=1-turn;

			
			int cnt=0;
			for(int i=0;i<8;i++){
				for(int j=0;j<8;j++){
					if(field[i][j]!='.')cnt++;
				}
			}
			if(cnt==64)break;
//			System.out.println(pass);
//			System.out.println(isPass);
//			output();
		}
		
		output();
	}
	static void output(){
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				System.out.print(field[i][j]);
			}
			System.out.println();
		}		
	}
	static void put(int x,int y,char c){
		field[x][y]=(char)c;
		for(int i=0;i<v1.length;i++){
			int xx=x+v1[i];
			int yy=y+v2[i];
			if(xx<0||yy<0||xx>=8||yy>=8)continue;
			if(field[xx][yy]==a[1-turn]){
				int u=uraCount(xx,yy,c,i);
				if(u!=-1){
					ura(xx,yy,c,i,u);
				}
			}
		}
	}
	static void ura(int x,int y,int c,int dir,int count){
		for(int i=0;i<count;i++){
			field[x][y]=(char)c;
			x+=v1[dir];
			y+=v2[dir];
		}
	}
	static int[] putCount(int x,int y,char c){
		
		// テ・ツ?凝ヲツ閉ーテ」ツ??ヲツ鳴ケテ・ツ青?
		int[] re={0,0};
		if(field[x][y]!='.')return null;
		for(int i=0;i<v1.length;i++){
			int xx=x+v1[i];
			int yy=y+v2[i];
			if(xx<0||yy<0||xx>=8||yy>=8)continue;
			if(field[xx][yy]==a[1-turn]){
				int u=uraCount(xx,yy,c,i);
				if(u!=-1){
//					System.out.println(u);
					re[0]+=u;
				}
			}
		}
		return re;
	}
	static int uraCount(int x,int y,int c,int dir){
		int re=1;
		for(;;){
			x+=v1[dir];
			y+=v2[dir];
			if(x<0||y<0||x>=8||y>=8)break;
			if(field[x][y]==c){
				return re;
			}
			else if(field[x][y]==a[1-turn]){
				re++;
			}
			else{
				break;
			}
		}
		return -1;
	}
	
}

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



int main(){

    int tele[6];rep(i,0,6) cin >> tele[i];
    int limit = tele[5];

    rep(i,0,4){
        rep(j,1,5){
            if(abs(tele[i]-tele[j])>limit){
            cout <<":(" << endl;
            return 0;
            }
        }

    }
    cout << "Yay!" << endl;


}


Measured memory_bytes: 256
S = input()
N = len(S)
T = list(S)
M = (N-1)/2
i = 0
j = int(M)

if j%2 == 1:
    while i == j-1 or i == j:
        if T[i] != T[j-1]:
            j = -1
            break
        i += 1
        j -= 1
        
P = int((N+3)/2)
i = 0
while P < N+1:
    if T[i] != T[P-1]:
        j = -1
        break
    i += 1
    P += 1

if j != -1:
    print('Yes')
else :
    print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
//最大公約数
template<typename T>
constexpr T gcd(T a, T b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

//最小公倍数
template<typename T>
constexpr T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}



const long long MOD = 1000000007;

long long inverse(long long mod, long long val) {
	long long x[2] = { mod, val };
	long long a[2] = { 1, 0 };
	long long i;
	for (i = 0; x[!i]; i ^= 1) {
		a[!i] -= x[i] / x[!i] * a[i];
		x[i] = x[i] % x[!i];
	}
	if (!i) a[!i] += mod;
	return a[!i];
}

ll f(ll k) {
	ll res = 1;
	for (ll i = 1; i <= k; ++i) {
		res *= i;
		res %= MOD;
	}
	return res;
}

int main() {
	int k;
	int n;
	string s;
	cin >> k;
	cin >> s;
	n = s.size()-1;
	ll b = f(n + k);
	b %= MOD;
	b*=inverse(MOD, f(k));
	b %= MOD;
	b *= inverse(MOD, f(n));
	b %= MOD;
	for (int i = 0; i < k; ++i) {
		b *= 25;
		b %= MOD;
	}
	ll res = b;
	for (int i = 0; i < k; ++i) {
		b *= 26 * (k - i);
		b %= MOD;
		b *= inverse(MOD, 25);
		b %= MOD;
		b *=inverse(MOD, (n + k - i));
		b %= MOD;
		res += b;
		res %= MOD;
	}
	cout << res << endl;
	return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> 
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	int n;
	cin >>n;
	VI a(n);
	rep(i,n) cin >>a[i];
	
	int flg=1, cnt =0;
	while(flg){
		flg=0;
		for(int j=n-1; j>=1; j--){
			if(a[j] < a[j-1]){
				swap(a[j], a[j-1] );
				flg=1; cnt++;
			}
		}
	}
	rep(i,n) cout <<a[i] << (i==n-1?"\n":" ");
	cout <<cnt <<"\n";
	return 0;
}




Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
const int N=1e6;
ll v[N+10];
int main()
{
     ll n;

     cin>>n;

     if(n%1000==0)cout<<0<<endl;
     else
    cout<<1000-(n%1000)<<endl;
}



Measured memory_bytes: 3636
/*
Author: Dynamic JQ

Problem: ARC100C - Or Plus Max

Time & Date(start): Jun/30/2018 9:04

Verdict: Coding

Tags: Bitmasks & DP
*/
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 1e9 + 7;

struct maxi_pr
{
	pair<PII, PII> x;
	maxi_pr()
	{
		x.first = x.second = MP(0, -1);
	}
	void insert(PII num)
	{
		if(num > x.first) {
			if(num.second != x.first.second) x.second = x.first;
			x.first = num;
		} else if(num > x.second && num.second != x.first.second) x.second = num;
	}
};

int n, a[262144];
maxi_pr dp[262144];

int main()
{
	scanf("%d", &n);
	rep(i, 1 << n) scanf("%d", &a[i]);
	rep(i, 1 << n) {
		dp[i].insert(MP(a[i], i));
		rep(j, n) if((i >> j) & 1) {
			int ni = i ^ (1 << j);
			dp[i].insert(dp[ni].x.first);
			dp[i].insert(dp[ni].x.second);
		}
	}
	int ca = 0;
	for(int i = 1; i < (1 << n); i ++) {
		ca = max(ca, dp[i].x.first.first + dp[i].x.second.first);
		printf("%d\n", ca);
	}
	return 0;
}

Measured memory_bytes: 8192
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int m = sc.nextInt();
		long[] hs = new long[n];
		for(int i=0; i<n; i++){
			hs[i] = sc.nextLong();
		}
		Map<Integer, List<Integer>> map = new HashMap<>();
		for(int i=1; i<=n; i++){
			map.put(i, new ArrayList<Integer>());
		}
		for(int i=0; i<m; i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			List<Integer> aList = map.get(a);
			List<Integer> bList = map.get(b);
			aList.add(b);
			map.put(a, aList);
			bList.add(a);
			map.put(b, bList);
		}
		int ans=0;
		for (Map.Entry<Integer, List<Integer>> ns : map.entrySet()) {
            int key = ns.getKey();
			List<Integer> values = ns.getValue();
			long valuesMax = 0;
			for(int tou: values){
				valuesMax = Math.max(hs[tou-1], valuesMax);
			}
			if(hs[key-1] > valuesMax){
				ans++;
			}
		}
		System.out.println(ans);
	}
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 66196
n = int(input())
s = input()
rl = s.count('R')
gl = s.count('G')
bl = s.count('B')
rr = 0
gr = 0
br = 0
if s[0] == 'R':
    rl -= 1
    rr += 1
elif s[0] == 'G':
    gl -= 1
    gr += 1
else:
    bl -= 1
    br += 1

ans = 0
for i in range(1, n-1):
    for j in range(1, n//2+1):
        if i-j < 0 or i+j > n-1:
            break
        if s[i+j] != s[i-j] and s[i+j] != s[i] and s[i-j] != s[i]:
            ans -= 1
    if s[i] == 'R':
        ans += bl*gr + br*gl
        rl -= 1
        rr += 1
    elif s[i] == 'G':
        ans += rr*bl + rl*br
        gl -= 1
        gr += 1
    else:
        ans += gr*rl + gl*rr
        bl -= 1
        br += 1
print(ans)


Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
#define ssd ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug_x(x) cout<< #x <<"---> : "<<x<<endl;
#define debug_ve(x) for(auto it: x) cout<<it<<" ";
#define rep(i,a,n) for (int i=a;i<n;i++)
#define _rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef double db;
//std::mt19937 mrand(random_device{}());
//int rnd(int x) { return mrand() % x ; }
const ll mod=1e7;
ll ksm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

/***********************/
char s[1<<17];
int l =-1,r=-1,i;
int main(){
    ssd;
    cin>>s;
    for(int i=1;s[i];i++) if(s[i-1] == s[i]) l=i,r=i+1;
    for(int i=2;s[i];i++) if(s[i-2] == s[i]) l=i-1,r=i+1;
    cout<<l<<" "<<r<<endl;
}

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

using LL = long long;

LL N;

LL count(auto l, auto r) {
  if(l<0 || N<=r) return 0;
  if(l>r) return 0;
  return (r-l+1)*(r-l+2)/2;
}

int main() {
  cin >> N;
  vector<LL> A(N), I(N);
  for(auto& i: A) cin >> i;
  for(auto i = 0; i < N; ++i) I[A[i]-1] = i;
  set<LL, greater<LL>> L;
  set<LL> R;
  L.emplace(-1);
  R.emplace(N);
  auto res = 0ll;
  for(auto i: I) {
    auto l = *L.lower_bound(i)+1;
    auto r = *R.lower_bound(i)-1;
    auto n = count(l, r);
    n -= count(l, i-1);
    n -= count(i+1, r);
    res += n*A[i];
    L.emplace(i);
    R.emplace(i);
  }
  cout << res << endl;
}


Measured memory_bytes: 22144
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=a;i<=b;i++)
int a[100005],fa[100005];
int find(int x)
{
	return fa[x]==x?x:fa[x]=find(fa[x]);
}
int main(int argc, char** argv) {
	int n,m;
	cin>>n>>m;
	rep(i,1,n)
	scanf("%d",&a[i]),fa[i]=i;
	rep(i,1,m)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		int x=find(l),y=find(r);
		if(x!=y)
		{
			fa[x]=y;
		}
	}
	int ans=0;
	rep(i,1,n)
	{
		if(find(a[i])==find(i))
		{
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
L = [10, 50, 100, 500]

def solve():
    r = calc(N)
    return map(lambda a, b: max(0, a - b), N, r)

def calc(N):
    ret = [0] * 4
    r = sum(L[i] * N[i] for i in xrange(4)) - M
    for i in xrange(3, -1, -1):
        ret[i] += r / L[i]
        r -= ret[i] * L[i]
    return ret

M = int(raw_input())
while M != 0:
    N = map(int, raw_input().split())
    for i, n in zip(L, solve()):
        if n == 0:
            continue
        print i, n
    M = int(raw_input())
    if M == 0:
        break
    print

Measured memory_bytes: 4248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int f[110][15];
int p[110][15];

int main() {
  int N;
  scanf("%d", &N);
  
  FOR(i,0,N-1){
    FOR(j,0,9){
      scanf("%d", &f[i][j]);
    }
  }
  FOR(i,0,N-1){
    FOR(j,0,10){
      scanf("%d", &p[i][j]);
    }
  }

    int sumbit = 10;
    int ref[N];
    int ans = -1000000000;

    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 1; bit < (1<<sumbit); ++bit) {
        int pro = 0;
        FOR(i,0,N-1){
          ref[i] = 0;
        }
        for (int i = 0; i < sumbit; ++i) {
            if (bit & (1<<i)) { // i が bit に入るかどうか
                for(int j = 0; j<N ; ++j){
                  if(f[j][i]) ref[j]++;
                }
            }
        }

        // cout << "tes" << endl;

        FOR(i,0,N-1){
          pro += p[i][ref[i]];
        }

        if(pro>ans) {
          ans = pro;
          // cout << ref[0] << endl;
          // cout << p[0][0] << " " << p[1][1] << endl;
        }

        
    }

    cout << ans << endl;


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    int n,flg = 0;
    cin >> n;
    vector<string> w(n);
    map<string,int> mp;
    for (int i = 0; i < n; ++i) {
        cin >> w[i];
        if(!mp.count(w[i])) mp[w[i]]++;
        else flg = 1;
    }
    for (int i = 0; i < n-1; ++i) {
        if(w[i][w[i].size()-1] != w[i+1][0]) flg = 1;
    }
    if(flg) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

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


int main()
{
    long A,B,C;
    std::cin >> A>>B>>C;
    if(C>A-B){
        std::cout<<(C-(A-B));
    }else{
        std::cout << 0;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner input=new Scanner(System.in);
        int H,W,i,j;
        while(true){	
            H = input.nextInt();	
            W = input.nextInt();	
        if(H+W <= 0)break;	
           for (i = 0; i < H; i++ ){
            for (j = 0; j < W; j++ ){
                if((i+j)%2 == 0)
                    System.out.print("#");
                else 
                    System.out.print(".");
            }
             System.out.println("");
		    }
		    System.out.println();
        }
    }
}


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

const int  mod = 1000000007;
struct mint{
    ll x;
    mint (ll x=0) : x((x%mod+mod)%mod){}//カッコの中で初期化している
    mint& operator+=(const mint a){//operatorは構造体同士の比較に用いられる
        if((x +=a.x)>=mod) x-=mod;
        return *this;//thisとは現在のオブジェクトのこと
    }
    mint& operator-=(const mint a){
        if((x +=mod-a.x)>=mod) x-=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x*=a.x)%=mod;
        return *this;
    }
    mint operator+(const mint a){
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a){
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a){
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const{
        if(!t) return 1;
        mint a=pow(t>>1);
        a*=a;
        if(t&1) a*=*this;
        return a;
    }
    mint inv() const{
        return pow(mod-2);//逆元
    }
    mint&operator/=(const mint a) {
        return (*this)*=a.inv();
    }
    mint&operator/(const mint a) const{
    mint res(*this);
    return res/=a;
    }
};
 
int main(void){
    int n;
    cin>>n;
    vector<int> v(n);
    map<int, int> mp;
    rep(i, n) {
        int a;
        cin>>a;
        mp[a]++;
    }
    mint ans = 1;
    bool ok = true;
    if(n%2 == 0){
        int now = 1;
        for(auto p : mp){
            if(p.first == now && p.second == 2){
                ans *= 2;
                now += 2;
            }
            else {
                ok = false;
                break;
            }
        }
    }
    else{
        int now = 0;
        int num = 1;
        for(auto p : mp){
            if(p.first == now && p.second == num){
                if(num == 1){
                    now += 2;
                    num = 2;
                }
                else{
                    ans *= 2;
                    now += 2;
                }
            }
            else {
                ok = false;
                break;
            }
        }
    }
    if(ok) cout<<ans.x<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 3584
M, D = map(int, input().split())
count = 0
for m in range(1, M + 1):
    for d in range(10, D + 1):
        d_1 = d % 10
        d_10 = d //10
        count += (d_1 * d_10 == m and d_1 > 1 and d_10 > 1)

print(count)

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


const int N = 100010;
vector<int> edge[N];

int n;
int son[N];
int fa[N];
int dep[N];
void dfs(int u, int f) {
    fa[u] = f;
    son[u] = 1;
    dep[u] = dep[f] + 1;
    for (int v : edge[u]) {
        if (v != f) {
            dfs(v, u);
            son[u] += son[v];
        }
    }
}

int main () {
    scanf("%d", &n);
    int a, b;
    for (int i = 1; i < n; i++) {
        scanf("%d%d", &a, &b);
        edge[a].emplace_back(b);
        edge[b].emplace_back(a);
    }
    dfs(1, 0);
    int up = dep[n] / 2 - 1;
    int u = n;
    for (int i = 0; i < up; i++) {
        u = fa[u];
    }
    int white_sum = son[u] - 1;
    int black_sum = n - son[u] - 1;
    if (black_sum == 0) {
        puts("Snuke");
        return 0;
    }
    if(black_sum > white_sum) {
        puts("Fennec");
    } else {
        puts("Snuke");
    }
    return 0;
}


Measured memory_bytes: 13184
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
data=Counter(a)
count=0
for i,j in data.items():
    if i==j:
        count+=0
    elif i<j:
        count+=j-i
    elif j<i:
        count+=j
    else:
        pass
print(count)


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

using namespace std;

const int N = 1e5 + 5;
string s;
int n, cur = 1;

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s; n = s.size(); s = '#' + s;
    if (s.back() == '1' || s[1] != '1') return cout << -1, 0;
    for (int i = 1; i <= n - 1; ++i) if (s[i] != s[n - i]) return cout << -1, 0;

    for (int i = 2; i < n; ++i) if (s[i] == '1') {
        cout << cur << ' ' << i << '\n';
        while (++cur < i) cout << cur << ' ' << i << '\n';
    }

    cout << cur << ' ' << n << '\n';
    while (++cur < n) cout << n << ' ' << cur << '\n';

    return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(int64)(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,w;
    cin >> n >> w;
    vector<int32> v[4];
    int32 w1 = -1;
    REP(i,n){
        int32 wi,vi;
        cin >> wi >> vi;
        if(i == 0)w1 = wi;
        v[wi-w1].pb(vi);
    }
    REP(i,4)sort(ALL(v[i]),greater<int32>());
    vector<int64> vRuiseki[4];
    REP(i,4){
        vRuiseki[i].pb(0);
        REP(j,v[i].size()){
            vRuiseki[i].pb(vRuiseki[i].back() + v[i][j]);
        }
    }
    int64 ans = -1;
    REP(i,v[0].size() + 1){
        REP(j,v[1].size() + 1){
            if(i * w1 + j * (w1 + 1) > w)break;
            REP(k,v[2].size() + 1){
                if(i * w1 + j * (w1 + 1) + k * (w1 + 2) > w)break;
                REP(l,v[3].size() + 1){
                    if(i * w1 + j * (w1 + 1) + k * (w1 + 2) + l * (w1 + 3) > w)break;
                    ans = max(ans, vRuiseki[0][i] + vRuiseki[1][j] + vRuiseki[2][k] + vRuiseki[3][l]);
                }
            }
        }
    }
    ANS(ans);
    return 0;
}

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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] TX = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            Console.WriteLine(TX[0]<TX[1]?0:10);
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 27484
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int n, m;
vector<int> p;
int t;
vector<int> q;
vector<int> o;
int ans;

int b(int x){
	int l = 0;
	int r = q.size();
	while(r - l > 1){
		int i = (l + r) / 2;
//		printf("l=%d, r=%d, i=%d, q[i]=%d, x=%d\n", l, r, i, q[i], x);
		if(q[i] <= x){
			l = i;
		}else{
			r = i;
		}
	}
//	printf("%d\n", q[l]);
	return q[l];
}

int main(){
	while(1){
		scanf("%d %d", &n, &m);
		if(n == 0 && m == 0) break;
		p = o;
		p.push_back(0);
		for(int i=0; i<n; i++){
			scanf("%d", &t);
			p.push_back(t);
		}
		q = o;
		ans = 0;

		for(int i=0; i<p.size(); i++){
			for(int j=0; j<p.size(); j++){
				q.push_back(p[i] + p[j]);
			}
		}
		sort(q.begin(), q.end());
/*
		for(int i=0; i<q.size(); i++)
			printf("%d\n", q[i]);
*/
		for(int i=0; i<q.size(); i++){
			int a = q[i];
			if(m - a < 0) continue;
			ans = max(ans, b(m - a) + a);
//			printf("%d\n", b(m - a));
		}

		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 6504
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ll t; t=1;
    while(t--)
    {
        int n; cin>>n;
        int a[n],cnt=0; 
        for(int i=0;i<n;i++) cin>>a[i];
        sort(a,a+n);
        for(int i=0;i<n-2;i++)
        {
            for(int j=i+1;j<n-1;j++)
            {
                for(int k=j+1;k<n;k++)
                {
                    if(a[i]+a[j]>a[k] && a[i]!=a[j] && a[j]!=a[k] )
                    cnt++;
                }
            }
        }
        cout<<cnt<<"\n";
   }
    return 0;
}

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

int main(){

  int a,b,ans=-100000;
  cin >> a >> b;

  ans = max(a*b, ans);
  ans = max(a+b, ans);
  ans = max(a-b, ans);

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


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

 int main(){
 	int A,B,C,D;
 	cin >> A >> B >> C >> D ;
 	if( A+B == C+D ){
 		cout << "Balanced" << endl;
 	}
 	else if(A+B > C+D){
 	 cout << "Left" << endl;
 	 }
  	else if(A+B<C+D){
 	 cout << "Right" << endl;
 	 }

 	 }

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=510;
struct fk{int x,id;}q[N];
int n,a[N*N],cnt[N],flag;
bool cmp(fk a,fk b){return a.x<b.x;}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&q[i].x),q[i].id=i;
    sort(q+1,q+n+1,cmp);
    for(int i=1;i<=n;i++){
        int id=q[i].id;
        a[q[i].x]=id;++cnt[id];
        for(int j=1;j<q[i].x;j++){
            if(cnt[id]==id)break;
            if(!a[j])a[j]=id,++cnt[id];
        }
        if(cnt[id]<id)flag=1;
    }
    if(flag){puts("No");return 0;}
    flag=0;
    for(int i=n;i>=1;i--){
        int id=q[i].id;
        for(int j=n*n;j>q[i].x;j--){
            if(cnt[id]==n)break;
            if(!a[j])a[j]=id,++cnt[id];
        }
        if(cnt[id]<n)flag=1;
    }
    if(flag){puts("No");return 0;}
    puts("Yes");
    for(int i=1;i<=n*n;i++)printf("%d ",a[i]);
    puts("");
}


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

using namespace std;
const int N = 1e6+100;
typedef long long ll;
int main(){
	int s,a,b;
	cin>>s;
	a=s/100; b=s%100;
	if(a<13&&a>0)
	{
		if(b<13&&b>0)
		{
			cout<<"AMBIGUOUS"<<endl;
			return 0;
		} 
		else 
		{
			cout<<"MMYY"<<endl;
			return 0;
		}
	 } 
	else if(b<13&&b>0) 
				{
					cout<<"YYMM"<<endl;
					return 0;
				}
				else cout<<"NA"<<endl;
	return 0;
}


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

namespace ConsoleApp14
{
    class Class34
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var B = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = new int[N];
            A[0] = B[0];
            for(int i = 0; i < N-1; i++)
            {
                A[i] = Math.Min(A[i], B[i]);
                A[i + 1] = B[i];
            }
            
            Console.WriteLine(A.Sum());
        }
    }
}


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



namespace Test
{
    class MainClass
    {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            int ans;
            if (n % 2 == 0) {
                ans = Math.Max(2, n);
            }
            else {
                ans = 2 * n;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

//自作関数 a^n mod MODを求める
int m_pow(int a, int n){
  if(n == 0) return 1;
  if(n % 2 == 0){
    int t = m_pow(a, n / 2);
    return t * t % MOD;
  }
  return a * m_pow(a, n - 1) % MOD;
}

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

  string s;

  cin >> s;

  char c = s[0];

  REP(i,3){
    if(c != s[i]) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
	int w, h;
	cin >> w >> h;
	vector<int> p(w), q(h);
	priority_queue<P, vector<P>, greater<P> > pq;	
	rep(i, 0, w){
		cin >> p[i];
		pq.push(P(p[i], 1));
	}
	rep(i, 0, h){
		cin >> q[i];
		pq.push(P(q[i], -1));
	}
	int ans = 0;
	while(pq.size()){
		P now = pq.top(); pq.pop();
		if(now.second == 1){
			ans += (h + 1) * now.first;
			w--;
		}else{
			ans += (w + 1) * now.first;
			h--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 6000
N = int(input())
HList = list(map(int,input().split()))
hlen = len(HList)
pos = 0
ans = 0
while pos < hlen-1:
    count = 0
    while pos < hlen-1:
        if HList[pos] >= HList[pos+1]:
            count += 1
            pos += 1
        else:
            break
    if ans < count:
        ans = count
    pos += 1

print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N ;
  vector<int> vec(N);
  for(int i = 0 ;i<N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  int c = N;
  
  for(int i = 0 ;i<N-1; i++){
    if(vec.at(i) == vec.at(i+1)){
      c--;
  }
  }
  cout << c << endl;
}

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

int nlist[100010];

typedef long long int lli;

int main () {
  int N, x;
  cin >> N >> x;
  for (int i = 0; i < N; i++) cin >> nlist[i];
  lli ans = 0;
  for (int i = 0; i < N ;i++) {
    if (nlist[i] > x) {
      ans += (nlist[i] - x);
      nlist[i] = x;
    }
  }
  for (int i = 0; i < N - 1; i++) {
    if (nlist[i] + nlist[i + 1] > x) {
      ans += (nlist[i] + nlist[i + 1] - x);
      nlist[i + 1] -= (nlist[i] + nlist[i + 1] - x);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 768
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    prev_idx = 1
    flag = False
    num = 0
    seen = [-1] * N
    while True:
        if prev_idx == 2:
            flag = True
            break

        # if it visits the same point twice,
        # it means this graph has loop structure.
        if seen[prev_idx-1] != -1:
            break
        seen[prev_idx-1] = num
        prev_idx = A[prev_idx-1]
        num += 1

    if flag:
        print(num)
    else:
        print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 11032
#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast")
using namespace std;
int main()
{
        int N;
        cin >> N;
        vector<int> A(N), B(N), C(N);
        for (int i = 0; i < N; ++i)
        {
                cin >> A.at(i);
        }
        for (int i = 0; i < N; ++i)
        {
                cin >> B.at(i);
        }
        for (int i = 0; i < N; ++i)
        {
                cin >> C.at(i);
        }
        sort(A.begin(), A.end());
        sort(B.begin(), B.end());
        sort(C.begin(), C.end());
        vector<long> can_put(N);
        for (int i = 0; i < N; ++i)
        {
                // can_put.at(i) = binaly_search(A, B.at(i)) + 1;

                auto Iter1 = lower_bound(A.begin(), A.end(), B[i]);
                long k1 = Iter1 - A.begin();
                can_put.at(i) = k1;
                // cout << can_put.at(i) << ",";
        }
        for (int i = 1; i < N; ++i)
        {
                can_put.at(i) = can_put.at(i - 1) + can_put.at(i);
        }
        // for (int i = 0; i < N; ++i)
        // {
        //   cout << can_put.at(i) << ",";
        // }
        long long ans = 0;
        int num = 0;
        for (int i = 0; i < N; ++i)
        {
                auto Iter2 = lower_bound(B.begin(), B.end(), C[i]);
                long k2 = Iter2 - B.begin() - 1;
                // cout << num;
                if (k2 == -1)
                {
                  continue;
                }
                ans += can_put.at(k2);
        }
        cout << ans << endl;

}


Measured memory_bytes: 2176
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;

int main() {
    ll n;
    cin >> n;
    ll AC=0,WA=0,TLE=0,RE=0;
    rep(i,n){
        string s;
        cin >> s;
        if(s=="AC") AC++;
        if(s=="WA") WA++;
        if(s=="TLE") TLE++;
        if(s=="RE") RE++;
    }
    cout << "AC" << " " << "x" << " " << AC << endl;
    cout << "WA" << " " << "x" << " " << WA << endl;
    cout << "TLE" << " " << "x" << " " << TLE << endl;
    cout << "RE" << " " << "x" << " " << RE << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
int main(void){
	int a,b,c,d,n,cnt;
	
	while(scanf("%d",&n)!=EOF){
	cnt=0;
	if(n>=37){
		printf("%d\n",0);
	}
	else{
		for(a=0;a<=9;a++){
			for(b=0;b<=9;b++){
				for(c=0;c<=9;c++){
					for(d=0;d<=9;d++){
						if((a+b+c+d)==n){
							cnt++;
						}
					}
				}
			}
		}
	
	printf("%d\n",cnt);}
}
	return 0;
}

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

void __print(int x) {cerr << x;};void __print(long x) {cerr << x;};void __print(long long x) {cerr << x;};void __print(unsigned x) {cerr << x;};void __print(unsigned long x) {cerr << x;};void __print(unsigned long long x) {cerr << x;};void __print(float x) {cerr << x;};void __print(double x) {cerr << x;};void __print(long double x) {cerr << x;};void __print(char x) {cerr << '\'' << x << '\'';};void __print(const char *x) {cerr << '\"' << x << '\"';};void __print(const string &x) {cerr << '\"' << x << '\"';};void __print(bool x) {cerr << (x ? "true" : "false");}

#define int             long long
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define endl             '\n'
#define pb              push_back
#define all(x)          x.begin(),x.end()
int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int string_to_int(string s){int ans = 0;int p=1;for(int i=s.size()-1;i>=0;i--){ans += (s[i]-'0')*p;p *= 10;}return ans;}

//DEBUGGING-LINES
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr <<'}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i);cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

void t_c_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif*/

	int n,l,r; cin >> n >> l >> r;
	int ans = 0;
	for(int i=n;i<=l;i++){
		if(i%r==0){
			ans++;
		}
	}
	cout << ans << endl;
}

int32_t main()
{
	t_c_c();
	return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;
import java.lang.Math;
class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long i = 10000000000000000L;
        for (long j=1; j<=Math.sqrt((double)n)+1; j++) {
        		if(n%j == 0) {
        			long k = n/j;
        			if (i > (j+k-2)) i = j+k-2;
        		}
        }
        System.out.println(i);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int input, ans = 0, flag;
    cin >> input ;
    
    vector<int> side(input);
    for(int i = 0; i < input; i++){
        cin >> side.at(i);
    }
    
    sort(side.begin(), side.end());
    reverse(side.begin(), side.end());

    for(int i = 0; i < input; i++){
        flag = 0;
        for(int j = i + 1; j < input; j++){
            for(int k = j + 1; k < input; k++){
                if(side.at(i) < side.at(j) + side.at(k) && side.at(j) < side.at(k) + side.at(i) && side.at(k) < side.at(i) + side.at(j) ){
                    ans++;
                } else {
                    break;
                    flag++;
                }
            }
            if(flag != 0){
                break;
            }
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 3664
N, K, Q = map(int, input().split())
P = [0 for i in '0'*N]
for n in '0'*Q:
    A = int(input()) - 1
    P[A] += 1
for s in map(lambda x:'Yes' if x-Q+K>0 else 'No', P):
    print(s)

Measured memory_bytes: 4716
N = int(input())
As = list(map(int, input().split()))
As.sort(reverse=True)
rs = []
a = -1
for i in range(N):
  A = As[i]
  if A == a:
    rs.append(A)
    a = -1
  else:
    a = A
if len(rs) < 2:
  print(0)
  exit()
r = rs[0]*rs[1]
print(r)


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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

int n;
int u, k, v;
int hour = 0;
int pos;
int d[101];
int gra[101][101] = {};
int color[101] = {};
queue<int>que;



int main(void) {
	cin >> n;
	
	FOR(i, 1, n) {
		cin >> u >> k;
		FOR(t, 1, k) {
			cin >> v;
			gra[u][v] = 1;
		}
	}

	FOR(i, 1, n) {
		d[i] = -1;
	}

	que.push(1);
	d[1] = hour;
	color[1] = 1;
	
	while (que.empty() != 1) {
		pos = que.front();
		que.pop();
		FOR(i, 1, n) {
			if (gra[pos][i] == 1 && color[i] == 0) {
				que.push(i);
				d[i] = d[pos] + 1;
				color[i] = 1;
			}
		}
	}

	FOR(i, 1, n) {
		cout << i << " " << d[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3116
while n = gets
n = n.chomp.to_i
break if n == 0
ary = []
ary2 = Array.new(n+1,0)
n.times do
line = gets.split.map(&:to_i)
tmp = 0
for i in 0..(n-1)
  tmp += line[i]
  end
line << tmp
ary << line
end

for i in 0..(n-1)#3
  for j in 0..n #0..4
    ary2[j] += ary[i][j]
  end
end

ary << ary2
ary.each do |i|
  i.each do |j|
    printf("%5d",j)
  end
  puts
end
end


Measured memory_bytes: 6884
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORL(i,a,b) for(LL i=(a);i<(b);++i)
#define REPL(i,n)  FORL(i,0,n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);

 //debug func
template<typename T>
void vprint(vector<T> v) {
    for(auto x : v) {
        cerr << x << " ";
    }
    cerr << endl;
}
 
template<typename T>
void vvprint(vector<vector<T>> vv) {
    REP(i, SIZE(vv)) {
        REP(j, SIZE(vv[i])) {
            cerr << vv[i][j] << " ";
        }
        cerr << endl;
    }
}

template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

template<typename T>
T gcd(T a, T b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b%a, a);
}

template<typename T>
T lcm(T a, T b) {
    return (a / gcd(a, b)) * b;
}

template<typename T>
map<T, T> prime_list(T n) {
    map<T, T> ret;
    for(T i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            ret[i] = 0;
            while(n % i == 0) {
                n /= i;
                ret[i]++;
            }
        }
    }
    if(n != 1) ret[n]++;
    return ret;
}

#define MOD 1000000007

LL mypow(LL a, LL n) {
    if(n == 1) return a % MOD;
    if(n % 2 == 1) return (a * mypow(a, n-1)) % MOD;
    LL t = mypow(a, n/2);
    return (t * t) % MOD; 
}

int main(void) {
    LL x;
    cin >> x;
    LL t = 1;
    while(t * (t+1) / 2 < x) t++;
    cout << t << endl;
}

Measured memory_bytes: 256
class Union:
  def __init__(self, num):
    self.T = [-1 for i in range(num)]

  def root(self, x):
    if self.T[x] == len(self.T):
      return len(self.T)
    if self.T[x] < 0: return x
    k = self.root(self.T[x])
    self.T[x] = k
    return k

  def merge(self, x, y):
    if y >= len(self.T):
      self.T[-1] = len(self.T)
      return True
    a = self.root(x)
    b = self.root(y)
    self.T[a] = b
    return True


N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort(key = lambda x:x[1], reverse = True)

ans = 0
T = Union(M)
for i in range(N):
  if AB[i][0] > M:
    continue
  t = AB[i][0] - 1
  k = T.root(t)
  if t == k:
    ans += AB[i][1]
    T.merge(t, t + 1)
  else:
    t = k
    if t < M:
      ans += AB[i][1]
      T.merge(t, t + 1)

print(ans)

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


int N;

int main(int argc, const char * argv[]) {
    //    freopen("/Volumes/4HOPE/Dropbox/17Todai/CodeJam/R1C-2015-C/in.txt","r",stdin);
    //    freopen("/Volumes/4HOPE/Dropbox/17Todai/CodeJam/R1C-2015-C/out.txt","w",stdout);
    int a_bef;
    int a_now;
    int cnt=0;
    int upFlag=0;//1:up 0:neutral -1:down
    scanf("%d",&N);
    if(N == 1){
        printf("1\n");
        return 0;
    }
    scanf("%d",&a_bef);
    for(int k=0;k<N-1;k++){
        scanf("%d",&a_now);
        if(upFlag == 0){
            if(a_now > a_bef){
                upFlag = 1;
                cnt++;
            }
            if(a_now < a_bef){
                upFlag = -1;
                cnt++;
            }
        }else{
            if((a_now > a_bef && upFlag == -1) ||
               (a_now < a_bef && upFlag == 1)){
                upFlag = 0;
            }
        }
        a_bef = a_now;
    }
    if(upFlag == 0){
        cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 128