akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define MN 300000
#define mod 1000000007
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
char st[MN+5];
int p[MN+5],n,f[MN+5][2][3],ans;
inline void R(int&x,int y){x+=y;x>=mod?x-=mod:0;}
int main()
{
    scanf("%s",st+1);n=strlen(st+1);p[n+1]=f[0][0][0]=1;
    for(int i=n;i;--i) p[i]=p[i+1]*((st[i]=='?')+1)%mod;
    for(int i=1;i<=n;++i) for(int j=0;j<2;++j) for(int k=0;k<3;++k) if(f[i-1][j][k])
    {
        if(st[i]!='0')
        {
            if(k) R(f[i][j][k-1],f[i-1][j][k]);
            else if(!j) R(f[i][1][0],f[i-1][j][k]);
            else R(ans,1LL*f[i-1][j][k]*p[i+1]%mod);
        }
        if(st[i]!='1') R(f[i][j][k<2?k+1:1],f[i-1][j][k]);
    }
    printf("%d",(1LL*ans+f[n][2][1]+f[n][1][0])%mod);
    return 0;
}



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

int main() {
  int n;
  cin >> n;
  int c[26], s[n][26];
  for (int i = 0; i < 26; ++i)
    cin >> c[i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 26; ++j)
      cin >> s[i][j];
  for (int i = 0; i < n - 1; ++i)
    cout << distance(s[i], max_element(s[i], s[i] + 26)) + 1 << endl;
  cout << distance(s[n-1], max_element(s[n-1], s[n-1] + 26)) + 1;
  return 0;
}

Measured memory_bytes: 3672
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j,k;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		long[] a = new long[n];
		for(i=0;i<n;i++) {
			a[i] = parseLong(sc.next());
		}
		long[] b = new long[n];
		for(i=0;i<n;i++) {
			b[i] = parseLong(sc.next());
		}
		long[] c = new long[n];
		for(i=0;i<n;i++) {
			c[i] = parseLong(sc.next());
		}
		sc.close();
		Arrays.parallelSort(a);
		Arrays.parallelSort(b);
		Arrays.parallelSort(c);
//		out.println(Arrays.toString(a));
//		out.println(Arrays.toString(b));
//		out.println(Arrays.toString(c));
		long sum=0;
		long[] bc = new long[n];
		k=0;
		for(j = 0; j < n; j++) {
			while(k<n&&c[k]<=b[j])k++;
			if(k==n)break;
			bc[j]=n-k;
		}
//		out.println(Arrays.toString(bc));
		long tmp=0;
		j=n-1;
		for(i = n-1; i >= 0; i--) {
			while(j>=0&&a[i]<b[j]) {
				tmp += bc[j];
				j--;
			}
//			out.printf("%d:%d%n", i,tmp);
			if(j==n-1)continue;
//			if(j<0)break;
			sum += tmp;
		}
		out.println(sum);
	}
}

Measured memory_bytes: 63540
// Problemp_u : C - mp_uanagemp_uent
// Contest : AtCoder - AtCoder Beginner Contest 163
// URL : https://atcoder.jp/contests/abc163/tasks/abc163_c
// mp_uemp_uory Limp_uit : 1024 mp_uB
// Timp_ue Limp_uit : 2000 mp_us
// Powered by CP Editor (https://github.comp_u/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

 
int main() 
{
	fastio;
	
	int n,i;
	
	cin>>n;
	
    int v[n-1],v2[n+1]={0};
    
    for(i=0;i<n-1;i++)
    	cin >> v[i];
    	
    unordered_map<int, int> mp_u;
    
    for(i=0;i<n-1;i++)
    	mp_u[v[i]]++;
    
    for(auto it :mp_u)
    	v2[it.first]=it.second;
    	
    for(i=1;i<=n;i++)
    	cout << v2[i] << endl;
    	
	return 0;
}


Measured memory_bytes: 12952
#include<iostream>
#include<vector>
#include<algorithm>
#include<cassert>

#define max_v 100010

using namespace std;

int dfnum[max_v];
int vertex[max_v];
int parent[max_v];
int ancestor[max_v];
int idom[max_v];
int semi[max_v];
int samedom[max_v];
int best[max_v];
vector<int>bucket[max_v];

vector<int>G[max_v],rG[max_v];

void dfs(int p, int n,int &k){
  if(dfnum[n]==0 && !(n==0 && p>0)){
    dfnum[n]=k;
    vertex[k++]=n;
    parent[n]=p;
    for(int i=0;i<G[n].size();i++){
      dfs(n,G[n][i],k);
    }
  }
}

int ancestorWithLowestSemi(int v){
  int a=ancestor[v];
  if(ancestor[a]>0){
    int b=ancestorWithLowestSemi(a);
    ancestor[v]=ancestor[a];
    if(dfnum[semi[b]] < dfnum[semi[best[v]]])best[v]=b;
  }
  return best[v];
}

void link(int p,int n){
  ancestor[n]=p;
  best[n]=n;
}

