akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int, input().split()))
arrays = []
a.sort()

b = []
c = []

for i in a:
    if i < 0:
        c.append(i)
    else:
        b.append(i)

if len(c) >= 1 and len(b) >= 1:
    while len(b) > 1:
        x = b.pop(0)
        array = [c[0], x]
        c[0] -= x
        arrays.append(array)
    while len(c) > 1:
        y = c.pop(0)
        array = [b[0], y]
        b[0] -= y
        arrays.append(array)

    array = [b[0], c[0]]
    arrays.append(array)

    print(b[0] - c[0])

elif len(b) == 0 and len(c) >= 1:
    mi = c.pop(-1)
    while len(c) > 1:
        x = c.pop(0)
        array = [mi, x]
        mi -= x
        arrays.append(array)
    array = [mi, c[0]]
    arrays.append(array)
    print(mi - c[0])


elif len(b) >= 1 and len(c) == 0:
    mi = b.pop(0)
    while len(b) > 1:
        x = b.pop(0)
        array = [mi, x]
        mi -= x
        arrays.append(array)
    array = [b[0], mi]
    arrays.append(array)
    print(b[0]-mi)


for x, y in arrays:
    print(x, y)



Measured memory_bytes: 22572
use proconio::{
    input,
    marker::Chars,
};

fn main() {
    input! {
        s: Chars,
        t: Chars,
    }

    let t_len = t.len();
    let sub = s.len() - t_len;
    let mut ans = 0;

    for n in 0..=sub {
        let mut tmp = 0;
        for i in 0..t_len {
            if s[n + i] == t[i] {
                tmp += 1;
            }
        }
        if ans < tmp {
            ans = tmp;
        }
    }
    println!("{}", t_len - ans)
}


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

using namespace std;

typedef long long ll;

const int N = 200100;
const ll M = 1e9 + 7;

ll f[N], finv[N];

ll binpow(ll a, ll p) {
    ll s = 1;
    while (p) {
        if (p & 1) {
            s = s * a % M;
        }
        a = a * a % M;
        p >>= 1;
    }
    return s;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    f[0] = finv[0] = 1;
    for (int i = 1; i < N; ++i) {
        f[i] = f[i - 1] * i % M;
        finv[i] = binpow(f[i], M - 2);
    }
    ll ans = 0;
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    /*
     *    000
     *    x00
     */
    int row = h - a;
    for (int col = b + 1; col <= w; ++col) {
        ll t1 = f[row + col - 2] * finv[row - 1] % M * finv[col - 1] % M;
        ll t2 = f[a + w - col - 1] * finv[a - 1] % M * finv[w - col] % M;
        ans = (ans + t1 * t2) % M;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	ll ans = 0;
	int n; cin >> n;
	vi a(n + 1);
	for(int &i : a) cin >> i;
	rep(i, n){
		int b, c; cin >> b;
		c = min(a[i], b);
		a[i] -= b; b -= c;
		ans += c;
		ans += min(a[i + 1], b);
		a[i + 1] -= min(a[i + 1], b);
	}
	cout << ans << endl;
	
	return 0;
}

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

int compare_char(char *a,char *b){
	return strcmp(a,b);
}

int intsort(const void *a, const void *b){
	return *(int*)b - *(int*)a;
	/*qsort(a,aの配列数,sizeof(int),intsort);*/
}

int longsort(const void *a, const void *b){
	long *A=(long *)a;
	long *B=(long *)b;
	if(*A>*B) return -1;
	if(*A<*B) return 1;
	return 0;
}

int main(){
  int i,N,K,a[200000];
  char ss[10000];
  scanf("%d",&N);
  scanf("%d",&K);
  if(N<6){
    printf("%d\n",0);
  }else if(N<13){
    printf("%d\n",K/2);
  }else{
    printf("%d\n",K);
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>



using namespace std;

int main(){
 int n,x;
 cin >> n >> x;
  
  int cnt=1;
  int d=0;
  int l;
  
  for(int i=0;i<n;i++){
  cin >> l;
   d+=l; 
    if(d<=x){
    cnt++;
    }
    else{
    break;
    }
  }

 
 cout << cnt << endl;
 
}

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

int main() {
  //入力
  vector<int>abc(5);
  for(int i=0;i<5;i++)
  {
    cin >> abc[i];
  }

  //処理
  int ans=0;
  for(int i=0;i<5;i++)
  {
    ans+=abc[i];
    abc[i]=abc[i]%10;
  }
  sort(abc.begin(),abc.end());
  //reverse(abc.begin(),abc.end());
  int o=0;
  for(int i=0;i<5;i++)
  {
    if(abc[i]==0)
    {
    continue;
    }
    else if(o==1)
    {
      ans+=10-abc[i];
    }
    else
    {
      o++;
    }
  }

  cout << ans <<endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] takoyaki = new int[n];
	for(int i = 0; i < n; i++){
	  takoyaki[i] = sc.nextInt();
    }
    
    int ans = 0;
    for(int i = 0; i < n-1; i++){
      for(int j = i+1; j < n; j++){
            ans += takoyaki[i]*takoyaki[j];
      }
    }
      	System.out.println(ans);
	
  }
}

Measured memory_bytes: 35820
D=int(input())
*c,=map(int,input().split())
s=[]
for i in range(D):
    *x,=map(int,input().split())
    s.append(x)

dt=[]
last=[-1]*26
v=0
for d in range(D):
    news=[s[d][i]+c[i]*(d-last[i])*(d-last[i]-1)//2 for i in range(26)]
    maxi=0
    tmp=-float('inf')
    for i in range(26):
        if tmp<news[i]:
            maxi=i
            tmp=news[i]
    last[maxi]=d
    v+=s[d][maxi]
    for i in range(26):
        v-=c[i]*(d-last[i])
    dt.append(maxi+1)

def score(T):
    last=[-1]*26
    v=0
    for d in range(D):
        v+=s[d][T[d]-1]
        last[T[d]-1]=d
        for i in range(26):
            v-=c[i]*(d-last[i])
    return v

v0=max(score(dt)+10**6,0)

for d in range(1,D):
    y=-1
    newdt=dt+[]
    for i in range(26):
        if dt[d]!=i+1:
            newdt[d]=i+1
            v1=max(score(newdt)+10**6,0)
            if v0<v1:
                y=i+1
                v0=v1
    if y!=-1:
        dt[d]=y

for i in dt:
    print(i)

Measured memory_bytes: 75180
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String string = sc.nextLine();
		
		String[] array = string.split(" ");
		int[] array2 = new int[2];
		for(int i=0; i<array.length; i++) {
				array2[i] = Integer.parseInt(array[i]);
		}
		array2[1] -=1;
		String line = sc.nextLine();
		String ans = line.substring(0, array2[1]) + line.substring(array2[1],array2[1]+1).toLowerCase() + line.substring(array2[1]+1);
		System.out.println(ans);

	}

}

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

