akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)
const int MOD = 998244353;

int mul(int a , int b , int m = MOD){
   return (1LL * (a % m) * (b % m)) % m;
}

int add(int a , int b , int m = MOD){
   return (1LL * (a % m) + (b % m)) % m;
}

int powMOD(int x , int n , int m = MOD){
   if(!n)return 1;
   int ret = 1;
   if(n & 1)ret = mul(x , powMOD(x , n - 1 , m) , m);
   else{
      int y = powMOD(x , n / 2 , m);
      ret = mul(y , y , m);
   }
   return ret;
}
int main() {
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   int n;
   cin >> n;
   vector<int> a(n);
   for(int &x : a)
      cin >> x;
   
   sort(a.begin() + 1 , a.end());
   if(a[0] != 0 || count(all(a) , 0) != 1){
      cout << "0\n";
      return 0;
   }
   int curLevel = 0 , lst = 0 , ans = 1;
   for(int i = 0 ; i < n ; ++i){
      if(a[i] != curLevel){
         cout << "0\n";
         return 0;
      }
      int j = i;
      while (j < n && a[j] == curLevel){
         ++j;
      }
      int cnt = j - i;
      if(lst)ans = mul(ans , powMOD(lst , cnt , MOD));
      lst = cnt;
      i = j - 1;
      curLevel++;
   }

   cout << ans << "\n";
}

Measured memory_bytes: 640
#include <vector>
#include <iostream>

using namespace std;

int main()
{
	unsigned int n;
	cin >> n;

	vector<unsigned int> v(n);
	for (unsigned int i = 0; i < n; ++i)
		cin >> v[i];

	for (unsigned int j = 0; j < n - 1; ++j)
		cout << v[j] << " ";
	cout << v[n - 1] << endl;
	for (unsigned int i = 1; i < n; ++i) {
		unsigned int t = v[i];
		int j = i - 1;
		while (j >= 0 && v[j] > t) {
			v[j+1] = v[j];
			--j;
		}
		v[j+1] = t;
		for (unsigned int j = 0; j < n - 1; ++j)
			cout << v[j] << " ";
		cout << v[n - 1] << endl;
	}

	return 0;
}



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

ll N, M, S;

ll dfs(ll n, ll m, ll s) {
  if(s > S) return 0;
  if(m == M) return s == S;

  ll ret = 0;
  REP(i, n, N + 1) ret += dfs(i + 1, m + 1, s + i);
  return ret;
}

int main(void) {
  while(cin >> N >> M >> S, N && M && S) cout << dfs(1, 0, 0) << endl;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>S;
    vec alpha(26,0);
    for(char c : S){
        ++alpha[c - 'a'];
    }
    rep(i,26){
        if(alpha[i] == 0){
            cout<<char(97 + i)<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
}

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    int ma = *max_element(begin(a), end(a));
    int mi = *min_element(begin(a), end(a));
    cout << ma - mi << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <chrono>
#include <algorithm>

using namespace std;
using namespace std::chrono;

int N;

int main() {
	cin >> N;
    if (N >= 1 && N <= 999) {
      cout << "ABC" << '\n';
      return 0;
    }
  
	cout << "ABD";
	return 0;
}

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

void minCost(int index, vector<int> &arr, vector<int> &dp){
    //Base cases
    if(index == arr.size() - 1){
        dp[index] = 0;
        return;
    }else if(index == arr.size() - 2){
        dp[index] = abs(arr[arr.size() - 1] - arr[arr.size() - 2]);
        return;
    }

    if(dp[index+1] == -1){
        minCost(index+1, arr, dp);
    }

    if(dp[index + 2] == -1){
        minCost(index + 2, arr, dp);
    }

    dp[index] = min(dp[index + 1] + abs(arr[index] - arr[index + 1]), dp[index + 2] + abs(arr[index] - arr[index + 2]));

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }

    vector<int> dp(n, -1); // the ith position gives minCost from ith to N
    minCost(0, arr, dp);

    cout << dp[0] << endl;
    
    return 0;
}

Measured memory_bytes: 5760
li = list(input())

for i in range(len(li)):
    if i % 2 == 1:
        if li[i] == "R":
            print("No")
            quit()
        else:
            continue
    else:
        if li[i] == "L":
            print("No")
            quit()
        else:
            continue
print("Yes")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <queue>
#include <string.h>
#include <stdint.h>
#include <cmath>

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);

#define ll long long
#define ld long double
#define ull unsigned long long
#define ut uint64_t

#define pb push_back
#define ins insert
#define er erase

#define fi(i, b) for (int i=0;i<b;i++)
#define fll(i, b) for (ll i=0;i<b;i++)
#define fla(i,a,b) for (ll i=a;i<b;i++)

#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vb vector<bool>
#define vst vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvl vector<vector<ll>>


#define all(v) v.begin(), v.end()
#define lb lower_bound
#define ub upper_bound
#define mxe max_element
#define mne min_element

#define srt(v) sort(all(v))
#define rsrt(v) sort(v.rbegin(), v.rend())

#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second

#define mii map<int, int>
#define mll map<ll, ll>
#define umii unordered_map<int, int>
#define umll unordered_map<ll, ll>

#define si set<int>
#define sll set<ll>
#define usi unordered_set<int>
#define usll unordered_set<ll>
#define spii set<pii>
#define spll set<pll>

#define pqi priority_queue<int>
#define pqll priority_queue<ll>

 #define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*1ll * (b)) / gcd(a, b)

#define nl "\n"
#define sz(x)  (int)x.size()
using namespace std;

double PI = (acos(-1));

ll ma = 1000000007;
ll md = 998244353;

ll pw(ll a, ll b)
{
    ll c = 1, m = a;
    while (b){
        if (b & 1)c = (c * m);
        m = (m * m);
        b /= 2;
    }
    return c;
}