void dominator(int sz,int root){
  for(int i=0;i<sz;i++){
    bucket[i].clear();
    dfnum[i]=semi[i]=ancestor[i]=idom[i]=samedom[i]=0;
  }

  int N=0;
  dfs(0,root,N);
  
  for(int i=N-1;i>0;i--){
    int n=vertex[i],p=parent[n],s=p;
    for(int j=0;j<rG[n].size();j++){
      int v=rG[n][j],s1;
      if(dfnum[v]<=dfnum[n])s1=v;
      else s1=semi[ancestorWithLowestSemi(v)];
      
      if(dfnum[s1]<dfnum[s])s=s1;
    }
    semi[n]=s;
    bucket[s].push_back(n);
    link(p,n);
    for(int j=0;j<bucket[p].size();j++){
      int v=bucket[p][j],y=ancestorWithLowestSemi(v);
      if(semi[y]==semi[v])idom[v]=p;
      else samedom[v]=y;
    }
    bucket[p].clear();
  }

  for(int i=1;i<N;i++){
    int n=vertex[i];
    if(samedom[n]>0){
      idom[n]=idom[samedom[n]];
    }
  }

  for(int i=1;i<N;i++){
    for(int j=0;j<rG[i].size();j++){
      if(rG[i][j]==root)idom[i]=0;
    }
  }
}

int main(void){

  int n,m;
  cin >> n >> m;

  for(int i=0;i<m;i++){
    int s,t;
    cin >> s >> t;
    s--,t--;
    G[s].push_back(t);
    rG[t].push_back(s);
  }

  dominator(n,0);

  int q,r;
  cin >> q;
  while(q--){
    cin >> r;
    r--;
    if(idom[r]==0)cout << r+1 << endl;
    else cout << idom[r]+1 << endl;
  }

  return 0;
}

Measured memory_bytes: 22096
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int z = sc.nextInt();
    int total = x + y + z;
    
    if(total > 21){
      System.out.println("bust");
    }else{
      System.out.println("win");
    }
    
  }
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

typedef long long int ll;
typedef long int li;

const ll mod = 1000000007;
const ll inf = 1000000000000000000;

typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vli> vvli;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef map<ll, ll> mll;
typedef map<ll, string> mls;
typedef map<string, ll> msl;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#pragma GCC optimize ("-O3")
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
#define PI 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define tol(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define tou(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define all(v) v.begin(), v.end()
#define FOR(i, j, k, in) for(li i=j; i<k; i+=in)
#define RFOR(i, j, k, de) for(li i=j; i>=k; i-=de)
#define rep(i,j,k) FOR(i, j, k, 1)
#define rrep(i,j,k) RFOR(i, j, k, 1)
#define repc(v) for(auto it=v.begin(); it!=v.end(); it++)
#define T ll t; cin>>t; while(t--)

ll gen(){
    ll temp;
    cin>>temp;
    return temp;
}

int main(){
  FAST

  ll n ;
  cin>>n;
  cout<<(2*PI*n);
  
  return 0;
}







Measured memory_bytes: 3744
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"s=int(input());print(['NA','MMYY','YYMM','AMBIGUOUS'][(9<s<1e3)-(0<s%100<13)*2])\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 8132
import java.io.PrintWriter;
import java.util.Scanner;

public class Main  implements Runnable { //Runnableを実装する

    public static void main(String[] args) {

        new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行

    }

    public void run() {
		Scanner sc = new Scanner(System.in);
		//Scanner sc = new Scanner("1 1 1");
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		String str = sc.next();
		char c[] = str.toCharArray();
		int max = 0;
		int state = 0;
		int ci = 1;
		int la[] = new int[n+2];
		la[0] = 0; 
		for(int i = 0; i < n ; i++)
		{
			if((int)(c[i]-'0') == state)
			{
				la[ci]++;
			}
			else
			{
				ci++;
				la[ci] = 1;
				if (state == 0)
				{
					state = 1;
				}
				else
				{
					state = 0;
				}
			}
		}
		ci++;
		for(int i = 0; i < ci ; i=i+2)
		{
			int tmp = 0;
			for (int j = i; j < (i + 2*k+1) && j < ci ; j++)
			{
				tmp += la[j];
			}
			if(tmp > max)
			{
				max = tmp;
			}
		}
		int ans = max;

		//int x, y, z;
		//int n = Integer.parseInt(sc.next());
		//int na[] = new int[n];
		//int ans;
		//for(int i = 0; i < n ; i++)
		//{
		//	na[i] = Integer.parseInt(sc.next());
		//}


		PrintWriter out = new PrintWriter(System.out);

		out.println(ans);
		out.flush();
	}
}

Measured memory_bytes: 29328
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include <algorithm>
#include <array>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

int gcd(int x, int y) {
  int a = std::max(x,y), b = std::min(x,y);
  int r = a % b;
  while(r!=0){ a = b; b = r; r = a % b; }
  return b;
}

int main(void) {
  int N, x;
  scanf("%d %d", &N, &x);
  std::vector<int> a(N);
  for (int i = 0; i < N; ++i) scanf("%d", &a[i]);
  std::sort(a.begin(), a.end());
  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    if (a.at(i) > x) break;
    x -= a.at(i);
    ++cnt;
  }
  if (cnt == N && x > 0) --cnt;
  printf("%d\n", cnt);

  return 0;
}

Measured memory_bytes: 256
[N,M] = list(map(int,input().split()))
S = list(map(int,input().split()))
T = list(map(int,input().split()))

ta = [[0] * (M+1) for i in range(N+1)]
ta[0][0]=1
wa = [[0] * (M+1) for i in range(N+1)]
wa[0][:]=[1]*(M+1)
for i in range(N+1):
    wa[i][0]=1
