akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

long long  factorial(long long n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}

//int ()



int main()
{
  int a ,b, c, d, e, X, Y;
//  long long  a, b, c, d, e, X, Y;
  //  double  c;
  int  A[200003]={};
//  long long  A[100003]={};
//  long long  B[100003]={};
  int  C[100003][11]={};

  int  flg=0;

//  long long  a, b, c, d, X, Y;
  char s[101][101]={};
  char t[101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p,q;
//  int flag=0;
//  int tmp=0;
  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int len=0;
  int l=0;
  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  long long ans=1;
  int max=0;
  int sum=0;
  int addr=0;
  int ptn=0;
//  bool on_off[100]={};
  
//  char alp[26]={'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'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
  scanf("%d", &a);
//    printf("%d\n", num);
  for(i=0;i<a;i++){
    scanf("%d", &A[i]);
  }
  for(i=0;i<a;i++){
    if(num2<A[i]){
      num2=A[i];
    } 
    if(num1<num2){
      ptn=num1;
      num1=num2;
      num2=ptn;
      num=i;
    }
  }
  for(i=0;i<a;i++){
    if(i==num)    printf("%d\n", num2);
    else          printf("%d\n", num1);
  }
  

    
//    printf("%s %d %d\n", s[i],C[i][0],C[i][1]);
   // printf("%d\n", C[i][1]);
/*  for(i=0;i<addr;i++){
//  scanf("%lld%lld", &B[0][i],&B[1][i]);
//    ans=ans+A[i];
    printf("%lld ", A[i]);
  }
*/
//    printf("%d ", cnt);
   

return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define avjo ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    avjo;
    int s,w;
    cin>>s>>w;
    if(w>=s)
        cout<<"unsafe";
    else
        cout<<"safe";
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define FOR(x, z, y) for(int x = (z); y; x++)
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; FOR(cnt, 0, getline(stream,res,sp_word))
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
typedef long long ll;
using namespace std;

int main(){
  ll N;
  scanf("%lld",&N);

  int anser = 11;
  for(ll i = 1; i <= sqrt(N); i++){
    auto divi = lldiv(N,i);
    if(divi.rem == 0)
      anser = min(anser,digit(divi.quot));
  }

  printf("%d",anser);
  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>


int main(void)
{
    int n,i=0,j=0,k=0,l,flog=0,c=0;
    char str[200];
    scanf("%d",&n);
    for(i=0;c<n;i++){
        if(str[i]!=' ') c++;
        scanf("%c",&str[i]);
    }
    for(l=0;c>=0;l++){
        if(str[i]!=' ') c--;
        if(str[l]=='P') i=l;
        else if(str[l]=='W') j=l;
        else if(str[l]=='G') k=l;
        if(str[l]=='Y') flog=1;
    }
    if(flog==1)printf("Four\n");
    else printf("Three\n");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9

// #define fisier 1

using namespace std;

typedef long long ll;


int add(int a, int b)
{
    int x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

ll pw(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand_seed()
{
    long long a = rng();
    return a;
}

vector<int> v[200002];

int dp[200002];
int main()
{

    #ifdef fisier
        ifstream f("input.in");
        ofstream g("output.out");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, m;
    cin >> m >> n;
    vector<int> v(n);
    for(int i = 1; i <= n; ++i)
		cin >> v[i-1];
	sort(v.begin(), v.end());
	int s = 0;
	for(int i = 0; i < n; ++i)
		s += v[i];
    if(s > m)
    cout << -1;
    else
    cout << m - s;
    return 0;
}


Measured memory_bytes: 8380
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
D, X = nl()

count = X
for i in range(N):
    count += 1
    A = n()
    day = A + 1
    while day <= D:
        count += 1
        day += A
print(count)


Measured memory_bytes: 3060
N, a, b = list(map(int, input().split()))
p = 10 ** 9 + 7

factinv = [1, 1]
inv = [0, 1]

for i in range(2, 10**6):
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

def comb(n, k):
    cmb = 1
    for i in range(n-k+1, n+1):
        cmb = cmb * i % p
    return cmb * factinv[k]


print(((2 ** N - 1) % p - comb(N, a) % p - comb(N, b) % p) % p)


Measured memory_bytes: 335652
use io::*;
use std::*;

fn solve(A: i64, B: i64, K: i64) {
    let mut i = A;
    while i <= B{
        println!("{}", i);
        if i == A + K - 1{
            let j = B - K;
            if j > i{
                i = j;
            }
        }
        i += 1;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut A: i64;
    A = scanner.next();
    let mut B: i64;
    B = scanner.next();
    let mut K: i64;
    K = scanner.next();
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(A, B, K)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


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

int main(){
    int h, w;
    cin >> h >> w;

    char m[h][w];
    int che[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> m[i][j];
            che[i][j] = 0;
        }
    }

    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(m[i][j] == '.'){
                int cou = 1;
                for(int k = 1; i + k < h; k++){
                    if(m[i + k][j] == '.'){
                        cou++;
                    }else{
                        break;
                    }
                }

                for(int k = 1; i - k >= 0; k++){
                    if(m[i - k][j] == '.'){
                        cou++;
                    }else{
                        break;
                    }
                }

                for(int k = 1; j + k < w; k++){
                    if(m[i][j + k] == '.'){
                        cou++;
                    }else{
                        break;
                    }
                }

                for(int k = 1; j - k >= 0; k++){
                    if(m[i][j - k] == '.'){
                        cou++;
                    }else{
                        break;
                    }
                }

                if(ans < cou){
                    ans = cou;
                }
            }

            if(ans == h + w - 1){
                break;
            }
        }

        if(ans == h + w - 1){
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 19840
#include <bits/stdc++.h>
using namespace std;
using ll=int_fast64_t;
using P=pair<int,int>;
const ll INF=1<<30;
const ll LINF=1LL<<60;
const double EPS=1e-11;
int main(){
    ll n,x;cin>>n>>x;
    ll s[60],p[60];
    s[0]=1;
    p[0]=1;
    for(int i=1;i<=n;i++){
        s[i]=s[i-1]*2LL+3LL;
        p[i]=p[i-1]*2LL+1LL;
    }
    ll ans=0;
    if(x==1){
        cout<<0<<endl;
        return 0;
    }
    for(int i=n-1;i>=0;i--){
        if(x==s[i]+1){
            ans+=p[i];
            break;
        }else if(x==s[i]+2){
            ans+=p[i]+1;
            break;
        }else if(x>=s[i]*2+2){
            ans+=p[i]*2+1;
            break;
        }else if(x>s[i]+2){
            ans+=p[i]+1;
            x-=s[i]+2;
        }else{
            x--;
        }
    }
    if(x==1){

    }
    cout<<ans<<endl;
}

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

long long x, y;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> x >> y;
	if(y == 1 || x % y == 0) cout << -1 << "\n";
	else cout << x * (y - 1) << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int A, B, C;
	cin >> A >> B >> C;
	bool flg = false;
	if(A == B || A == C)
		if(B != C)
			flg = true;
	if(B == C)
		if(A != B & A != C)
			flg = true;

	cout << (flg?"Yes":"No") << endl;

	return 0;
}

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

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

#define rep(a,n) for(int a = 0;a < n;a++)
vector<vector<pair<int, int>>> g;
vector<int> color;
vector<int> visited;

void dfs(int v) {
	if (visited[v]) return;
	visited[v] = 1;
	auto c = color[v];
	for (auto e : g[v]) {
		if (color[e.first] == 0) {
			color[e.first] = (e.second % 2 == 0 ? c : -c);
			dfs(e.first);
		}
	}
}

int main(void)
{
	ll n;
	cin >> n;
	g.resize(n);
	color.resize(n, 0);
	visited.resize(n, 0);
	rep(i, n - 1) {
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		g[a].emplace_back(b, c);
		g[b].emplace_back(a, c);
	}
	color[0] = 1;
	dfs(0);
	rep(i, n) {
		cout << max(0, color[i]) << endl;
	}
	return 0;
}

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

int main(){
  int n,m;
  long long ans=1;
  cin>>n>>m;
  if(n==m){
    for(int i=1;i<=n;i++){
      ans*=i;
      ans%=1000000007;
      ans*=i;
      ans%=1000000007;
    }ans*=2; ans%=1000000007;
  }else if(n==m+1||m==n+1){
    for(int i=1;i<=min(n,m);i++){
      ans*=i;
      ans%=1000000007;
      ans*=i;
      ans%=1000000007;
    }ans*=max(n,m); ans%=1000000007;
  }else{
    cout<<0<<endl;
    return 0;
  }cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  int k; 
  int a,b; cin>>k>>a>>b;
  for(int i=a;i<=b;i++){
  	if(i%k==0){
  		cout<<"OK\n";
  		return 0;
  	}
  }
  cout<<"NG\n";
  return 0;
}

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

#define SZ(c) int(c.size())
#define all(c) c.begin(), c.end()
#define pb  push_back
#define clr(a, n) memset(a, n, sizeof a)

const int mod = 1e9+7;

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

int main() {

	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	if (u == s) {
		cout << --a << " " << b << '\n';
	} else if (u == t) {
		cout << a << " " << --b << '\n';
	}

	return 0;
}


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

std::string str;
int n, ans;

int main()
{
    std::cin >> n >> str;
    for (int i = 2; i < n; ++i)
        if (str[i - 2] == 'A' && str[i - 1] == 'B' && str[i] == 'C')
            ++ans;
    std::cout << ans << std::endl;
    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))

s = [0] * N
for i in range(N):
  s[A[i]-1] += 1

total = 0
for i in range(N):
  total += s[i]*(s[i]-1) // 2

for k in range(N):
  ans = total - s[A[k]-1]*(s[A[k]-1]-1)//2 + (s[A[k]-1]-1)*((s[A[k]-1]-1)-1) // 2
  print(ans)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

const int N_MAX = 1e5;

int a[N_MAX];

//-------------------------------------------------
//--Union Find tree
//-------------------------------------------------
class UnionFind
{
private:
    vector<int> par;
    vector<int> rank;
    vector<int> mini;
public:
    UnionFind(int n):par(n), rank(n), mini(n){
        for(int i=0; i<n; i++){
            par[i] = i;
            rank[i] = 0;
            mini[i] = a[i];
        }
    }
    int root(int x){
        if (par[x]==x) return x;
        return par[x] = root(par[x]);
    }
    bool same(int x, int y){
        return root(x)==root(y);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if (rx==ry) return;
        if (rank[rx]>rank[ry]){
            par[ry] = rx;
            mini[rx] = min(mini[rx],mini[ry]);
        }else{
            par[rx] = ry;
            if (rx==ry) rank[ry]++;
            mini[ry] = min(mini[rx],mini[ry]);
        }
    }
    int getMin(int x){
        return mini[root(x)];
    }
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin>>N>>M;
    rep(i,N) cin>>a[i];
    UnionFind uf(N);
    rep(i,M){
        int x,y; cin>>x>>y;
        uf.unite(x,y);
    }
    if (2*(N-M-1)>N){
        cout<<"Impossible\n";
        return 0;
    }
    if (M==N-1){
        cout<<"0\n";
        return 0;
    }
    ll ans=0, cnt=0;
    vector<bool> use(N,false);
    multiset<int> ms;
    rep(i,N) ms.ins(a[i]);
    rep(i,N)if(!use[uf.root(i)]){
        use[uf.root(i)] = true;
        int t = uf.getMin(i);
        ans+=t;
        auto itr = ms.find(t);
        ms.erase(itr);
        cnt++;
    }
    int extra = 2*(N-M-1)-cnt;
    auto itr = ms.begin();
    rep(i,extra){
        ans+=(*itr);
        itr++;
    }
    cout<<ans<<endl;
    return 0;
}


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

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

	//freopen("01-handmade-05", "r", stdin);
	
	int n, m;
 
	cin >> n >> m;
 
	vector<bool> accepted(n + 1);
	vector<int> wrongAnswers(n + 1);
	
 
	int problem;
	string verdict;
 
	int countCorrect = 0;
	int countPenalties = 0;
 
	for (int i = 0; i < m; i++)
	{
		cin >> problem >> verdict;
 
		if (verdict == "WA")
		{
			if (accepted[problem] == false)
			{
				wrongAnswers[problem]++;
			}
		}
		else
		{
			if (accepted[problem] == false)
			{
				countCorrect++;
				accepted[problem] = true;
				countPenalties += wrongAnswers[problem];
			}
		}
	}
 
	cout << countCorrect << " " << countPenalties;

	return 0;
}

Measured memory_bytes: 640
x = list(map(int, input().split("/")))
if x[0] > 2019:
    print("TBD")
    exit()
elif x[0] == 2019:
    if x[1] > 4:
        print("TBD")
        exit()
    elif x[1] == 4:
        if x[2] > 30:
            print("TBD")
            exit()
        else:
            print("Heisei")
            exit()
    else:
        print("Heisei")
        exit()
else:
    print("Heisei")
    exit()


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

int main()
{
	int n = 0;
	cin >> n;
	if ((n % 10) == n / 100) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;

public class Main {
    public static void main(String[] args) throws IOException {
//    	long l = System.currentTimeMillis();
        new Main().exec();
//    	long l2 = System.currentTimeMillis();
//    	System.out.println(l2 - l);
    }
    
    public void exec() throws IOException {
        InputUtil in = new InputUtil();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int[] A = in.nextInt(new int[n]);
        HashSet<Integer> okNumber = new HashSet<>();
        calc(A,okNumber);
        for(int m : in.nextInt(new int[in.nextInt()])) {
        	out.println(okNumber.contains(m)?"yes":"no");
        }
        out.flush();
    }
    
    private void calc(int[] A, HashSet<Integer> okNumber) {
    	okNumber.add(0);
    	for(int i=0; i<A.length; i++) {
        	for(int n: okNumber.toArray(new Integer[0])) {
        		okNumber.add(n+A[i]);
        	}
    	}
    }
}

class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 50000;
	
	//Fields
	protected InputStream in;
	private char[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private BufferedReader br = null;
	
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {br = new BufferedReader(new InputStreamReader(this.in = in));}
	protected void initBuf(int bufsiz) {buf = new char[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && br.ready()) {
			max = br.read(buf);
			ptr = 0;
		}
	}
	//Number Input Reader/Parser
	private boolean isNum(char b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(char b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		char c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}

Measured memory_bytes: 24532
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main() {
	string a;
	int k;
	int A,B;
	int counter = 0;
	while (cin >> a) {
		if (a[0] == '0') {
			break;
		}
		k = a.size();
		A = 0;
		B = 0;
		for (int i = 1; i < k; i++) {
			if (a[i] == 'A') {
				A++;
			} else {
				B++;
			}
		}
		if (A > B) {
			A++;
		} else {
			B++;
		}
		cout << A << " " << B << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#! /usr/bin/perl --

my $A = <STDIN>; # 500
my $B = <STDIN>; # 100
my $C = <STDIN>; # 50
my $X = <STDIN>; # 円

my $pat = 0;
for($cA = 0; $cA <= $A; $cA++){
	for($cB = 0; $cB <= $B; $cB++){
		for($cC = 0; $cC <= $C; $cC++){
			my $yen = ($cA * 500) + ($cB * 100) + ($cC * 50);
			if($yen == $X){
				$pat++;
			}
		}
	}
}

print $pat;


Measured memory_bytes: 384
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
int main(){
  ll N,X,M,i,ans = 0;scanf("%lld%lld%lld",&N,&X,&M);
  ll last[M];fill(last,last+M,-1);
  vector<ll> num;
  num.emplace_back(X);
  last[X] = 0;
  ans += X;
  for(i=1;i<N;i++){
    X = X*X%M;
    if(last[X] != -1) break;
    last[X] = i;
    ans += X;
    num.emplace_back(X);
  }
  if(i == N){
    printf("%lld\n",ans);return 0;
  }
  N -= i;
  ll ssum = 0,sturn = num.size()-last[X];
  for(i=last[X];i<num.size();i++) ssum += num[i];
  ans += ssum*(N/sturn);
  N %= sturn;
  ans += accumulate(num.begin()+last[X],num.begin()+last[X]+N,0LL);
  printf("%lld\n",ans);
}

Measured memory_bytes: 4652
#
# abc061 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 4
1 1
2 2
3 3"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10 500000
1 100000
1 100000
1 100000
1 100000
1 100000
100000 100000
100000 100000
100000 100000
100000 100000
100000 100000"""
        output = """1"""
        self.assertIO(input, output)


def resolve():
    N, K = map(int, input().split())
    D = [list(map(int, input().split())) for _ in range(N)]

    D.sort()
    t = 0
    for d in D:
        t += d[1]
        if t >= K:
            print(d[0])
            break


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 34764
n=int(input())
b=list(map(int,input().split()))
a=[0]*n
ans=0
if n == 2:
    print(b[0]*2)
elif n==3:
    print(min(b)*2 + max(b))
else:
    a[0]=b[0]
    for i in range(1,n-1):
        a[i]=min(b[i-1], b[i])
    a[n-1]=b[n-2]
    ans =sum(a)
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
using namespace std;
using ll = long long;
int main(){
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i,0,n)cin >> a[i];
    //b[i][k]=k回魔法を唱えてスライムiを手に入れるための最小の時間-k*x
    //       =min(a_i, ..., a_{i-k})
    //       =min(b[i][k-1],a_{i-k})
    vector<vector<ll>> b(n,vector<ll>(n));
    rep(i,0,n){
        b[i][0]=a[i];
        rep(k,1,n)b[i][k]=min(b[i][k-1],a[(i-k+n)%n]);
    }
    ll ans=1e15;
    rep(k,0,n){
        ll tmp=k*x;
        rep(i,0,n)tmp+=b[i][k];
        ans=min(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 31616
#include<stdio.h>

int T[5000001],H;
int parent(int i){
  return i/2;
}
int left(int i){
  return i*2;
}
int right(int i){
  return i*2+1;
}
void maxHeapify(int *T,int i){
  int l,r,largest,tmp;
  l = left(i);
  r = right(i);
  if(l<=H && T[l]>T[i]){
    largest = l;
  }
  else largest = i;
  if(r<=H && T[r] > T[largest]){
    largest = r;
  }
  if(largest != i){
    tmp = T[i];
    T[i] = T[largest];
    T[largest] = tmp;
    maxHeapify(T,largest);
  }
}
void buildMaxheap(int *T){
  int i;
  for(i=H/2;i>0;i--){
    maxHeapify(T,i);
  }
}


int main(){
  int i,n;
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&T[i]);
  }
  buildMaxheap(T);
  for(i=1;i<=H;i++){
    printf(" %d",T[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
const int m = 2019;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  reverse(s.begin(), s.end());
  vector<int> cnt(m);
  cnt[0] = 1;
  int x = 1; // exp modint
  int a = 0; // sum(10^0-10^i) modint
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    a = (a + (s[i] - '0') * x) % m;
    cnt[a]++;
    x = x * 10 % m;
  }
  for (int i = 0; i < m; i++) {
    if (cnt[i] > 1)
      ans += cnt[i] * (cnt[i] - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3756
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=2e5+7,M=N<<1;
const int mod=inf;

int f[N][3],pw2[N];
int v[N],nxt[N];
int p[N],dep[N],head[N],up[N],from[N];
int q[N],st,ed;
int node[N],sz;
bool inq[N];
int n,ans;

il void dfs(const int &u){
	if(u){
		dep[u]=dep[p[u]]+1;
		up[u]=(nxt[head[p[u]]]?u:up[p[u]]);
	}
	for(int e=head[u];e;e=nxt[e]){
		dfs(v[e]);
	}
}

il int top(const int &u){
	return up[u]==u?u:up[u]=top(up[u]);
}

il void inc(int &x,const int &y){
	x+=y;
	if(x>=mod) x-=mod;
}

il bool cmp(const int &x,const int &y){
	return dep[x]>dep[y];
}

int main(){
//	fileio("test");
	scanf("%d",&n);
	pw2[0]=1;
	rep(i,1,n+1){
		pw2[i]=pw2[i-1]<<1;
		if(pw2[i]>=mod) pw2[i]-=mod;
	}
	rep(i,1,n){
		scanf("%d",p+i);
		v[i]=i,nxt[i]=head[p[i]],head[p[i]]=i;
	}
	dfs(0);
//	rep(i,1,n) cerr<<i<<" "<<up[i]<<endl;
	for(st=0,ed=0,q[ed]=0;st<=ed;){
		int cur=dep[q[st]],cnt=0;
		sz=0;
		for(;st<=ed&&dep[q[st]]==cur;++st){
			int u=q[st];
			++cnt;
			f[u][0]=f[u][1]=1,f[u][2]=0;
			node[++sz]=u;
			inq[u]=true;
			for(int e=head[u];e;e=nxt[e]) q[++ed]=v[e];
			for(int v=top(u),par=p[v];v;v=top(par),par=p[v]){
				from[par]=(!from[par]?v:-1);
				if(inq[par]) break;
				node[++sz]=par;
				f[par][0]=1,f[par][1]=f[par][2]=0;
				inq[par]=true;
			}
		}
		if(!inq[0]){
			node[++sz]=0;
			f[0][0]=1,f[0][1]=f[0][2]=0;
			inq[0]=true;
		}
		sort(node+1,node+sz+1,cmp);
		rep(i,1,sz){
			int u=node[i],v=p[top(u)];
			inq[u]=false;
			if(from[u]>0) up[from[u]]=u;
			from[u]=0;
			if(!u){
				inc(ans,1ll*f[u][1]*pw2[n+1-cnt]%mod);
				break;
			}
			ll cnt0=f[u][0]+f[u][2],cnt1=f[u][1];
			f[v][2]=((cnt0+cnt1)*f[v][2]+cnt1*f[v][1])%mod;
			f[v][1]=(cnt0*f[v][1]+cnt1*f[v][0])%mod;
			f[v][0]=(cnt0*f[v][0])%mod;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 11904
#include <stdio.h>

#define N 100

int main(){
  int i,j,n,u,k,v;
  int V[N][N];

  scanf("%d",&n);

  for(i=0; i<n; i++)
    for(j=0; j<n; j++)
      V[i][j]=0;

  for(i=0; i<n; i++){
    scanf("%d%d",&u,&k);
    for(j=0; j<k; j++){
      scanf("%d",&v);
      V[u-1][v-1] = 1;
    }
  }

  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      if(j) printf(" ");
      printf("%d",V[i][j]);
    }
    printf("\n");
  }

  return 0;
}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

struct Item {
  int numA, numB, val;
  int size() const { return numA + numB; }
  bool operator < (const Item& o) const {
    return size() < o.size();
  }
};

int main2() {
  int N = nextLong();

  vector<int> a(N), b(N);
  REP(i, N) a[i] = nextLong();
  REP(i, N) b[i] = nextLong();

  map<int, int> A, B;
  REP(i, N) A[a[i]]++;
  REP(i, N) B[b[i]]++;

  for (int i = 1; i <= N; i++) {
    if (A[i] + B[i] > N) {
      cout << "No" << endl;
      return 0;
    }
  }

  vector<int> aa, bb;
  priority_queue<Item> pq;
  for (int i = 1; i <= N; i++) {
    if (A[i] + B[i] > 0) {

      if (min(A[i], B[i]) > 0) {
        pq.push((Item){ A[i], B[i], i });
      } else {
        REP(_, A[i]) aa.push_back(i);
        REP(_, B[i]) bb.push_back(i);
      }
    }
  }

  vector<pair<int,int>> ps;
  for (; pq.size() >= 2 ;) {
    Item x = pq.top(); pq.pop();
    Item y = pq.top(); pq.pop();
    if (y.numA > 0) {
      ps.push_back({y.val, x.val});
      x.numB--;
      y.numA--;
    } else {
      ps.push_back({x.val, y.val});
      x.numA--;
      y.numB--;
    }

    if (x.numA > 0 && x.numB > 0) {
      pq.push(x);
    } else {
      REP(_, x.numA) aa.push_back(x.val);
      REP(_, x.numB) bb.push_back(x.val);
    }
    if (y.numA > 0 && y.numB > 0) {
      pq.push(y);
    } else {
      REP(_, y.numA) aa.push_back(y.val);
      REP(_, y.numB) bb.push_back(y.val);
    }

  }

  if (pq.size() > 0) {
    Item x = pq.top(); pq.pop();

    while (x.numA > 0) {
      x.numA--;
      ps.push_back({x.val, bb.back()});
      bb.pop_back();
    }
    while (x.numB > 0) {
      x.numB--;
      ps.push_back({aa.back(), x.val});
      aa.pop_back();
    }
  }

  while (aa.size()) {
    ps.push_back({aa.back(), bb.back()});
    aa.pop_back();
    bb.pop_back();
  }
  sort(ALL(ps));

  vector<int> ans(N);
  REP(i, N) ans[i] = ps[i].second;


  cout << "Yes" << endl;
  REP(i, N) {
    if (i) cout << ' ';
    cout << ans[i];
  }
  cout << endl;

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 30132
from collections import Counter
n = int(input())
list_A = list(map(int, input().split()))
mod = pow(10, 9) + 7

list_Counter = list(Counter(list_A).items())
ans = 1
list_Counter.sort(key=lambda x:x[0])

if n % 2 == 0:
    for i in range(n//2):
        l = list_Counter[i]
        if l[0] != 2*i + 1 or l[1] != 2:
            ans = -1

    if ans == -1:
        print(0)
    else:
        print((2**(n//2))%mod)
else:
    if list_Counter[0][0] == 0 and list_Counter[0][1] == 1:
        for i in range(1, n//2+1):
            l = list_Counter[i]
            if l[0] != 2*i or l[1] != 2:
                ans = -1
    else:
        ans = -1

    if ans == -1:
        print(0)
    else:
        print((2**(n//2))%mod)



Measured memory_bytes: 16096
#include <stdio.h>
int a[1000],c[1000];
int main(){
	int N,M,b,max[2],i,j;
	for(i=0;i<1000;i++){
		c[1000]=0;
	}
	scanf("%d %d",&N,&M);
	for(i=0;i<N;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<M;i++){
		scanf("%d",&b);
		for(j=0;j<N;j++){
			if(a[j]<=b){
				c[j]+=1;
				break;
			}
		}
	}
	max[0]=c[0];
	max[1]=1;
	for(i=1;i<N;i++){
		if(max[0]<c[i]){
			max[0]=c[i];
			max[1]=i+1;
		}
	}
	printf("%d\n",max[1]);
	return 0;
}

Measured memory_bytes: 604
N = int(input())
Plist = []
c = 0
for i in range(N):
    c += i
    Plist.append(list(map(int,input().split())))
import math
    
D = 0
for j in range(N):
    for k in range(N):
        if j <= k :
            continue
        D += math.sqrt((Plist[j][0]-Plist[k][0])**2 + (Plist[j][1]-Plist[k][1])**2)
print(D*(N-1)/c)

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

typedef pair <int,int> ii;

bool check(int A,int B,int C) {
  for (int x=0; x<=30; ++x) {
      int k=C-A*x;
      if (k>=0 && k%B==0) return true;
      }
  return false;
  }

int main () {
  double p,maxp=-1.0;
  int A,B,C,D,E,F,water,sugar;
  scanf("%d %d %d %d %d %d",&A,&B,&C,&D,&E,&F);
  A*=100,B*=100;
  
  ii ans(0,0);
  for (water=A; water<=F; ++water) if (water%100==0)
  for (sugar=0; sugar<=F; ++sugar) if (water+sugar<=F && sugar<=(water/100)*E)
      if (check(A/100,B/100,water/100) && check(C,D,sugar)) {
          p=100.0*sugar/(water+sugar);
          if (p>maxp) { maxp=p; ans={water+sugar,sugar}; }
          }
  printf("%d %d\n",ans.first,ans.second);
  
  return 0;
  }


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;


int main() {
    int n;
    cin >> n;
    
    vector <vector<pi>> graph(n);
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(make_pair(b, i));
        graph[b].push_back(make_pair(a, i));
    }
    
    vi ans(n-1);
    int max_color = 0;
    rep(i, n) max_color = max(max_color, (int)graph[i].size());
    queue<pair<int, int>> q;
    q.push(make_pair(0, 0));
    vi res(n-1, -1);
    while(!q.empty()){
        pi p = q.front(); q.pop();
        int ni = p.first;
        int c = p.second;
//        cout << ni << " " << c << endl;
        rep(i, graph[ni].size()){
            int nj = graph[ni][i].first;
            int idx = graph[ni][i].second;
            if (res[idx] == -1){
                c = (c+1) % max_color;
                res[idx] = c;
                q.push(make_pair(nj, c));
            }
        }
    }
    cout << max_color << endl;
    rep(i, n-1){
        cout << res[i] + 1 << endl;
    }
}


Measured memory_bytes: 7424
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
using namespace std;

bool binary_search(int key, vector<ll> &v){
  ll left = 0, right = v.size();
  while(right >= left){
    ll mid = left + (right - left) / 2;
    if (v[mid] == key) return true;
    else if (v[mid] > key) right = mid - 1;
    else left = mid + 1;
  }
  return false;
}

int main(){
  ll n, q;
  cin >> n;
  vector<ll> s(n);
  rep(i, n) cin >> s[i];
  cin >> q;
  vector<ll> t(q);
  rep(i, q) cin >> t[i];
  
  ll ans = 0;
  rep(i, q){
    if (binary_search(t[i], s))
      ans++;
  }
  cout << ans << endl;
  
  return 0;
}


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

#define ll long long
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

using namespace std;
ll power(ll a,ll n)
{
          ll result=1;
          while(n>0)
          {
               if(n&1)
                    result=result*a;
               a=a*a;
               n=n>>1;
          }
          return result;
}
ll lcm(ll a,ll b)
{
          return ((a*b)/__gcd(a,b));
}
bool ispow2(ll n)
{
          return (ceil(log2(n))==floor(log2(n)));
}
bool isprime(ll n)
{
          if(n==1)
               return false;
          else if(n==2)
               return true;
          else
          {
               for(ll i=2;i*i<=n;++i)
               {
                    if(n%i==0)
                         return false;
               }
               return true;
          }
}

ll ncr(ll n,ll r)
{
    if(r > n - r)
          r = n - r;
    ll ans = 1;
    ll i;

    for(i = 1; i <= r; i++)
     {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
void sieve(int n)
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
     prime[1]=false;
     prime[0]=false;
    for (int p=2; p*p<=n; p++)
    {
        // If prime[p] is not changed, then it is a prime
        if (prime[p] == true)
        {
            // Update all multiples of p greater than or
            // equal to the square of it
            // numbers which are multiple of p and are
            // less than p^2 are already been marked.
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }

    // Print all prime numbers
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout<<p<<" ";
}
int main()
{
          ios_base::sync_with_stdio(0);
          cin.tie(0);

          int t=1;
          //cin>>t;
          while(t--)
          {
                    ll a,b,c,d;
                    cin>>a>>b>>c>>d;
                    ll ans1 = a*c;
                    ll ans2 = b*d;
                    ll ans3 = a*d;
                    ll ans4 = b*c;
                    cout<<max({ans1,ans2,ans3,ans4});
          }
          return 0;
}


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

using namespace std;

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

    int n;
    cin>>n;
    int score1=0,score2=0;
    while(n--)
    {
        string s,s2;
        cin>>s>>s2;
        if(s>s2)
            score1+=3;
        else if(s==s2)
        {
            score1++;score2++;
        }
        else
            score2+=3;
    }
    cout<<score1<<" "<<score2<<endl;

}



Measured memory_bytes: 3176
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int ans = 0;
        for(int i = 1; i <= N && i < 10; i ++) {
            ans++;
        }
        for(int i = 100; i <= N && i < 1000; i ++) {
            ans++;
        }
        for(int i = 10000; i <= N && i < 100000; i ++) {
            ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#!/usr/bin/env python3
k = int(input())
a = []
for i in range(1, 10):
    a.append(i)
while True:
    if k <= len(a):
        print(a[k - 1])
        exit()
    k -= len(a)
    old = []
    a, old = old, a
    for x in old:
        for i in range(-1, 2):
            d = x % 10 + i
            if d < 0 or d > 9:
                continue
            nx = x * 10 + d
            a.append(nx)


Measured memory_bytes: 11028
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

bool func(Int n, Int k, vector<Int> &a, Int d){
	vector<Int> b(a), c(a);
	for(Int i=0; i<n; ++i) b[i] = a[i] % d;
	sort(b.begin(), b.end());
	for(Int i=0; i<n; ++i) c[i] = d - b[i];
	for(Int i=1; i<n; ++i) b[i] += b[i-1];
	for(Int i=n-2; i>=0; --i) c[i] += c[i+1];
//	cout << d << "\n";
//	for(Int i=0; i<n; ++i)
//		cout << b[i] << " " << c[i] << "\n";
	for(Int i=0; i<=n-2; ++i)
		if(b[i] == c[i+1] && b[i] <= k)
			return true;
	return false;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n, k; cin >> n >> k;
	vector<Int> a(n);
	for(auto &i:a) cin >> i;
	Int s = accumulate(a.begin(), a.end(), 0ll);
	for(Int i=1; i*i<=s; ++i){
		if(s % i != 0) continue;
		Int d = s / i;
		if(func(n, k, a, d)){
			cout << d << "\n";
			return 0;
		}
	}
	for(Int i=sqrt(s); i>=1; --i){
		if(s % i != 0) continue;
		if(func(n, k, a, i)){
			cout << i << "\n";
			return 0;
		}
	}
	cout << 1 << "\n";
}

Measured memory_bytes: 256
def main():
    N, M = list(map(int, input().strip().split()))
    load_counts = [0 for _ in range(N)]
    for _ in range(M):
        a, b = list(map(int, input().strip().split()))
        load_counts[a - 1] += 1
        load_counts[b - 1] += 1

    print("\n".join(map(str, load_counts)))

if __name__ == '__main__':
    main()


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

int N,M,A,B,C,D,s,g,V,P;
int cost[32][32];
int length[32][32];
const int Inf = 10000*100000+100;

int main()
{
    scanf("%d%d", &N, &M); 
    for(int i=1;i<=N;i++)
       for(int j=1;j<=N;j++)
       {
           if(i==j)
             cost[i][j]=0;
           else
             cost[i][j]=Inf;
       }
    for (int i=0; i<M; ++i) 
    {
        scanf("%d,%d,%d,%d", &A, &B, &C, &D);
        cost[A][B]=C;
        cost[B][A]=D;
    }
    for(int i=1;i<=N;i++)
       for(int j=1;j<=N;j++)
       {
           length[i][j]=cost[i][j];
       }
    for(int k=1;k<=N;k++)
       for(int i=1;i<=N;i++)
          for(int j=1;j<=N;j++)
             if(length[i][k]+length[k][j]<length[i][j])
               length[i][j]=length[i][k]+length[k][j];
    scanf("%d,%d,%d,%d", &s, &g, &V, &P);
    int reward=V-P-length[s][g]-length[g][s];
    printf("%d\n",reward);
}


Measured memory_bytes: 3232
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, std::vector<std::string> s){
    int cnt = 0;
    map<string,int> ss;
    for(int i = 0; i < n; ++i){
        chmax(cnt, ++ss[s[i]]);
    }
    for(auto& x : ss){
        if(x.second == cnt)
            cout << x.first << endl;
    }
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 26752
#include<cstdio>
#include<cstdlib>
#include<cstring>
#define maxn 100005
#define mod 1000000007
using namespace std;
typedef int Mat[5][5];
int n,m,a[maxn];
void Mulmat(Mat a,Mat s,Mat c)
{
	static int b[5][5],ans[5][5];
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++)
			b[i][j]=s[j][i];
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++)
		{
			register long long t=0;
			for(int *x=a[i]+1,*y=b[j]+1,k=1;k<=3;++x,++y,++k)
				t+=1ll**x**y%mod;
			ans[i][j]=t%mod;
		}
    memcpy(c,ans,sizeof(ans));
}
Mat res,mul;
Mat T1,T2;
void init()
{
    T1[1][1]=T1[1][2]=T1[1][3]=T1[2][2]=T1[3][3]=1,T1[2][3]=2;
    T2[1][1]=T2[1][2]=T2[1][3]=T2[2][2]=T2[3][1]=T2[3][2]=1,T2[3][3]=T2[2][3]=2;
    res[1][1]=res[2][2]=res[3][3]=1;
}
void ksm(Mat a,int b)
{
    Mat s;
    memset(s,0,sizeof(s));
    s[1][1]=s[2][2]=s[3][3]=1;
    while(b)
    {
        if(b&1) Mulmat(s,a,s);
        Mulmat(a,a,a);
        b>>=1;
    }
    memcpy(a,s,sizeof(s));
}
int main()
{
    init();
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++) scanf("%d",&a[i]);
    a[0]=-1;
    for(int i=1;i<=m;i++)
    {
        memcpy(mul,T2,sizeof(T2));
        ksm(mul,a[i]-a[i-1]-1);
        Mulmat(res,mul,res);
        Mulmat(res,T1,res);
    }
    memcpy(mul,T2,sizeof(T2));
    ksm(mul,n-a[m]-1);
    Mulmat(res,mul,res);
    printf("%d",res[1][3]);
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long int
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int N = 1e6 + 5;
const int oo = 1e9 + 5;
const LL ooll = 1e18 + 5;
 
// clock_t start = clock();

int vis[N];
void solve() {
	int k;
	cin >> k;
	for (int i=0;i<k;++i) vis[i] = 0;
	int go = 0;
	for (int i=1;;++i) {
		go = (go * 10 + 7)%k;
		if (vis[go]) break;
		if (go == 0) {
			cout << i << '\n';
			return;
		}
		vis[go] = 1;
	}
	cout << "-1\n";
}
 
int main() {
	FASTIO;
	int T = 1;
	// cin >> T;
	while(T--) {
		solve();
	}
	// cout << fixed << setprecision(10);
	// cout << (clock() - start) / ((long double)CLOCKS_PER_SEC) << '\n';
	return 0;
} 

Measured memory_bytes: 7540
#include<iostream>
#include<string>
#include<cstdio>

using namespace std;

int main(){
	int q;
	int c,a,n;
	int ans;
	int team;
	int flagc,flaga;
	cin >> q;
	while(q--){
		cin >> c >> a >> n;
		ans = 0;
		team = 0;
		flagc=flaga=0;
		while(1){
			if(team == 3){
				ans++;
				team = 0;
			}
			if(c == 0)
				break;
			c--;
			team++;
			if(a>0 && team == 1){
				a--;
				flaga=1;
				team++;
			}
			if(n>0 && flaga ==1){
				n--;
				flaga = 0;
				team++;
			}
		}
		cout <<ans <<endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
int main(){
    int n;
    cin >> n;
    n %= 100;
    n %= 10;
    switch (n)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;
    
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;
    default:
        cout << "bon" << endl;
        break;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
struct item{
    string name;
    int p,s1,s2,x,r,m;
    double y;
    item(){
        int a,b,c,d,e;
        cin>>name>>p>>a>>b>>c>>d>>e>>x>>r>>m; 
        s1=a+b+c;s2=d+e;
        y=(double)(x*r*m-p)/(s1+s2*m);
    }
};

int main(){
    int n;
    while(cin>>n,n){
        vector<item> v(n);
        sort(all(v),[](item a, item b){return a.y>b.y || (a.y==b.y && a.name<b.name);});
        for(auto p : v)cout<<p.name<<endl;
        cout<<"#"<<endl;
    }
}

Measured memory_bytes: 3152