int main() {
    int a, b, c, ans = 0;
    cin >> a >> b >> c;
    while (a <= b && c) {
        b -= a;
        c--;
        ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define se second
#define fi first
#define pb push_back
const int N=2e5 + 5;
int v[N];
int n;

ll check(int mid){
	ll ret=0;
	mid++;
	for(int i=1;i <= n;i++){
		ret+=abs(v[i] - mid);
		mid++;
	}
	return ret;
}

int main(){

//	freopen("in.txt","r",stdin);

	scanf("%d",&n);
	int l=1e9,r=-1e9;
	for(int i=1;i <= n;i++){
		scanf("%d",v + i);
		r=max(r,v[i] - i);
		l=min(l,v[i] - i);
	}
	ll ans=1e18;
	for(int it=0;it < 1000 && (r - l) > 50;it++){

		int l1=(l * 2LL + r) / 3;
		int l2=(l + r * 2LL) / 3;
		ll c1=check(l1),c2=check(l2);
		ans=min(ans,c1);
		ans=min(ans,c2);
		if(c1 <= c2) r=l2;
		else l=l1;
	}
	for(int i=l;i <= r;i++){
		ans=min(ans,check(i));
	}
	cout << ans << endl;
	return 0;
}


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

int main(void){
    int n, k;
    string s;
    cin >> n >> k >> s;
    int sum = 0;
    int able = 0;
    rep(i,n-1){
        if (s[i] == s[i+1]) sum++;
        else able++;
    }
    cout << sum + min(able, k*2) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
 
using namespace std;

#define mod 1000000007

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    int beforec = s[0];
    for(int i = 1; i < s.length(); i++){
        if(s[i] != beforec){
            ans++;
            beforec = s[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
 
int H,W;
char S[25][25];
 
int bfs(pair<int,int> u){
 
    vector<vector<int>> dis(25,vector<int>(25,0));
    
    queue<pair<int,int>> q;
    q.push(u);
 
    while(!q.empty()){
        pair<int,int> v;
        v = q.front();
        q.pop();
        int vx = v.first;
        int vy = v.second; 
        
        for(int i=0; i<4; i++){
            int nx,ny;
            nx = vx+dx[i];
            ny = vy+dy[i];
            if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
            if(S[ny][nx] == '#') continue;
            if(dis[ny][nx] != 0) continue;
            if(nx == u.first && ny == u.second) continue;
            dis[ny][nx] = dis[vy][vx]+1;
            q.push({nx,ny});
        }
    }
 
    int ma = 0;
 
    for(int i=0; i<H; i++) ma = max(ma,*max_element(dis[i].begin(),dis[i].end()));
 
    return ma;
}
 
 
int main(){
    cin>>H>>W;
 
    for(int i=0; i<H;  i++){
        for(int j=0; j<W; j++){
            cin>>S[i][j];
        }
    }
 
    queue<pair<int,int>> q;
    int ans = 0;
 
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(S[i][j] == '.') ans = max(ans,bfs({j,i}));
        }
    }
 
    cout<<ans<<endl;
 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {

  std::string s;
  std::cin >> s;
  int count = 0;

  for(int i=0; i<s.size(); ++i) {
    if(s[i] == 'o') {
      count++;
    }
  }

  std::cout << 700+count*100 << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 using namespace std; 
  int main() { 
    long long a,b;
    cin>>a>>b;
   long long sum=0;
  vector<int>k;
   for(int i=0;i<a;i++){
       long long x;
       cin>>x;
      k.push_back(x);
     }
  sort(k.begin(),k.end());
  if(b<=a){
  
  for(int i=a-1;i>a-b-1;i--){
      k[i]=0;
  }
  for(int i=0;i<a;i++){
      sum=sum+k[i];
  }
      
  }else if(b>a){
      sum=0;
  }
  cout<<sum;
     }


Measured memory_bytes: 1400
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  vector<int> vec;
  vec.push_back(a);
  vec.push_back(b);
  vec.push_back(c);
  sort(vec.begin(),vec.end());
  vec.erase(unique(vec.begin(),vec.end()),vec.end());
  cout << vec.size() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>

int main(){
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  int N,Y;
  std::cin >> N;
  std::set<int> s;
  for(int x=0;x<N;x++){
    std::cin >> Y;
    s.insert(Y);
  }
  std::cout << s.size() << std::endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.sql.Array;
import java.util.*;



public class Main {

    public static void main(String[] args){
	// write your code here
        Scanner sc=new Scanner(System.in);
        double r = sc.nextDouble();
        System.out.printf("%f %f",Math.PI*r*r,Math.PI*r*2);
    }
}



Measured memory_bytes: 28280
import java.util.Scanner;

//Commute routes
public class Main{

	static int[][][] dp;
	static int w;
	static int h;
	
	//k=0: start
	//k=1: right 1
	//k=2: right >= 2
	//k=3: up 1
	//k=4: up >= 2
	static int get(int i, int j, int k){
		if(dp[i][j][k]!=-1)return dp[i][j][k];
		int s = 0;
		if(k==0){
			if(i-1>=0){
				s += get(i-1, j, 4);
			}
			if(j+1<w){
				s += get(i, j+1, 2);
			}
		}
		else if(k==1){
			if(j+1<w){
				s += get(i, j+1, 2);
			}
		}
		else if(k==2){
			if(i-1>=0){
				s += get(i-1, j, 3);
			}
			if(j+1<w){
				s += get(i, j+1, 2);
			}
		}
		else if(k==3){
			if(i-1>=0){
				s += get(i-1, j, 4);
			}
		}
		else if(k==4){
			if(i-1>=0){
				s += get(i-1, j, 4);
			}
			if(j+1<w){
				s += get(i, j+1, 1);
			}
		}
		return dp[i][j][k] = s%100000;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			if((w|h)==0)break;
			dp = new int[h][w][5];
			for(int i=0;i<h;i++)for(int j=0;j<w;j++)for(int k=0;k<5;k++)dp[i][j][k]=-1;
			for(int i=0;i<h;i++){
				dp[i][w-1][2] = dp[i][w-1][3] = dp[i][w-1][4] = 1;
			}
			for(int j=0;j<w;j++)dp[0][j][1] = dp[0][j][2] = dp[0][j][4] = 1;
			System.out.println(get(h-1, 0, 0));
		}
	}
}

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

#define rep(a, b, c) for (long a = b; a < c; a++)
using namespace std;

int A, L;

int convert(vector<int> list) {
    int rtn = 0;
    rep(i, 0, list.size()) {
        rtn *= 10;
        rtn += list[list.size() - i - 1];
    }
    return rtn;
}

vector<int> convert(int num) {
    vector<int> rtn(L, 0);
    rep(i, 0, rtn.size()) {
        rtn[i] = num % 10;
        num /= 10;
    }
    return rtn;
}

int makeMax(vector<int> list) {
    sort(list.begin(), list.end());
    return convert(list);
}

int makeMin(vector<int> list) {
    sort(list.begin(), list.end(), greater<int>());
    return convert(list);
}

void saiki(map<int, int> rem, vector<int> list, int i) {
    int num = convert(list);
    if (rem.count(num) != 0) {
        cout << rem[num] << " " << num << " " << (i - rem[num]) << endl;
        return;
    }
    rem.insert(map<int, int>::value_type(num, i));
    saiki(
            rem,
            convert(makeMax(list) - makeMin(list)),
            i + 1
    );
}

int main() {
    while(true) {
        cin >> A >> L;
        if (A == 0 && L == 0) {
            break;
        }
        saiki(
                map<int, int>(),
                convert(A),
                0
        );
    }
    return 0;
}

Measured memory_bytes: 1236
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
map<int,int> mp;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	ll f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
int main(){
	int n=read();
	for(int i=1;i<=n;i++)
		mp[read()]++;
	int m=read();
	for(int i=1;i<=m;i++){
		int x=read();
		if(!mp[x]){
			printf("NO\n");
			return 0;
		}
		else mp[x]--;
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
//#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    sort(a,a+n);
    if(a[0]==0){
        cout<<0<<endl;
    }else{
        ll ans=1;
        rep(i,0,n-1){
            if(ans>(powl(10,18)/a[i])){
                cout<<-1<<endl;
                return 0;
            }else{
                ans=ans*a[i];
                if(ans>powl(10,18)){
                    cout<<-1<<endl;
                    return 0;
                }
            }
        }
        cout<<ans<<endl;
    }
    
    return 0;
}





Measured memory_bytes: 4428
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] p = new int[n];
    for(int i = 0;i < n;i++){
      p[i] = sc.nextInt();
    }
    Arrays.sort(p);
    p[n-1] /= 2;
    int total = 0;
    for(int i = 0;i<n;i++){
      total += p[i];
    }
    System.out.println(total);
  }
}


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

string a[200005];
int maxcnt, cnt[200005];

int main()
{
    
    int n;
    cin >> n;
    
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
    }

    sort(a, a+n);

    cnt[0] = 1;
    maxcnt = 1;
    for(int i=1; i<n; i++)
    {
        if(a[i] == a[i-1])
        {
            cnt[i] = cnt[i-1] + 1;
        }
        else
        {
            cnt[i] = 1;
        }
        
        maxcnt = max( maxcnt, cnt[i]);
    }

    for(int i=0; i<n; i++)
    {
        if(cnt[i] == maxcnt)
        {
            cout << a[i] << "\n";
        }
    }
    


    return 0;    

}


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

int main(){
  int w,h,n;
  cin >> w >> h >> n;
  int x[n],y[n], a[n],b[4]={0,w,0,h};
  for(int i = 0;i < n;++i){
    cin >> x[i] >> y[i] >> a[i];
    if(a[i] == 1){
      if(x[i] > b[0]){
        b[0] = x[i];
      }
    }else if(a[i] == 2){
      if(x[i] < b[1]){
        b[1] = x[i];
      }
    }else if(a[i] == 3){
      if(y[i] > b[2]){
        b[2] = y[i];
      }
    }else{
      if(y[i] < b[3]){
        b[3] = y[i];
      }
    }
  }
 
  if(b[1] - b[0] >= 0&& b[3] -b[2]>= 0){
    cout << (b[3]-b[2])*(b[1]-b[0])<<endl;
  }else{
    cout << 0 << endl;
  }
  
 
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int a, b, c, d, n, kazu, ans[60], an;
	an = 0;
	while (cin >> n) {
		an++;
		kazu = 0;
		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) {
							kazu = kazu + 1;
						}
					}
				}
			}
		}
		ans[an] = kazu;
	}
	for (int i = 1; i <= an; i++) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 1000000007;