output = 1
for i in range(1,N+1):
    for j in range(1,M+1):
        if S[i-1]==T[j-1]:
            ta[i][j]=wa[i-1][j-1]
            wa[i][j]=(wa[i-1][j]+wa[i][j-1])%(10**9+7)
        else:
            wa[i][j]=(wa[i-1][j]+wa[i][j-1]-wa[i-1][j-1]+(10**9+7))%(10**9+7)
output = wa[N][M]
print(int(output))

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

#define pb            push_back
#define mp            make_pair
#define ins           insert
#define endl          '\n'
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<endl<<(#X)<<" = "<<(X)<<endl; }
//#define cerr if(0)cerr

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int a[9],b[9]={0};
    int i;
    for (i=0; i<9; ++i)
        cin>>a[i];

    int n,N;
    cin>>n;
    int num;
    N=n;
    while (n--) {
        cin>>num;
        for (i=0; i<9; ++i)
            if (a[i]==num) {
                b[i]=1;
                break;
            }
    }

    for (int i=0; i<9; ++i)
        cerr<<b[i];

    if (N<=2) cout<<"No";
    else {
        if (b[0]==b[1]&&b[1]==b[2]&&b[0])
            cout<<"Yes";
        else if (b[3]==b[4]&&b[4]==b[5]&&b[5])
            cout<<"Yes";
        else if (b[6]==b[7]&&b[7]==b[8]&&b[7])
            cout<<"Yes";
        else if (b[0]==b[3]&&b[3]==b[6]&&b[0])
            cout<<"Yes";
        else if (b[1]==b[4]&&b[4]==b[7]&&b[1])
            cout<<"Yes";
        else if (b[2]==b[5]&&b[5]==b[8]&&b[2])
            cout<<"Yes";
        else if (b[0]==b[4]&&b[4]==b[8]&&b[0])
            cout<<"Yes";
        else if (b[2]==b[4]&&b[4]==b[6]&&b[2])
            cout<<"Yes";
        else
            cout<<"No";
    }
    cout<<endl;

}



Measured memory_bytes: 256
n = int(input())
keta = len(str(n))
if keta == 1:
    print(n)
elif keta == 2:
    print(9)
elif keta == 3:
    print(9+n-99)
elif keta == 4:
    print(909)
elif keta == 5:
    print(909+n-9999)
else:
    print(90909)

Measured memory_bytes: 9132
import heapq

n, q = map(int, input().split())
Q = [[] for i in range(n)]
for i in range(q):
    x, *y = map(int, input().split())
    if x == 0:
        heapq.heappush(Q[y[0]], -y[1])
    elif x == 1 and Q[y[0]]:
        print(-Q[y[0]][0])
    elif x == 2 and Q[y[0]]:
        heapq.heappop(Q[y[0]])


Measured memory_bytes: 13172
// ========================================================================================================
// Library
// ========================================================================================================
#define _CRT_SECURE_NO_WARNINGS

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

// competitive macro
#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 (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ========================================================================================================
// ========================================================================================================

int main()
{
	fastIOS();

	string s; cin >> s;
    string result = "";
    
    REP(i,s.size()){
        if(s[i] == 'B' && result.size() > 0)
        {
            result.erase(result.size()-1);
        }
        else if (s[i] != 'B'){
            result += s[i];
        }
    }
    
    cout << result +"\n";
    
    return 0;
}

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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

// hash_parse ::= letter | '[' op hash_parse hash_parse ']'
// op ::= '+' | '*' | '^'
// letter ::= 
//
int hash_parse(const string &str, int &idx, const int data){
	if(isalpha(str[idx])){
		idx++;
		switch(str[idx-1]){
			case 'a': return data/1000;
			case 'b': return (data/100)%10;
			case 'c': return (data/10)%10;
			case 'd': return data%10;
		}
	}
	if('['){
		char op = str[++idx]; ++idx;
		int lhs = hash_parse(str, idx, data);
		int rhs = hash_parse(str, idx, data);
		assert(str[idx] == ']'); ++idx;
		switch(op){
			case '*': return lhs & rhs;
			case '+': return lhs | rhs;
			case '^': return lhs ^ rhs;
		}
	}
	assert(0);
	return -1;
}

signed main(){
	while(true){
		string str; cin >> str;
		if(str == ".")break;
		int idx = 0;
		int raw; cin >> raw;
		int val = hash_parse(str, idx, raw);
		int ans = 0;
		for(int i = 0; i < 10000; i++){
			idx = 0;
			if(val == hash_parse(str, idx, i)){
				ans++;
			}
		}
		cout << val << " " << ans << endl;
	}

	return 0;
}




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

int main(){
   int n, d, x;
   cin >> n >> d >> x;
   int array[n];
   int sum = x;
   for(int i = 0; i < n; i++){
       cin >> array[i];
       for(int k = 1; k <= d; k += array[i]){
           sum++;
       }
       //cout << "sum: " << sum;
   }
   cout << sum << endl;
   return 0;
}

Measured memory_bytes: 256
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

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

using i64 = long long;
const i64 MOD = 1e9 + 7;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<char> a(n);
    for(auto& x : a) cin >> x;
    vector<i64> dp(n + 1, 0LL);
    dp[0] = 1LL;
    for(int i : in(n)) {
        char c = a[i];
        if(c == '-') continue;
        vector<i64> dp_(n + 1, 0LL);
        if(c == 'D') {
            for(i64 j : in(i + 2)) {
                (dp_[j] += dp[j] * j) %= MOD;
                (dp_[j] += dp[j + 1] * (j + 1) * (j + 1)) %= MOD;
            }
        }
        else {
            for(i64 j : in(i + 2)) {
                if(j > 0) (dp_[j] += dp[j - 1]) %= MOD;
                (dp_[j] += dp[j] * j) %= MOD;
            }
        }
        dp = dp_;
    }
    cout << dp[0] << endl;
    return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 2; i < (o); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

