akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int N;
  cin>>N;
  LL a[N];
  REP(i, N) cin>>a[i];

  LL sum=0;
  LL ans1=0, ans2=0;
  REP(i, N){
    //cout<<sum<<" "<<ans1<<endl;
    if(i%2==0){
      if(sum +a[i]>0){
        sum +=a[i];
        continue;
      }
      else {
        ans1 += 1-(sum+a[i]);
        sum=1;
      }
    }
    else {
      if(sum+a[i]<0){
        sum +=a[i];
        continue;
      }
      else{
        ans1 += 1+(sum+a[i]);
        sum=-1;
      }
    }
  }

  sum=0;
  REP(i, N){
    //cout<<sum<<" "<<ans2<<endl;
    if(i%2==1){
      if(sum +a[i]>0){
        sum +=a[i];
        continue;
      }
      else {
        ans2 += 1-(sum+a[i]);
        sum=1;
      }
    }
    else {
      if(sum+a[i]<0){
        sum +=a[i];
        continue;
      }
      else{
        ans2 += 1+(sum+a[i]);
        sum=-1;
      }
    }
  }
  cout<<min(ans1, ans2)<<endl;

  return 0;
}


Measured memory_bytes: 1024
require 'prime'

$primes = []

def main
  $primes = Prime.first 80000
  while num = gets
    num = num.chomp.to_i
    puts solve(num).to_s
  end
end

def solve num
  nn = $primes.bsearch { |x| x > num}
  $primes.index nn
end

main

Measured memory_bytes: 6960
#include<iostream>
using namespace std;
int main(){
  int m,f,r;
  cin >> m >> f >> r;
  while(m!=-1||f!=-1||r!=-1){
    if(m==-1||f==-1) cout << "F" << endl;
    else if(m+f>=80) cout << "A" << endl;
    else if(m+f>=65) cout << "B" << endl;
    else if(m+f>=50) cout << "C" << endl;
    else if(m+f>=30)
      if(r>=50) cout << "C" << endl;
      else cout << "D" << endl;
    else cout << "F" << endl;

    cin >> m >> f >> r;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int sdkys(int a,int b){
    if(b==0) return a;
    return sdkys(b,a%b);
}
int sskbs(int a,int b){
    return a*b/sdkys(a,b);
}
int sosu(int a){
    if(a==2){
        return 1;
    }
    for(int i=2;i<sqrt(a)+1;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}
vector<int> v;
int n,m,cnt=0,ans=0,aa[220000];
pair<int,int> pp[220000];
string s,ss[220000];
char ch;
double d[220000];
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>aa[i];
    }
    rep(i,n){
        rep(j,i){
            rep(k,j){
                if(max({aa[i],aa[j],aa[k]})<aa[i]+aa[j]+aa[k]-max({aa[i],aa[j],aa[k]})&&aa[i]!=aa[j]&&aa[j]!=aa[k]&&aa[i]!=aa[k]){
                    cnt++;
                }
            }
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 10636
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 998244353;

string str;

ll dp[4010][4010];
ll sum[4010];
ll sum2[4010];

int main() {
    cin >> str;
    ll n = str.size();
    rep(i,n) {
        if (str[i] == '0') sum[i] = 2;
        else if (str[i] == '1') sum[i] = 1;
    }
    for (int i = 1; i < 2*n; i++) sum[i] += sum[i-1];
    rep(i,n) {
        if (str[i] == '2') sum2[i] = 2;
        else if (str[i] == '1') sum2[i] = 1;
    }
    for (int i = 1; i < 2*n; i++) sum2[i] += sum2[i-1];
    dp[0][0] = 1;
    rep(i,2*n) {
        rep(j,2*n+1) {
            if (sum[i] > j) {
                dp[i+1][j+1] = (dp[i+1][j+1]+dp[i][j])%MOD;
            }
            if (sum2[i] > i-j) {
                dp[i+1][j] = (dp[i+1][j]+dp[i][j])%MOD;
            }
        }
    }
    cout << dp[2*n][sum[2*n-1]] << endl;
}



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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    string s;cin >>s;
    ll n=s.size();
    vector<vector<ll>>dp(n+1,vector<ll>(13,0));
    dp[0][0]=1;
    for (int i = 0; i < n; ++i) {
        if(s[i]=='?'){
            for (int j = 0; j < 13; ++j) {
                for (int k = 0; k < 10; ++k) {
                    ll f=((j*10)%13+k)%13;
                    dp[i+1][f]+=dp[i][j];
                    dp[i+1][f]%=mod;
                }
            }
        }
        else {
            ll now=s[i]-'0';
            for (int j = 0; j < 13; ++j) {
                ll k=((j*10)%13+now)%13;
                dp[i+1][k]+=dp[i][j];
                dp[i+1][k]%=mod;
            }
        }
    }
    cout <<dp[n][5]<<endl;
    return 0;
}


Measured memory_bytes: 16704
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    c = collections.Counter(a)
    box = []
    for i in c:
        if c[i] >= 2:
            for _ in range(c[i]//2):
                box.append(i)
    if len(box) < 2:
        print(0)
    else:
        box.sort(reverse=True)
        print(box[0]*box[1])
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 23164
#include <algorithm>
#include <iostream>
#include <string>


int main() {
    std::string s, t;

    std::cin >> s >> t;

    if (s.compare(t) == 0) {
       std::cout << "Yes" << std::endl;
       return 0;
    }

    std::string answer = "No";
    const int length = s.length();
    for (int i = 0; i < length; ++i) {
        std::string temp = s.substr(length - 1, 1);
        s.pop_back();
        s = temp + s;
        if (s.compare(t) == 0) {
            answer = "Yes";
            break;
        }
    }
    
    std::cout << answer << std::endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    ac, wa, tle, re = 0, 0, 0, 0
    n = int(input())
    for _ in range(n):
        S = input()
        if S == "AC":
            ac += 1
        elif S == "WA":
            wa += 1
        elif S == "TLE":
            tle += 1
        elif S == "RE":
            re += 1
    print("AC", "x", ac)
    print("WA", "x", wa)
    print("TLE", "x", tle)
    print("RE", "x", re)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9208
import java.util.Scanner;

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

		int a[] = new int[1000];

		int n, m;
		n = sc.nextInt();
		m = sc.nextInt();

		while (n + m > 0) {
			int best = -1;
			int i;
			int j;

			for (i = 0;i < n;i++) {
				a[i] = sc.nextInt();
			}

			for (i = 0;i < n;++i) {
				for (j = i + 1;j < n;++j) {
					if (a[i] + a[j] <= m && best < a[i] + a[j]) {
						best = a[i] + a[j];
					}
				}
			}

			if (best == -1) {
				System.out.println("NONE");
			} else {
				System.out.println(best);
			}

			n = sc.nextInt();
			m = sc.nextInt();
		}
	}
}



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


/*高速化*/
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


/* define */
#define ALL(V) (V).begine(),(V).end()
#define SORT(V) sort(ALL(V))
#define REV(V) reverse(ALL(V))
#define RSORT(V) SORT(V);REV(V)
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i = 0;i < (int)(n);++i)
#define Rep(i,n) for(int i = 1;i <= (int)(n);++i)
#define REP(i,n,m) for(int i = (int)(n);i < (int)(m);++i)
#define Mod(n) n % 1000000007


/* 最大値と最小値に置き換える */
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;}


/* 型定義 */
typedef vector<long long> vi;
typedef long long ll;
using Graph = vector<vi>;


/* 定数 */
const double PI = 3.141592;
const double e = 2.6;
const long long Inf = 1LL << 60;
const long long mInf = -Inf;

vector<vector<int> > calcNext(const string &S) {
    int n = (int)S.size();
    vector<vector<int> > res(n+1, vector<int>(9, n));
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j < 9; ++j) res[i][j] = res[i+1][j];
        res[i][S[i]-'a'] = i;
    }
    return res;
}