ll mypow(ll a, ll b)
{
  ll res = 1;
  a %= mo;
  while (b)
  {
    if (b & 1)
      res = res * a % mo;
    a = a * a % mo;
    b >>= 1;
  }
  return res;
}
const ll MAX = 510000;
const ll MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(ll n, ll k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
ll b , w ;
cin >> b >> w ;
vector<vector<ll>> v(b+w, vector<ll>(2,0) );
ll buf=0;
ll half=mypow(2,mo-2);
COMinit();
for (ll i = w; i < b+w; i++)
{
  v[i][0]=(buf*half)%mo+(mypow(mypow(2,i),mo-2)*COM(i,w))%mo;
  v[i][0]%=mo;
  buf=(buf*half)%mo;
  buf+=v[i][0];
  buf%=mo;
}
buf=0;
for (ll i = b; i < b+w; i++)
{
  v[i][1]=(buf*half)%mo+(mypow(mypow(2,i),mo-2)*COM(i,b))%mo;
  v[i][1]%=mo;
  buf=(buf*half)%mo;
  buf+=v[i][1];
  buf%=mo;
}
rep(i,b+w){
  cout << ((half+half*(v[i][0]-v[i][1]))%mo+mo)%mo << endl;
}
return 0;
}

Measured memory_bytes: 25088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