bool is_prime(ll x) {
    for (ll i = 2; i < x; i++)
    {
        /* code */
        if (x%i == 0)
        {
            return false;
        }
    }
    return true;
}

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

  ll ans = x;
  while (!is_prime(ans))
  {
      /* code */
      ans++;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
    "fmt"
    "os"
)

func contains(s []int, e int) bool {
    for _, v := range s { 
        if e == v { 
            return true
        }   
    }   
    return false
}

func main() {
    var row []int = make([]int, 9, 9)

    var N int
    var in int 

    for j := 0; j < 3; j++ {
        fmt.Scan(&row[j])
    }   
    for j := 3; j < 6; j++ {
        fmt.Scan(&row[j])
    }   

    for j := 6; j < 9; j++ {
        fmt.Scan(&row[j])
    }   
    fmt.Scan(&N)

    var appeared []int = make([]int, N, N)
    for j := 0; j < N; j++ {
        fmt.Scan(&in)
        appeared[j] = in
    }
   //Check BINGO
    // aei, ceg
    if contains(appeared, row[0]) && contains(appeared, row[4]) && contains(appeared, row[8]) {
        fmt.Println("Yes")
        os.Exit(0)
    }
    if contains(appeared, row[2]) && contains(appeared, row[4]) && contains(appeared, row[6]) {
        fmt.Println("Yes")
        os.Exit(0)
    }
    for k := 0; k < 3; k++ {
        // abc, def, ghi
        if contains(appeared, row[k*3+0]) && contains(appeared, row[k*3+1]) && contains(appeared, row[k*3+2]) {
            fmt.Println("Yes")
            os.Exit(0)
        }
        // adg, beh, cfi
        if contains(appeared, row[k]) && contains(appeared, row[k+3]) && contains(appeared, row[k+6]) {
            fmt.Println("Yes")
            os.Exit(0)
        }

    }
    fmt.Println("No")

}

Measured memory_bytes: 512
package main

import "fmt"

func pf(n int) []int {
	pf := make([]int, 101)
	pf[1]++
	for i := 2; i <= n; i++ {
		x := i
		for j := 2; j <= i; j++ {
			for x%j == 0 {
				pf[j]++
				x /= j
			}
		}
	}
	return pf
}

func num(e []int, x int) int {
	ct := 0
	for _, v := range e {
		if v >= x {
			ct++
		}
	}
	return ct
}

func main() {
	var n int
	fmt.Scan(&n)
	e := pf(n)
	ans := 0
	ans += num(e, 74)
	ans += num(e, 24) * (num(e, 2) - 1)
	ans += num(e, 14) * (num(e, 4) - 1)
	ans += num(e, 4) * (num(e, 4) - 1) * (num(e, 2) - 2) / 2
	fmt.Println(ans)
}


Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
//#include<cstdio>//"scanf("%lf",&(double));printf("%f",(double));"
//#include<iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;"
//#include<string>//"reverse(s's it,s's it)"
//#include<functional>//"greater<T>" "sort(a,a+n,greater<int>());""
//#include<cmath>//"abs" "sqrt"
//#include<numeric>//"accumulate(inputit,inputit,init,(optional) object)"
//#include<algorithm>//"lower_bound(it,it,v)" "next_permutation(a,a+n)"
//"reverse(v's it,v's it)"(v: vector)
//#include<cassert>//"assert(cond);": error if cond doesn't hold.
using namespace std;
#define pb push_back//also for STRING
#define fi first
#define sc second
#define mp make_pair
#define is insert//also use as v.is(v's it,w's it,w's it);//Be careful in topcoder
#define ps push//stack,(priority) queue,//Be careful in topcoder.
#define fr front//queue//for priority, use top().//Be careful in topcoder.
typedef long long ll;//not necessarily//Be careful in topcoder.
typedef pair<int,int> pii;//Be careful in topcoder.
//Add other types in the same way.
const ll M=1000000007;//can be changed
int mod(int a){	return (a+M)%M;	}//M can be a variable
void plmod(ll &a,ll b){	a=(a+b+M)%M;	return;	}
void mnmod(ll &a,ll b){	a=(a-b+M)%M;	return;	}
void mlmod(ll &a,ll b){	a=(a*b)%M;  	return;	}
//Caution! you may need sth larger than "+M"!
void chmax(int &a,int b){	a=max(a,b);	return;	}
void chmin(int &a,int b){	a=min(a,b);	return;	}
//These 2 could be better in long long

#define MAX_N 100000
int a[MAX_N];

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;++i) scanf("%d",&a[i]);
	sort(a,a+n);
	int i=lower_bound(a,a+n-1,(a[n-1]/2))-a;
	if(i==n-1) printf("%d %d\n",a[n-1],a[n-2]);
	else if(i==0) printf("%d %d\n",a[n-1],a[i]);
	else if(abs(2*a[i-1]-a[n-1])<abs(2*a[i]-a[n-1])) printf("%d %d\n",a[n-1],a[i-1]);
	else printf("%d %d\n",a[n-1],a[i]);
}

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

typedef long long ll;

