akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
string s,t;

vi ff(){
	vi a(n);
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(t[(i+j)%n]=='1'){
		a[i]=j;
		break;
	}
	reverse(t.begin(),t.end());
	return a;
}

int f(){
	vi a=ff(),b=ff();
	reverse(b.begin(),b.end());
	vp c(n);
	int res=inf;
	for(int i=0;i<n;i++){
		int M=0,d=i;
		fill(c.begin(),c.end(),P(0,0));
		for(int j=0;j<n;j++) if(s[j]!=t[(i+j)%n]) c[j]={max(0,a[j]-i),b[j]},d++;
		sort(c.begin(),c.end());
		for(int j=n-1;j>=0;j--){
			res=min(res,2*c[j].first+2*M+d);
			M=max(M,c[j].second);
		}
		res=min(res,2*M+d);
	}
	reverse(s.begin(),s.end());
	reverse(t.begin(),t.end());
	return res;
}

int main(){
	cin>>s>>t;
	n=s.size();
	if(s==t){
		cout<<0<<endl;
		return 0;
	}
	if(t==string(n,'0')){
		cout<<-1<<endl;
		return 0;
	}
	cout<<min(f(),f())<<endl;
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<int64_t> A(N);
  for (int64_t i = 0; i < N; ++i) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  int64_t result = 0;
  for (int64_t i = 0; i < N; ++i) {
    const int64_t a = A[i];
    for (int64_t j = i + 1; j < N; ++j) {
      const int64_t b = A[j];
      const int64_t pos = static_cast<int64_t>(lower_bound(A.begin(), A.end(), (a + b)) - A.begin());
      result += max(static_cast<int64_t>(pos - 1 - j), static_cast<int64_t>(0));
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector> 
#include<algorithm> 
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	vector<int>rec(n,0);
	for(int i=0;i<n;++i){
		cin>>rec[i];
	}
	sort(rec.begin(),rec.end());
	int s=0;
	for(int i=0;i<k;++i){
		s+=rec[i];
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n, h, w;
  cin >> n >> h >> w;
  ll ans = 0;
  rep(i,n){
    ll a, b;
    cin >> a >> b;
    if(a>=h&&b>=w)ans++;
  }
  print(ans);
}

Measured memory_bytes: 256
//Daniel Grzegorzewski
    #include <bits/stdc++.h>
     
    #define MP make_pair
    #define PB push_back
    #define ST first
    #define ND second
     
    using namespace std;
     
    typedef pair<int, int> PII;
    typedef vector<int> VI;
    typedef vector<PII> VII;
    typedef long long LL;
     
    void init_ios()
    {
         ios_base::sync_with_stdio(0);
         cin.tie(0);
    }
     
    const int MOD = (int)1e9 + 7;
    const int N = 810;
     
    int n, c, a[N], b[N], sil[N], odwr[N], ile[N], dp[N][N], sumpot[N][N], pot[N][N];
     
    int main()
    {
        init_ios();
        cin >> n >> c;
        for (int i = 1; i <= n; ++i)
        	cin >> a[i];
        for (int i = 1; i <= n; ++i)
        	cin >> b[i];
        for (int i = 1; i <= n; ++i)
        	for (int j = 0; j <= c; ++j) {
        		int tmp = 0;
        		for (int k = a[i]; k <= b[i]; ++k) {
        			if (pot[k][j] == 0) {
        				if (j == 0)
        					pot[k][j] = 1;
        				else
        					pot[k][j] = (1LL*k*pot[k][j-1])%MOD;
        			}
        			sumpot[i][j] = sumpot[i][j]+pot[k][j];
        			if (sumpot[i][j] >= MOD)
        				sumpot[i][j] -= MOD;
        		}
        	}
        for (int i = 0; i <= c; ++i)
        	dp[n][i] = sumpot[n][i];
        for (int i = n-1; i >= 1; --i)
        	for (int j = 0; j <= c; ++j)
        		for (int k = 0; k <= j; ++k) {
        			dp[i][j] = (dp[i][j] + (1LL*sumpot[i][k]*dp[i+1][j-k])%MOD);
        			if (dp[i][j] >= MOD)
        				dp[i][j] -= MOD;
        		}
        cout<<dp[1][c]<<"\n";
    }

Measured memory_bytes: 4096
s = input()
mid = len(s)//2
flag = 1
for i in range(len(s)//2+1):
    if s[mid-i] == s[mid+i]:
        continue
    else:
        flag = 0

t = s[:(len(s)-1)//2]

for i in range(len(t)):
    if t[i] == t[~i]:
        continue
    else:
        flag = 0

t = s[(len(s)+1)//2:]

for i in range(len(t)):
    if t[i] == t[~i]:
        continue
    else:
        flag = 0

if flag == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
  a[i] -= 1
t = [-1] * n
c = []
t[0] = 0
c.append(0)
x = 0
for i in range(k):
  x = a[x]
  if t[x] != -1:
    l = i + 1 - t[x]
    break
  t[x] = i + 1
  c.append(x)
if len(c) > k:
  print(c[k] + 1)
else:
  for i in range(k % l + (len(c) + l) // l * l, -1, -l):
    if i < len(c):
      print(c[i] + 1)
      break


Measured memory_bytes: 32240
fun main(args:Array<String>) {
    val len = readLine()!!.toInt()
    val s = readLine()!!
    val ans = if(getAns(s)) "Yes" else "No"
    println(ans)
}

fun getAns(s:String) : Boolean {
    if(s.length % 2 != 0) {
        return false
    }
    return s.substring(0 until s.length/2) == s.substring(s.length/2)
}




Measured memory_bytes: 31768
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    int n,sum,ant,tt;
    while(scanf("%d",&n)==1)
    {
        sum=0;tt=1;
        for(int i=n;i>=1;i--)
        {
            ant=0;
            int biao=i;
            while(biao%2==0)
            {
                ant++;
                biao=biao/2;
            }
            if(ant>sum)
            {
                sum=ant;
                tt=i;
            }
        }
        printf("%d\n",tt);

    }
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
use std::str::Chars;
use std::i32;
use std::u8;
use std::f64;
use std::ascii::AsciiExt;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::io::prelude::*;
use std::time::Duration;
use std::cmp;

macro_rules! println_stderr(
    ($($arg:tt)*) => { {
        let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

macro_rules! print_stderr(
    ($($arg:tt)*) => { {
        let r = write!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

fn main() {
    let n = next_int();
    let mut v = next_ints();
    v.sort();
    let mut first : i64 = 0;
    let mut ans : i64 = 0;
    let mut i = 0;
    for e in v {
        if i % 2 == 0 {
            first = e;
        }
        else {
            ans += cmp::min(first,e);
        }
        i += 1;
    }
    println!("{}",ans);
}
#[allow(dead_code)]
fn next_string() -> String {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    input
}

#[allow(dead_code)]
fn next_strings() -> Vec<String> {
    let input = next_string();
    input.split_whitespace().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn next_int() -> i64 {
    let input = next_string();
    i64::from_str(input.trim()).unwrap()
}

#[allow(dead_code)]
fn next_ints() -> Vec<i64> {
    let input = next_string();
    input.split_whitespace().map(|x| x.parse().unwrap()).collect()
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N;
vector<int> p(100001, 0);

int main(void){
    
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) scanf("%d", &p[i]);
    
    int ans = 0, sum = 0;
    for(int i = 0; i < N; ++i){
        if(p[i] == i + 1) ++sum;
        else{
            if(sum == 1) ans += sum;
            else if(sum) ans += (sum % 2 == 0) ? sum / 2 : sum / 2 + 1;
            sum = 0;
        }
    }
    if(sum == 1) ans += sum;
    else if(sum) ans += (sum % 2 == 0) ? sum / 2 : sum / 2 + 1;
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i,j,k;
 	string s1,s2;
  cin>>s1>>s2;
  int n=s1.size(),m=s2.size();
  int dp[n+1][m+1];
  for(i=0;i<=n;i++)
  {
   	for(j=0;j<=m;j++)
    {
     	if(i==0 || j==0)
        {
        	dp[i][j]=0;
        }
         	 else if(s1[i-1]==s2[j-1])
             {
              	 dp[i][j]=1+dp[i-1][j-1];
             }
          else
          {
           	dp[i][j]=max(dp[i-1][j],dp[i][j-1]); 
          }
        
    }
  }
  //for(i=0;i<=n;i++)
  //{
  // 	for(j=0;j<=m;j++)
  //  {
  //   	cout<<dp[i][j]; 
  //  }
  //  cout<<"\n";
  //}
  i=n;
  j=m;
  vector<char>ch;
  while(i>=0 && j>=0)
  {
  	if(dp[i][j-1]==dp[i][j])
  	{
  		j--;
  	}
  	else if(dp[i][j-1]!=dp[i][j] && dp[i-1][j]==dp[i][j])
  	{
  		i--;
  	}
  	else 
  	{
  		ch.push_back(s1[i-1]);
  		i--;
  		j--;
  	}

  }
  for(i=ch.size()-1;i>=0;i--)
  {
  	cout<<ch[i];
  }
  //cout<<dp[n][m];
  
}

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

signed compare(const void *a, const void *b){
	return *(int *)a - *(int *)b;
}

int main(){
	int N, x, i, sum = 0;
	scanf("%d%d", &N, &x);
	int *a = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &a[i]);
	}
	qsort(a, N, sizeof(int), compare);
	for(i = 0; i < N; i++){
		if(sum + a[i] > x){
			printf("%d\n", i);
			return 0;
		}
		sum += a[i];
	}
	if(sum == x){
		printf("%d\n", N);
	}
	else{
		printf("%d\n", N - 1);
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    long long H,W;

    while(1){
        
        cin >> H >> W;

        if(H==0 && W==0){
            break;
        }

        for(long long i=1;i<=H;i++){

            for(long long j=1;j<=W;j++){
                if((i+j)%2==0){
                    cout << "#";
                }else{
                    cout << ".";
                }
                
            }

            cout << endl;

        }
        cout << endl;
    }


    return 0;

}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
int main(){
    int n;cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    deque<int> d;
    for(int i=0;i<n;i++){
        int p=lower_bound(d.begin(),d.end(),a[i])-d.begin();
        if(p==0){
            d.push_front(a[i]);
        }
        else d[p-1]=a[i];
    }
    cout << d.size() << endl;
    return 0;
}

Measured memory_bytes: 1024
# include"stdio.h"
int main(){
    int x,a,b;
    scanf("%d %d %d",&x,&a,&b);
    int da,db;
    da=a-x;
    db=b-x;
    if(a-x<0)da=x-a;
    if(b-x<0)db=x-b;
    if(da>db) printf("B\n");
    else printf("A\n");
}


Measured memory_bytes: 1620
H, W = (int(_) for _ in input().split())
grid = []
black = []
nextb = []
count = 0
total = 0
white = True
for i in range (H):
    line = input()
    for j in range(W):
        if line[j] == '#':
            black.append([i,j])
            total += 1
    grid.append([line[j] for j in range(W)])

if H == 1 and W == 1:
    print(0)
else:
    if total == H*W:
        print(0)
        exit()
    while white:
        for coord in black:
            y = coord[0]
            x = coord[1]
            if y > 0:
                if grid[y-1][x] == '.':
                    grid[y-1][x] = '#'
                    nextb.append([y-1, x])
                    total += 1
            if y <= H-2:
                if grid[y+1][x] == '.':
                    grid[y+1][x] = '#'
                    nextb.append([y+1, x])
                    total += 1
            if x > 0:
                if grid[y][x-1] == '.':
                    grid[y][x-1] = '#'
                    nextb.append([y, x-1])
                    total += 1
            if x <= W-2:
                if grid[y][x+1] == '.':
                    grid[y][x+1] = '#'
                    nextb.append([y, x+1])
                    total += 1
        black = nextb
        nextb = []
        count += 1
        if total == H*W:
            white = False
        
    print(count)
    


Measured memory_bytes: 173016
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

// B - 美しい文字列 / Beautiful Strings
// https://atcoder.jp/contests/abc044/tasks/abc044_b
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char[] w = scanner.next().toCharArray();
        scanner.close();

        if (w.length % 2 == 1) {
            System.out.println("No");
            return;
        }

        Map<Character, Integer> map = new HashMap<>();

        for (char c : w) {
            if (map.containsKey(c)) {
                map.put(c, map.get(c) + 1);
            } else {
                map.put(c, 1);
            }
        }

        for (Integer v : map.values()) {
            if (v % 2 != 0) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
}


Measured memory_bytes: 23124
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
using namespace std;
typedef long long ll;
const long long llnrm=LLONG_MAX;
const int nrm=INT_MAX;
const int nrn=INT_MIN;
const int nmax=1e5+5;
const int mod=1e9+7;
const int lim=1e8;
ll n,a[500000],ans;
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
  //freopen("solution.in","r",stdin);
  //freopen("solution.out","w",stdout);o
  cin>>n;
  for(int i=0;i<n*3;i++)cin>>a[i];
  sort(a,a+n*3);
  reverse(a,a+n*3);
  for(int i=0;i<n*2;i+=2) ans+=a[i+1];
  cout<<ans<<endl;
  return(0);
}



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

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	if (n == 1) {
		if (a != b) {
			cout << 0 << endl;
			return 0;
		}
		else {
			cout << 1 << endl;
			return 0;
		}
	}
	else if (n == 2) {
		cout << 1 << endl;
		return 0;
	}
	else if (a > b) {
		cout << 0 << endl;
		return 0;
	}
	cout << (b - a) * (n-2) + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;

int DP[11][1001];
int H, W, K;
vector<string> SS;
int Min = 100000;

int dfs(string S){
    if(S.size() == H-1){
        int hcnt=0;
        vector<int> CH;
        for(int i = 0; i < S.size(); i++)if(S[i] == '1'){hcnt++;CH.push_back(i);}
        CH.push_back(H-1);
        vector<int> WB(hcnt+1), WB_(hcnt+1);
        int wcnt=0;
        //cout << S << " " << hcnt << endl;
        if(hcnt >= Min) return 0;
            
        
        for(int i = 0; i < W; i++){
            int s = 0;

            for(int idx = 0; idx < hcnt+1; idx++){
                int x = CH[idx];
                for(int j = s; j <= x; j++){
                    if(SS[j][i] == '1') WB[idx]++;

                }
                s = x+1;
            }

            for(int idx = 0; idx < hcnt+1; idx++){
                if(WB[idx] > K){
                    i--;
                    wcnt++;
                    if(hcnt+wcnt >= Min) return 0;
                    WB = WB_;
                    break;
                } 
            }
        }
        Min = min(Min, wcnt+hcnt);
        //cout << S << " " << hcnt << " " << wcnt << endl;
        return 0;
    }
    string S_ = S+'0';
    dfs(S_);
    string S__ = S+'1';
    dfs(S__);
    return 0;

}



int main(){
     cin >> H >> W >> K;
     SS.resize(H); for(int i = 0; i < H; i++) cin >> SS[i];
     vector<int> CH(H), CW(W);
     dfs("");
     cout << Min << endl;
    
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();

        int[] b = new int[m];
        for (int i = 0; i < m; i++) {
            b[i] = sc.nextInt();
        }

        int ans = 0;

        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int index = 0; index < m; index++) {
                sum += sc.nextInt() * b[index];
            }
            if (sum + c > 0) {
                ans++;
            }
        }

        // 出力
        System.out.println(ans);
    }
}

Measured memory_bytes: 24020
def ceil(n):
    return(n//1)

a,b=map(float,input().split())
t=[]
for i in range(10000):
    if ceil(i*0.08)==a and ceil(i*0.1)==b:
        t.append(i)
if len(t)==0:
    print(-1)
else:
    print(min(t))

Measured memory_bytes: 3060
h,w,m=map(int,input().split())
B=[[] for i in range(h)]
H=[0]*h
W=[0]*w
for i in range(m):
    p,q=map(int,input().split())
    B[p-1].append(q-1)
    H[p-1]+=1
    W[q-1]+=1
mH=max(H)
mW=max(W)
CH=[]
for i in range(h):
    if H[i]==mH:
        CH.append(i)
CW=[]
for i in range(w):
    if W[i]==mW:
        CW.append(i)
CW=set(CW)
flag=0
if len(CH)*len(CW)>m:
    flag=1
else:
    for ch in CH:
        b=set(B[ch])
        if CW<=b:
            continue
        else:
            flag=1
            break
if flag:
    print(mH+mW)
else:
    print(mH+mW-1)

Measured memory_bytes: 90208
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int dp[4000][4000];
int main(){
	string s,t;
	while(cin>>s>>t){
		int ans=0;
		memset(dp,0,sizeof(dp));
		for(int i=0;i<s.size();i++){
			for(int j=0;j<t.size();j++){
				if(i==0||j==0){
					if(s[i]==t[j])dp[i][j]=1;
				}else{
					if(s[i]==t[j])dp[i][j]=dp[i-1][j-1]+1;
				}
				ans=max(ans,dp[i][j]);
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 63716
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n, x;
  scanf("%d%d", &n, &x);
  int m[n];
  for (int i=0; i<n; i++) scanf("%d", m+i);
  int sum=0, min=1001;
  for (int i=0; i<n; i++) {
    sum+=m[i];
    min = (min > m[i]) ? m[i] : min;
  }
  int ans = n;
  x -= sum;
  ans += x/min;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    ll s, c; // s:n m:c
    cin >> s >> c;
    if(s>=c/2) cout << c/2 << endl;
    else{
        int tmp = s;
        c -= s*2;
        cout << tmp + c/4 << endl;
    }
    return 0;
}

Measured memory_bytes: 888
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    it.next();
    let w = std::mem::size_of::<usize>() * 8;
    let mut dp = vec![0usize; (2000 * 2000 + 1 + w - 1) / w];
    let mut sum = 0;
    dp[0] = 1;
    for s in it {
        let a: usize = s.parse().unwrap();
        let (q, r) = (a / w, a % w);
        if r == 0 {
            for i in (0..(sum / w + 1)).rev() {
                dp[i + q] |= dp[i];
            }
        } else {
            for i in (0..(sum / w + 1)).rev() {
                dp[i + q + 1] |= dp[i] >> (w - r);
                dp[i + q] |= dp[i] << r;
            }
        }
        sum += a;
    }
    let mut ans = (sum + 1) / 2;
    loop {
        let (q, r) = (ans / w, ans % w);
        if (dp[q] >> r) & 1 == 1 {
            println!("{}", ans);
            return;
        }
        ans += 1;
    }
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s.size()%2==1){
  	cout << "No" << endl;
  	return 0;
  }
  for(int i=0;i<s.size()/2;i++){
  	if(s[i]=='p'){
  	  if(s[s.size()-1-i]!='q'){
  	  	cout << "No" << endl;
  	  	return 0;
  	  }
  	}else if(s[i]=='q'){
  	  if(s[s.size()-1-i]!='p'){
  		cout << "No" << endl;
  		return 0;
  	  }
  	}else if(s[i]=='b'){
  	  if(s[s.size()-1-i]!='d'){
  		cout << "No" << endl;
  		return 0;
  	  }
  	}else if(s[i]=='d'){
  	  if(s[s.size()-1-i]!='b'){
  		cout << "No" << endl;
  		return 0;
  	  }
  	}
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	ll ans=1;
	FOR(i,1,n+1){
		ans*=i;
		ans%=mod;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    la=list(map(int,input().split()))
    lb=list(map(int,input().split()))
    lc=list(map(int,input().split()))
    manzoku=sum(lb)
    for j in range(n-1):
        if la[j+1]-la[j]==1:
            manzoku+=lc[la[j]-1]
    print(manzoku)

resolve()

Measured memory_bytes: 3064
n,k = map(int,input().split())
s = [0] * n
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in a:
        s[j-1] = 1

ans = 0
for i in s:
    if i == 0:
        ans += 1
print(ans)



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

int main(){
  int N,M,X;
  cin >>N>>M>>X;
  
  vector<int> A(M);
  rep(i,0,M) cin >>A[i];
  
  int r=0, l=0;
  rep(i,0,M){
    if(A[i]<X) l++;
    else r++;
  }
  
  int ans = min(l,r);
  cout <<ans<< endl;
}

Measured memory_bytes: 256
package main
 
import (
	"fmt"
)
 
func main() {
  var a, b, c int
  fmt.Scanf("%d %d %d", &a, &b, &c)
  
  ans := "No"
  if a == b + c {
    ans = "Yes"
  }
  if b == c + a {
    ans = "Yes"
  }
  if c == a + b {
    ans = "Yes"
  }
  
  fmt.Printf("%s\n", ans)
}

Measured memory_bytes: 1832
A = [
    [0, 300, 500, 600, 700, 1350, 1650],
    [6, 0, 350, 450, 600, 1150, 1500],
    [13, 7, 0, 250, 400, 1000, 1350],
    [18, 12, 5, 0, 250, 850, 1300],
    [23, 17, 10, 5, 0, 600, 1150],
    [43, 37, 30, 25, 20, 0, 500],
    [58, 52, 45, 40, 35, 15, 0],
]

while 1:
    d = int(input()); d -= 1
    if d == -1:
        break
    hd, md = map(int, input().split())
    dt = hd*100 + md
    a = int(input()); a -= 1
    ha, ma = map(int, input().split())
    at = ha*100 + ma
    if not a <= d:
        d, a = a, d
    if A[d][a] <= 40 and (1730 <= dt <= 1930 or 1730 <= at <= 1930):
        print((A[a][d] // 2 + 49)//50*50)
    else:
        print(A[a][d])



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

#define MAX_N 100050

int N;
string s[MAX_N];

void solve() {
  long long ans = 0;
  long long count = 1;

  for (int i = 0; i < N; i++) {
    sort(s[i].begin(), s[i].end());
  }
  
  sort(s, s + N);

  for (int i = 1; i < N; i++) {
    if (s[i] == s[i - 1]) {
      count++;
    } else {
      ans += (count * (count - 1)) / 2;
      count = 1;
    }

    if (i == N - 1) ans += (count * (count - 1)) / 2;
  }

  cout << ans;
}

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

  return 0;
}

Measured memory_bytes: 7296
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc =  new Scanner(System.in);
		String str = sc.nextLine();

		String[] spl = str.split(" ");
		for(int i =0;i<3;i++){
			System.out.print(spl[i] = spl[i].substring(0, 1));
		}
		sc.close();
	}
}


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

int main() {
  int K, S = 0;
  cin >> K;
  vector<vector<vector<int>>> v(K+1, vector<vector<int>>(K+1, vector<int>(K+1, 1)));
  for(int i = 2;i < K + 1;i++) {
    for(int j = i;j < K + 1;j += i) {
      for(int k = i;k < K + 1;k += i) {
        for(int l = i;l < K + 1;l += i) v[l][j][k] = i;
      }
    }
  }
  for(int i = 1;i < K + 1;i++) {
    for(int j = 1;j < K + 1;j++) {
      for(int k = 1;k < K + 1;k++) {
        S += v[i][j][k];
      }
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 36632
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int ans;

vector<int> z_algorithm(const string &s)
{
  vector<int> prefix(s.size());
  for (int i = 1, j = 0; i < s.size(); i++)
  {
    if (i + prefix[i - j] < j + prefix[j])
    {
      prefix[i] = prefix[i - j];
    }
    else
    {
      int k = max(0, j + prefix[j] - i);
      while (i + k < s.size() && s[k] == s[i + k])
        ++k;
      prefix[i] = k;
      j = i;
    }
  }
  prefix[0] = (int)s.size();
  return prefix;
}
int main(int argc, char const *argv[])
{
  string s;
  int n;
  cin >> n >> s;
  ans = 0;
  rep(i, n)
  {
    string t = s.substr(i);
    //cerr << t << endl;
    auto ret = z_algorithm(t);
    rep(j, ret.size())
    {
      //cerr << ret[j] << " ";
      if (j >= ret[j])
      {
        ans = max(ans, ret[j]);
      }
    }
    //cerr << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b<=a+c&&a+b<=b+c){
		cout<<a+b<<endl;
	}
	else if(a+c<=a+b&&a+c<=b+c){
		cout<<a+c<<endl;
	}
	else if(b+c<=a+b&&b+c<=a+c){
		cout<<b+c<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=103,INF=1<<30;
double dp[MAX][MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,T,L,B;cin>>N>>T>>L>>B;
        if(N+T+L+B==0) break;
        
        memset(dp,0,sizeof(dp));
        
        dp[0][0]=1.0;
        
        vector<int> state(N+1);
        
        for(int i=0;i<L;i++){
            int a;cin>>a;
            state[a]=1;
        }
        
        for(int i=0;i<B;i++){
            int a;cin>>a;
            state[a]=2;
        }
        
        for(int i=0;i<T;i++){
            for(int j=0;j<N;j++){
                for(int k=1;k<=6;k++){
                    int to=j+k;
                    if(to>N) to-=2*(to-N);
                    if(state[to]==0){
                        dp[i+1][to]+=dp[i][j]/6.0;
                    }else if(state[to]==1){
                        dp[i+2][to]+=dp[i][j]/6.0;
                    }else if(state[to]==2){
                        dp[i+1][0]+=dp[i][j]/6.0;
                    }
                }
            }
        }
        
        double ans=0.0;
        
        for(int i=0;i<=T;i++){
            ans+=dp[i][N];
        }
        
        cout<<fixed<<setprecision(25)<<ans<<endl;
    }
}




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

int main(){
  string S;
  cin >> S;
  size_t N = S.length();
  int odd,even;
  int O[100000]={0};
  int last_RL[100001]={0};
  int last_LR[100001]={0};
  int j=0,k=0;
  for (int i=0;i<N-1;i++){
      if((S[i]=='R')&&(S[i+1]=='L')){
        last_RL[j++]=i+1;
      }
      if((S[i]=='L')&&(S[i+1]=='R')){
        last_LR[k++]=i+1;
      }
  }

  even = last_LR[0]/2;
  odd = last_LR[0]-even;
  if (last_RL[0]%2==0){
          O[last_RL[0]-1]=even;
          O[last_RL[0]]=odd;
      }else{
          O[last_RL[0]-1]=odd;
          O[last_RL[0]]=even;
      }
  for (int i=1;i<j-1;i++){
      even = last_LR[i]/2-last_LR[i-1]/2;
      odd = last_LR[i]-last_LR[i-1]-even;
      if (last_RL[i]%2==0){
          O[last_RL[i]-1]=even;
          O[last_RL[i]]=odd;
      }else{
          O[last_RL[i]-1]=odd;
          O[last_RL[i]]=even;
      }
  }
  even = N/2-last_LR[k-1]/2;
  odd = N-(last_LR[k-1])-even;
  if (last_RL[j-1]%2==0){
    O[last_RL[j-1]-1]=even;
    O[last_RL[j-1]]=odd;
}else{ 
    O[last_RL[j-1]-1]=odd;
    O[last_RL[j-1]]=even;
}
  for(int i=0;i<N;i++) cout << O[i] << " ";
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <tuple>
#include <cmath>
#define rep(i, n) for(i = 0; i < (n); i++)
#define int long long
using namespace std;

const int DEPTH = 17;
struct SegTree {
	int d[1 << (DEPTH + 1)];
	SegTree() {
		int i;
		rep(i, (1 << (DEPTH + 1))) d[i] = 0;
	}
	
	void update(int pos, int x) {
		pos += (1 << DEPTH) - 1;
		d[pos] = x;
		while (pos > 0) {
			pos = (pos - 1) / 2;
			d[pos] = max(d[pos * 2 + 1], d[pos * 2 + 2]);
		}
	}
	
	int getMax(int l, int r, int a = 0, int b = (1 << DEPTH), int id = 0) {
		if (a >= r || b <= l) return 0;
		if (l <= a && b <= r) return d[id];
		int vl = getMax(l, r, a, (a + b) / 2, id * 2 + 1);
		int vr = getMax(l, r, (a + b) / 2, b, id * 2 + 2);
		return max(vl, vr);
	}
	
};

int n;
int p[100000];
SegTree seg;

int getL(int pos, int x) {
	int st = -1, ed = pos, mid; //oooxxx, [st, ed)
	while (ed - st >= 2) {
		mid = (st + ed) / 2;
		if (seg.getMax(mid, pos) > x) st = mid;
		else ed = mid;
	}
	return st;
}

int getR(int pos, int x) {
	int st = pos, ed = n, mid;	//xxxooo, (st, ed]
	while (ed - st >= 2) {
		mid = (st + ed) / 2;
		if (seg.getMax(pos + 1, mid + 1) > x) ed = mid;
		else st = mid;
	}
	return ed;
}

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> p[i];
	rep(i, n) seg.update(i, p[i]);
	
	int ans = 0;
	rep(i, n) {
		int x = p[i];
		int l1 = getL(i, x);
		int l2 = getL(l1, x);
		int r1 = getR(i, x);
		int r2 = getR(r1, x);
		
		int left = (l1 - l2) * (r1 - i);
		int right = (r2 - r1) * (i - l1);
		ans += (left + right) * p[i];
		//cout << l1 << ", " << l2 << ", " << r1 << ", " << r2 << "| " << left << ", " << right << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3072
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


prime_list = primes(100000)
ruiseki = [0] * 100010
tmp = 0

rrr = []
for i in prime_list:
    if int((i+1)/2) in prime_list:
        for j in range(1,i - tmp + 1):
            ruiseki[tmp+j] = ruiseki[tmp]
        ruiseki[i] += 1
        tmp = i
        rrr.append(tmp)
    if i == prime_list[-1]:
        for i in range(tmp,100000):
            ruiseki[i+1] = ruiseki[i]

#for i in rrr:
#    ruiseki[i] -= 1

Q = int(input())
l,r = [],[]
for i in range(Q):
    a,b = map(int,input().split())
    l.append(a)
    r.append(b)
for i in range(Q):
    print(ruiseki[r[i]] - ruiseki[l[i]-1])


Measured memory_bytes: 14156
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
#define all(a) a.begin(),a.end()
using namespace std;
int n;
int a[200005];
ll ans=0;
int main(void){
	cin>>n;
	REP(i,n)cin>>a[i];
	int last=a[0];
	FORN(i,1,n){
		if(a[i]>=last)last=a[i];
		else ans+=(last-a[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4408
import math
n = int(input())
 
m = n-1
ans1 = 0
for i in range(1, math.ceil(math.sqrt(m))):
  if m%i == 0:
    ans1 += 2
if math.sqrt(m).is_integer():
  ans1 += 1
ans1 -= 1

ans2 = 0
for i in range(2, math.ceil(math.sqrt(n))):
  if n%i == 0:
    k = n
    while k % i == 0:
      k = k // i
    if k % i == 1:
      ans2 += 1
    k = n
    j = n/i
    while k % j == 0:
      k = k // j
    if k % j == 1:
      ans2 += 1
      
if math.sqrt(n).is_integer():
  ans2 += 1
ans2 += 1
#print(ans1, ans2)
print(ans1+ans2)

Measured memory_bytes: 40940
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
using namespace std;

#define F(i, n) for(int i = 0; i < n; ++i)
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 200*1000+47;

VI G[MAX];
int A[MAX];
bool DFS(int v)
{
    FOR(i, 0, SZ(G[v]))
    {
        int to = G[v][i];
        if (A[to] < A[v])
            if (!DFS(to))
                return 1;
    }
    return 0;
}

int main()
{
    int n;
    scanf("%d", &n);
    FOR(i, 0, n)scanf("%d", A + i);
    
    FOR(i, 0, n-1)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        --a, --b;
        G[a].PB(b);
        G[b].PB(a);
    }
    FOR(i, 0, n)
        if (DFS(i))
            printf("%d ", i+1);
    
    return 0;
}











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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int H, W;
int N;
int A[10010];
int vmap[110][110];

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

	cin >> H >> W >> N;
	rep(i, 0, N)
	{
		cin >> A[i];
	}

	int cnt = 0;
	int col = 0;

	rep(i, 0, H)
	{
		if (i % 2 == 0)
		{
			rep(j, 0, W)
			{
				vmap[i][j] = col + 1;
				cnt++;
				if (cnt == A[col])
				{
					col++;
					cnt = 0;
				}
			}
		}
		else
		{
			rrep(j, 0, W)
			{
				vmap[i][j] = col + 1;
				cnt++;
				if (cnt == A[col])
				{
					col++;
					cnt = 0;
				}
			}
		}
	}

	rep(i, 0, H)
	{
		rep(j, 0, W)
		{
			cout << vmap[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
long long n,a,b;
main(){
    cin>>n>>a>>b;
    if(a>b or (n==1 and a!=b))cout<<0<<endl;
    else if(a==b)cout<<1<<endl;
    else cout<<(a-b)*(2-n)+1<<endl;
}

Measured memory_bytes: 256
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		ll x=0;
		int n;
		string s;
		cin >> n >> s;
		vector<int>v;
		for (int i=0 ; i<n ; i++)
		{
			if(s[i]=='I') x++;
			v.pb(x);
			//ll store=x;
			//x=max((ll)0,x);
			//cerr << imie(x);
			if (s[i]=='D') x--;
			v.pb(x);
			//x=max(store,x);
		}
		//for (auto x:v)
		//cout << x << endl;
		sort(v.rbegin(),v.rend());
		cout << v[0] << endl;
		return 0;  
}  


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<int,P> PP;

vector<PP> v;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main()
{
	
	int x,a;
	cin >> x >> a;
	cout << (x<a?"0":"10") << endl;
	return 0;
}


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

int main(){
  //使用する変数の初期化
  int n, a, c;
  //数値が何個あるか変数nに代入
  cin >> n;
  //動的配列初期化
  vector<int> v;
  //変数nの数値分ループ
  for(int i = 0; i < n; i++){
    //2で割った回数のカウンタ初期化
    c = 0;
    //2で割る数値を変数aに代入
    cin >> a;
    //2で割り切れる間ループ
    while(a % 2 == 0){
      //2で割った回数+1
      c++;
      //変数aの数値を最新化
      a = a / 2;
    }
    //動的配列の最後尾に変数aを2で割り切れた回数を追加
    v.push_back(c);
  }
  //動的配列の中身を小さい順に並び変える
  sort(v.begin(), v.end());
  //動的配列の先頭を出力
  cout << v[0];
}

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

using namespace std;

#define int long long

signed main(){
  int N;
  int Y;

  cin>>N>>Y;

  for(int i = 0; i <= N; i++){
    for(int j = 0; i + j <= N; j++){
      int k = N - i - j;
      if(i * 10000 + j * 5000 + k * 1000 == Y) {
        cout<<i<<" "<<j<<" "<<k<<endl;
        return 0;
      }
    }
  }

  cout<<-1<<" "<<-1<<" "<<-1<<endl;
  return 0;
}


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

int main() {
    string s, p;
    cin >> s;
    cin >> p;
    rep(i, p.size()-1) {
        s.push_back(s.at(i));
    }
    if (s.find(p) != std::string::npos) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 3200
import math
n, d = map(int, input().split())
p = []
cnt = 0
for i1 in range(n):
    p.append(list(map(int, input().split())))

def check(l1, l2, d1):
    v = 0
    for k in range(d1):
        v += (l1[k] - l2[k]) ** 2
    if float.is_integer(math.sqrt(v)):
        return True
    else:
        return False

for j1, j2 in enumerate(p[:n]):
    for j3 in p[j1+1:]:
        if check(j2, j3, d):
            cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int>a(n);
    int mx=0,g=0;
    bool ok=false;
    rep(i,n){
        cin>>a[i];
        mx=max(mx,a[i]);
        g=__gcd(g,a[i]);
        if(a[i]==k)ok=true;
    }
    if((k%g==0&&k<=mx)||ok)cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

Measured memory_bytes: 640
import java.io.*;
import java.util.StringTokenizer;

class Point {
	double x,y;
	Point(double x,double y) {
		this.x = x;
		this.y = y;
	}
}

class Vec {
	double x,y;
	Vec(Point p1,Point p2) {
		this.x = p2.x-p1.x;
		this.y = p2.y-p1.y;
	}
	Vec(Vec v1,Vec v2) {
		this.x = v2.x-v1.x;
		this.y = v2.y-v1.y;
	}
	Vec(double x,double y) {
		this.x = x;
		this.y = y;
	}
	double Size() {
		return Math.pow(this.x,2)+Math.pow(this.y,2);
	}
	Vec projection(Vec v) {
		double f = (this.x*v.x+this.y*v.y)/this.Size();
		return new Vec(f*this.x,f*this.y);
	}
	void arrange() {
		this.x *= 2;
		this.y *= 2;
	}
}

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			while ((buf = br.readLine())!=null) {
				StringTokenizer st = new StringTokenizer(buf,",");
				Point P1 = new Point(Double.parseDouble(st.nextToken()),Double.parseDouble(st.nextToken()));
				Point P2 = new Point(Double.parseDouble(st.nextToken()),Double.parseDouble(st.nextToken()));
				Point Q = new Point(Double.parseDouble(st.nextToken()),Double.parseDouble(st.nextToken()));
				Vec a = new Vec(P1,P2);
				Vec b = new Vec(P1,Q);
				Vec c = new Vec(b,a.projection(b));
				c.arrange();
				System.out.println((Q.x+c.x)+" "+(Q.y+c.y));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static double dot(Vec a,Vec b) {
		return a.x*b.x+a.y*b.y;
	}
}

Measured memory_bytes: 16952
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

int main() {
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);

  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << (H-h)*(W-w) << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define str string
#define sec .second
 
ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30;
ll A[1000000] = {}, B[1000000] = {}, weight[1000] = {}, value[1000] = {};
ll dp[1000][100100] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, n = 0, su = 0, ma = INF, mi = -1;
double ans;
pair<str, ll> S[1000];
bool an = true, bn = false;
long long mod = 1e9 + 7;
 
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Code Line
	cin >> n >> a;
	for (int i = 0; i < n; i++)cin >> weight[i] >> value[i];
 
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= a; j++) {
			
			if (j >= weight[i])dp[i + 1][j] = max(dp[i][j - weight[i]] + value[i], dp[i + 1][j]);
			dp[i + 1][j] = max(dp[i][j],dp[i+1][j]);
		}
	}
	cout << dp[n][a] << endl;
 
		return 0;
}


Measured memory_bytes: 81536
program main
    implicit none
    integer n, m
    integer, allocatable, dimension(:) :: a
    integer i, sum
    read(*,*) n, m
    allocate(a(m))
    read(*,*) a

    sum = 0
    do i = 1, m
        sum = sum + a(i)
    end do

    if(sum > n) then
        write(*,*) -1
    else
        write(*,*) n-sum
    end if
    
end program

Measured memory_bytes: 2852
#include <stdio.h>

int main (void)
{
  int k;
  char s[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  scanf("%d", &k);
  
  printf("%d", s[k-1]);
  
  return 0;
  
}

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

int main() {
    int A, B;
    cin >> A >> B;
    int sum = 0;
    for (int i = 0; i < 2; i++) {
        if (A >= B) {
            sum += A;
            A--;
        } else {
            sum += B;
            B--;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
    char S[4];
    bool Good = false;

    scanf("%s", &S);

    for (int i=0; i<3; i++) {
        if (S[i]==S[i+1]) Good = true;
    }
    
    if (Good) printf("Bad\n");
    else printf("Good\n");

    return 0;
}

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

int main()
{
	int a;
	double h, m, s;
	cin >> a;
	if (0 <=a && a < 60) {
		h = 0;
		m = 0;
		s = a;
	}
	else if (60 <= a && a < 60 * 60) {
		h = 0;
		m = a/60;
		s = a%60;
	}
	else if (60 * 60 <= a && a < 86400) {
		h = a/(60*60);
		m = (a%(60*60))/60;
		s = (a%(60*60))%60;
	}
	cout << h << ":" << m << ":" << s <<"\n";
    return 0;
}




Measured memory_bytes: 3260
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
string S;
bool chk(string s){
	ll n=(s[0]-'0')*10+s[1]-'0';
	return 1<=n&&n<=12;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>S;
	bool f1=chk(S.substr(0,2)),f2=chk(S.substr(2,2));
	if(f1&&!f2){
		cout<<"MMYY";
	}else if(!f1&&f2){
		cout<<"YYMM";
	}else if(f1&&f2){
		cout<<"AMBIGUOUS";
	}else{
		cout<<"NA";
	}
	cout<<endl;
}

Measured memory_bytes: 256