void calc()
{
    int N,D;
    cin >> N >> D;
    vector<vi> V(N,vi(D));
    int x;
    rep(i,N)
    {
        rep(j,D)
        {
            cin >> x;
            V[i][j] = x;
        }
    }
    int ans = 0;
    rep(i,N)
    {
        REP(j,i+1,N)
        {
            int diff = 0;
            rep(k,D)
            {
                diff += (V[i][k] - V[j][k]) * (V[i][k] - V[j][k]);
            }
            if(sqrt(diff) == (int)sqrt(diff))
                ans++;
        }
    }
    cout << ans << '\n';
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    calc();
}


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

int main() {
  string s;
  cin >> s;
  vector<bool> a(4, false);
  rep(i, s.size()) {
    if (s[i] == 'N') a[0] = true;
    if (s[i] == 'W') a[1] = true;
    if (s[i] == 'S') a[2] = true;
    if (s[i] == 'E') a[3] = true; 
  }
  bool home = true;
  if (a[0] && !a[2] || !a[0] && a[2] || a[1] && !a[3] || !a[1] && a[3]) home = false;
  if (home) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int KUPC[126], ans;
string str;

int main(void){

  cin >> str;
  for(int i = 0 ; i < str.size() ; i++){
    if(str[i] == 'K') KUPC['K']++;
    else if(str[i] == 'U') KUPC['U']++;
    else if(str[i] == 'P') KUPC['P']++;
    else if(str[i] == 'C') KUPC['C']++;
    ans = min(min(KUPC['K'], KUPC['U']), min(KUPC['P'], KUPC['C']));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1188
from sys import stdin 
n,k = map(int,stdin.readline().split())
a = map(int,stdin.readline().split())
i = 50
cur = 0 
ans = 0 
while i>=0:
    one = 0 
    
    po = 1 << i 
    for j in a:
        if j & po :
            one+= 1 
    zero = n - one 
    if cur + po > k:
        ans += po * one  
    else:
        ans += max(one,zero)*po 
        if zero > one:
            cur += po 
    #print po,one,n-one,cur 
    i-=1 
print ans 
    

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

int N, M, A[30], B[30], ans;
vector< vector<int> > G(9);

void dfs(int node, vector<bool> vis){
    bool res = true;
    for(int i=1;i<=N;i++){
        if( !vis[i] ){
            res = false;
            break;
        }
    }
    if( res ){
        ans++;
        return;
    }

    for(int i=0;i<G[node].size();i++){
        if( !vis[ G[node][i] ] ){
            vis[ G[node][i] ] = true;
            dfs(G[node][i], vis);
            vis[ G[node][i] ] = false;
        }
    }
}

int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++)    cin >> A[i] >> B[i];

    for(int i=0;i<M;i++){
        G[ A[i] ].push_back(B[i]);
        G[ B[i] ].push_back(A[i]);
    }

    vector<bool> vis(N+1);
    for(int i=1;i<=N;i++)   vis[i] = false;

    vis[1] = true;
    ans = 0;
    dfs(1, vis);

    cout << ans << endl;
}

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

int main()
{
  char S[4];
  int a = 0;

  for(int i = 0; i < 4; i++)
  {
    cin >> S[i];
    if(S[i] == '+')
    a++;
    else if(S[i] == '-')
    a--;
  }

  cout << a;

}

Measured memory_bytes: 256
n = int(input())
ans = 0
p_list = list(map(int,input().split()))
for i in range(0,n-2):
    a = p_list[i]
    b = p_list[i+1]
    c = p_list[i+2]
    if min(a,b,c) != b and max(a,b,c) != b:
        ans += 1
print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n,k;
	cin>>n>>k;
	ll v[n];
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
	}
	int kk = k;
	ll maxsum=0;
	for(int i=0;i<=min(n,k);i++)
{

	int ab=i;
	for(int j=0;j<=ab;j++)
	{
		int pre=j;
		int suf=ab-j;
		ll sum=0;
		multiset<ll>val;
		for(int l=0;l<pre;l++)
		{
			sum += v[l];
			val.insert(v[l]);
		}
		int count=0;
		for(int l=n-1;l>=0;l--)
		{
			if(count<suf)
			{
				sum += v[l];
				count++;
				val.insert(v[l]);
			}
			else
				break;
		}
		int rem = k-ab;
		while(rem>0&&val.size()>0)
		{
			if(*val.begin()<0){
				sum -= *val.begin();
				val.erase(*val.begin());
				rem--;
			}
			else
				break;

		}
	if(sum>maxsum)
		maxsum=sum;
	}
}
	cout<<maxsum<<"\n";
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
char a[1001][1001];
int col[1001][1001];
vector<int>v[1001];
int n,m,k;
int col_cnt;
signed main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='#')
				v[i].push_back(j);
		}
	for(int i=1;i<=n;i++)
	{
		if(!v[i].size())
		{
			for(int j=1;j<=m;j++)
				col[i][j]=col[i-1][j];
		}
		else
		{
			int pre=1;
			for(int j=0;j<v[i].size();j++)
			{
				++col_cnt;
				for(int t=pre;t<=v[i][j];t++)
					col[i][t]=col_cnt;
				pre=v[i][j]+1;
			}
			for(int t=m;t>=1;t--)
				if(col[i][t]==0)
					col[i][t]=col_cnt;
		}
	}
	for(int i=n;i>=1;i--)
		if(col[i][1]==0)
			for(int j=1;j<=m;j++)
				col[i][j]=col[i+1][j];
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
			printf("%d ",col[i][j]);
		printf("\n");
	}
	return 0;
}


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