ll pwmd(ll a, ll b){
    ll c = 1, m = a;
    while (b){
        if (b & 1)
            c = ((c * m)) % md;
        m = (m * m) % md;
        b /= 2;
    }
    return c;
}


ll modinv(ll n)
{
    return pwmd(n, md - 2);
}
ll min(ll a,ll b){
    if(a>=b)return b;
    return a;
}
ll nc2(ll n)
{
    return (1ll * n * (n - 1)) / 2;
}
 
ll nsum(ll n)
{
    return (1ll * n * (n + 1)) / 2;
}

bool is(string r)
{
    string p = r;
    reverse(p.begin(), p.end());
    return (r == p);
}





//vst vect={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
/*ll lis;
ll vis;
int dfs(ll &x){
    vis[x]=1;
    if(x==n-1)return 0;
    else {
        return max()
    }
}*/
bool prime(ll a){
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }return true;
}

void solve(){
    string s;cin>>s;
    
    if(s>="a")cout<<"a";
    else cout<<"A";
    
}


// AB DEKHO JAADU...

int main(){
    fast;
    ll tests=1;
    //cin>>tests;
    while(tests--){
        solve();
    }
    

    return 0;
    }

// KHATAM HO GAYA:)...

//656843682888290175



Measured memory_bytes: 3612
#include <iostream>

using namespace std;

int main () {

    int N, Count;
    string S;

    cin >> N;
    cin >> S;

    Count = 0;

    for (int i = 0; i < S.size() - 2; i++) {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
            Count++;
        }
    }

    cout << Count << endl;

    return 0;
}

Measured memory_bytes: 256
import numpy as np
n,k,q = map(int,input().split())

a = np.zeros(q,dtype = int)

for i in range(q):
    a[i] = int(input())


score = np.array([k]*n)
sub = np.zeros(n,dtype = int)
for i in range(q):
    sub[a[i]-1] += 1

score = score + sub - q
for i in range(n):
    if score[i] > 0:
        print('Yes')
    else:
        print('No')
    

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