ll n;
ll a[1000100];

int main(){
	while (cin >> n&&n){
		bool f = 0;
		ll ans = 0;
		REP(i, n){
			cin >> a[i];
			if (a[i] >= 2)f = 1;
		}
		if (f){
			REP(i, n){
				if (a[i] != 0)ans++;
			}
			cout << ans + 1 << endl;
		}
		else cout << "NA" << endl;
	}
}

Measured memory_bytes: 3168
import numpy as np
N, M, Q = map(int, input().split())
table = np.zeros((N, N), np.int64)
for _ in range(M):
    L, R = map(lambda n: int(n) - 1, input().split())
    table[L][R] += 1
table = np.rot90(np.rot90(table, k=-1).cumsum(axis=0).cumsum(axis=1), k=1).tolist()
for _ in range(Q):
    p, q = map(lambda n: int(n) - 1, input().split())
    print(table[p][q])

Measured memory_bytes: 21568
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

int main() {
	IOS();
	ll a, b;
	cin >> a >> b;
	ll ans = 0;
	if (a > b) {
		ans += a;
		a--;
		ans += max(a, b);
	} else {
		ans += b;
		b--;
		ans += max(a, b);
	}
	dump(ans);
	return 0;
}

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



int main(){
    
    ll N,A,B,C,D;cin>>N>>A>>B>>C>>D;
    string s;cin>>s;
    int pc=0,sc=0,pok=0,sng=0;
    rep(i,A,C-1){
        
        if(s.at(i)=='#'&&s.at(i+1)=='#'){
            cout<<"No"<<endl;
            return 0;
        }
    
    }
    rep(i,B,D-1){
        
        if(s.at(i)=='#'&&s.at(i+1)=='#'){
            cout<<"No"<<endl;
            return 0;
        }
    
    }
    if(C>D){
        rep(i,B-1,D){
            if(pok==1)break;
            if(s.at(i-1)=='.'&&s.at(i)=='.'&&s.at(i+1)=='.')pok=1;
        }
        if(pok==0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;

}






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

int main(){
    int N;
    map < string, int > memo;

    cin >> N;

    for(int i = 0; i < N; i++){
        string s;
        cin >> s;

        memo[s] += 1;
    }

    int maxv = 0;
    for(const auto& x : memo){
        int v = x.second;
        if(v > maxv) maxv = v;
    }

    for(auto it = memo.begin(); it != memo.end(); it++){
        if(it->second == maxv){
            cout << it->first << endl;
        }
    }

}

Measured memory_bytes: 25216
import sys
sys.setrecursionlimit(10**9)

N,M=map(int,input().split())
A=list(map(int,input().split()))
M=[0,2,5,5,4,5,6,3,7,6]

#まず最高何桁の数にできるか考えよう.

SET_A=set(A)

ANSLIST=[0]
def dfs(i,NOW):
    if ANSLIST[0]!=0:
        return
    ANS=0
    if NOW==N:
        L=sorted(list(i),reverse=True)
        #print(L)
        
        ANSLIST[0]=int(("".join(L)))
        return

    elif NOW>N:
        return 
    else:
        for a in A:
            dfs(i+str(a),NOW+M[a])


A.sort(reverse=True)
A.sort(key=lambda x:M[x])
dfs("",0)

x=ANSLIST[0]
stx=str(x)
from collections import Counter
counter=Counter(stx)


import itertools
for i,j,k in list(itertools.combinations(range(1,10),3)):
    for l,m,n in list(itertools.combinations(range(1,10),3)):
        if i in SET_A and j in SET_A and k in SET_A and l in SET_A and m in SET_A and n in SET_A and M[i]+M[j]+M[k]==M[l]+M[m]+M[n] and \
           counter[str(i)]>0 and counter[str(j)]>0 and counter[str(k)]>0 and (n>k or (n==k and m>j) or (n==k and m==j and l>i)):
                    x=min(counter[str(i)],counter[str(j)],counter[str(k)])
                    counter[str(i)]-=x
                    counter[str(j)]-=x
                    counter[str(k)]-=x
                    counter[str(l)]+=x
                    counter[str(m)]+=x
                    counter[str(n)]+=x

for i,j in list(itertools.combinations(range(1,10),2)):
    for l,m in list(itertools.combinations(range(1,10),2)):
        if i in SET_A and j in SET_A and l in SET_A and m in SET_A and M[i]+M[j]==M[l]+M[m] and \
           counter[str(i)]>0 and counter[str(j)]>0 and (m>j or (m==j and l>i)):
                    x=min(counter[str(i)],counter[str(j)])
                    counter[str(i)]-=x
                    counter[str(j)]-=x

                    counter[str(l)]+=x
                    counter[str(m)]+=x

for i in range(1,10):
    for l in range(1,10):
        if i in SET_A and l in SET_A and l>i and M[i]==M[l] and counter[str(i)]>0:
            counter[str(l)]+=counter[str(i)]
            counter[str(i)]=0



ANS=""
for i in range(9,-1,-1):
    ANS+=str(i)*counter[str(i)]

print(ANS)



Measured memory_bytes: 20168
/**
 *      ///----- My Info -----///
 *      Code by: Ernesto Abreu
 *      Codeforces User: Ernest0_0Abreu
 *      Country: Cuba
 *      E-mail: ernestoabreup@gmail.com
 *      CopyRight
**/
#include <bits/stdc++.h>
#ifdef Ernest0_0Abreu
#include <debug/to_string.h>
#endif
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
    	///----- My Template -----///
///======================================================================================================================================
/// Red-Black Tree
// #include <ext/pb_ds/assoc_container.hpp>  // .find_of_order(x); .order_of_key(x);
// using namespace __gnu_pbds;
// typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > indexed_set;
/// Function
#define pi (acos(-1))
#define lg2(x) 31-__builtin_clz(x)
#define lgx(x,b) log(b)/log(x)
/// Macros
#define fst first
#define scd second
#define left (node<<1)
#define right ((node<<1)+1)
#define size(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
/// Debug
#define _end cout << "\n"
#ifdef Ernest0_0Abreu
#define db(x) cerr << "[ "<< #x << " ]: " << to_string(x) << "\n"
#define dbrange(x,begin,end) cerr << "[ "<< #x << " ]: " << to_string(x,begin,end) << "\n"
#define dbname(x) cerr << to_string(x,#x) << "\n"
#define dbnamerange(x,begin,end) cerr << to_string(x,#x,begin,end) << "\n"
#define dbmat(x,begin_n,end_n,begin_m,end_m) cerr << to_string(x,#x,begin_n,end_n,begin_m,end_m) << "\n"
#define dbST(x,end) cerr << to_string(x,end) << "\n";
#define dbendl cerr << "\n";
#else 
#define db(x) ;
#define dbrange(x,begin,end) ;
#define dbname(x) ;
#define dbnamerange(x,begin,end) ;
#define dbmat(x,begin_n,end_n,begin_m,end_m) ;
#define dbST(x,end) ;
#define dbendl ;
#endif
/// Typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/// Constant
const int MAXN = 1e5+7;
const int MOD = 1e9+7;
const ull BASE = 311;
const ld EPS = 1e-9;
const int INF = ((1<<30)-1);
const ll INFLL = ((1ll<<62ll)-1ll);
const ll oo = 2e18;
/// Hash Prime Numbers: 2, 277, 293, 307, 331, 337, 1009, 2027;
/// Module Prime Numbers: 3, 998244353, 1000000007, 1000000009, 1000000021, 1000000033;
///=======================================================================================================================================
#define int long long
		///----- My code -----///

int cnt[MAXN];

int32_t main(){
	
	ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

	int N, K;
	cin >> N >> K;
	for(int i = 1; i <= K; i++){
		int d;
		cin >> d;
		for(int i = 1; i <= d; ++i){
			int a;
			cin >> a;
			cnt[a]++;
		}
	}
	int ans = 0;
	for(int i = 1; i <= N; i++){
		if(!cnt[i]) ans++;
	}
	cout << ans;

	return 0;
}


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

int main(){ 
    Int X;
    cin >> X;



    vector<Int> five(1001);

    rep(i,1001) {
        five[i] = i * i * i * i * i;
    }

    rep(i,1001) {
        for (int j = i; j < 1001; j++) {
            if (five[i] + five[j] == X) {
                cout << i << " " << -j << endl;
                return 0;
            } else if (five[j] - five[i] == X) {
                cout << j << " " << i << endl;
                return 0;
            }
        }
    }

    
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int divup(int x, int y) { return (x + y - 1) / y; }
int main() {
    int A, B; cin >> A >> B;
    cout << divup(B - 1, A - 1) << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,c;
int b=1;
int main(){
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>c;
    if(c%2==0&&c%3!=0&&c%5!=0)b=0;
  }
  if(b)cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
}

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

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b) {
        for(int i=0;i<a;i++) {
            cout<<b;
        }
    }
    else {
        for(int i=0;i<b;i++) {
            cout<<a;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, Q; cin >> N >> Q;
    vector<PiP> p(N);
    int S, T, X;
    REP(i, N){
        cin >> S >> T >> X;
        p[i] = PiP(X, Pii(S, T));
    }
    Sort(p);

    vec D(Q); cin >> D;
    set<int> s;
    REP(i, Q) s.insert(D[i]);
    map<int, int> ans;

    REP(i, N){
        int x = p[i].f, t1 = p[i].s.f, t2 = p[i].s.s;
        t1 -= x;
        t2 -= x;
        auto it1 = s.lower_bound(t1);
        auto it2 = it1;
        while(it2 != s.end() && (*it2) < t2){
            ans[*it2] = x;
            it2++;
        }
        s.erase(it1, it2);
    }
    REP(i, Q){
        if(ans.count(D[i]) == 0) Out(-1);
        else Out(ans[D[i]]);
    }

    return 0;
}


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

int main()
{
	int H, W;
	cin >> H >> W;
	vector<string> S( H );
	for ( int i = 0; i < H; i++ ) {
		cin >> S[i];
	}

	cout << string( W + 2, '#' ) << endl;
	for( int i = 0; i < H; i++ ) {
		cout << '#' << S[i] << '#' << endl;
	}
	cout << string( W + 2, '#' ) << endl;
}


Measured memory_bytes: 3628
# coding: utf-8

n = int(input().rstrip())

low = 0
high = 50000

# 二分探索
while high-low > 1:
    mid = (high+low)//2
    mid_x = int(mid*1.08)

    if mid_x == n:
        print(mid)
        exit()
    elif mid_x > n:
        high = mid
    elif mid_x < n:
        low = mid

print(":(")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
//library begin
int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int log(int a){
    int b=a;
    int cnt=0;
    while(b%2==0){
        b/=2;
        cnt++;
    }
    return cnt;
}
int mypow(int a,int b){
    if(b==0)return 1;
    if(b==1)return a;
    int t=mypow(a,b/2);
    if(b%2==0)return t*t;
    return t*t*a;
}
//library end
string s,t;
int a,b;
string u;
signed main(){
    cin>>s;
    int l=s.size();
    rep(i,l)cout<<"x";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int N = sc.nextInt();
        int R = sc.nextInt();

        System.out.println(solve(N, R));
    }

    private static int solve(int N, int R) {
        if (N>=10) return R;

        return R + 100 * (10-N);
    }
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;



int main() {
    string s; cin >> s;
    string u = s + s;
    ll k; cin >> k;
    ll n = s.size();

    bool funi = true;
    rep(i, n - 1) {
        if (s[i] != s[i + 1]) funi = false;
    }
    if (funi) {
        cout << (n * k) / 2 << endl;
        return 0;
    }

    ll num = 0;
    ll i = 0;
    while (i < n - 1) {
        if (s[i] == s[i + 1]) {
            num++;
            i += 2;
        }
        else {
            i += 1;
        }
    }
    ll ans = num * k;

    ll a = 0, b = 1;
    while (a < n) {
        if (u[n - 1 + a] == u[n - 1 + a + 1]) a++;
        else break;
    }
    while (b < n ) {
        if (u[n - b] == u[n - b - 1]) b++;
        else break;
    }
    if (a % 2 == 1 && b % 2 == 1) ans += k - 1;

    cout << ans << endl;


}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
  int n;
  std::cin >> n;

  double ans = 0;
  for(int i=0; i<n; i++){
    double x;
    string s;
    cin >> x >> s;
    if( s == "JPY" ){
      ans += x;
    }else{
      ans += x * 380000;
    }
  }
  printf("%.10lf\n", ans);
  return 0;
}


Measured memory_bytes: 256
length = int(input())
lower = []
higher = []
for i in range(length):
    x, y = map(int, input().split(" "))
    lower.append([x, y])

for i in range(length):
    x, y = map(int, input().split(" "))
    higher.append([x, y])

match = [set() for n in range(length)]
for high in range(length):
    for low in range(length):
        high_x, high_y = higher[high][0], higher[high][1]
        low_x, low_y = lower[low][0], lower[low][1]
        if high_x > low_x and high_y > low_y:
            match[high] |= {low}

matched_lower_set = set()
matched_higher_set = set()

def ret_minimum_match(match, lower_i, matched_higher_set, matched_lower_set):
    min_i = -1
    min_len = 101
    for i, ma in enumerate(match):
        if i in matched_higher_set or lower_i not in ma:
            continue
        if min_len > len(ma - matched_lower_set) > 0:
            min_len = len(ma - matched_lower_set)
            min_i = i
    return {min_i}

while True:

    lowers = [[] for n in range(length)]
    for i, mat in enumerate(match):
        if i in matched_higher_set:
            continue
        for m in mat:
            if m not in matched_lower_set:
                lowers[m].append(i)
    only_one_deleted = 0
    # print(lowers, matched_lower_set, matched_higher_set)
    for i, lo in enumerate(lowers):
        if len(lo) == 1:
            matched_higher_set |= ret_minimum_match(match, i, matched_higher_set, matched_lower_set)
            matched_lower_set |= {i}
            only_one_deleted = 1
            break

    if all([True if len(n) <= 0 else False for n in lowers]):
        break
    if not only_one_deleted:
        min_i, min_len = -1, 101
        for i, lo in enumerate(lowers):
            if min_len > len(lo) > 0:
                min_i = i
                min_len = len(lo)
        matched_higher_set |= ret_minimum_match(match, min_i, matched_higher_set, matched_lower_set)
        matched_lower_set |= {min_i}

print(len(matched_lower_set))


Measured memory_bytes: 3192
#coding:utf-8
import bisect,sys
A,B,Q=map(int,raw_input().split())
s=[0]*A
t=[0]*B
for i in range(A):    
    s[i]=int(raw_input())
for i in range(B):
    t[i]=int(raw_input())
buf=[]
def f(x):
    sl=bisect.bisect_left(s,x)-1
    sr=sl+1
    tl=bisect.bisect_left(t,x)-1
    tr=tl+1
    ans=float("inf")
    if sl!=-1 and tl!=-1:
        A=max(s[sl],t[tl])
        B=min(s[sl],t[tl])
        L=abs(x-A)+abs(A-B)
        ans=min(ans,L)
    if sl!=-1 and tr!=len(t):
        L=abs(x-s[sl])*2 + abs(t[tr]-x)        
        ans=min(ans,L)
        ans=min(ans,abs(x-s[sl])+abs(t[tr]-x)*2)
    if tl!=-1 and sr!=len(s):
        ans=min(ans,abs(x-t[tl])*2+abs(s[sr]-x))
        ans=min(ans,abs(x-t[tl])+abs(s[sr]-x)*2)
    if tr!=len(t) and sr!=len(s):
        A=min(s[sr],t[tr])
        B=max(s[sr],t[tr])
        L=abs(A-x)+abs(B-A)
        ans=min(ans,L)
    return str(ans)


for i in xrange(Q):
    x=int(raw_input())
    ans=f(x)
    print(ans)

    
    




Measured memory_bytes: 13296
n=int(input())
s=input()

from collections import Counter

c=Counter(s)

# ans = 1
# for i in list(c.values()):
#     ans*=i

r=s.count('R')
g=s.count('G')
b=s.count('B')

cnt=0
for i in range(n):
    for j in range(i+1,n):
        k = j+(j-i)
        if k>=n:
            break
        else:
            if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
                cnt+=1

print((r*g*b)-cnt)

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

t_diff = [abs(a-(t-int(h_)*0.006)) for h_ in h]
ans = 0
ans_diff = 9999
for idx,t_diff_ in enumerate(t_diff):
    if ans_diff > t_diff_:
        ans_diff = t_diff_
        ans = idx
print(ans+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+5;
multiset<ll> S[20];
char buff[20]; 
ll PW10[20]={1};
int main() {
	for(int i=1;i<=10;i++) PW10[i]=PW10[i-1]*10;
	cin>>(buff+1);int len=strlen(buff+1);
    for(int i=1;i<=len;i++) buff[i]-='0';
    S[0].insert(0);
    for(int i=1;i<=len;i++) {
    	ll now=0;
    	for(int j=i;j>=1;j--) {
    		now=now+PW10[i-j]*buff[j];
    		for(auto x:S[j-1]) S[i].insert(now+x);
    	}
    }
    ll ans=0;
    for(auto x:S[len]) ans+=x;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
static const int MAX_N = 100000;
using namespace std;
int n;
int b[MAX_N+1];

void add(int i,int v){
    while(i <= n){
        b[i] += v;
        i += i&-i;
    }
}

int sum(int i){
    int s = 0;
    while(i > 0){
        s += b[i];
        i -= i&-i;
    }
    return s;
}

int main(){
    int q, com, x, y;
    scanf("%d %d", &n, &q);
    for(int i = 0; i < q; i++){
        scanf("%d %d %d",&com, &x, &y);
        if (com) printf("%d\n", sum(y)-sum(x-1));
        else add(x, y);
    }
}



Measured memory_bytes: 3140
#include <iostream>
#include <cmath>
using namespace std;
#define ll long long
int res(ll n){
    int ans =0;
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){
            int fac =0;
            while(n%i==0){
                n/=i;
                fac++;
            }
            ans+=(sqrt(8*fac+1)-1)/2;

        }
    }
    if(n>1) ans++;
    return ans;
}
int main(){
    ll n;
    cin >> n;
    cout << res(n) << endl;
}


Measured memory_bytes: 3152
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

ll dp[401][401];

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<ll> a(n),s(n+1,0);
    int i,j,k;
    for(i=0; i<n; i++) {
        scanf("%lld", &a[i]);
        s[i+1]=s[i]+a[i];
    }

    for(j=2; j<=n; j++) {
        for(i=0; i<=n-j; i++) {
            dp[i][j]=LINF;
            for(k=1; k<j; k++) {
                dp[i][j]=MIN(dp[i][j],dp[i][k]+dp[i+k][j-k]);
            }
            dp[i][j] += (s[i+j]-s[i]);
        }
    }

    printf("%lld\n", dp[0][n]);

    return 0;
}


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

struct Graph {
    struct Vertex { int n; };
    struct Edge { int i, n; };
    Graph(int n, int m) : v(n, { -1 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j) {
        e[m] = { j, v[i].n };
        v[i].n = m;
        m++;
    }
    int dfs(int i, int p) {
        int r = 0;
        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge& o = e[j];
            if (o.i == p) continue;
            r ^= dfs(o.i, i) + 1;
        }
        return r;
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
};

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

    int n;
    cin >> n;

    Graph g(n, (n - 1) * 2);
    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        g.add_edge(x, y);
        g.add_edge(y, x);
    }

    cout << (g.dfs(0, -1) != 0 ? "Alice" : "Bob") << endl;

    return 0;
}