int main() {
  long long N, a = 2, b = 1;
  cin >> N;
  for (int i = 0; i < N / 2; i++) {
    a += b;
    b += a;
  }
  if (N % 2 == 0) {
    cout << a << endl;
  }
  else {
    cout << b << endl;
  }
}

Measured memory_bytes: 256
#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	S = list(input())
	N = int(len(S) // 2)

	ans = 0
	for i in range(N):
		if S[i] != S[-1 - i]:
			ans += 1
	print(ans)

if __name__ == '__main__':
	main()

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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;

ll N, M, Q, A, B, C, D, E, X, Y, Z, arr[1000005];

string s;

const ll mod = 1000000007;

ll mod_inv(ll base){
	ll ans = 1, expo = 1000000005;
	while (expo){
		if (expo & 1){
			ans *= base;
		}
		base *= base;
		base %= mod;
		ans %= mod;
		expo >>= 1;
	}
	return ans;
}

ll choose(ll n, ll k){
	return (((arr[n]*mod_inv(arr[k]))%mod)*mod_inv(arr[n-k]))%mod;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> M >> A;
	arr[0] = 1;
	for (ll i = 1; i <= 1000000; ++i){
		arr[i] = arr[i-1]*i;
		arr[i] %= mod;
	}
	ll tot = 0;
	for (ll i = 1; i < N; ++i){
		tot += (((N-i)*((((M*M)%mod)*i)%mod)%mod)*((choose(N*M-2,A-2))%mod))%mod;
		tot %= mod;
	}
	for (ll i = 1; i < M; ++i){
		tot += (((M-i)*((((N*N)%mod)*i)%mod)%mod)*((choose(N*M-2,A-2))%mod))%mod;
		tot %= mod;
	}
	cout << tot << '\n';
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

//fi降順 se昇順
bool cmp(pii p1, pii p2){
	if(p1.fi == p2.fi) return p1.se < p2.se;
	return p1.fi > p2.fi;
}

int main(){
	int n,m;
	while(1){
		cin>>n>>m;
		if(n==0 && m==0) break;
		vector<pii> d(m);
		rep(i,0,m) d[i].se=i;
		int a;
		rep(i,0,n){
			rep(j,0,m){
				cin>>a;
				if(a==1){
					d[j].fi++;
				}
			}
		}
		//sort(all(d));
		sort(all(d),cmp);
		//reverse(all(d));
		rep(i,0,m){
			if(i) cout<<" ";
			cout<<d[i].se+1;
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1200
n,m = map(int,input().split())

low = 0
high = 10 ** 5 + 1
for i in range(m):
    ll,rr = map(int,input().split())
    
    low = max(low,ll)
    high = min(high,rr)

if high>=low:
    print(high-low+1)
else:
    print(0)


Measured memory_bytes: 3188
#include <stdio.h>

int main(void) {
	int a, b, k;
	char c;
	while (1) {
		scanf("%d %c %d", &a, &c, &b);
		if (c == '+') k = a + b;
		else if (c == '-') k = a - b;
		else if (c == '*') k = a * b;
		else if (c == '/') k = a / b;
		else if (c == '?') break;
		printf("%d\n", k);
	}
	return 0;
}


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

int main() {
  long long int a=100;
  long long int x;
  int count=0;
  cin>>x;
  while(1){
    a=a*1.01;
    count++;
    if(a>=x)break;
  }
  cout<<count<<endl;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x[ohara],y[ohara],sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
  
       cin.tie(0);
    ios::sync_with_stdio(false);
      
      cin>>n>>m>>b>>c;
      rep(i,n)cin>>x[i];
      rep(i,m)cin>>y[i];
      sort(x,x+n);
      sort(y,y+m);
      cmp=x[n-1];
      cmpp=y[0];
      ans=cmp+1;
      if(cmpp<ans){
        Cout("War");
        return 0;
      }
      if(b<ans&&ans<=c)Cout("No War");
      else Cout("War");
    
       
return 0;
}


Measured memory_bytes: 2304
/*@author Vipen Loka*/
#include <bits/stdc++.h>
#define endl '\n'
#define ff first
#define ss second
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define deb(x) cout << #x << ':' << x << '\n';

using namespace std;
class Graph{
	int n;
	list<int> *graph;
	vector<int> dp;
public:
	int ans=0;
	Graph(int n){
		this->n=n;
		graph=new list<int>[n];
		dp.assign(n,0);
	}
	void addEdge(int a,int b){
		a--;b--;
		graph[a].push_back(b);
	}

	void dfs(int s,bool* &visited){
		visited[s]=1;

		for(auto &x:graph[s]){
			if(!visited[x])dfs(x,visited);
			// dfs(x,visited);
			dp[s]=max(dp[s],dp[x]+1);
			ans=max(dp[s],ans);
		}
	}

	void dfs(){
		bool *visited=new bool[n];
		for (int i = 0; i < n; i++)
		{
			visited[i]=0;
		}
		for (int i = 0; i < n; ++i)
		{
			if(visited[i])continue;
			dfs(i,visited);
		}
	}


};
void solve(){
	int i,j;
	int n,e;
	cin >> n >> e;
	Graph g(n);
	for (int i = 0; i < e; ++i)
	{	
		int a,b;cin >> a >> b;
		g.addEdge(a,b);
	}

	g.dfs();

	printf("%d\n",g.ans);
}


int main(){
	int T=1;
	// cin >> T;
	while (T--){
		solve();
	}
}


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

using namespace std;

#define LL long long
#define ULL unsigned LL
#define LD long double
#define debug(x) cerr << #x << " " << x << endl;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	cout<<n*n*n;
}


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

slowRunner = 0
fastRunner = 0
flag = 1
while slowRunner!=fastRunner or flag:
    flag = 0
    nextSlow = listA[slowRunner]-1
    r = listA[fastRunner]-1
    nextFast = listA[r]-1
    slowRunner = nextSlow
    fastRunner = nextFast

f = 0
slowR1 = 0
slowR2 = slowRunner
while slowR1!=slowR2:
    f+=1
    nextR1 = listA[slowR1]-1
    nextR2 = listA[slowR2]-1
    slowR1 = nextR1
    slowR2 = nextR2

nodeL = []
start = slowR1
s = slowR1
flag = 1
while s!=start or flag:
    flag = 0
    nodeL.append(s+1)
    next = listA[s]-1
    s = next

if k > f:
    amari = (k-f)%len(nodeL)
    print(nodeL[amari])
else:
    i = k
    r = 0
    while i > 0:
        next = listA[r]-1
        r = next
        i-=1
    print(r+1)

Measured memory_bytes: 32048
#include "bits/stdc++.h"
// Custom Header <<<
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;
// >>>

struct FastIO {
    FastIO() { cin.tie(nullptr); ios::sync_with_stdio(false); }
} fastIO_ydk ;

constexpr i64 modPow(i64 n, i64 p, const int mod = MOD)
{
    i64 ret = 1;
    while(p) {
        if (p & 1) ret = (ret * n) % mod;
        n = (n * n) % mod;
        p >>= 1;
    }
    return ret;
}

template<int MOD> class ModInt {
private:
    long long n;
    using T = ModInt<MOD>;
public:
    constexpr inline ModInt(long long n_) : n(n_ % MOD) {}
    template<class Int> constexpr explicit inline operator Int() const { return n; }
    constexpr inline T operator~() const { return modPow(n, MOD-2, MOD); }
    constexpr inline T& operator+=(T o) { n = (n + o.n) % MOD; return *this; }
    constexpr inline T& operator-=(T o) { n = (n - o.n + MOD) % MOD; return *this; }
    constexpr inline T& operator*=(T o) { n = (n * o.n) % MOD; return *this; }
    constexpr inline T& operator/=(T o) { n = (n * (~o).n) % MOD; return *this; }
};
using Mint = ModInt<MOD>;
Mint operator+(Mint a, Mint b) { return Mint(a) += b; }
Mint operator-(Mint a, Mint b) { return Mint(a) -= b; }
Mint operator*(Mint a, Mint b) { return Mint(a) *= b; }
Mint operator/(Mint a, Mint b) { return Mint(a) /= b; }

template<size_t N> struct Factrial {
    i64 a[N];
    constexpr inline Factrial() : a{1} { for (int i = 1; i < N; ++i) a[i] = (a[i-1] * i) % MOD; }
    constexpr inline i64 operator[] (size_t i) const { return a[i]; }
};

Factrial<100010> fact;

i64 comb(i64 n, i64 r) {
    if (n < r) return 0;
    if (r <= 0) return 1;
    return i64(Mint(fact[n]) / (Mint(fact[r]) * fact[n-r]));
}

i64 perm(i64 n, i64 r) {
    if (n < r) return 0;
    if (r <= 0) return 1;
    return i64(Mint(fact[n]) / Mint(fact[r]));
}

signed main()
{
    int N;
    int a[100010];
    bool exist[100010] {};
    int twice;

    cin >> N;
    rep(i, 0, N+1) {
        cin >> a[i];
        if (exist[a[i]]) {
            twice = a[i];
        } else {
            exist[a[i]] = true;
        }
    }

    int l, r;
    for (l = 0; a[l] != twice; ++l);
    for (r = N; a[r] != twice; --r);

    const int M = N - (r - l);

    for (int k = 1; k <= N+1; ++k) {
        cout << int(Mint(comb(N+1, k)) - comb(M, k-1)) << endl;
    }
}

/* vim:set foldmethod=marker foldmarker=<<<,>>> : */


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

int main() {
  int a,b;
  cin >> a;
  b = (double) a / 1.08;
  if((int)(b*1.08)==a) cout << b << endl;
  else if((int)((b+1)*1.08)==a) cout << b+1 << endl;
  else cout << ":(" << endl;
}

Measured memory_bytes: 256
import bisect
N=int(input())
L=list(map(int,input().split()))

L.sort()
ans=0
for i in range(N-1):
  a=L[i]
  for j in range(i+1,N):
    b=L[j]
    right=bisect.bisect_left(L,a+b)
    ans+=right-j-1
print(ans)

Measured memory_bytes: 3188
import java.util.*;

class Main
{

    public static void main(String args[])
    {
	Scanner in = new Scanner(System.in);
	int N = in.nextInt();
	int[][] C = new int[N][N];
	for(int i=0;i<N;i++)
	    for(int j=0;j<N;j++)
		C[i][j] = in.nextInt();
	    
	long cost = 0;

	for(int i=0;i<N;i++)
	    for(int j=i+1;j<N;j++)
		cost += Math.min(C[i][j],C[j][i]);

	System.out.println(cost);
    }

}

Measured memory_bytes: 31404
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
 
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
    int n,k;
    int r,s,p;
    int t;
    cin>>n>>k>>r>>s>>p;
    lli ans=0;
    vector<char> mov;
    vector<char> tac;
    for(int i=0;i<k;i++){
        char temp;
        cin>>temp;
        mov.pb(temp);
        switch(temp){
            case 'r': ans+=p; tac.pb('p'); break;
            case 'p': ans+=s; tac.pb('s'); break;
            case 's': ans+=r; tac.pb('r'); break;
        }
        //cout<<ans<<'\n';
    }

    for(int i=k;i<n;i++){
        char temp;
        cin>>temp;
        mov.pb(temp);
        switch(temp){
            case 'r': if(tac[i-k]!='p'){
                        ans+=p;
                        tac.pb('p');
                      }
                      else tac.pb('a');
                        break;
            case 'p': if(tac[i-k]!='s'){
                        ans+=s;
                        tac.pb('s');
                      }
                      else tac.pb('a'); 
                        break;
            case 's': if(tac[i-k]!='r'){
                        ans+=r;
                        tac.pb('r');
                      }
                      else tac.pb('a');
                        break;
        }
        //cout<<ans<<'\n';
    }
    cout<<ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a, b, c;cin>>a>>b>>c;
	cout<<(a+b+c - max(a, max(b, c)));
	return 0;
}



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

bool cmp(const string &a, const string &b) {
    return a+b < b+a;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,l;
    while(cin >> n >> l) {
        vector<string> v(n);
        for(int i = 0; i < n; i++) {
            cin >> v[i];
        }
        sort(v.begin(), v.end());
        for(auto s : v) {
            cout << s;
        }
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define all(a) (a).begin(), (a).end()

using namespace std; 
template <typename T> using deq = deque<T>;

string s; 
char c;
int q, t,f; 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); 
	
	cin >> s; 
	cin >> q; 
	
	bool rev = false;
	
	deq<char> ans(all(s));
	
	while (q--) {
		cin >> t; 
		if (t==1) {
			rev = !rev;			
		}
		else {
			cin >> f >> c; 
			
			if ((f==1 && !rev) || (f==2 && rev)) {
				//s = c + s;
				ans.push_front(c);
			}
			else {
				//s.push_back(c);
				ans.push_back(c);
			}
		}
	}
	
	if (rev) reverse(all(ans));
	
	for (char c : ans) {
		cout << c; 
	}
	cout << endl;
	
}

Measured memory_bytes: 976
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}


vector<pair<int, int> > G[100000];

void dfs(int u, vector<bool> &v, vector<ll> &d, int K) {
    v[u] = true;
    for (int i = 0; i < G[u].size(); i++) {
        if (!v[G[u][i].first]) {
            d[G[u][i].first] = d[u] + G[u][i].second;
            dfs(G[u][i].first,v,d,K);
        }
    }
}

int main() {
    int N; 
    cin >> N;
    for (int i = 0; i < N-1; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        G[a-1].push_back(make_pair(b-1,c));
        G[b-1].push_back(make_pair(a-1,c));
    }
    vector<bool> visited(N,false);
    vector<ll> d(N,0);
    int Q, K; cin >> Q >> K; K--;
    vector<int> x(Q), y(Q);
    for (int i = 0; i < Q; i++) cin >> x[i] >> y[i];

    dfs(K,visited,d,K);

    for (int i = 0; i < Q; i++) {
        cout << d[x[i]-1] + d[y[i]-1] << endl;
    }


}


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

const long long INF = 1LL << 60;

int main() {
  int n,r;
  cin >> n >> r;
  if(n>9){
    cout << r << endl;
    return 0;
  }else{
    cout << r+100*(10-n);
}
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
      
        int c = a+b;
        int d = a-b;
        int e = a*b;
      
        int x = Math.max(c,d);
        int y = Math.max(x,e);
      
        System.out.println(y);
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<string.h>
int G[260][260],dp[260][260][4],mx[]={0,1,1,-1},my[]={1,1,0,1},i,j,k,N,r;
int main()
{
	for(;scanf("%d",&N),N;)
	{
		memset(dp,0,sizeof(dp));
		for(i=1;i<=N;i++)
			for(j=1;j<=N;j++)
				scanf("%1d",&G[i][j]);
		for(i=1;i<=N;i++)
			for(j=1;j<=N;j++)
				if(G[i][j])
				{
					for(k=0;k<4;k++)
					{
						dp[i+my[k]][j+mx[k]][k]=dp[i][j][k]+1;
					}
				}
		r=0;
		for(i=0;i<=N+1;i++)
			for(j=0;j<=N+1;j++)
				for(k=0;k<4;k++)
					r=r<dp[i][j][k]?dp[i][j][k]:r;
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 1928
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <limits>

using namespace std;

int main(){
  vector<pair<double,string> > RankData(12);
  RankData[ 0].first= 0.0,RankData[ 0].second="light fly"; 
  RankData[ 1].first=48.0,RankData[ 1].second="fly";
  RankData[ 2].first=51.0,RankData[ 2].second="bantam";
  RankData[ 3].first=54.0,RankData[ 3].second="feather";
  RankData[ 4].first=57.0,RankData[ 4].second="light";
  RankData[ 5].first=60.0,RankData[ 5].second="light welter";
  RankData[ 6].first=64.0,RankData[ 6].second="welter";
  RankData[ 7].first=69.0,RankData[ 7].second="light middle";
  RankData[ 8].first=75.0,RankData[ 8].second="middle";
  RankData[ 9].first=81.0,RankData[ 9].second="light heavy";
  RankData[10].first=91.0,RankData[10].second="heavy";
  RankData[11].first=numeric_limits<double>::max(),RankData[11].second="limit";
  vector<double> weightdata;
  double weight;
  while(cin>>weight){
    weightdata.push_back(weight);
  }

  for(auto weight:weightdata){
    for(int i=0;i<RankData.size()-1;i++){
      if(RankData[i].first<weight&&weight<=RankData[i+1].first){
        cout<<RankData[i].second<<endl;
      }
    }
  }
}
      

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

int main(void)
{
	int A, B;
	cin >> A >> B;//Alice Bob

	if (A == B) {
		cout << "Draw" << endl;
		return 0;
	}
	if (A == 1) {
		cout << "Alice" << endl;
		return 0;
	}
	else if (B == 1) {
		cout << "Bob" << endl;
		return 0;
	}
	
	if (A < B)cout << "Bob" << endl;
	else cout << "Alice" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

int N, nxt[200200], prv[200200], rem;
string s;
set<int> pos;

int main () {
        cin >> s;
        N = (int) s.size();

        fo(i, 0, N-1) {
                nxt[i] = i+1;
                if (s[i] == 'S' && s[nxt[i]] == 'T') pos.insert(i);
        }
        nxt[N-1] = 2e9;

        fo(i, 0, N) {
                prv[i] = i-1;
        }

        while (pos.size()) {
                int i = *pos.begin(); pos.erase(i);
                rem += 2;
                int a = prv[i], b = nxt[nxt[i]];
                if (a == -1) continue;
                if (b == 2e9) continue;
                nxt[a] = b, prv[b] = a;
                if (s[a] == 'S' && s[b] == 'T') pos.insert(a);
        }
        cout << N - rem << endl;
        return 0;
}


Measured memory_bytes: 4356
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
 
typedef long long ll;

#define rep(i,n) for(ll i = 0; i < n; i++)

using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

int main(){
  int N;
  string S;
  cin >> N >> S;

  int A[300010] = {};
  for(int i = 1; i<=N; i++){
    if(S[i-1] == 'E') A[i] = A[i-1] + 1;
    else A[i] = A[i-1];
  }
  int ans = 1e+9;
  for(int i = 1; i<=N; i++){
    ans = min(ans, A[N]-A[i] + i-1-A[i-1] );
  }
  cout << ans << endl;
}


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

int main()
{
    int H, W;
    cin >> H >> W;

    vector<vector<bool>> board(H, vector<bool>(W));
    string S;
    for (int i = 0; i < H; i++)
    {
        cin >> S;
        for (int j = 0; j < W; j++)
        {
            board[i][j] = (S[j] == '#');
        }
    }

    vector<vector<bool>> visited(H, vector<bool>(W, false));

    vector<pair<int, int>> diff{
        pair<int, int>(1, 0),
        pair<int, int>(0, 1),
        pair<int, int>(-1, 0),
        pair<int, int>(0, -1)};
    queue<pair<int, int>> q;
    long long ans = 0;
    long long black, white;
    int x, new_x;
    int y, new_y;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (visited[i][j])
            {
                continue;
            }
            q.push(make_pair(i, j));
            black = 0;
            white = 0;
            while (!q.empty())
            {
                x = q.front().first;
                y = q.front().second;
                q.pop();
                if (visited[x][y])
                {
                    continue;
                }

                if (board[x][y])
                {
                    black++;
                }
                else
                {
                    white++;
                }
                visited[x][y] = true;

                for (pair<int, int> d : diff)
                {
                    new_x = x + d.first;
                    new_y = y + d.second;
                    if (new_x < 0 || new_y < 0)
                    {
                        continue;
                    }
                    if (new_x >= H || new_y >= W)
                    {
                        continue;
                    }
                    if (visited[new_x][new_y])
                    {
                        continue;
                    }

                    if (board[x][y] != board[new_x][new_y])
                    {
                        q.push(make_pair(new_x, new_y));
                    }
                }
            }
            ans += black * white;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll a,b,m;cin>>a>>b>>m;
  vector<ll> A(a), B(b), X(m), Y(m), C(m);
  rep(i,a){
    cin>>A[i];
  }
  rep(i,b){
    cin>>B[i];
  }
  rep(i,m){
    cin>>X[i]>>Y[i]>>C[i];X[i]--;Y[i]--;
  }
  ll ans = LINF;
  rep(i,m){
    chmin(ans, A[X[i]] + B[Y[i]] - C[i]);
  }
  sort(all(A));
  sort(all(B));
  chmin(ans, A[0] + B[0]);
  cout<<ans<<endl;

}

Measured memory_bytes: 4224
#include<iostream>
#include<cmath>
using namespace std;
int main() {
  double x=0;
  double y=0;
  int d;
  int a=90;
  int _a;
  char c;
  while(true){
    cin>>d>>c>>_a;
    if(d==0 && _a==0)
      break;
    x+=d*cos(a*M_PI/180);
    y+=d*sin(a*M_PI/180);
    a-=_a;
  }
  cout<<(int)x<<endl;
  cout<<(int)y<<endl;
  return 0;
}



Measured memory_bytes: 3440
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  int ans=n/3;
  cout<<ans<<endl;

  return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] num1 = {sc.nextInt(),sc.nextInt(),sc.nextInt()};
		int count = 0;
		for(int i = 0; i < 3; i++) {
			if(num1[i] == 5) {
				count++;
			} else if(num1[i] == 7) {
				count += 2;
			} else {
				System.out.println("NO");
				return ;
			}
		}
		System.out.println(count == 4 ? "YES" : "NO");

	}

}


Measured memory_bytes: 21844
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]
  member this.ScanMatrix n f  = [| for i in 1..n -> stream.ReadLine().Split() |> Array.map f |]
  member this.ScanCharMatrix n = [| for i in 1..n -> stream.ReadLine().ToCharArray() |]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let n,a,b = util.Scan3 int

min (n*a) b
|> printfn "%d" 

Measured memory_bytes: 14044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  ll res = 0;
  for(int i = 1;i <= n;i++){
    string s = to_string(i);
    if(s.size() % 2 == 1)res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 3692
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;

    cin >> n;
    for (int i=0; i<n; i++) cin >> R[i];

    int maxv = -2147483648;
    int minv = R[0];

    for (int i=1; i<n; i++) {
        maxv = max(maxv, R[i]-minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}


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

int main() {
   
  int n;
  cin >> n;
  int x = n;
  
  int sum = 0;
  for (int i = 0; i < 9; i++){
     sum += x % 10;
     x /= 10;
   }
  
  if (n % sum == 0){
   cout << "Yes" << endl;
  }
  else {
   cout << "No" << endl;
  }
}



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

int main() {
    int N, Q;
    cin >> N;
    long long sum=0;
    long long A[100010]={0};
    for (int i=0; i<N; i++) {
        int a;
        cin >> a;
        A[a]++;
        sum+=a;
    }
    cin >> Q; 
    for (int i=0; i<Q; i++) {
        long long B,C;
        cin >> B >> C;
        sum+=(C-B)*A[B];
        A[C]+=A[B];
        A[B]=0;
        cout << sum << endl;
    }
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod=1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head
void add(int& a, int b) {
    a += b;
    if(a >= mod) a -= mod;
}
void sub(int& a, int b) {
    a -= b;
    if(a < 0) a += mod;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i,0,n) cin >> a[i];

    vi dp(k + 1, 0);
    dp[0] = 1;

    for(int i = 0; i < n; i++) {
        vector<int> del(k + 2, 0);
        for(int j = k; j >= 0; j--) { // candies remaining at this point
            int delta = dp[j];
            // first cell is j + 1, last is j + min(k - j, a[i])
            add(del[j + 1], delta);
            sub(del[j + min(k - j, a[i]) + 1], delta);
        }
        for(int j = 0; j <= k; j++) add(del[j + 1], del[j]);
        for(int j = 0; j <= k; j++) add(dp[j], del[j]);
    }

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


Measured memory_bytes: 1024
# vim: set fileencoding=utf-8:


def main():
    x1, y1, x2, y2 = map(int, raw_input().split())
    if x1 <= x2 and y1 >= y2:
        a = abs(y1 - y2)
        b = abs(x1 - x2)
        y3 = y2 + b
        x3 = x2 + a
        y4 = y3 + a
        x4 = x3 - b
    elif x1 <= x2 and y1 <= y2:
        a = abs(x1 - x2)
        b = abs(y1 - y2)
        y3 = y2 + a
        x3 = x2 - b
        y4 = y3 - b
        x4 = x3 - a
    elif x1 >= x2 and y1 >= y2:
        b = abs(y1 - y2)
        a = abs(x1 - x2)
        y3 = y2 - a
        x3 = x2 + b
        y4 = y3 + b
        x4 = x3 + a
    elif x1 >= x2 and y1 <= y2:
        a = abs(y1 - y2)
        b = abs(x1 - x2)
        y3 = y2 - b
        x3 = x2 - a
        y4 = y3 - a
        x4 = x3 + b

    print("%s %s %s %s " % (x3, y3, x4, y4))


if __name__ == "__main__":
    main()


Measured memory_bytes: 2696
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;


int main(void){

    int N,M; cin>>N>>M;
    vector<ll> H(N+1,0);
    for (int i = 1; i <= N; ++i) {
        cin>>H[i];
    }
    vector<int> check(N+1,0);
    for (int i = 1; i <= M; ++i) {
        int A,B; cin>>A>>B;

        if(H[A]<H[B]){
            check[A]++;
        }else if(H[B]<H[A]){
            check[B]++;
        }else{
            check[A]++; check[B]++;
        }
    }

    int sum=0;
    for (int i = 1; i <= N; ++i) {
        if(check[i]==0) sum++;
    }

    cout<<sum<<endl;

}


Measured memory_bytes: 4584
#include<cstdio>

int main() {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if((a == 5) + (b == 5) + (c == 5) == 2 && (a == 7) + (b == 7) + (c == 7) == 1) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))

int main()
{
	int N;
	cin >> N;

	vector<queue<int>>A(N);
	rep(i, N) {
		rep(j, N - 1) {
			int now;
			cin >> now;
			A[i].push(now - 1);
		}
	}

	int res = 0;
	map<int, set<int>>opp;
	vector<int> now, next;
	rep(i, N)now.push_back(i);

	while (true) {
		bool wake = false;
		for (int me : now)if (!A[me].empty()) {
			wake = true;
			int other = A[me].front();

			if (opp[me].find(other) != opp[me].end()) {
				// 相手を見つけた -> 自分のところから取得
				next.push_back(me);
				next.push_back(other);
				A[me].pop();
				A[other].pop();
				opp[me].erase(other);
			}
			else {
				// 相手が見つからない -> 相手に要求
				opp[other].insert(me);
			}
		}
		if (!wake)break;
		res++;
		now = next;
		next.clear();
	}
	for (auto& row : A)if (!row.empty()) {
		cout << -1 << endl;
		return 0;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 4736
import java.util.Scanner;

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

        while(true){
            int n = scan.nextInt();
            if(n == 0){
                break;
            }
            int[] array_s = new int[n];
            int sum = 0;
            double v_2 = 0;
            double a;
            for(int i = 0; i < n; i++){
                array_s[i] = scan.nextInt();
                sum += array_s[i];
            }

            double m = (double)sum/(double)n;

            for(int i = 0; i < n; i++){
                v_2 += Math.pow(array_s[i]-m, 2);
            }

            a = Math.sqrt(v_2/n);
            System.out.println(a);
        }

    }
}



Measured memory_bytes: 31488
N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
for a in range(min(N, K) + 1):
    for b in range(min(N, K) + 1 - a):
        juels = sorted(V[:a] + V[len(V)-b:])
        if not juels:
            continue
        cd = K - a - b
        now = sum(juels)
        for i in range(min(len(juels), cd)):
            if juels[i] < 0:
                now -= juels[i]
        ans = max(ans, now)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    string S,T;
    cin >> S >> T;
    bool ans = false;

    for(int i=0;i<S.length();i++){
        if(S == T){
            ans = true;
            break;
        }
        S = S.back()+S.substr(0,S.size()-1);
          }
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
        
    }
return 0;
}



Measured memory_bytes: 256
w, h, n = map(int, input().split())

g = [[1 for _ in range(w)] for __ in range(h)]

for _ in range(n):
    x, y, a = map(int, input().split())
    for i in range(h):
        for j in range(w):
            if a == 1 and j < x:
                g[i][j] = 0
            elif a == 2 and x <= j:
                g[i][j] = 0
            elif a == 3 and i < y:
                g[i][j] = 0
            elif a == 4 and y <= i:
                g[i][j] = 0

print(sum(map(sum, g)))


Measured memory_bytes: 43244