int main(void){
    string str1,str2;
    
    cin>>str1;
    cin>>str2;
    
    str1+=str1;
    if(-1!=str1.find(str2)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


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

using namespace std;

constexpr int MAXN = 1000000;

char X[MAXN + 2];

int main() {
	int N;
	cin >> N >> X;
	int m = 0;
	for(int i = 0; i < N; i++) {
		X[i] -= '1';
		m |= 1 << X[i];
	}
	m = !(m & 2);
	for(int i = 0; i < N; i++)
		if(X[i] == 2)
			X[i] = m;
	int comb = __builtin_ctz(N - 1);
	bool res = X[0] ^ X[N - 1];
	for(int i = 1; i < N - 1; i++) {
		if(comb == 0) res ^= X[i];
		comb += __builtin_ctz(N - 1 - i);
		comb -= __builtin_ctz(i + 1);
	}
	int ans = res ? (m ? 2 : 1) : 0;
	cout << ans << '\n';
}


Measured memory_bytes: 1280
a, b = gets.strip.split.map(&:to_i)
HEIGHT = 100
WIDTH = 100

BLACK_PER_ROW = HEIGHT / 2


# 全部を白で塗っておく
table = []
HEIGHT.times do
  table << "." * WIDTH
end

# 黒の連結成分をを B - 1 個作る
# 1行に50個作れるので　必要な行数 = ((B - 1) + 49) / 50
black_lines = ((b - 1) + HEIGHT / 2 - 1) / (HEIGHT / 2)

# 黒に塗っていく
(b - 1).times do |i|
  row = (i / BLACK_PER_ROW) * 2
  col = (i - (i / BLACK_PER_ROW) * BLACK_PER_ROW) * 2
  # puts "i = #{i}, row = #{row}, col = #{col}"
  table[row][col] = '#'
end

# 残りで白の連結成分を作る
# 黒で塗られているところは高々10行目までしか来ないので
# 下から80行の間でなんとかする
limit = 20
white = a - 1
line = HEIGHT - 2
#黒の最後の連結成分を作成
(limit...HEIGHT).each do |i|
  table[i][0] = '#'
end

while line >= limit do
  if white <= 0
    break
  end
  # 黒で塗りつぶす
  table[line] = "#" * WIDTH
  line -= 2
  white -= 1
end

# まだ白の連結成分が足りない場合
# puts "white = #{white}"
if white > 0
  line = HEIGHT - 1
  col = 2
  while white > 0
    # puts "aaaaaaaaaaaa"
    table[line][col] = '#'
    col += 2
    white -= 1
    if col >= WIDTH
      col = 2
      line -= 2
    end
  end
end

def print_table(table)
  HEIGHT.times do |i|
    puts table[i]
  end
end

puts "#{HEIGHT} #{WIDTH}"
print_table(table)

Measured memory_bytes: 3836
#include <iostream>
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t,sum=0;
    cin>>t;
    for(ll i=1;i<=t;i++){
        if(i%3==0 || i%5==0 || i%15==0){

        }else{sum+=i;}
    }
    cout<< sum<<endl;

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h> 
#define ll long long 
#define ld long double
#define ull unsigned long long
#define yes cout<<"Yes"<<"\n"
#define no cout<<"No"<<"\n"
using namespace std;
const double pi=3.14159265358979323846;
const int MAX_CHARS = 256; 
  
// This function receives text and shift and 
// returns the encrypted text 
string encrypt(string text, int s) 
{ 
    string result = ""; 
  
    // traverse text 
    for (int i=0;i<text.length();i++) 
    { 
        // apply transformation to each character 
        // Encrypt Uppercase letters 
        if (isupper(text[i])) 
            result += char(int(text[i]+s-65)%26 +65); 
  
    // Encrypt Lowercase letters 
    else
        result += char(int(text[i]+s-97)%26 +97); 
    } 
  
    // Return the resulting string 
    return result; 
} 
  
// Driver program to test the above function 
int main() 
{ 
    ll n,d;
    cin>>n>>d;
    ll count=0;
    for(ll i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        if(sqrt(x*x+y*y)<=d)
        count++;
    }
    cout<<count<<"\n";
} 

Measured memory_bytes: 3720
mod=10**9+7
n,k=map(int,input().split())
k1=(k*(k+1)//2)%mod
k2=(k*(k-1)//2)%mod
a=list(map(int,input().split()))
p=0
for i,j in enumerate(a):
    e=0
    for m in a[i:]:
        e+=j>m
    p=(p+(e*k1)%mod)%mod
for i,j in enumerate(a):
    e=0
    for m in a[:i]:
        e+=j>m
    p=(p+(e*k2)%mod)%mod
print(p)

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int m = 0;
    vector<int> b(n + 1);
    for(int i = n; i > 0; i--) {
        int sum_for_i = 0;
        for(int j = i; j <= n; j += i) {
            sum_for_i += b[j];
        }
        if(sum_for_i % 2 != a[i]) {
            b[i] = 1;
            m++;
        }
    }
    cout << m << endl;
    if(m > 0) {
        for(int i = 0; i <= n; i++) {
            if(b[i] == 1)
                cout << i << ' ';
        }
    }
    cout << endl;
}


Measured memory_bytes: 2432
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String weathers[] = new String[3];
        weathers[0] = "Sunny";
        weathers[1] = "Cloudy";
        weathers[2] = "Rainy";
        String today = sc.next();
        int cnt = 0;
        for (String weather : weathers) {
            if (weather.equals(today)) {
                System.out.println(weathers[(cnt + 1) % 3]);
                return;
            }
            cnt++;
        }
    }
}

Measured memory_bytes: 21716
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
while True:
    x,y,s = map(int,raw_input().split(" "))
    if x == 0 and y == 0 and s == 0:
        break
    cost = 0
    for i in range(s*100//(100+x),s+1):
        for j in range(1,i//2+1):
            if (j*(100+x)//100) + ((i-j)*(100+x)//100) == s:
                cost = max(cost,(j*(100+y)//100 + (i-j)*(100+y)//100))
            else:
                continue
    print(cost)

Measured memory_bytes: 4236
h,w =map(int,input().split())
s = list(input().split() for _ in range(h))
moji = ["A","B","C","D","E","F","G","H","I","J","K","L","N","M","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
x =0
y =0
for i in range(h):
    for j in range(w):
        if s[i][j] == "snuke":
            x=i
            y=j
ans = moji[y]+str(x+1)
print(ans)

Measured memory_bytes: 3064
import math
from functools import reduce


K = int(input())
ans = 0

def gcd(*numbers):
    return reduce(math.gcd, numbers)

for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans += gcd(a,b,c)
print(ans)

Measured memory_bytes: 69592
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 3e18+7
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,ll> P;
typedef pair<pair<int,ll>,ll> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}

vector<P> G[310000];
ll d[310000];

//s…始点
void dijkstra(int s){
  // greater<P>を指定することでfirstが小さい順に取り出せる
  priority_queue<P,vector<P>,greater<P>> que;
  fill(d,d+300001,INF);
  d[s]=0;
  que.push(P(0,s));

  while(!que.empty()){
    P p=que.top(); que.pop();
    ll v=p.second;
    if(d[v]<p.first) continue;
    for(int i=0;i<(int)G[v].size();i++){
      P e=G[v][i];
      if(d[e.first]>d[v]+e.second){
        d[e.first]=d[v]+e.second;
        que.push(P(d[e.first],e.first));
      }
    }
  }
}


int main(){
    int N,M;
    cin>>N>>M;
    for(int i=0;i<M;i++){
        int u,v;
        cin>>u>>v;
        u--; v--;
        G[u].push_back(P(v+N,1)  );
        G[u+N].push_back(P(v+2*N,1));
        G[u+2*N].push_back(P(v,1));
    }
    int S,T;
    cin>>S>>T; S--; T--;
    dijkstra(S);
    if(d[T]==INF) cout<<-1<<endl;
    else cout<<d[T]/3<<endl;
}


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

int count(vector<vector<int>>& v, int k, int y1, int x1, int y2, int x2) {
	int r;
	y1 %= 2 * k;
	x1 %= 2 * k;
	y2 = (y2 - 1) % (2 * k) + 1;
	x2 = (x2 - 1) % (2 * k) + 1;
	if (y1 == y2 || x1 == x2) {
		r = 0;
	} else if (y2 < y1) {
		r = count(v, k, y1, x1, 2 * k, x2) + count(v, k, 0, x1, y2, x2);
	} else if (x2 < x1) {
		r = count(v, k, y1, x1, y2, 2 * k) + count(v, k, y1, 0, y2, x2);
	} else {
		r = v[y2 - 1][x2 - 1];
		if (0 < y1) {
			r -= v[y1 - 1][x2 - 1];
		}
		if (0 < x1) {
			r -= v[y2 - 1][x1 - 1];
		}
		if (0 < y1 && 0 < x1) {
			r += v[y1 - 1][x1 - 1];
		}
	}
	// cout << r << " (" << y1 << ", " << x1 << " / " << y2 << ", " << x2 << ")" << endl;
	return r;
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<vector<vector<int>>> u(2, vector<vector<int>>(2 * k, vector<int>(2 * k))), v(2, vector<vector<int>>(2 * k, vector<int>(2 * k)));
	for (int i = 0; i < n; i++) {
		int x, y;
		string s;
		cin >> x >> y >> s;
		u[s[0] == 'B'][y % (2 * k)][x % (2 * k)]++;
	}
	for (int c = 0; c < 2; c++) {
		v[c][0][0] = u[c][0][0];
		for (int i = 1; i < 2 * k; i++) {
			v[c][i][0] = v[c][i - 1][0] + u[c][i][0];
			v[c][0][i] = v[c][0][i - 1] + u[c][0][i];
		}
		for (int y = 1; y < 2 * k; y++) {
			for (int x = 1; x < 2 * k; x++) {
				v[c][y][x] = v[c][y - 1][x] + v[c][y][x - 1] - v[c][y - 1][x - 1] + u[c][y][x];
			}
		}
	}
	/*
	for (int c = 0; c < 1; c++) {
		for (int y = 0; y < 2 * k; y++) {
			for (int x = 0; x < 2 * k; x++) {
				cout << v[c][y][x] << " ";
			}
			cout << endl;
		}
		cout << endl;
	}
	*/
	int m = 0;
	for (int y = 0; y < 2 * k; y++) {
		for (int x = 0; x < 2 * k; x++) {
			m = max(m, count(v[0], k, y, x, y + k, x + k) + count(v[0], k, y + k, x + k, y, x) + count(v[1], k, y + k, x, y, x + k) + count(v[1], k, y, x + k, y + k, x));
		}
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 78720
#include <iostream>
#include <cstdlib>
#include <math.h>

using namespace std;
int main() {
    int x, y, a, b, c, k, M=0;
    cin >> a >> b >> c >> k;
    for(x=0; x<=k; x++) {
        for(y=0; y<=k-x; y++) {
            M = max(M, int(a*pow(2, x) + b*pow(2, y) + c*pow(2, k-x-y)));
        }
    }
    cout << M << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        long a, b, c;
        a = sc.nextLong();
        b = sc.nextLong();
        c = sc.nextLong();

        long a_calc = 0;
        long b_calc = 0;
        long c_calc = 0;
        long min = 0;

        if (a%2 == 0 || b%2 == 0 || c%2 == 0){
            System.out.println(min);
        }else{
            a_calc = (a/2+1-a/2)*b*c;
            b_calc = a*(b/2+1-b/2)*c;
            c_calc = a*b*(c/2+1-c/2);

            min = a_calc;
            if(min > b_calc)min = b_calc;
            if(min > c_calc)min = c_calc;
            System.out.println(min);
        }

    }
}

Measured memory_bytes: 21844
N, K, Q = gets.chomp.split().map(&:to_i)
points = Array.new(N, K - Q)

Q.times do
    winner = gets.chomp.to_i - 1
    points[winner] += 1
end
points.each do |point|
    if point > 0
        puts "Yes"
    else
        puts "No"
    end
end

Measured memory_bytes: 3196
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <inttypes.h>

int main(void){
	int x1,x2,x3,x4,x5;

	scanf("%d %d %d %d %d",&x1,&x2,&x3,&x4,&x5);
	if(x1==0){
		printf("1");
	}else if(x2==0){
		printf("2");
	}else if(x3==0){
		printf("3");
	}else if(x4==0){
		printf("4");
	}else{
		printf("5");
	}
	return 0;
}


Measured memory_bytes: 1620
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let x: usize = read();
    for i in 1..180 {
        if 360 * i % x == 0 {
            println!("{}", 360 * i / x);
            return;
        }
    }
}


Measured memory_bytes: 2168
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

struct UnionFind{
    vector<int> rank,p,size;
    UnionFind(int n){
        rank.resize(n,0);
        p.resize(n,0);
        size.resize(n,0);
        for(int i = 0; i < n; i++){
            p[i] = i;
            rank[i] = 0;
            size[i] = 1;
        }
    }
    bool same(int x,int y){
        return root(x) == root(y);
    }
    int root(int x){
        if(x != p[x]){
            p[x] = root(p[x]);
        }
        return p[x];
    }
    bool unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return false;
        if(rank[rx] > rank[ry]){
            p[ry] = rx;
            size[rx] += size[ry];
        }else{
            p[rx] = ry;
            size[ry] += size[rx];
            if(rank[rx] == rank[ry]){
                rank[ry]++;
            }
        }
        return true;
    }
    int tree_size(int x){
        return (size[root(x)]);
    }
};

vector<pair<int,pair<int,int> > > vec;

int main()
{
    int v,e;
    cin >> v >> e;
    for(int i = 0; i < e; i++){
        int s,t,w;
        cin >> s >> t >> w;
        vec.push_back(make_pair(w,make_pair(s,t)));
    }
    sort(vec.begin(),vec.end());
    UnionFind uf(v);
    ll ans = 0;
    for(int i = 0; i < e; i++){
        pair<int,pair<int,int> > p = vec[i];
        if(!uf.same(p.second.first,p.second.second)){
            uf.unite(p.second.first,p.second.second);
            ans += p.first;
        }
    }
    cout << ans << endl;
}


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

void shuffle( vector <int>& cards )
{
	vector <int> a;
	vector <int> b;

	int n = cards.size()/2;
	for ( int i = 0; i < n; i++ )
	{
		a.push_back( cards[i] );
	}

	for ( int i = n; i < cards.size(); i++ )
	{
		b.push_back( cards[i] );
	}

	cards.clear();

	vector <int>::iterator it_a = a.begin();
	vector <int>::iterator it_b = b.begin();

	bool sw = true;
	for ( int i = 0; i < 2*n; i++ )
	{
		if ( sw )
		{
			cards.push_back( *it_a );
			it_a++;
		}
		else
		{
			cards.push_back( *it_b );
			it_b++;
		}
		sw = !sw;
	}

}

void cut( vector <int>& cards, int k )
{
	vector <int> a;
	vector <int> b;

	for ( int i = 0; i < k; i++ )
	{
		a.push_back( cards[i] );
	}

	for ( int i = k; i < cards.size(); i++ )
	{
		b.push_back( cards[i] );
	}

	cards.clear();
	cards.insert( cards.end(), b.begin(), b.end() );
	cards.insert( cards.end(), a.begin(), a.end() );

}

void print( vector <int>& cards )
{
	for ( vector <int>::iterator it = cards.begin(); it != cards.end(); it++ )
	{
		cout << *it << endl;
	}
}

int main( void )
{
	int n; // J[hÌ
	int m; // ìÌñ

	cin >> n >> m;

	vector <int> cards( 2 * n );

	for ( int i = 0; i < 2 * n; i++ )
		cards[i] = i + 1;

	for ( int lpc = 0; lpc < m; lpc++ )
	{
		int k; // ì
		cin >> k;

		if ( k == 0 )
		{
			shuffle( cards );
		}
		else
		{
			cut( cards, k );
		}

	}

	print( cards );

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::terminate;
using std::sort;
using std::find;
using std::vector;

template<class T> inline T min(T X, T Y) {
    return X < Y ? X : Y;
}

template<class T> inline T abs(T X) {
    return X > 0 ? X : -X;
}

void solve() {
    int x, n; cin >> x >> n;
    if (n == 0) {
        cout << x << endl;
        return ;
    }

    vector<int> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());

    int y = 102; int ans = 0;
    for (int i = 0; i <= 101; ++i) {
        auto it = find(p.begin(), p.end(), i);
        if (it == p.end()) {
            if (y > abs(x - i)) {
                y = abs(x - i);
                ans = i;
            }
        }
    }

    cout << ans << endl;
}

int main() {

#ifdef DEV
    std::ifstream in("input");
    cin.rdbuf(in.rdbuf());

    int t; cin >> t;
    for (int x = 1; x <= t; ++x) {
        solve();
    }
#else
    solve();
#endif

    return 0;
}


Measured memory_bytes: 3552
#include<stdio.h>

int main(void){
  int a,b;
  scanf("%d %d\n",&a,&b );
  if(a < b){
    while(b>0){
      printf("%d",a );
      b--;
    }
  }else{
    while(a>0){
      printf("%d",b );
      a--;
    }
  }
  return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	unsigned int N=in<unsigned int>();
	bitset<32> bs(N);
	auto nbs(bs),lbs(bs),rbs(bs);
	nbs.flip();
	lbs <<= 1;
	rbs >>= 1;

	out(bs);
	out(nbs);
	out(lbs);
	out(rbs);

	return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str;
  cin>>str;
  int n,k,ans;
  n=str.size();
  vector<int> vec(n);
  for(int i=0; i<n; i++){
    if(str.at(i)=='A'||str.at(i)=='T'||str.at(i)=='C'||str.at(i)=='G'){
      vec.at(i)=1;
      
    }
    else{
      vec.at(i)=0;
    }
  }
  ans=0;
  k=0;
  for(int i=0; i<n; i++){
    if(vec.at(i)==1){
      k=k+1;
    }
    else{
      ans=max(k,ans);
      k=0;
    }
  }
  ans=max(k,ans);
  cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;

template <class Monoid>
class SegmentTree
{
public:
  using Func = function<Monoid(Monoid, Monoid)>;
  const Func F;
  const Monoid M1;
  int sz;
  vector<Monoid> seg;

  SegmentTree(int n,const Func fu, const Monoid &m1): F(fu) , M1(m1) {init(n);}
  void init(int n)
  {
      sz= 1;
      while (sz < n) sz *= 2;
      seg.assign(sz * 2, M1);
  }
  void update(int k,const Monoid &x)
  {
    k+=sz;
    seg[k]=x;
    while(k>>=1)
    {
      seg[k]=F(seg[k*2],seg[k*2+1]);
    }
  }
  Monoid query(int l,int r)
  {
    Monoid L=M1,R=M1;
    l+=sz;r+=sz;
    for(;l<r;l>>=1,r>>=1)
    {
      if(l&1)L=F(L,seg[l++]);
      if(r&1)R=F(seg[--r],R);
    }
    return F(L,R);
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m;cin>>n>>m;
  struct kukann{ll l,r,c;};
  vector<kukann>lr(m);
  rep(i,m){
    cin>>lr[i].l>>lr[i].r>>lr[i].c;
    lr[i].l--;
  }
  sort(all(lr),[&](kukann a,kukann b){return a.l<b.l;});
  SegmentTree<ll> st(n+7,[&](ll a,ll b){return min(a,b);},(ll)1e17);
  st.update(0,0);
  rep(i,m){
    ll nc=st.query(lr[i].r-1,lr[i].r);
    nc=min(st.query(lr[i].l,lr[i].r)+lr[i].c,nc);
    st.update(lr[i].r-1,nc);
  }
  ll res=st.query(n-1,n);
  if(res>=1e17)res=-1;
  cout<<res<<endl;
  return 0;

}


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

int main()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> R;
    vector<int> G;
    vector<int> B;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'R')
        {
            R.push_back(i);
        }
        if (s[i] == 'G')
        {
            G.push_back(i);
        }
        if (s[i] == 'B')
        {
            B.push_back(i);
        }
    }

    ll count=R.size()*G.size()*B.size();
    for (int i=0;i<=(n-3)/2;i++){
        for (int j=0;j<=n-2* i-3;j++){
            if (s[j]!=s[j+1+i] && s[j+1+i]!= s[j+2+2*i] && s[j+2+2*i]!=s[j]){
                count --;
            }
            
        }
    }
    cout <<count;
}


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

int main()
{
	int64_t n, inf = (1LL << 60);
	cin >> n;
	vector<int64_t> as(n);
	for (auto &a : as)
	{
		cin >> a;
	}

	reverse(as.begin(), as.end());

	vector<int64_t> dp(n, inf);

	for (auto &a : as)
	{
		*upper_bound(dp.begin(), dp.end(), a) = a;
	}

	cout << distance(dp.begin(), lower_bound(dp.begin(), dp.end(), inf)) << endl;

	return 0;
}

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

const int MAXN = 100005;

long long a[MAXN], b[MAXN];
int n, T[MAXN], m;
long long k;
int x[MAXN], tot = 1;

struct dp {
	int a[MAXN];
	friend dp operator * (const dp &a, const dp &b)
	{
		dp ret;
		for (register int i = 1; i < n; i++)
			ret.a[i] = b.a[a.a[i]];
		return ret;
	}
} pt;

inline dp power(dp a, long long k)
{
	dp ans;
	for (int i = 1; i < n; i++) ans.a[i] = i;
	for (; k; k >>= 1) {
		if (k&1) ans = ans*a;
		a = a*a;
	}
	return ans;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
	long long s = a[1];
	for (int i = 1; i <= n-1; i++) a[i] = a[i+1]-a[i], pt.a[i] = i;
	scanf("%d%lld", &m, &k);
	for (int i = 1; i <= m; i++) {
		scanf("%d", &x[i]);
		swap(pt.a[x[i]-1], pt.a[x[i]]);
	}
	pt = power(pt, k);
	for (int i = 1; i < n; i++) b[i] = a[pt.a[i]];
	b[0] = s;
	for (int i = 1; i < n; i++) b[i] += b[i-1];
	for (int i = 1; i <= n; i++)
		printf("%lld\n", b[i-1]);
	return 0;
}


Measured memory_bytes: 5120
n, k = list(map(int, input().split()))


from functools import reduce
from operator import mul

def cmb(n, r):
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0:
        return 1
    # なんでn + 1じゃないのか？
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under

TEISU = 10 ** 9 + 7

for i in range(k):
    print(int(cmb(n - k + 1, i + 1) * cmb(k - 1, i)) % TEISU)



Measured memory_bytes: 3940
#include<bits/stdc++.h> 
using namespace std;
   
int main()  
{ 
    long long int n,k;
    cin>>n>>k;
    long long int p=(n%k);
    if(p<0){
    	p=p-(2*p);
	}
	long long int y=(k-p);
	if(y<0){
		y=y-(2*y);
	}
    if(y>=p){
    	cout<<p;
	}
	else{cout<<y;
	}
    return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    char inputA, inputB, inputC;

    scanf("%c%c%c", &inputA, &inputB, &inputC);
    (inputA + inputB + inputC == 195 || inputA + inputB + inputC == 198) ? puts("No") : puts("Yes");

    return 0;
}

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

using namespace std;

typedef long long int li;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

vi par,sz,vis,dis;
vector<vi> graph;
vector<vector<pair<li,li>>> wgraph;

void init(li n)
{
    par.resize(n);
    sz.resize(n);
    wgraph.resize(n);
    dis.resize(n);
    vis.resize(n);
    graph.resize(n);

    f(i,0,n-1)
    {
        par[i]=i;
        sz[i]=1;
        dis[i]=INT_MAX;
    }
}

li root(li a)
{
    while(a!=par[a])
    {
        par[a]=par[par[a]];
        a=par[a];
    }

    return a;
}

void unio(li a,li b)
{
    li r_a=root(a);
    li r_b=root(b);

    if(par[r_a]!=r_b)
    { 
        if(sz[r_a]<sz[r_b])
        {
            par[r_a]=par[r_b];
            sz[r_b]+=sz[r_a];
            sz[r_a]=0;
        }
        else
        {
            par[r_b]=par[r_a];
            sz[r_a]+=sz[r_b];
            sz[r_b]=0;
        }
    }
}

void dijkstra(li start)
{
    dis[start]=0;

    multiset<pair<li,li>> s;

    s.insert({0,start});

    while(!s.empty())
    {
        pair<li,li> tp=*s.B;
        s.erase(s.begin());

        li p=tp.S;

        if(!vis[p]) 
        {
            vis[p]=1;

            for(pair<li,li> v:wgraph[p])
            {
                if(dis[p]+v.S<dis[v.F])
                {
                    dis[v.F]=dis[p]+v.S;
                    s.insert({dis[v.F],v.F});
                }
            }
        }
    }
}

int main()
{    
 

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li h,n;

    cin>>h>>n;

    vector<pi> v;

    f(i,0,n-1)
    {
        li a,b;

        cin>>a>>b;

        v.PB({b,a});
    }

    sort(v.B,v.E);

    li dp[n][25555];

    li ans=1e18;

    f(i,0,25550)
    {
        dp[0][i]=ceil((double)i/(double)(v[0].S))*v[0].F;
        if(i>=h)
        ans=min(ans,dp[0][i]);
    }

    f(i,0,n-1)
    {
        dp[i][0]=0;
    }

    f(i,1,n-1)
    {
        f(j,0,25550)
        {
            if(j<v[i].S)
            {
                dp[i][j]=dp[i-1][j];
            }
            else
            {
                dp[i][j]=min(dp[i-1][j],v[i].F+min(dp[i-1][j-v[i].S],dp[i][j-v[i].S]));
            }

            if(j>=h)
            {
                ans=min(ans,dp[i][j]);
            }
        }
    }

    cout<<ans;

    return 0;
}

Measured memory_bytes: 199936
import Foundation

var input_lines = [String]()
input_lines.append(readLine()!)
let strings = input_lines[0].componentsSeparatedByString(" ")

let K = (Int)(strings[0])!
let S = (Int)(strings[1])!

var counter = 0

for i in 0...K {
    if (S - i) > (K * 2) {
        continue
    }
    for j in 0...K {
        let k = (S - i - j)
        
        if 0 <= k && k <= K {
            counter += 1
        }
    }
}

print(counter)


Measured memory_bytes: 7524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    int N;
    cin >> N;
    string S;
    cin >> S;
    int l = 0, r = 0;
    string ans = "";
    REP(i, N) {
        if (S.at(i) == '(') l++;
        else r++;
        if (l < r) {
            l++;
            ans += '(';
        }
    }
    ans += S;
    REP(i, l - r) ans += ')';
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i=(ll)(r);i<(ll)(n);++i)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define pb(n) push_back(n)
#define endl '\n'
#define debug(x) cout << #x << " = " << (x) << endl
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c
#define VIN(V) for(int ii = 0; ii < (V).size(); ii++) {cin >> (V).at(ii);}
#define OUT(n) cout << n << endl
#define OUT2(n1,n2) cout << n1 << " " << n2 << endl
#define OUT3(n1,n2,n3) cout << n1 << " " << n2 << " " << n3 << endl
#define VOUT(V) REP(ii,(V).size()){cout << (V)[ii] << " ";} cout<<endl;
#define VOUT2(V) REP(jj,(V).size()){VOUT(V[jj])}
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<vi > vvi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
ll n, m, k, ans, sum, cnt = 0; string s; char c; bool flg;

int main(){
  cin.tie(0);ios::sync_with_stdio(false);
  ll a,b;
  IN3(n,a,b);
  ans = n * a;
  if (ans > b) ans = b;

  OUT(ans);
}


Measured memory_bytes: 256
def main():
    S = input()
    K = int(input())

    def cut(s):
        for c in s:
            yield c
            if c != '1': break

    *s, = cut(S)
    if len(s) < K:
        print(s[-1])
    else:
        print(s[K - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            if (input.Length != 6)
            {
                Console.WriteLine("No");
                return;
            }

            if (input[2] != input[3])
            {
                Console.WriteLine("No");
                return;
            }
            if (input[4] != input[5])
            {
                Console.WriteLine("No");
                return;
            }
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#define inf 1e9

using namespace std;

struct edge{
	int to, cap, rev, dir;
	edge(int a, int b, int c, int d){
		to = a, cap = b, rev = c, dir = d;
	}
};

int N, M, S, T;
vector<edge> G[1005];
bool reachS[1005], reachT[1005];
bool used[1005];

int dfs(int v, int f)
{
	used[v] = true;
	if(v == T) return f;
	
	int ret;
	for(int i = 0; i < G[v].size(); i++){
		if(used[G[v][i].to] || G[v][i].cap <= 0) continue;
		ret = dfs(G[v][i].to, min(f, G[v][i].cap));
		if(ret > 0){
			G[v][i].cap -= ret;
			G[G[v][i].to][G[v][i].rev].cap += ret;
			return ret;
		}
	}
	return 0;
}

void add_edge(int s, int t, int cap)
{
	G[s].push_back(edge(t, cap, G[t].size(), 0));
	G[t].push_back(edge(s, 0, G[s].size()-1, 1));
}

void reachdfsS(int v)
{
	reachS[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		if(reachS[G[v][i].to]) continue;
		if(G[v][i].cap == 0) continue;
		reachdfsS(G[v][i].to);
	}
}
void reachdfsT(int v)
{
	reachT[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		if(reachT[G[v][i].to]) continue;
		if(G[v][i].cap == 1) continue;
		reachdfsT(G[v][i].to);
	}
}

int main(void)
{
	while(1){
		cin >> N >> M >> S >> T;
		if(!N && !M && !S && !T) break;
		
		for(int i = 1; i <= N; i++) G[i].clear();
		int a, b;
		for(int i = 1; i <= M; i++){
			cin >> a >> b;
			add_edge(a, b, 1);
		}
		
		int ans = 0, flow;
		while(1){
			for(int i = 1; i <= N; i++) used[i] = false;
			flow = dfs(S, inf);
			if(flow <= 0) break;
			ans += flow;
		}
		
		for(int i = 1; i <= N; i++) reachS[i] = reachT[i] = false;
		reachdfsS(S), reachdfsT(T);
		
		int ans2 = 0;
		for(int i = 1; i <= N; i++){
			for(int j = 0; j < G[i].size(); j++){
				if(G[i][j].cap == 0 || G[i][j].dir == 1) continue;
				if(reachS[G[i][j].to] && reachT[i]) ans2++;
			}
		}
		if(ans2) ans++;
		
		cout << ans << " " << ans2 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n;
  vector<int> a(26,50);
  vector<int> b(26,0);
  for(int i=0; i<n; i++) {
    cin >> s;
    for(int j=0; j<s.size(); j++) {
      b[s[j]-'a']++;
    }
    for(int j=0; j<26; j++) {
      a[j]=min(a[j],b[j]);
      b[j]=0;
    }
  }
  char c;
  for(int i=0; i<26; i++) {
    c='a'+i;
    for(int j=0; j<a[i]; j++) {
      cout << c;
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
import qualified Data.Map as M

main :: IO ()
main = solve <$> getLine >>= print

solve :: String -> Int
solve s = (n - m) `div` 2
    where
        n = M.findWithDefault 0 'g' count
        m = M.findWithDefault 0 'p' count
        count = foldr (\c mp -> M.insertWith (+) c 1 mp) M.empty s

Measured memory_bytes: 10620
object MainKt {
  @JvmStatic fun main(args:Array<String>) {
    val (x,a,b)=readLine()!!.split(" ").map(String::toInt)
    println(arrayOf(Pair(Math.abs(a-x),"A"),Pair(Math.abs(b-x),"B")).minBy{it.first}!!.second)   
  }
}


Measured memory_bytes: 37700
# coding: utf-8
# Your code here!
while True:
    line = list(map(int,input().split()))
    m = line[0]
    r = line[1]
    f = line[2]
    
    if m==-1and r==-1 and m==-1:
        break
    
    elif m ==-1 or r == -1:
        print("F")
    elif (m+r)>=80:
        print("A")
    elif m+r >= 65 and m+r< 80:
        print("B")
    elif m+r >=50 and m+r <65:
        print("C")
    elif m+r >=30 and m+r <50 and f>=50:
        print("C")
    elif  m+r >=30 and m+r <50:
        print("D")
    elif m+r <30:
        print("F")


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

int main(){
  int a[26], i, j;
  char c;
  bool ans = true;
  string s;
  cin >> s;
  for(i = 0; i < 26; i++) a[i] = 0;
  for(i = 0; i < s.length(); i++){
    for(c ='a', j = 0; c <= 'z'; c++, j++){
      if(c == s[i]) a[j]++;
    }
  }
  for(i = 0; i < 26; i++)
    if(a[i] > 1) ans = false;
  if(ans) cout << "yes" << endl;
  else cout << "no" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
    #include<iostream>
    #include<cmath>
     
    using namespace std;
     
    int main() {
      long long int s, c;
      cin >> s >> c;
     
      long long start = min(s, c / 2);
      s -= start;
      c -= start * 2;
     
      if (c < 2) {
        cout << start << endl;
      } else {
        start += c / 4;
        cout << start << endl;
      }
    }

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>    
#include <vector>       
#include <set>
#include <utility>  
#include <cstring>
#include <stdio.h>
#include <limits.h>
#include <queue>
#include <algorithm> 
#define MAX_DOUBLE  40000000000.0 
#include <math.h> 
#include <unistd.h>

using namespace std;

long long mod = 1e9 + 7;

bool graph[21][21];

long long res[22][2097152];

int main(){
	int n;
	scanf("%d", &n);
	

	for(int i = 0; i<n; i++){
		for(int j = 0; j<n; j++){
			int a;
			scanf("%d", &a);
			if(a == 1) 
				graph[i][j] = true;
				
		}
	}
	
	for(int i = n-1; i>=0; i--){
		for(int j = 0; j < 2097152; j++){
			
			int count = 0;
			for(int z = 0; z<n; z++){
				count += ((j & (1<<z)) > 0);
			}
			if(count != (n - i) )continue;
			
			
			for(int z = 0; z<n; z++){		
				
				if(j < (1 << z)) break;
				
				if(graph[i][z] && j >= (1 << z) && (j & (1<<z) )){
					if(i == n-1){
						res[i][j] = 1;
					} else{
						res[i][j] = (res[i][j] + res[i+1][j - (1<<z)] ) % mod;
					}
				}
			}
		}
	}
	
	printf("%d" , res[0][(1<<n)-1]);
}


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

typedef struct trie Trie;

struct trie{
  bool flag;
  Trie* next[4];

  trie(){
    flag=false;
    fill(next,next+4,(trie*)0);
  }
};

int judge(const char c){
  int ret;
  switch(c){
  case 'A':
    ret=0;
    break;
  case 'C':
    ret=1;
    break;
  case 'G':
    ret=2;
    break;
  case 'T':
    ret=3;
    break;
  }
  return ret;
}

bool str_find(string str,Trie* tmp){
  bool flag=true;
  int ind;
  
  for(int i=0;i<(int)str.length();i++){
    ind=judge(str[i]);
    
    if(!tmp->next[ind]){
      flag=false;
      break;
    }
    tmp=tmp->next[ind];
  }
  if(!tmp->flag)
    flag=false;

  return flag;
}

void str_insert(string str,Trie* tmp){
  int ind;
  
  for(int i=0;i<(int)str.length();i++){
    ind=judge(str[i]);
    
    if(!tmp->next[ind])
      tmp->next[ind]=new Trie;
    tmp=tmp->next[ind];
  }
  tmp->flag=true;
}

int main(int argc,char* argv[]){
  std::ios_base::sync_with_stdio(false);
  
  int n;
  string str;
  Trie root;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>str;

    if(str[0]=='i'){
      cin>>str;
      str_insert(str,&root);
    }
    else{
      cin>>str;
      if(str_find(str,&root))
	cout<<"yes"<<endl;
      else
	cout<<"no"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 17516
a,b=gets.split.map(&:to_i)
r = 0
(b+1).times do |e|
  b1,b2=e.to_s.split('').map(&:to_i)
  b2||=0
  if b1 > 1 && b2 > 1
    r+=1 if b1 * b2 <= a
  end
end

p r


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,k,t,u,v,m;
  cin >> n >> k >> t >> u >> v >> m;
  int d[m+1];
  mem(d);
  rep(i,n) {
    int x;
    R x;
    d[x]++;
  }
  double ans=0,x=0;
  rep(i,m) {
    if(d[i]&&x<t*(k+1)) x+=t;
    x=min(x,(double)t*(k+1));
    if(!x) ans+=1.0/u;
    else {
      ans+=1.0/v;
      x-=1.0/v;
      if(fabs(x)<1e-9) x=0;
      x=max(x,0.0);
    }
  }
  pd(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3280
n = int(input())
a = list(map(int, input().split()))

l_a = a[0]-1
r_a = a[-1]
for i in range(len(a)-1):
    if l_a > a[i+1]:
        print("No")
        exit()
    elif l_a != a[i+1]:
        l_a = a[i+1]-1

    if l_a > r_a:
        print("No")
        exit()
else:
    print("Yes")


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
const int MAXN = 100500;

int main()
{                                                     
	ios_base::sync_with_stdio(0);

	int n, m, k;
	cin >> n >> m >> k;
	bool ok = false;

	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			ok |= i * j + (n - i) * (m - j) == k;
		}
	}
	
	cout << (ok ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	ll n, p;
	cin >> n >> p;
	
	map<ll, ll> prf;
	
	for(ll i = 2; i * i <= p; ++i) {
		while( p % i == 0 ) {
			prf[i]++;
			p /= i;
		}
	}
	
	if( p != 1 ) prf[p] = 1;
	
	ll ans = 1LL;
	for(auto x : prf) {
		if( x.second >= n ) {
			ans *= (ll)pow(x.first, x.second / n);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256