int main() {
    int N, K;
    cin >> N >> K;
    std::vector<ll> A(N);
    for (int i = 0; i < N; ++i)
        cin >> A[i];

    for (int i = 0; i + K < N; ++i) {
        if (A[i] < A[i + K]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 4840
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define pr(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll N, M;
vector<ll> g[11];
ll ans;
ll used[11];

void dfs(ll s) {
    ll i;
    ll flag=1;
    for(i=0; i<N; i++) {
        if(used[i]==0) flag=0;
    }
    
    if(flag) {
        ans++;
        return;
    }
    
    for(i=0; i<g[s].size(); i++) {
        if(used[g[s][i]]) continue;
        used[g[s][i]]=1;
        dfs(g[s][i]);
        used[g[s][i]]=0;
    }
    
    
}

int main(void) {
    ll i;
    cin >> N >> M;
    
    for(i=0; i<M; i++) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    
    used[0]=1;
    dfs(0);
    pr(ans);
    
}















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

using namespace std;

int main(){
  int n,a[100][100],ans=0;

  cin>>n;

  for(int i=0; i<2; ++i)
    for(int k=0; k<n; ++k)
      cin>>a[i][k];


  int cnt=0;
  while(true){
    if(cnt==n) break;
    int work=0;

    for(int i=n-1-cnt; i>=0; --i) work+=a[0][i];
    for(int i=0; i<cnt+1; ++i) work+=a[1][n-1-i];


    ans=max(ans,work);

    ++cnt;
    
  }

  cout << ans << endl;

  

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

bool seen[60];
vvi G(60);

void dfs(int v){
    seen[v] = true;
    for (auto nv : G[v]){
        if (seen[nv]) continue;
        dfs(nv);
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> vec(60);

    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
        vec[i].first = a;
        vec[i].second = b;
    }

    int ans = 0;
    rep(i,m){
        memset(seen, 0, sizeof(seen));

        int a, b;
        a = vec[i].first; b = vec[i].second;
        for (auto &ele : G[a]){
            if (ele == b) ele = a;
        }
        for (auto &ele : G[b]){
            if (ele == a) ele = b;
        }

        int cnt = 0;
        rep(j,n){
            if (seen[j]) continue;
            dfs(j);
            cnt++;
        }
        if (cnt > 1) ans++;

        for (auto &ele : G[a]){
            if (ele == a) ele = b;
        }
        for (auto &ele : G[b]){
            if (ele == b) ele = a;
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3616
def dfs(n,lst,s):
	if int(s) >n:
		return 
	if all([c in s for c in "753"]):
		lst.append(s)
	for c in "753":
		dfs(n,lst,s+c)

lst=[]
n =int(input())
for c in "753":
	dfs(n,lst,c)
print(len(lst))


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

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

    if(a >= 0 && b >= 0)
    {
        cout << (a == 0 || b == 0 ? "Zero" : "Positive") << endl;
        return 0;
    }

    int num_neg = b - a + 1;
    if(b >= 0)
    {
        cout << "Zero" << endl;
        return 0;
    }

    cout << (num_neg % 2 == 0 ? "Positive" : "Negative") << endl;
}


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

int main() {
    int N, A, B, xa , xb;
  cin >> N >> A >> B ;
  xa=N*A ;
  xb=B ;
    if (xa < xb) {
    cout << xa << endl;
  }
  else {
    cout << B << endl;
    }
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())
if A > B:
    print(0)
elif A == B:
    print(1)
else:
    if N == 1:
        if A == B:
            print(1)
        else:
            print(0)
    else:
        print((N - 2)*(B - A) + 1)


Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans = 0;
int main() {
	vl A,B(100001,0);
	ans = 1;
	cin >> n;
	inputv(A, n);
	B[0] = 3;
	rep(i, n) {
		x = A[i];
		ans = (ans * B[x]) % MOD;
		B[x]--;
		B[x + 1]++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

int N, ans;

int main()
{
    cin >> N;
    vector<int> h(N);

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

    int now = 0;

    for (int i = 1; i < N; i++)
    {
        if (h[i] <= h[i - 1])
            now++;
        else
            ans = max(ans, now), now = 0;
    }

    cout << max(ans, now) << endl;
}


Measured memory_bytes: 640
from collections import deque
def bfs(h,w,m,sy,sx):
    INF = 10**12
    max_length = 0
    # すべての点を INF で初期化
    d = [[INF for j in range(w)] for i in range(h)]
    
    # 移動4方向のベクトル
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    
    # スタート地点をキューに入れ、その点の距離を0にする
    q = deque([])
    q.append((sx,sy))
    d[sy][sx] = 0
    
    # キューが空になるまでループ
    while q:
        #キューの先頭を取り出す
        p = q.popleft()
        #四方向移動
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if 0 <= nx and nx < w and 0 <= ny and ny < h and m[ny][nx] != '#' and d[ny][nx] == INF:
                q.append((nx,ny))
                d[ny][nx] = d[p[1]][p[0]] + 1
                if d[ny][nx] > max_length:
                    max_length = d[ny][nx]
    return max_length

h,w = map(int, input().split())
m = []
max_len = 0
for i in range(h):
    m.append(input())
for i in range(h):
    for j in range(w):
        if m[i][j] == '.':
            length = bfs(h,w,m,i,j)
            if length > max_len:
                max_len = length
print(max_len)

Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = 1;
    for(int i = 1; i * i <= N; i++) {
        ans = i * i;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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



	int x, a, b;
	cin >> x >> a >> b;

	if (abs(a - x) < abs(b - x)) {
		cout<<"A"<<endl;
	}
	else
		cout<<"B"<<endl;
	return 0;
}



Measured memory_bytes: 256
s=input()
t=input()

ans=1<<30
for i in range(len(s)-len(t)+1):
    ss=s[i:i+len(t)]
    cnt=0
    for j in range(len(t)):
        if ss[j]!=t[j]:cnt+=1
    ans=min(ans,cnt)

print(ans)

Measured memory_bytes: 8988
using System;
using System.Linq;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        int[][] c = Enumerable.Repeat(0, 3).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
        if (c[0][0] + c[1][1] + c[2][2] == c[0][1] + c[1][2] + c[2][0] && c[0][1] + c[1][2] + c[2][0] == c[0][2] + c[1][0] + c[2][1])
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }    
}

Measured memory_bytes: 13396
import java.util.*;
import java.util.stream.*;

public class Main {

	public static void main(String[] args){
		
		// 方針：タブーリスト付きの深さ優先探索、この手に限る
		
		// 隣接行列、0か1なのでbooleanで十分
		boolean[][] adjacencyMatrix = createAdjacencyMatrix();
		int n= adjacencyMatrix.length;
		// 訪問履歴、タブーリスト
		boolean[] history = new boolean[n];
		// 1番のノード（インデックスの0）から探索を始めるよ
		history[0] = true;
		int eulerianTrailNum = traverseAndCountEulerianTrail(0, adjacencyMatrix, history);
		System.out.println(eulerianTrailNum);
		
	}
	
	// 入力から隣接行列を作る
	public static boolean[][] createAdjacencyMatrix(){
		
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int m = scan.nextInt();
		
		boolean[][] ret = new boolean[n][n];
		
		IntStream.range(0, m)
			.forEach(nouse -> {
				// 配列の番号じゃなくて、ノード番号で渡されるので-1
				int p = scan.nextInt() - 1;
				int q = scan.nextInt() - 1;
				ret[p][q] = true;
				ret[q][p] = true;
			});
		
		scan.close();
		return ret;
		
	}
	
	public static int traverseAndCountEulerianTrail(int currentNode, boolean[][] adjacencyMatrix, boolean[] history) {
		
		history[currentNode] = true;
		
		int n = history.length;
		// ここがゴールだったみたいです。1本見つけましたよ
		if(IntStream.range(0, n).boxed().allMatch(index -> history[index])) {
			history[currentNode] = false;
			return 1;
		}
		
		// ゴールじゃなかったので再帰して木探索してきてね
//		return IntStream.range(0, n)
		int ans  = IntStream.range(0, n)
						// 隣接してて、行ったことのないところに行きたい
						.filter(index -> adjacencyMatrix[currentNode][index] && history[index] == false)
						// map関数の中でhistoryトグルさせるのは予期できない挙動なので本当は嫌
						.map(index -> {
//							history[index] = true;
							// 再帰していってきます
							int num = traverseAndCountEulerianTrail(index, adjacencyMatrix, history);
							// 深さ優先探索なので配列を使いまわせる
//							history[index] = false;
							return num;
						})
						.sum();
		
		history[currentNode] = false;
		
		return ans;
		
	}

}


Measured memory_bytes: 47252
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(N);
    int ans = INF;
    for(int a = 1;a < N;a++){
        int total = 0;
        string s = to_string(a);
        string t = to_string(N-a);
        FOREACH(b,s){
            total+=b -'0';
        }
        FOREACH(b,t){
            total+=b - '0';
        }
        ans = min(total,ans);
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
long long int k,a,b;
cin >> k >> a >>b;
if (a+2>=b) cout << k+1 <<endl;
else {
if (k<=a-1)cout << k+1 <<endl;
else {
if ((k-(a-1))%2==0)cout << a+(b-a)*(k-(a-1))/2 <<endl;
else cout << a+(b-a)*(k-(a-1)-1)/2+1 <<endl;
}
}

}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

struct UnionFind{
    vector<int> data;
    //data[i] = -x ... iが根であり、サイズがx
    //data[i] = x ... iの親がx

    //最初は全員根
    UnionFind(int size): data(size,-1){}

    bool union_set(int x, int y){//サイズがx>yになるようにしてから、xにyをつなげる
        x=root(x);
        y=root(y);
        if(x != y){
            if(data[y] < data[x]) swap(x,y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool find_set(int x, int y){//ルートが一致するかどうかを返す
        return root(x) == root(y);
    }
    int root(int x){//根を見つける。ついでに深さ2にしちゃう
        return data[x]<0 ? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};

struct Edge{
    int s,t,cost;
    bool operator<(const Edge &o) const{
        return cost < o.cost;
    }
};

int dfs(vector<vector<int>>& g, vector<pair<int,int>>& res, int v, 
    int& count, int from, vector<int>& low, vector<int>& pre){
    pre[v] = count++;
    low[v] = pre[v];

    for(auto to: g[v]){
        if(pre[to] == -1){//未到達なら
            low[v] = min(low[v], dfs(g,res,to,count,v,low,pre));
            if(low[to] == pre[to]){
                res.push_back(make_pair(v,to));
            }
        }else{
            if(from == to){//来た道にはもどらない
                continue;
            }
            low[v] = min(low[v], low[to]);
        }
    }
    return low[v];
}

vector<pair<int,int>> bridges(vector<vector<int>>& g, int V){
    vector<pair<int,int>> res;
    if(V>0){
        vector<int> pre(V,-1);
        vector<int> low(V,-1);
        int count = 0;
        dfs(g,res,0,count,-1,low,pre);
    }
    return res;
}


int main() {
    int N,M; cin >> N >> M;
    vector<vector<int>> G(N);

//DFS
    REP(i,M){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector <pair<int,int>> bridge_num = bridges(G,N);
    cout << bridge_num.size() << endl;

//UnionFind
    // int ans = 0;
    // REP(i,M){
    //     UnionFind uf(N);
    //     REP(j,M){
    //         if(i!=j){
    //             uf.union_set(a[j], b[j]);
    //         }
    //     }
    //     if(!uf.find_set(a[i],b[i])){
    //         ans++;
    //     }
    // }
    // cout << ans << endl;
    // return 0;




    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
const int N=5001;
int n,k,sum;
int a[N],dp[N][N];
bool check(int x)
{
    memset(dp,0,sizeof(dp));
    if(x==1)
    {
        dp[2][0]=1;
        dp[2][a[2]]=1;
        for(int i=3;i<=n;i++)
        {
            for(int j=0;j<=k;j++)
            {
                dp[i][j]=dp[i-1][j];
                if(j>=a[i])
                    dp[i][j]=dp[i-1][j]|dp[i-1][j-a[i]];    
            }
        }
    }
    else
    {
        dp[1][0]=1;
        dp[1][a[1]]=1;
        for(int i=2;i<=n;i++)
        {
            if(x==i)
            {
                for(int j=0;j<=k;j++)
                    dp[i][j]=dp[i-1][j];
                continue;
            }
            for(int j=0;j<=k;j++)
            {
                dp[i][j]=dp[i-1][j];
                if(j>=a[i])
                    dp[i][j]=dp[i-1][j]||dp[i-1][j-a[i]];   
            }
        }
    }
    /*
    printf("x:%d\n",x);
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=k;j++)   
            printf("%d ",dp[i][j]);
        printf("\n");
    }
    */
    for(int i=k-a[x];i<k;i++)
        if(dp[n][i])
            return true;
    return false;
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);  
        a[i]=min(a[i],k);
    }
    if(n==1)
    {
        if(a[1]>=k)
            printf("0\n");
        else
            printf("1\n");
        return 0;
    }
    sort(a+1,a+n+1);
    int lb=0,ub=n+1;
    while(lb+1<ub)
    {
        int mid=(lb+ub)/2;
        if(check(mid))  
            ub=mid;
        else 
            lb=mid;
    }
    printf("%d\n",lb);
    return 0;
}


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


using namespace std;

int main()
{
    int c=0;
    string s,t;
    cin>>s;
    cin>>t;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
        {
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
using LL = int64_t;
LL inv(LL a, LL n = mod) {
  return a < 2 ? a : ((1 - n * 1LL * inv(n % a, a)) / a % n + n) % n;
}
int main() {
  int n;
  scanf("%d", &n);
  unordered_map<int, int> m;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    a[i] = x;
    unordered_map<int, int> t;
    for (LL i = 2; i * i <= x; ++i) {
      while (x % i == 0) {
        t[i]++;
        x /= i;
      }
    }
    if (x > 1) t[x]++;
    for (auto &it : t) {
      m[it.first] = max(m[it.first], it.second);
    }
  }
  LL lcm = 1;
  for (auto &it : m) {
    for (int i = 0; i < it.second; ++i) {
      lcm = lcm * it.first % mod;
    }
  }
  LL ans = 0;
  for (auto &x : a) {
    ans += lcm * inv(x);
    ans %= mod;
  }
  printf("%lld\n", ans);
  return 0;
}



Measured memory_bytes: 768
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
    int k[101],a,b,i;
	for (i=0;i<101;i++) k[i]=0;
	while(cin >> a >> b) {
		if (a+b>0) { k[a]++; k[b]++; continue;}
		for (i=3;i<101;i++) if ((k[i] % 2)==1) break;
		if (i<101 || k[1] % 2==0 || k[2] % 2==0) cout << "NG"; else cout << "OK";
		cout << endl;
        for (i=0;i<101;i++) k[i]=0;
	}
 return 0;
}

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

int main() {
	int N, M, Q;
	int L[200000], R[200000];
	int nijigen[501][501] = {};
	cin >> N >> M >> Q;
	repeat(i, M) {
		cin >> L[i] >> R[i];
		nijigen[L[i]][R[i]] += 1;
	}
	int p[100000], q[100000];
	repeat(i, Q) {
		cin >> p[i] >> q[i];
	}


	int ruikei[502][502] = {};

	repeat(i, N) {
		repeat(ii, N) {
			ruikei[i + 1][ii + 1] = ruikei[i + 1][ii] + nijigen[i + 1][ii + 1];
		}
	}

	repeat(ii, N) {
		repeat(i, N) {
			ruikei[N - i][ii + 1] = ruikei[N - i + 1][ii + 1] + ruikei[N - i][ii + 1];
		}
	}

	repeat(i, Q) {
		//printf("%d\n", ruikei[p[i]][q[i]]);
		cout << ruikei[p[i]][q[i]] << "\n";
	}
	Would you return 0;
}

Measured memory_bytes: 5376
#include "bits/stdc++.h"

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	string s;
	cin >> s;

	vb alphabet(26);
	for (auto c : s) {
		alphabet[c - 'a'] = true;
	}

	string res = "None";
	for (int i = 0; i < alphabet.size(); i++) {
		if (!alphabet[i]) {
			string str;
			str = (i + 'a');
			res = str;
			break;
		}
	}

	cout << res << endl;
	return 0;
}

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

class Program
{
    public static void Main()
    {
        var s=Console.ReadLine().Split(' ');
        long S = long.Parse(s[0]);
        long C = long.Parse(s[1]);
        long c = Math.Min(S, C / 2);
        C -= 2 * c;
        Console.WriteLine(C / 4 + c);
    }
}


Measured memory_bytes: 13140
while 1:
    n = input()
    if n==0:break
    L = map(len, [raw_input() for i in xrange(n)])
    pair = [5, 7, 5, 7, 7]
    for i in xrange(n):
        idx = 0
        cnt = 0
        for j in xrange(i, n):
            cnt += L[j]
            if cnt == pair[idx]:
                idx += 1
                cnt = 0
                if idx == 5:
                    print i+1
                    break
            elif cnt > pair[idx]:
                break
        if idx==5:break

Measured memory_bytes: 6448
import math
import sys
from decimal import Decimal


N = int(sys.stdin.readline())
TA = []
for i in range(N):
    TA.append(list(map(int, sys.stdin.readline().split())))

current_T = 1
current_A = 1
for i in range(N):
    count = max(math.ceil(Decimal(current_T)/Decimal(TA[i][0])), math.ceil(Decimal(current_A)/Decimal(TA[i][1])))
    current_T = TA[i][0] * count
    current_A = TA[i][1] * count

print(current_T + current_A)


Measured memory_bytes: 5076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	string s;
	cin>>s;
	int n=s.size();
	if(s[0]=='A' && s[1]=='A' && s[2]=='A')
		cout<<"No"<<endl;
	else if(s[0]=='B' && s[1]=='B' && s[2]=='B')
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
}

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

#define N 200123
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define all(cont) cont.begin(), cont.end()
#define fastio ios::sync_with_stdio(false); cin.tie(0)

int main(){
	fastio;
   	int a, b, c;
   	cin >> a >> b >> c;
   	cout << min(a+b, min(a+c, b+c)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int num[N],n,a,ans;
int main()
{
	std::ios::sync_with_stdio(false);
	cin>>n;
	while(n--)
	{
		cin>>a;
		a++;
		num[a+1]++;
		num[a]++;
		num[a-1]++;
	}
	for(int i=0;i<N;i++)ans=max(ans,num[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>>s(h,vector<char>(w));
    vector<vector<int>>yoko(h,vector<int>(1));
    vector<vector<int>>tate(w,vector<int>(1));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>s[i][j];
            if(s[i][j]=='#'){
                yoko[i].push_back(j+1);
                tate[j].push_back(i+1);
            }
        }
        yoko[i].push_back(w+1);
    }
    for(int i=0;i<w;i++)tate[i].push_back(h+1);
    int x=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#')continue;
            int a=upper_bound(yoko[i].begin(),yoko[i].end(),j)-yoko[i].begin();
            int b=upper_bound(tate[j].begin(),tate[j].end(),i)-tate[j].begin();
            x=max(x,yoko[i][a]-yoko[i][a-1]+tate[j][b]-tate[j][b-1]-3);
        }
    }
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 38400
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <string>
using namespace std;
 
int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
 
	string A,B,d;
  int a,b;
  cin>>A>>B;
  cin>>a>>b;
  cin>>d;

  if(!A.compare(d))a--;
  else if(!B.compare(d))b--;

  cout<<a<<" "<<b;
 
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int N=10000;
int INFTY=(1<<21);
int W=0,G=1,B=2;

main(){
  int n,i,j,k,b,c=0,u,v,minv,M[500000][3];
  int d[N],color[N];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      M[c][W] = u;
      scanf("%d %d",&v,&b);
      M[c][G] = v;
      M[c][B] = b;
      c++;
    }
  }
  color[u] = G;
  for(i=0;i<n;i++){
    d[i] = INFTY;
  }
  d[0] = 0;
  while(color[u] != 0){
    color[u] = W;
    for(v=0;v<c;v++){
      if(d[M[v][G]] > d[M[v][W]] + M[v][B]){
        d[M[v][G]] = d[M[v][W]] + M[v][B];
        color[u] = G;
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d %d\n",i,(d[i]==INFTY?-1:d[i]));
  }
  return 0;
}


Measured memory_bytes: 7556
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N, K;
	cin >> N >> K;

	if (N % K) {
		cout << 1 << endl;
	} else {
		cout << 0 << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    string s;
    cin>>s;
    int a=0,b=0,c=0;
    for(int i = 0;i < s.size(); i++){
        if( s[i] == 'A' ) a++;
        if( s[i] == 'B')  b++;
    }
    if(a>0 && b>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
#include<numeric>
using namespace std;
#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)
int INF=1e9;
const long long mod=1e9+7;
typedef long long ll;

int main(){
  ll A,B,C,D;
  cin>>A>>B>>C>>D;
  ll E=__gcd(C,D);
  ll lcm=C*D/E;
  ll F=(A-1)/C;
  ll G=B/C;
  ll H=(A-1)/D;
  ll I=B/D;
  ll J=(A-1)/lcm;
  ll K=B/lcm;
  cout<<(B-A+1)-(G-F)-(I-H)+(K-J)<<endl;
  return 0;
}

Measured memory_bytes: 256