akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int x[100000];
int y[100000];

int main(){
	int n,k;
	cin>>n;
	while(cin>>n>>k){
		REP(i,n)cin>>x[i];
		int ans = 0;
		REP(i,n-1){
			ans += (y[i] = x[i+1]-x[i]);
		}
		sort(y,y+n-1);
		//debug(y,y+n-1);
		int bnd = min(k-1,n-1);
		for(int i = 0; i < bnd; i++){
			ans -= y[n-2-i];
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
from collections import deque
N = int(input())
ab = [[] for _ in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    ab[a].append(b)
    ab[b].append(a)

sd = [-1]*(N+1)
q = deque()
q.append((1, 0))
while len(q) > 0:
    u, c = q.popleft()
    sd[u] = c
    for v in ab[u]:
        if sd[v] == -1:
            q.append((v, c+1))

ed = [-1]*(N+1)
q = deque()
q.append((N, 0))
while len(q) > 0:
    u, c = q.popleft()
    ed[u] = c
    for v in ab[u]:
        if ed[v] == -1:
            q.append((v, c+1))

sc = 0
for i in range(1, N+1):
    if sd[i] <= ed[i]:
        sc += 1
ec = N-sc
if sc > ec:
    print("Fennec")
else:
    print("Snuke")


Measured memory_bytes: 64672
import scala.io.StdIn.readLine
import Math.sqrt

object Main {

  def main(args: Array[String]) = {
      val Array(a,b) = readLine.split(" ").map(_.toInt)
      print(a/b);print(" ");print(a%b);print(" ");println("%.5f".format(a.toDouble/b))
  }
}

Measured memory_bytes: 44080
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    alpha = input()

    if alpha.upper() == alpha:
        return 'A'

    return 'a'


def main():
    print(solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m,i,b,j;
  while(cin>>n>>m,n){
    int a[2][n]={0},s=0;
  for(i=0;i<n;s+=a[0][i],i++){
    cin>>a[0][i];
    a[1][i]=0;
  }
  for(i=0;i<m;i++)for(cin>>b,j=0;j<n;j++){
      if(b==a[0][j]&&(!a[1][j])){
        a[1][j]++;
        break;
      }
      if(j==n-1)s+=b;
  }
  cout<<s<<endl;
  }
}

Measured memory_bytes: 3040
N=input()
zoro=int(N[0])*100+int(N[0])*10+int(N[0])
zoro_up=(int(N[0])+1)*100+(int(N[0])+1)*10+(int(N[0])+1)
if int(N)<=zoro:
    print(zoro)
else:
    print(zoro_up)

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

int main() {
    string s;
    cin >> s;

    int c = 0;
    if (s[0] == 'o') c++;
    if (s[1] == 'o') c++;
    if (s[2] == 'o') c++;

    cout << 700 + 100 * c << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

n, k = map(int, input().split())
a = [int(item) for item in input().split()]
total = sum(a)

div = divisors(total)
ans = 1
for d in div:
    modd = []
    for item in a:
        modd.append(item % d)
    modd.sort(reverse=True)
    plus = sum(modd)
    opr = 0
    for i, item in enumerate(modd):
        if plus == 0:
            opr += sum(modd[i:])
            break
        plus -= d
        opr += d - item 

    if opr <= k * 2:
        ans = max(ans, d)
print(ans)

Measured memory_bytes: 42092
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;

namespace Codeforces
{
	internal class Template
	{

		private long[] weight = new long[110];
		private long[] value = new long[110];

		private Dictionary<Tuple<long, long>, long> dp; 

		private void Solve()
		{
			var n = cin.NextLong();
			var w = cin.NextLong();
			for (var i = 0; i < n; i++)
			{
				weight[i] = cin.NextLong();
				value[i] = cin.NextLong();
			}
			dp = new Dictionary<Tuple<long, long>, long>();
			var res = Calc(n - 1, w);
			Console.WriteLine(res);
		}

		private long Calc(long take, long w)
		{
			if (take < 0)
			{
				return 0;
			}
			var idx = Tuple.Create(take, w);
			if (dp.ContainsKey(idx))
			{
				return dp[idx];
			}
			if (weight[take] > w)
			{
				return Calc(take - 1, w);
			}
			var res = Math.Max(Calc(take - 1, w), Calc(take - 1, w - weight[take]) + value[take]);
			dp[idx] = res;
			return res;
		}

		private static readonly Scanner cin = new Scanner();

		private static void Main()
		{
#if DEBUG
			var inputText = File.ReadAllText(@"..\..\input.txt");
			var testCases = inputText.Split(new[] { "input" }, StringSplitOptions.RemoveEmptyEntries);
			var consoleOut = Console.Out;
			for (var i = 0; i < testCases.Length; i++)
			{
				var parts = testCases[i].Split(new[] { "output" }, StringSplitOptions.RemoveEmptyEntries);
				Console.SetIn(new StringReader(parts[0].Trim()));
				var stringWriter = new StringWriter();
				Console.SetOut(stringWriter);
				var sw = Stopwatch.StartNew();
				new Template().Solve();
				sw.Stop();
				var output = stringWriter.ToString();

				Console.SetOut(consoleOut);
				var color = ConsoleColor.Green;
				var status = "Passed";
				if (parts[1].Trim() != output.Trim())
				{
					color = ConsoleColor.Red;
					status = "Failed";
				}
				Console.ForegroundColor = color;
				Console.WriteLine("Test {0} {1} in {2}ms", i + 1, status, sw.ElapsedMilliseconds);
			}
			Console.ReadLine();
			Console.ReadKey();
#else
			new Template().Solve();
			Console.ReadLine();
#endif
		}
	}

	internal class Scanner
	{
		private string[] s = new string[0];
		private int i;
		private readonly char[] cs = { ' ' };

		public string NextString()
		{
			if (i < s.Length) return s[i++];
			var line = Console.ReadLine() ?? string.Empty;
			s = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 1;
			return s.First();
		}

		public double NextDouble()
		{
			return double.Parse(NextString());
		}

		public int NextInt()
		{
			return int.Parse(NextString());
		}

		public long NextLong()
		{
			return long.Parse(NextString());
		}
	}
}

Measured memory_bytes: 23084
#include <stdio.h>
#include <string.h>
 
int main(){
    char x[2000000], y[2000000];
    int len, i, count = 0;
    scanf("%s %s", &x, &y);
    len = strlen(x);
    for (i = 0; i < len; i++){
        if (x[i] != y[i]) count++;
    }
    printf("%d", count);
    return 0;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll h, w; cin >> h >> w;

    if(h == 1 || w == 1) cout << 1 << endl;
    else{
        ll ans = (h * w + 1) / 2;
        cout << ans << endl;
    }

    return 0;
}


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

bool binarysearch(int a,int s[],int l,int r){
    int mid;
    while(l<=r){
        mid = (r+l)/2;
        if(s[mid]==a){return 1;}

        if(s[mid]<a){
            l = mid + 1;
        }else{
            r = mid - 1;
        }
    }
    return 0;
}

int main(){
    int n,q,c(0);
    cin >> n;
    int s[n];
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    cin >> q;
    int t[q];
    for(int i=0;i<q;i++){
        cin >> t[i];
        if(binarysearch(t[i],s,0,n-1)){c++;}
    }

    cout << c << endl;
    return 0;
}


Measured memory_bytes: 3588
n=int(input())

s=[]
for i in range(n):
    s.append(input())

c=[]
f=1
for i in range(len(s)):
    if i < len(s)-1:
        if s[i][-1:] != s[i+1][0]:
            print("No")
            f=0
            break
    if s[i] not in c:
        c.append(s[i])
    else:
        print("No")
        f=0
        break

if f:
    print("Yes")


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

using namespace std;

constexpr int mod = 1e9 + 7;

int main(void) {
    int N, M;
    cin >> N >> M;
    priority_queue<int> que;
    // vector<int> A(N);
    int a;
    for (int i = 0; i < N; i++) {
        cin >> a;
        que.push(a);
    }

    // for (int i : A) cout << i << " ";

    int cnt = 0;
    vector<int> wari(N, 0);
    // sort(A.begin(), A.end());
    // for(int i = 0; i < N;i++){
    //     wari[i] = (A[i]/A[i+1])/2;
    // }

    for (int i = 0; i < M; i++) {
        a = que.top();
        que.pop();
        a /= 2;
        que.push(a);
    }

    long long ans = 0;
    while (!que.empty()) {
        ans += que.top();
        que.pop();
    }

    cout << ans << endl;
}

Measured memory_bytes: 1144
def factoring(n):
    for i in range(100, 0, -1):
        if n%i == 0:
            return i
    return n

def is_sq(n):
    for i in range(1,100):
        if i**2 == n:
            return True
    return False

def make_ichimatsu(n):
    height = factoring(n)
    width = n // height
    if width%2:
        width, height = height, width
    ret = []
    for h in range(height):
        line = '#.' * (width//2)
        line = line[h%2:] + line[:h%2]
        ret.append(line)
    return (height, width, ret)

def make_oddichimatsu(w,b):
    width = height = factoring(w+b)
    ret = '.' * (w>b) + '#.' * (n-1) + '#' * (w<b)
    ret = list(map(''.join, zip(*[iter(ret)]*height)))
    return (height, width, ret)



def calc(W, B):
    if W==B and factoring(W+B)<W+B:
        return make_ichimatsu(W+B)

def main():
    W, B = list(map(int, input().split()))

    # 初期マップ生成（上半分が城，下半分が黒の100x100）
    ret = '.'*100*50 + '#'*100*50
    ret = list(map(list, zip(*[iter(ret)]*100)))

    # 白の世界に黒ドットを(指定-1)個数だけ打ち込む（2列2行ごとに1点）
    for bidx in range(B-1):
        ret[(bidx//50)*2][(bidx%50)*2] = '#'
    
    # 黒の世界に城ドットを(指定-1)個数だけ打ち込む（2列2行ごとに1点）
    for widx in range(W-1):
        ret[99-(widx//50)*2][99-(widx%50)*2] = '.'

    print('{} {}'.format(100, 100))
    for line in ret:
        print(''.join(line))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

int main() {
  ll n, a, b;
  scanf("%lld %lld %lld", &n, &a, &b);
  vll x(n);
  vll d(n-1);
  scanf("%lld", &x[0]);
  FOR (i, 1, n) {
    scanf("%lld", &x[i]);
    d[i-1] = x[i] - x[i-1];
  }
  ll ans = 0;
  rep (i, n-1) {
    ans += min(b, a * d[i]);
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
/*
数え上げpdfを読んで
A<2^t<=Bと出来ることはわかった
そうするとA~(2^t)-1までの数は全部作れる
2^t以上の数を作る時、A~(2^t)-1の力を借りる必要があるかどうかで場合分け
・借りる必要がある場合
2^t+A~(2^t)+(2^t)-1まではそれぞれ作れる（少なくとも2^tはいるため）
逆にこいつらの力を借りる以上こいつらより小さいものは作れない
・借りる必要がない場合
2^t~Bを全部orしてできる奴が最大でそこまで全部作れる
全部orしていると間に合わないけど、つまりBに立ってる2^t以外での最上位bitを見ればいいはず
*/
int pw(int n,int k){
  int res=1;
  while(k){
    if(k&1)res*=n;//res%=MOD;
    n*=n;//n%=MOD;
    k>>=1;
  }
  return res;
}
void smart(int &a,int &b){
  int k=pw(2,60);
  while(true){
    if((a&k)^(b&k))return;
    if(a-k>=0)a-=k;
    if(b-k>=0)b-=k;
    k/=2;
  }
}
int bmax(int b){
  if(b==0)return 0;
  int k=pw(2,60);
  while(true){
    if(b&k)return k;
    k/=2;
  }
  return 0;
}
int bmax2(int b){
  b^=bmax(b);
  return bmax(b);
}
//main
signed main(){
  int A,B;cin>>A>>B;
  if(A==B){cout<<1<<endl;return 0;}
  smart(A,B);
  //if(A==0){cout<<bmax(B)*2<<endl;return 0;}
  int ans=0;
  ans+=(bmax(B)-A)*2;
  ans+=max(1LL,bmax2(B)*2);
  ans-=max(0LL,max(1LL,bmax2(B)*2)-A);
  cout<<ans<<endl;
}


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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

ll combination(ll n, ll i){
	ll count = 0;
	ll multi = 1;
	ll div =1;
	int limit = i;
	while(count < limit){
		multi *= n;
		n--;
		multi/= count+1;
		count ++ ;
	}
	return multi / div;
}

int main()
{
	cout <<setprecision(10);
	int c[3][3];
	rep(i,3){
		rep(j,3){
			cin >>c[i][j];
		}
	}
	rep(i,2){
		rep(j,2){
			if(c[i][j] - c[i+1][j] != c[i][j+1] - c[i+1][j+1]){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	coY();


}


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

using namespace std;


const int mod = 1e9+7,N = 1e3+20;

int f[N][N];
char s[N][N];

bool vis[N][N];
int main()
{
	int h,w;
	cin>>h>>w;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin>>s[i][j];
			if(s[i][j]=='.')	vis[i][j]=1;
		}
	}
	f[1][1]=1;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(i==1&&j==1)	continue;
			else 
			{
				f[i][j]=(f[i-1][j]*vis[i-1][j]+f[i][j-1]*vis[i][j-1])%mod;
			}
		}
	}
	cout<<f[h][w];
	
	

	
	  
}

Measured memory_bytes: 6272
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B;
    cin>>A>>B;
    if(A>=13){
        cout<<B<<endl;
    }
    else if(6<=A & A<=12){
        cout<<B/2<<endl;
    }
    else{
        cout<<0<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPI(i,a,b) for(ll i=b-1;i>=a;i--)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define G(a,b) get<a>(b)
#define VI vector<int>
#define VLL vector<long long>
 
#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
 
ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[],ll b[],ll n);
ll logint(ll x,ll y);
 
 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}
 
ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}
 
void pairsort(int a[],int b[],int n)
{
    pair<int,int> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}
 
void pairsortll(ll a[],ll b[],ll n)
{
    pair<ll,ll> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}
 
ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<=x;i++)
    {
        if(x<a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
 
    ll q=1;
    //cin>>q;
    while(q--)
    {
        ll n;
        cin>>n;
        double p[n];
        double dp[n+1];
        dp[0]=1;
        REP(i,1,n+1) dp[i]=0;
        REP(i,0,n)
        {
            double t;
            cin>>t;
            p[i]=t;
            REPI(j,1,n+1)
            {
                dp[j]=dp[j]*(1-t)+dp[j-1]*t;
            }
            dp[0]=dp[0]*(1-t);
        }
        double ans=0;
        REP(i,n/2+1,n+1)
        {
            ans+=dp[i];
        }
        printf("%.20f",ans);
    }
 
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
int n;
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>s;
    s=s.c_str();
    int bl=0;
    for(int i=0;i<n;i++){
        if(s[i]=='#'){
            bl++;
        }
    }
    int wh=n-bl;
    int bln=0;
    int whn=n-bl;
    int ans=max(bln,whn);
    for(int i=0;i<n;i++){
        if(s[i]=='.'){
            whn--;
        }
        else{
            bln++;
        }
        ans=min(ans,whn+bln);
    }
    cout <<ans<< "\n";
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define re register
#define SIZE 100005
using namespace std;
int n,m;
int In[SIZE];
queue<int> q;
int sum[SIZE];
int ans=0;
int head[SIZE];
int tot=0;
struct Edge
{
	int Next,ver;
}p[SIZE];
inline void add(int f,int s)
{
	++tot;
	p[tot].ver=s;
	p[tot].Next=head[f];
	head[f]=tot;	
}
inline void TP()
{
	while(!q.empty())
	{
		int Q=q.front();
		q.pop();
		for(int i=head[Q];i!=0;i=p[i].Next)
		{
			int a=p[i].ver;
			sum[a]=max(sum[a],sum[Q]+1);
			ans=max(ans,sum[a]);
			In[a]--;
			if(In[a]==0)
				q.push(a);
		}
	}
}
int main()
{
	cin>>n>>m;
	for(re int i=1;i<=m;++i)
	{
		int x,y;
		cin>>x>>y;
		add(x,y);
		++In[y];
	}
	for(re int i=1;i<=n;++i)
		if(In[i]==0)
			q.push(i);
	TP();
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 2432
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.Char

f x y [] = [x, y]
f x y ([s,t] : ss)
  | s < t = f x (y+3) ss
  | s > t = f (x+3) y ss
  | otherwise = f (x+1) (y+1) ss

main = readLn >>= flip replicateM (words <$> getLine) >>= putStrLn . unwords . map show . f 0 0
    

Measured memory_bytes: 4396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
int main () {
  int n;
  cin >> n;
  
  vector<unsigned long> a(n);
  rep(i, n) cin >> a[i];

  unsigned long lim = pow(10, 18);
  unsigned long ans = 1;
  
  rep(i, n) {
    // check multiple 0
    if (a[i] == 0) {
      cout << 0;
      return 0;
    }
  }

  unsigned long pre_ans = 1;
  rep(i, n) {
    // check overflow
    if (pre_ans > lim / a[i]) {
      cout << -1;
      return 0;
    }
    ans *= a[i];
    pre_ans = ans;
  }
  cout << ans;
}

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

using namespace std;

int main()
{

   int sum[10005] = {0};

   for (int i=0;i<10005;i++)
   {
       int temp = i;

       sum[i] = temp%10;
       temp = (temp-temp%10)/10;
       sum[i] = sum[i] + temp%10;
       temp = (temp-temp%10)/10;
       sum[i] = sum[i] + temp%10;
       temp = (temp-temp%10)/10;
       sum[i] = sum[i] + temp%10;
       temp = (temp-temp%10)/10;
       sum[i] = sum[i] + temp%10;
       temp = (temp-temp%10)/10;
       sum[i] = sum[i] + temp%10;
       temp = (temp-temp%10)/10;

    }

    int N,A,B;

    cin >> N >> A >> B;

    long long int tot = 0;

    for (int i=1;i<=N;i++)
    {
        if (sum[i]>=A && sum[i]<=B)
        {
            tot = tot + i;
        }
    }

    cout << tot << "\n";



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
bool comp(int a,int b){
return a>b;
}
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main()
{
	fast;
	ll N,D;
	cin>>N>>D;
	int cnt=0;
	while(N--)
	{
		ll a,b;
		cin>>a>>b;
		ll res=a*a+b*b;
		res=ceil(sqrt(res));
	//	cout<<res<<endl;
		if(res<=D)
		cnt++;
		
	}
	cout<<cnt;


}



Measured memory_bytes: 3708
from sys import stdin

def main():
    cnt = [0] * 4
    n = int(input())
    for i in range(n):
        res = input()
        if res == "AC":
            cnt[0] += 1
        elif res == "WA":
            cnt[1] += 1
        elif res == "TLE":
            cnt[2] += 1
        elif res == "RE":
            cnt[3] += 1
    print("AC x "+str(cnt[0]))
    print("WA x "+str(cnt[1]))
    print("TLE x "+str(cnt[2]))
    print("RE x "+str(cnt[3]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 9156
#!/usr/bin/env python3
As = [list(map(int, input().split())) for i in range(3)]
N = int(input())
x = []
bingo = [[False]*3 for i in range(3)]
for i in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if As[i][j] == b:
                bingo[i][j] = True

ans = True
for i in range(3):
    if bingo[i][0] and bingo[i][1] and bingo[i][2] : 
        print("Yes")
        exit()
for j in range(3):
    if bingo[0][j] and bingo[1][j] and bingo[2][j]:
        print("Yes")
        exit()
if bingo[0][0] and bingo[1][1] and bingo[2][2]:
    print("Yes" )
    exit()
if bingo[0][2] and bingo[1][1] and bingo[2][0]:
    print("Yes")
    exit()
print("No")


Measured memory_bytes: 3064
from scipy.sparse.csgraph import dijkstra
import numpy as np 

N,X,Y = map(int,input().split())

edge = tuple([0]*N for i in range(N))

for i in range(N-1):
    edge[i][i+1] = 1
    edge[i+1][i] = 1

edge[X-1][Y-1] = 1
edge[Y-1][X-1] = 1

ans = np.array(dijkstra(edge),dtype="int32")
cnt = [0]*N
for i in range(N):
    for j in ans[i]:
        cnt[j] += 1

for i in range(1,N):
    print(cnt[i]//2)

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

int main() {
  string s;cin>>s;
  string ans="Yes";
  for(int i=0;i<s.size();i++){
    char c=s[i];
  	if((c=='R'*(i&1))+(c=='L'*!(i&1))){
      ans = "No";break;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int N_MAX = 50;
int main (void) {
    int N;
    int M;

    cin >> N >> M;

    int road[N][N];

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            road[i][j] = 0;
        }
    }

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        road[a][b]++;
        road[b][a]++;
    }

    for (int i = 0; i < N; i++) {
        int ans = 0;
        for (int j = 0; j < N; j++) ans += road[i][j];
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;

int main()
{
    int n;
    ll d;
    cin >> n >> d;
    ll a[200005];
    priority_queue<P, vector<P>, greater<P>> que;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        que.push(P(a[i], i));
    }
    bool used[200005]{0};
    ll ans = 0;
    while(que.size()){
        P p = que.top();
        que.pop();
        int u = p.second;
        if(u > 0 && !used[u]){
            ans += d + a[u] + a[u - 1];
            if(d + a[u] < a[u - 1]){
                a[u - 1] = d + a[u];
                que.push(P(a[u - 1], u - 1));
            }
            used[u] = true;
        }
        if(u < n - 1 && !used[u + 1]){
            ans += d + a[u] + a[u + 1];
            if(d + a[u] < a[u + 1]){
                a[u + 1] = d + a[u];
                que.push(P(a[u + 1], u + 1));
            }
            used[u + 1] = true;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 7408
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()

    c = collections.Counter(a)

    ans = True
    odd = n % 2

    if odd:
        if 0 in c.keys():
            c[0] += n % 2
    for i in range(0 + odd ^ 1, n, 2):
        if i not in c.keys():
            ans = False
            break
        if c[i] != 2:
            ans = False
            break

    if ans:
        print(2 ** (n // 2) % MOD)
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24428
# C - Colorful Leaderboard
N = int(input())
a = list(map(int, input().split()))
DP = [0]*8
tmp = 0

for i in range(N):
    if 1 <= a[i] <= 399:
        DP[0] = 1
    elif 400 <= a[i] <= 799:
        DP[1] = 1
    elif 800 <= a[i] <= 1199:
        DP[2] = 1
    elif 1200 <= a[i] <= 1599:
        DP[3] = 1
    elif 1600 <= a[i] <= 1999:
        DP[4] = 1
    elif 2000 <= a[i] <= 2399:
        DP[5] = 1
    elif 2400 <= a[i] <= 2799:
        DP[6] = 1
    elif 2800 <= a[i] <= 3199:
        DP[7] = 1
    else:
        tmp += 1

ans1 = sum(DP)

if ans1 == 0:
    ans1 = 1 
else:
    pass

ans2 = sum(DP)+tmp
print(ans1,ans2)

Measured memory_bytes: 3064
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4 5
4 2
5 2
2 1
8 3

output:
13
"""

import sys
from collections import namedtuple


def solve():
    for i, item in enumerate(item_list, 1):
        for cp in range(1, real_cp + 1):
            # capacity allows putting in, calculate value
            if item.w <= cp:
                values[i][cp] = max(values[i - 1][cp], values[i - 1][cp - item.w] + item.v)
            # can't put in, skip current item
            else:
                values[i][cp] = values[i - 1][cp]

    return values[c_items][real_cp]


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    c_items, real_cp = map(int, _input[0].split())
    items = map(lambda x: x.split(), _input[1:])

    Item = namedtuple('Item', ('v', 'w'))
    item_list = [Item(int(v), int(w)) for v, w in items]

    values = [[0] * (real_cp + 1) for _ in range(c_items + 1)]
    ans = solve()
    print(ans)

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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

string n;

main() {
    cin >> n;
    if(n[0] == n[2]) ct("Yes")
    else ct("No")
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,r,sorce;
	cin >>n>>r;
	if(n<10){
		sorce=r+(100*(10-n));
		
	}
	else sorce=r;
	printf("%d",sorce);
	return 0;
	
 } 

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
#include <ios>
#include <iomanip>
using namespace std;

#define rep(i,N) for(int i=0; i<N; i++)
#define revrep(i,N) for(int i=N-1; i>=0; i--)
#define coutline cout<<"------------ ("<<__LINE__<<")"<<endl;

typedef long long ll;

int main(void)
{
    int N;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    rep(i,N)
    {
        cin >> V.at(i);
    }
    rep(i,N)
    {
        cin >> C.at(i);
    }

    int ret = 0;
    rep(i,N) {
        if (V.at(i) - C.at(i) > 0) ret += V.at(i) - C.at(i);
    }


    cout << ret << endl;

    return 0;
}


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

int main(void){
    int h, w;
    cin >> h >> w;
    
    while(h != 0 || w != 0){
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
}


Measured memory_bytes: 3088
//written by libra9z
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <cmath>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for (int i=0;i<(n);i++)
#define repit(it,a) for (__typeof(a.begin()) it=a.begin();it!=a.end();++it)
#define RET(p,x) return p<<x<<endl,0
#define all(a) (a).begin(),(a).end()
#define reunique(v) v.erase(unique(all(v)),v.end())
#define sz(a) (int)a.size()
#define sqr(x) ((x)*(x))
const int inf=1e9;
const ll lnf=1e18;
const int mod=1e9+7;
int a,b,c,x,y;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie();cout.tie();
	cout<<setprecision(15);
	cin>>a>>b>>c>>x>>y;
	int z=min(x,y);
	c=min(2*c,a+b);
	ll ans=0;
	ans+=c*z;
	x-=z,y-=z;
	ans+=min(c,a)*x+min(c,b)*y;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
def main

  n = gets().chomp.to_i
  r = /[a-z]/
  colors = []

  gets().split("").each {|v| colors << v if r.match(v)}
  return if (n < 1 && 100000 < n) || n != colors.length()

  colors.each_with_index.reverse_each do |slime, index|

    next if colors.length == index
    colors.delete_at(index) if slime == colors[index +1]
  end

  p colors.size

end

main

Measured memory_bytes: 20456
#include <queue>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MP make_pair
#define ll long long
#define fi first
#define se second
using namespace std;

template <typename T>
void read(T &x) {
    x = 0; bool f = 0;
    char c = getchar();
    for (;!isdigit(c);c=getchar()) if (c=='-') f=1;
    for (;isdigit(c);c=getchar()) x=x*10+(c^48);
    if (f) x=-x;
}

template<typename F>
inline void write(F x, char ed = '\n') {
	static short st[30];short tp=0;
	if(x<0) putchar('-'),x=-x;
	do st[++tp]=x%10,x/=10; while(x);
	while(tp) putchar('0'|st[tp--]);
	putchar(ed);
}

template <typename T>
inline void Mx(T &x, T y) { x < y && (x = y, 0); }

template <typename T>
inline void Mn(T &x, T y) { x > y && (x = y); }

const int N = 50500;
int vis[N], cnt, n, s, t;
int h[N], ne[N<<1], to[N<<1], w[N<<1]; ll dis[N], d[N<<1], tot = 1;
inline void add(int x, int y, int z, ll t) {
	ne[++tot] = h[x], to[h[x] = tot] = y, w[tot] = z, d[tot] = t;
}
inline void adde(int x, int y, int z, ll t) { add(x, y, z, t), add(y, x, 0, -t); }
const int inf = 0x3f3f3f3f;
queue<int> q;
bool spfa(void) {
	memset(dis, -0x3f, cnt * 8 + 30);
	memset(vis, 0, cnt * 4 + 30);
	q.push(s), dis[s] = 0;
	while (q.size()) {
		int x = q.front(); q.pop(); vis[x] = 0;
		for (int i = h[x]; i; i = ne[i]) {
			int y = to[i]; if (!w[i] || dis[y] >= dis[x] + d[i]) continue;
			dis[y] = dis[x] + d[i]; if (!vis[y]) vis[y] = 1, q.push(y);
		}
	}
	return dis[t] > -1e15;
}

int dfs(int x, int lim) {
	if (x == t || !lim) return lim;
	int res = 0, fl; vis[x] = 1;
	for (int i = h[x]; i; i = ne[i]) {
		int y = to[i]; if (vis[y]) continue;
		if (!w[i] || dis[y] != dis[x] + d[i]) continue;
		fl = dfs(y, min(w[i], lim));
		w[i] -= fl, w[i^1] += fl;
		res += fl, lim -= fl;
		if (!lim) return res;
	}
	return res;
}

int main() {
	read(n); cnt = 2 * n, s = ++cnt, t = ++cnt;
	int t1 = ++cnt, t2 = ++cnt, t3 = ++cnt, t4 = ++cnt;
	for (int i = 1, x, y, z;i <= n; i++) {
		read(x), read(y), read(z);
		adde(s, i, z, 0);
		adde(i, t1, inf, x + y);
		adde(i, t2, inf, x - y);
		adde(i, t3, inf, -x + y);
		adde(i, t4, inf, -x - y);
	}
	for (int i = 1, x, y, z; i <= n; i++) {
		read(x), read(y), read(z);
		adde(i + n, t, z, 0);
		adde(t1, i + n, inf, -x - y);
		adde(t2, i + n, inf, -x + y);
		adde(t3, i + n, inf, x - y);
		adde(t4, i + n, inf, x + y);
	}
	ll ans = 0;
	while (spfa()) 
		ans += dis[t] * dfs(s, inf);
	write(ans);
	return 0;
}

Measured memory_bytes: 4124
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string a;
	long long s,f=1;
	cin>>a>>s;
	if(a.length()==1) cout<<a[0]<<endl;
	else{
		for(long long i=0;i<s;i++)
			if(a[i]!='1'){
				cout<<a[i]<<endl;
				f=0;
				break;
			}
		if(f) cout<<"1"<<endl;
	}
}

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

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

    std::vector<int> x_list(n), y_list(m);
    for (int i = 0; i < n; ++i)
    {
        int tmp;
        std::cin >> tmp;
        x_list[i] = tmp;
    }
    for (int i = 0; i < m; ++i)
    {
        int tmp;
        std::cin >> tmp;
        y_list[i] = tmp;
    }

    int64_t sum_x = 0;
    for (int64_t i = 1; i <= n; ++i)
    {
        sum_x += (i - 1) * x_list[i - 1] - (n - i) * x_list[i - 1];
    }
    int64_t sum_y = 0;
    for (int64_t i = 1; i <= m; ++i)
    {
        sum_y += (i - 1) * y_list[i - 1] - (m - i) * y_list[i - 1];
    }

    constexpr int32_t MOD = 1000000007;

    sum_x %= MOD;
    sum_y %= MOD;

    const int64_t result = (sum_x * sum_y) % MOD;
    std::cout << result << std::endl;

    return 0;
}


Measured memory_bytes: 4044
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

ll lcm(ll a,ll b){
	return a * b / gcd(a,b);
}





signed main(){
	string s;
	ll n,ans = 0;
	cin >> n >> s;

	rep(i,0,s.size()-1){
		if(s[i] != s[i+1]) ans++;
	}


	cout << ++ans << endl;
    return 0;
}

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

/*
  let's try computer shogi!!!
 */

int main(){
  long long int N;
  cin >> N;
  vector<long long int> A;
  A.resize(N);
  for(long long int i=0;i<N;++i){
    long long int b;
    cin >> b;
    A[i] = b;
  }

  sort(A.begin(),A.end());
  long long int v=0;
  long long int out = 0;
  long long int cnt=0;
  for(long long int i=0;i<N;++i){
    cerr<<A[i]<<endl;
    if(A[i] != v || i==N-1){
      if(i==N-1){
	cnt+=1;
	v = A[i];
      }
      cerr<<cnt<<","<<v<<","<<out<<endl;
      out += (cnt >= v ? cnt - v : cnt);
      cnt = 1;
      v = A[i];
    
    }else{
      cnt+=1;
    }
  }
  cout<<out<<endl;
  return 0;
  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <typename T> lint gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> lint lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b) a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b) a=b;}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    vec[i] = a;
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (vec[vec[i]-1] == i + 1) {
      ++cnt;
    }
  }
  cout << cnt / 2 << '\n';
}


Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

#define MAX (ll(1e6)+7)
#define MOD (ll(1e9)+7)
#define INF (ll(1e18)+7)

#define elif else if
#define def inline auto

#define for_in(a,b,c) for(ll a=(b);a<(c);++a)
#define repeat(a,b) for(ll a=0;a<(b);++a)
#define repeat_down(a,b) for(ll a=(b);a>=0;--a)

#define array_size(a) ll(sizeof(a)/sizeof(a[0]))

#define def_input(...) ll __VA_ARGS__;input(__VA_ARGS__)
#define if_print(a,b,c) output(a?#b:#c)
#define print(a) output(#a)
#define fout(a) cout<<fixed<<setprecision(10)<<a
#define fillout(a,b,c) cout<<setfill(a)<<setw(b)<<right<<c
#define ios_boost cin.tie(0);ios::sync_with_stdio(false)

#define digit(a) to_string(a).length()
#define lcm(a,b) a*b/gcd(a,b)

char N='\n',S=' ';
const ll primes[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
ll temp_index;

inline void input(){}
template<class T,class...A>inline void input(T&&t,A&&...a){cin>>t;input(move(a)...);}
template<class T>inline void output(T&t){cout<<t<<N;}
template<class T,class...A>inline void output(T t,A...a){cout<<t<<S;output(move(a)...);}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>const&v)
{bool d=0;for(T x:v){if(d)o<<S<<x;else{o<<x,d=1;}}o<<N;return o;}

def get_ll(){ll x;input(x);return x;}
def gcd(ll a,ll b){ll c;while(a){c=a;a=b%a;b=c;}return b;}

inline bool is_prime(ll a){
    if(a<48){for_in(i,0,15)if(primes[i]==a)return 1;}
    elif(a<2809)return gcd(614889782588491410,a)==1;
    else {print(Error:Argument>2808);exit(1);}return 0;
}

template<class T>def sum_array(T&a,T&b){
    b[0]=a[0];
    for_in(i,1,array_size(a))b[i]=a[i]+b[i-1];
}

map<string,ll>LIST;
map<ll,string>VLIST;

def val(string a){
    auto IT=LIST.find(a);
    if(IT!=LIST.end()){
        return LIST[a];
    }
    else{
        ll v=LIST.size();
        LIST[a]=v;
        VLIST[v]=a;
        return v;
    }
}

ll a,b,c,d;ll p[201];
int main(){
    ios_boost;
    def_input(n);
    p[3*5*7]=1;
    p[3*5*11]=1;
    p[3*5*13]=1;
    p[3*3*3*5]=1;
    p[3*3*3*7]=1;
    repeat(i,n+1)if(p[i])a++;
    cout<<a<<"\n";
}

//for compilation: g++ -o _ _.cpp -std=c++14 (or 17)
//
//for fastening: g++ -O2 -o _ _.cpp -std=c++14 (or 17)
//for fastening: g++ -O3 -mtune=native -march=native -o _ _.cpp -std=c++14 (or 17)


Measured memory_bytes: 256
import javax.swing.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args)throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String[] s=br.readLine().split(" ");

        int n1=Integer.parseInt(s[0]);
        int n2=Integer.parseInt(s[1]);
        int n3=Integer.parseInt(s[2]);
        int max=Integer.parseInt(s[3]);
        algo(n1,n2,n3,max);
    }

    public static void algo(int n1,int n2,int n3,int max)
    {
        int sum=0;
        if(n1>=max)
        {
            System.out.println(max);
            return;
        }
        max=max-n1;
        sum+=n1;
        if(n2>=max)
        {
            System.out.println(sum);
            return;
        }
        max-=n2;
        sum-=max;
        System.out.println(sum);
    }


}


Measured memory_bytes: 32684
#include<stdio.h>
int main(void) {
	int N, T;
	int c[1000];
	int t[1000];
	int k;
	int c0 = 1000000;
	int answer;
	scanf("%d%d", &N, &T);

	for (k = 1; k <= N; k++) {
		scanf("%d%d", &c[k], &t[k]);
		if (t[k] <= T) {
			if (c[k] < c0) {
				c0 = c[k];
				answer = c0;
			}
		}
     
	}
  if(answer == 0){
    printf("TLE");
  }
  else{
	printf("%d", answer);
  }
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
 
class Main{
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] Args) throws IOException{
        final int n = Integer.parseInt(br.readLine());
        for(int i = 1; i<=n; i++){
            int x = i;
            if(x%3==0){
                out.print(" "+i);
                continue;
            }
            do{
                if(x%10==3){
                    out.print(" "+i);
                    break;
                }
                x /= 10;
            }while(x!=0);
        }
        out.println();
        out.flush();
    }
}

Measured memory_bytes: 25820
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int m,d;
    cin>>m>>d;
    int count=0;
    for (int i=1;i<=m;i++) {
        for (int j=1;j<=d;j++) {
            if (j/10>=2&&j%10>=2) {
                if ((j/10)*(j%10)==i) {
                    //cout<<i<<" "<<j<<endl;
                    count++;
                }
            }
        }
    }
    cout<<count<<endl;
}

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

long long int dfs(long long int pos,int n,int k){
  if(n==1) return pos;
  long long lb=0,ub=1e18+1;
  while(ub-lb>1){
    long long int mid=(ub+lb)/2;
    if(pos>=mid-(mid/k+1)){
      lb=mid;
    }
    else{
      ub=mid;
    }
  }
  if(lb%k!=0){
    return dfs(lb,n-1,k);
  }
  else{
    if(pos==lb+1-((lb+1)/k+1)){
      return dfs(lb+1,n-1,k);
    }
    else{
      //      assert(pos==lb-1-((lb-1)/k+1));
      return dfs(lb-1,n-1,k);
    }
  }
  assert(false);
}
int main(){
  int n;
  int k;
  cin>>n>>k;
  cout<<dfs(0,n,k)<<endl;
  return 0;
}

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

#define MX_N 100000
#define MX   1000000000

int n, w;
long long res;
int tab[MX_N+5][2];
long long dp[MX_N+5];

int main( )
{
    cin>>n>>w;
    for( int i=0; i<n; i++ )
        cin>>tab[i][0]>>tab[i][1];

    for( int i=0; i<n; i++ )
    {
        for( int j=w; j>=0; j-- )
        {
            if( j-tab[i][0]>=0 ) dp[j]=max( dp[j], dp[j-tab[i][0]]+tab[i][1] );
        }
    }
    for( int i=0; i<=w; i++ )
        res=max( res, dp[i] );
    cout<<res<<"\n";

}


Measured memory_bytes: 1024
n=int(input())
*a,=map(int,input().split())
*b,=map(int,input().split())

l=sorted([j-i for i,j in zip(a,b)])[::-1]
t=0
ans=0

if sum(l)>0:
  print(-1)
else:
  for i in l:
    if i>0:
      t+=i
      ans+=1
    else:break

  for i in l[::-1]:
    if t+i>=0 and i<0:
      t=t+i
      ans+=1
    elif t:
      t=0
      ans+=1
    else:
      break

  print(ans)

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

const int INF = 100100100;

int main(){
	int n, x, y;
  	cin >> n >> x >> y;
  	x--; y--;
  	
  	vector<int> ans(n);
  
  	//bfs
  	rep(sv, n){
    	vector<int> dist(n, INF);
      	queue<int> q;
      	
      	auto push = [&](int v, int d){
        	if(dist[v] != INF) return;
            dist[v] = d;
            q.push(v);
        };
               
        push(sv, 0);
        while(!q.empty()){
        	int v = q.front();
          	q.pop();
          
          	int d = dist[v];
          	if(v - 1 >= 0) push(v - 1, d + 1);
          	if(v + 1 < n) push(v + 1, d + 1);
          	if(v == x) push(y, d + 1);
          	if(v == y) push(x, d + 1);
        }
               
        rep(i, n) ans[dist[i]]++;
    }
  	
  	//同じ組も数えているので半分に
    rep(i, n) ans[i] /= 2;
         
	for(int i = 1; i < n; i++){
    	cout << ans[i] << endl;
    }
}

Measured memory_bytes: 384
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt(), i=1;
		int[] r = new int[51];
		while (M-->0) {
			r[sc.nextInt()]++; r[sc.nextInt()]++;
		}
		while (i<=N) System.out.println(r[i++]);
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int n_t, n_a;
    n_t = c / b;
    if(c % b) n_t++;

    n_a = a / d;
    if(a % d) n_a++;

    if(n_t <= n_a) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 3624
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<string> S(N);
  for(int i=0;i<N;++i) {
    cin>>S[i];
  }
  queue<pair<int, int> > que;
  que.push(mp(0, 0));
  pair<int, int> state;
  int node, parity;
  map<int, int> amap;
  for(int i=0;i<N;++i) amap[i] = -1;
  bool can = true;
  while(!que.empty()) {
    state = que.front();que.pop();
    node = state.fi;
    parity = state.se;
    if(amap[node]>-1) {
      if(amap[node]!=parity) can = false;
      continue;
    }
    amap[node] = parity;
    for(int j=0;j<N;++j) {
      if(S[node][j]=='1') {
        if(amap[j]==-1) que.push(mp(j, (parity^1)));
        else {
          if(amap[j]!=(parity^1)) can = false;
        }
      }
    }
  }
  if(!can) {
    cout<<-1<<endl;
    return 0;
  }
  int dist[N][N];
  for(int i=0;i<N;++i) {
    for(int j=0;j<N;++j) {
      if(i==j) dist[i][j] = 0;
      else if(S[i][j]=='1'){
        dist[i][j] = 1;
      }
      else dist[i][j] = inf;
    }
  }
  for(int k=0;k<N;++k) {
    for(int i=0;i<N;++i) {
      for(int j=0;j<N;++j) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int ans = 0;
  for(int i=0;i<N;++i) {
    for(int j=0;j<N;++j) {
      ans = max(ans, dist[i][j]);
    }
  }
  cout<<ans+1<<endl;
}


Measured memory_bytes: 3836