Measured memory_bytes: 4480
using System;
using System.Collections.Generic;

public class Dice
{
	public static void Main(String[] args)
	{
		//????????¶?????????????????¨?????\???????????????
		//int top=0;
		//int bottom=5;
		//int north=4;
		//	int south=1;
		//int east=2;
		//int west=3;
		//	int temp=0;
		// 0-5 1243
		//2-3 0154
		//1-4 0352
		List<int> pole05 =new List<int> { 1, 2, 4, 3 };
		List<int> pole23 = new List<int>{ 0, 1, 5, 4 };
		List<int> pole14 = new List<int>{ 0, 3, 5, 2 };
			
		string dataset = Console.ReadLine();
		string[] dice = dataset.Split();
		int q = int.Parse(Console.ReadLine());
			
		for (int i = 0; i < q; i++) {
			string dicenumbers = Console.ReadLine();
			string[] topSouth = dicenumbers.Split();
				
			int top = Array.IndexOf(dice, topSouth[0]);
			int south = Array.IndexOf(dice, topSouth[1]);
				
			int pm = 1;
			if (top == 5 || top==3 ||top== 4) {
				pm = -1;
			}
				
			switch (top) {
				case 0:
				case 5:
					Console.WriteLine(dice[diceRight(pole05, south, pm)]);
					break;
				case 2:
				case 3:
					
					Console.WriteLine(dice[diceRight(pole23, south, pm)]);
					break;
					
				case 1:
				case 4:
					
					Console.WriteLine(dice[diceRight(pole14, south, pm)]);
					break;

			}
				
		}
	}
			
			
		
		
					
	public  static int diceRight(List<int> pole, int s, int plusMinus)
	{
		int i = pole.IndexOf(s);
		if(i==3&&plusMinus>0){
			i=-1;
		}
		else if(i==0&&plusMinus<0){
			i=4;
		}
		return pole[i + plusMinus];
	}
		
}

Measured memory_bytes: 9460