akhauriyash/Code-Regression huggingface dataset:
n,k=map(int,input().split())

mod=10**9+7

MAX_N = n+5
fac = [1,1] + [0]*MAX_N
finv = [1,1] + [0]*MAX_N
inv = [0,1] + [0]*MAX_N
for i in range(2,MAX_N):
  fac[i] = fac[i-1] * i % mod
  inv[i] = mod - inv[mod % i] * (mod // i) % mod
  finv[i] = finv[i-1] * inv[i] % mod

def nCk(n,k):
  if n<k:
    return 0
  if n<0 or k<0:
    return 0
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod

for i in range(1,k+1):
  ans=nCk(n-k+1,i)*nCk(k-1,i-1)
  ans%=mod
  print(ans)

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

int ans[1100][1100];

int main(){
	int h,w,a,b; cin >> h >> w >> a >> b;
	if(2*a>w||2*b>h){
		cout << "No" << endl;
		return 0;
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			ans[i][j]=(i<b)^(j<a);
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout << ans[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 5504
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b) //最大公約数
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

ll lcm(ll a, ll b) //最小公倍数
{
	return a * b / gcd(a, b);
}

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);
	return s + n;
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}

// ===============================================================

int main() {
	ll a, b, c; cin >> a >> b >> c;
	cout << (a - c) / (b + c) << endl;
}

Measured memory_bytes: 3644
#!/usr/bin/env python3

import sys
import pprint
import itertools

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(0)
	n, m, x = map(int, sys.stdin.readline().split())
	c = []
	a = []
	for i in range(n):
		ci, *ai = map(int, sys.stdin.readline().split())
		c.append(ci)
		a.append(ai)
	ans = 10**9
	log.print(a)
	for i in range(2**n):
		cost = 0
		rikai = [0]*m
		case = []
		for j in range(n):
			case.append(i>>j & 1)
		for j in range(n):
			if not case[j]:
				continue
			cost += c[j]
			for k in range(m):
				rikai[k] += a[j][k]
		# log.print(case, rikai, len(list(filter(lambda z:z>=x, rikai))))
		if len(list(filter(lambda z:z>=x, rikai))) == m:
			ans = min(cost, ans)
	if ans == 10**9:
		print(-1)
		exit()
	print(ans)





main()

Measured memory_bytes: 70452
#include <bits/stdc++.h> 
#define aeiou printf("vowel") 
using namespace std; 
int main() { 
    char c; 
    c=getchar(); 
    for (int i = 0; i < 5; i++) { 
        if (c=='a'||c=='e'||c=='i'||c=='o'||c=='u') { 
            printf("vowel"); return (0-0); 
        } 
        
    } 
    printf("consonant"); 
    return 0; 
    
} 

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

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

const int mod = INF+7;
int main(){
    int a,b,c,x,y;cin>>a>>b>>c>>x>>y;
    int res = 0;
    if(a+b<=2*c){
        res = a*x+b*y;
    }
    else {
        res += 2*c*min(x,y);
        int mn = min(x,y);
        x -= mn,y -= mn;
        if(a*x+b*y>2*c*max(x,y))res += 2*c*max(x,y);
        else res += a*x+b*y;
    }
    cout<<res<<endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll dp[5001][2001];
int main()
{
	int n1, n2, gen;
	scanf("%d%d%d", &n1, &n2, &gen);
	dp[0][0] = 1;
	ll ans = 0;
	for (int i = 0; i < (n1 + n2) / (gen - 1); i++)
	{
		for (int j = 0; j <= n1; j++)
		{
			for (int k = 0; k <= gen - 1; k++)
			{
				if (j + k <= n1)
				{
					dp[i + 1][j + k] += dp[i][j];
					dp[i + 1][j + k] %= mod;
				}
			}
			for (int k = 1; k <= gen - 1; k++)
			{
				if (j + k <= n1 && i*(gen - 1) + gen - j - k <= n2 && (n1 - j - k) % (gen - 1) == 0)
				{
					ans += dp[i][j];
					ans %= mod;
				}
			}
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 63616
#include<iostream>

using namespace std;

int main(){
    int K, S, x, y, z, cnt = 0, num = 0;
    cin >>K >>S;
    for(x = 0; x <= K; x++){
        for(y = 0; y <=K; y++){
            if(S - x - y <= K && S - x - y >= 0){
               cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int max(int A, int B, int C){
  if(A > B){
    if(A > C){
      return A;
    }
  }else{
    if(B > C){
      return B;
    }
  }
  return C;
}

int main(){
  int A;
  int B;
  int C;
  int K;

  scanf("%d%d%d%d", &A, &B, &C, &K);

  for(int i = 0; i < K; i ++){
    int D = max(A, B, C);
    if(D == A){
      A = A * 2;
    }else if(D == B){
      B = B * 2;
    }else if(D == C){
      C = C*2;
    }
  }

  printf("%d\n", A+B+C);


}

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

typedef long long ll;

int MOD=1000000007;

int main(void){
  int N; cin >> N;
  vector<int> P(N),Q(N);
  for(int i=0; i<N; i++) cin >> P[i];
  for(int i=0; i<N; i++) cin >> Q[i];

  int a, b;
  vector<int> S;
  for (int i=1; i<=N; i++) S.push_back(i);
  int cnt = 0;
  do {
    cnt++;
    if (S==P) a=cnt;
    if (S==Q) b=cnt;
  } while (next_permutation(S.begin(), S.end()));
  
  cout << abs(a - b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const ll mod = 1e9+7;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        string s; cin >> s;
        rep(i,sz(s)){
            cout << 'x' ;
        }
        cout << endl;

    }
}


Measured memory_bytes: 256
#n, m = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for m in range(m)]
#light = [int(i) for i in input().split()]
s = int(input())
#list = list(s)

#print(n, m)
#print(table)
#print(light)

a = s // 100
b = s % 100

if (1 <= a and a <= 12) :
    if (1 <= b and b <= 12) :
        print("AMBIGUOUS")
    else :
        print("MMYY")
else :
    if (1 <= b and b <= 12) :
        print("YYMM")
    else :
        print("NA")



Measured memory_bytes: 2940
#include <stdio.h>

int main()
{
    char b;
    scanf("%c", &b);

   switch (b)
   {
   case 'A':
    printf("T\n");
       break;
   
   case 'T':
    printf("A\n");
       break;
   
   case 'G':
    printf("C\n");
       break;
   
   default:
    printf("G\n");
       break;
   }

return 0; 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//turn on extra precision
//#pragma GCC target("fpmath=387")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define watch(x) cout << (#x) << " is : " << (x) << newl

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
vi dirx = {0,0,1,-1};
vi diry = {1,-1,0,0};
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122) return char(x-32);
    if( 65 <= int(x) && int(x) <= 90) return x;
    return -1;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122) return x;
    if( 65 <= int(x) && int(x) <= 90) return char(x+32);
    return -1;
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57) return int(x-'0');
    if(97 <= int(x) && int(x) <= 122) return int(x-96);
    if(65 <= int(x) && int(x) <= 90) return int(x-64);
    return -1;
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1 = {l1,r1};
    pii p2 = {l2,r2};
    if(p1>p2)swap(p1,p2);
    return (p2.fi <= p1.se);
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1%MOD;
    else if(num2==1)return num1%MOD;
    else{
        ll temp = quickpow (num1,num2>>1LL,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2&1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template

int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

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

    int x; cin >> x;
    cout << (x >= 30 ? "Yes\n" : "No\n");


    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a + b < c + d) cout << "Right" << endl;
  else if(a + b == c + d) cout << "Balanced" << endl;
  else cout << "Left" << endl;
}


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

using namespace std;

string s, s1;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> s >> s1;
    if ((int)s.length() != (int)s1.length()) {
        if ((int)s.length() > (int)s1.length()) {
            cout << "GREATER" << endl;
            return 0;
        } else {
            cout << "LESS" << endl;
            return 0;
        }
    }
    for (int i = 0; i < (int)s.length(); ++i) {
        if (s[i] > s1[i]) {
            cout << "GREATER" << endl;
            return 0;
        }
        if (s[i] < s1[i]) {
            cout << "LESS" << endl;
            return 0;
        }
    }
    cout << "EQUAL" << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    xs = list(map(int, input().split()))
    i_m = n // 2 - 1
    ys = sorted((x, i) for i, x in enumerate(xs))
    for x in xs:
        if x <= ys[i_m][0]:
            print(ys[i_m + 1][0])
        else:
            print(ys[i_m][0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 34240
def ok(a)
  x,y = a.minmax
  d = y-x
  return false unless d <= 1
  return (x == a.size-1) || (2*x <= a.size) if d.zero?
  (a.count(x) <= x) && (2 * (y - a.count(x)) <= a.count(y))
end

gets
puts ok(gets.split.map &:to_i) ? "Yes" : "No"


Measured memory_bytes: 8068
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>

using namespace std;

int main(){
 int n,L[101],max=0,sum=0;

 cin >> n;
 for(int i = 0; i < n; i++){
   cin >> L[i];
   sum+=L[i];
   if(L[i]>max)
    max=L[i];
 }
 sum-=max;

 if(sum>max)
  cout << "Yes"<<endl;
else
  cout <<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
/*@author hussein zayed ;
    ___  ___
   |\  \|\  \
   \ \  \_\  \
    \ \   ___ \USSEIN
     \ \  \\ \ \
      \ \__\\ \_\
       \|__| \|__|
****************************************
*/

#include <bits/stdc++.h>
using namespace std;
#define fr for(int i=0;i<n;++i)
#define fr1 for(int i=1;i<=n;++i)
#define cinA for(int i=0;i<n;++i){cin>>arr[i];}
#define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
#define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
#define ll long long
#define lnarray sizeof(arr)/sizeof(*arr)
#define vi vector<int>
#define vs vector<string>
void Fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int RD()
{
    int i ;
    cin>>i;
    return i;
}

inline float RF()
{
    float i ;
    cin>>i;
    return i;
}

inline double RDO()
{
    double i ;
    cin>>i;
    return i;
}

inline string RS()
{
    string i ;
    cin>>i;
    return i;
}

inline ll RLL()
{
    ll i ;
    cin>>i;
    return i;
}

int cm[200000];

ll sumSet(ll n)
{
    return (1ll*n*(n+1))/2;
}
string s;


bool isPrime(int n)
{
    if(n==1)
        return false;
    for(int i=2; i*i<=n; ++i)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int sumDigit(int n){
int sum =0;
  while (n != 0)
    {
        sum+= + n % 10;
        n = n / 10;
    }
    return sum;
}

ll power2(int n){
  ll ans=(1<<n);
  return ans;
}

ll sumpow2(ll n){
 ll sum=(n*(n+1)*(2*n-1))/6;
 return sum;
}

int main(){
    Fast();
//freopen("output.txt" , "w" , stdout);
//freopen("wall.in" , "r" , stdin);
int x=RD(), a=RD(), b=RD();
    
    int A=abs(x-a), B=abs(x-b);
    if(A<B)
        cout<<"A\n";
    else
       cout<<"B\n";
 }




Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n,t ;
	cin >> n >> t ;
	vll a(n),b(n) ;
	for(int i=0;i<n;i++) cin >> a.at(i) >> b.at(i) ;
	vvll dp1(n+1,vll(t,0)),dp2(n+1,vll(t,0)) ;
	for(int i=1;i<=n;i++){
		for(int j=0;j<t;j++){
			dp1.at(i).at(j) = dp1.at(i-1).at(j) ;
			if(j>=a.at(i-1)) dp1.at(i).at(j) = max(dp1.at(i).at(j),dp1.at(i-1).at(j-a.at(i-1))+b.at(i-1)) ;
		}
	}
	reverse(all(a)) ;
	reverse(all(b)) ;
	for(int i=1;i<=n;i++){
		for(int j=0;j<t;j++){
			dp2.at(i).at(j) = dp2.at(i-1).at(j) ;
			if(j>=a.at(i-1)) dp2.at(i).at(j) = max(dp2.at(i).at(j),dp2.at(i-1).at(j-a.at(i-1))+b.at(i-1)) ;
		}
	}
	ll ans = 0 ;
	reverse(all(a)) ;
	reverse(all(b)) ;
	for(int i=1;i<=n;i++){
		ll sub = 0 ;
		for(int j=0;j<t;j++){
			sub = max(sub,dp1.at(i-1).at(j)+dp2.at(n-i).at(t-1-j)) ;
		}
		ans = max(ans,sub+b.at(i-1)) ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 141184
#include<stdio.h>
int main(){
  int t,n;
  int sum=0;
  int i,s,e;
  while(1){
    scanf("%d",&t);
    if(t == 0){
      break;
    }
    scanf("%d",&n);
    for(i = 0;i < n;i++){
      scanf("%d %d",&s,&e);
      sum+=e-s;
    }
    if(t<=sum){
      printf("OK\n");
    }
    else{
      printf("%d\n",t-sum);
    }
    sum = 0;
  }
  return(0);
}
	     



Measured memory_bytes: 2700
num = int(input())

def n2a(num):
    if num <= 26:
        return chr(64 + num)
    elif num % 26 == 0:
        return n2a(num//26 - 1) + chr(90)
    else:
        return n2a(num//26) + chr (64 + num % 26)

print(n2a(num).lower())

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,cost;
  while(cin >> n&&n != -1){
    cost = 1150;
    n -= 10;
    if(n>=0){
      cost += ((n<10)? (n%10):10) * 125;
      n -= 10;
    }
    if(n >= 0){
      cost += ((n<10)? (n%10):10) * 140;
      n -= 10;
    }
    if(n >= 0){
      cost += n * 160;
    }
    cout << 4280 - cost << endl;
  }
  return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  ll n,m;
  cin >> n >> m;
  ll ans = 0LL;
  
  if(n < m/2){
    ans += n;
    m -= n*2;
    ans += m/4;
  }else{
    ans += m/2;
  }
    
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a,b = LI()
    if a > b:
        return a -1

    return a



print(main())



Measured memory_bytes: 6476
#include <stdio.h>


int main(void){
    int n,a,b,c,d,k=0;
    
    while(scanf("%d",&n)!=EOF){
        
        for(a=0;a<10;a++)
            for(b=0;b<10;b++)
                for(c=0;c<10;c++){
                    d = n-a-b-c;
                    if(d>=0 && d<=9) k++;
                }
        
        printf("%d\n",k);
        k=0;
    }
    
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;


//#define debugger
#define rep int kase; scanf("%d", &kase); while(kase--)

int main(){
  #ifdef debugger
  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
  #endif // debugger
  int a,b,c,d,x,y;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  x = max(a,c);
  y = min(b,d);
  int ans = y-x;
  if(ans < 0) printf("0\n");
  else printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
class Dice{
public:
    int n1,n2,n3,n4,n5,n6;
     
    void East(){
        int t = n1;
        n1 = n4;
        n4 = n6;
        n6 = n3;
        n3 = t;
    }
    void West(){
        int t = n1;
        n1 = n3;
        n3 = n6;
        n6 = n4;
        n4 = t;
    }
    void South(){
        int t=n1;
        n1 = n5;
        n5 = n6;
        n6 = n2;
        n2 = t;
    }
    void North(){
        int t=n1;
        n1 = n2;
        n2 = n6;
        n6 = n5;
        n5 = t;
    }
};
 
int main() {
    Dice dice;
    int n1, n2, n3, n4, n5, n6;
    int q;
    cin >> n1 >> n2 >> n3 >> n4 >> n5 >> n6;
    dice.n1 = n1;
    dice.n2 = n2;
    dice.n3 = n3;
    dice.n4 = n4;
    dice.n5 = n5;
    dice.n6 = n6;
     
    cin >> q;
    for(int i=0; i<q; i++){
        int a, b;
        cin >> a >> b;
        if(b == dice.n1){
            dice.South();
        }else if(b == dice.n3){
            dice.West();
            dice.South();
        }else if(b == dice.n4){
            dice.East();
            dice.South();
        }else if(b == dice.n5){
            dice.South();

            dice.South();
        }else if(b == dice.n6){
            dice.North();
        }
        if(a == dice.n3){
            dice.West();
        }else if(a == dice.n4){
            dice.East();
        }else if(a == dice.n6){
            dice.East();
            dice.East();
        }
        cout << dice.n3 << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
from collections import deque

n = int(input())
neibors = [[] for i in range(n)]
for i in range(n-1):
    u,v,w = map( int, input().split() )
    neibors[u-1].append( (v-1,w%2) )
    neibors[v-1].append( (u-1,w%2) )

dist = [-1 for i in range(n)]
stack = deque([0])
while( len(stack) != 0 ):
    current = stack.popleft()
    current_dist = dist[current]

    for neibor_n, neibor_w in neibors[current]:
        if dist[neibor_n] == -1:
            stack.append( neibor_n )
            dist[neibor_n] = (neibor_w + current_dist) % 2  

for item in dist:
    print(item)

Measured memory_bytes: 35972
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;

    vector<long long> a(x), b(y), c(z);
    for (int i = 0; i < x; i++) { cin >> a[i]; }
    for (int i = 0; i < y; i++) { cin >> b[i]; }
    for (int i = 0; i < z; i++) { cin >> c[i]; }

    vector<long long> ab(x * y);
    for (int i = 0; i < x; i++) {
        for (int j = 0; j < y; j++) {
            ab[i * y + j] = a[i] + b[j];
        }
    }

    sort(ab.begin(), ab.end(), greater<long long>());

    vector<long long> abc(min(x * y, k) * min(z, k));
    for (int i = 0; i < min(x * y, k); i++) {
        for (int j = 0; j < min(z, k); j++) {
            abc[i * min(z, k) + j] = ab[i] + c[j];
        }
    }

    sort(abc.begin(), abc.end(), greater<long long>());

    for (int i = 0; i < k; i++) {
        cout << abc[i] << endl;
    }
}


Measured memory_bytes: 31616
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        
        s = s.substring(0, s.length()-1);
        while(true){
            String first = s.substring(0, s.length()/2);
            String last = s.substring(s.length()/2);
            if(first.equals(last)){
                System.out.println(s.length());
                return;
            }else{
                s = s.substring(0, s.length()-1);
            }
        }
    }
}

Measured memory_bytes: 23636
N, M, T = map(int, input().split())

a = list(int(i) for i in input().split())
count = 0
count += max(a[0] - M,0)
for i in range(1,N):
	count += max(a[i] - a[i-1] -2*M, 0)
count += max(T - a[N-1] - M,0)
print(count)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x <= 1) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
ll k,n;
ll a[maxn];
int main(){
 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> k >> n;
	for(int i = 0;i < n;i++) cin >> a[i];
	ll mx = -1;
	for(int i = 1;i < n;i++){
		mx = max(mx,a[i] - a[i-1]);
	}
	mx = max(mx,a[0] + k - a[n - 1]);
	cout << k - mx << endl;
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

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

using namespace std;

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    Rep (i, N) {
        cin >> A[i];
    }

    multiset<ll> color;
    ll num = 0;
    Rep (i, N) {
        auto itr = color.upper_bound(-A[i]);
        if (itr != color.end()) {
            color.erase(itr);
        }
        color.insert(-A[i]);
    }

    cout << color.size() << "\n";
}


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "

vector<vector<ll>> d(10, vector<ll>(10, 0));

void calc() {
  rep0(k, 10) {
    rep0(i, 10) {
      rep0(j, 10) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

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

  rep0(i, 10) {
    rep0(j, 10) {
      cin >> d[i][j];
    }
  }
  calc();

  ll ans = 0;
  rep0(i, H * W) {
    ll temp;
    cin >> temp;
    if (temp != -1) ans += d[temp][1];
  }

  cout << ans << BR;
  return 0;
}

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

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define asort(x) sort(x.begin(),x.end())

int main() {
    string s;
    cin>>s;
    cout << s[0] << s[1] << s[2] << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int n, h, w; cin >> n >> h >> w;
	int ans = 0;
	for (int i = 0; i < n / 2; i++) {
		int a, b; cin >> a >> b;
		ans += min(a + b, w * 2 - a - b);
	}
	cout << ans*h << endl;
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 200005;
ll A[MAX_N];

int main()
{
	int N;
	cin >> N;
	rep(i,N)
	{
		cin >> A[i];
	}
	sort(A,A+N);
	rep(i,N-1)
	{
		if (A[i] == A[i+1])
		{
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 1792
import math
a, b, h, m = map(int, input().split())
c = abs((60*h+m)*0.5 - m*6)
if c>180:
    c=360-c
c=(a**2 + b**2 - 2*a*b*math.cos(math.radians(c)))**0.5
print(c)

Measured memory_bytes: 9480
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int Max=8010;
const int mod=1e9+7;
int n,m,k,ans;
int f[Max][Max],inv[Max],mul[Max],a[200010],b[200010];

inline int get_int()
{
	int x=0,f=1;
	char c;
	for(c=getchar();(!isdigit(c))&&(c!='-');c=getchar());
	if(c=='-') c=-1,c=getchar();
	for(;isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+c-'0';
	return x*f;
}

inline int ksm(int a,int b)
{
	int ans=1;
	while(b)
	{
	  if(b&1) ans=(ans*a)%mod;
	  b>>=1;
	  a=(a*a)%mod;
	}
	return ans;
}

inline void pre()
{
	mul[0]=mul[1]=1;
	for(int i=2;i<=8000;i++) mul[i]=(mul[i-1]*i)%mod;
	inv[0]=inv[1]=1;
	for(int i=2;i<=8000;i++) inv[i]=ksm(mul[i],mod-2);
}

inline int C(int n,int m)
{
	if(n>=0 && m>=0 && n>=m) return (mul[n]*inv[m]%mod*inv[n-m]%mod)%mod;
	return 0;
}

signed main()
{
	pre();
	n=get_int();
	for(int i=1;i<=n;i++) a[i]=get_int(),b[i]=get_int(),f[2001-a[i]][2001-b[i]]++;
	for(int i=1;i<=4001;i++)
	  for(int j=1;j<=4001;j++)
	    f[i][j]=(f[i][j]%mod+(f[i][j-1]+f[i-1][j])%mod)%mod;

	for(int i=1;i<=n;i++) ans=(ans+f[2001+a[i]][2001+b[i]])%mod;
	for(int i=1;i<=n;i++) ans=((ans-C((a[i]<<1)+(b[i]<<1),a[i]<<1))%mod+mod)%mod;
	ans=1ll*ans*(mod+1)/2%mod;
	cout<<(ans%mod+mod)%mod<<"\n";

	return 0;
}

Measured memory_bytes: 254208
use std::io::stdin;
use std::str::FromStr;
use std::cmp::min;

fn main(){
    let n: usize = get_one();
    let xs: Vec<i64> = get_vec();
    let can_all_positive = {
        let mut n_neg = 0;
        for &x in &xs {
            if x == 0 { n_neg=0; break; };
            if x < 0 { n_neg += 1 };
        }
        n_neg % 2 == 0
    };
    let abss: Vec<i64> = xs.iter().map(|&x|x).map(i64::abs).collect();
    let m = vec_min(&abss);
    let mut ans = vec_sum(&abss);
    if !can_all_positive {
        ans -= m * 2;
    }
    println!("{}", ans);
}

#[allow(dead_code)]
fn get_line() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn get_vec<T: std::str::FromStr>() -> Vec<T> {
    let line = get_line();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn get_one<T: FromStr + Copy>() -> T {
    let v = get_vec();
    v[0]
}

#[allow(dead_code)]
fn get_pair<T: FromStr + Copy>() -> (T, T) {
    let v = get_vec();
    (v[0], v[1])
}

#[allow(dead_code)]
fn get_triple<T: FromStr + Copy>() -> (T, T, T) {
    let v = get_vec();
    (v[0], v[1], v[2])
}

#[allow(dead_code)]
fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}

#[allow(dead_code)]
fn vec_min(xs: &Vec<i64>) -> i64 {
    xs.iter().map(|&x|x).fold(std::i64::MAX, std::cmp::min)
}

#[allow(dead_code)]
fn vec_max(xs: &Vec<i64>) -> i64 {
    xs.iter().map(|&x|x).fold(std::i64::MIN, std::cmp::max)
}

#[allow(dead_code)]
fn vec_sum(xs: &Vec<i64>) -> i64 {
    xs.iter().fold(0, |acc, &x| acc+x)
}



Measured memory_bytes: 8444
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

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

    void run() {

        int n = sc.nextInt();
        int[] arr = new int[n];
        int cnt = 0;
        int min = Integer.MAX_VALUE;
        boolean zero = false;
        long sum = 0;
        for (int i=0; i<n; i++) {
            arr[i] = sc.nextInt();
            if (arr[i] < 0) cnt++;
            min = Math.min(min, Math.abs(arr[i]));
            if (arr[i] == 0) zero = true;
            sum += Math.abs(arr[i]);
        }

//        System.out.println(zero);
//        System.out.println(cnt);

        if (zero || (cnt % 2 == 0)) {
            System.out.println(sum);
        } else {
            System.out.println(sum - 2 * min);
        }





    }

    int gcd(int m, int n) {
        if (n == 0) return m;
        return gcd(n, m%n);
    }


}



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

int main()
{
    char s[10], t[10], u[10];
    int a, b;

    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if (strcmp(s, u) == 0)
        a--;
    else
        b--;

    cout << a << ' ' << b;

    return 0;
}

Measured memory_bytes: 256
import collections
n = int(input())
c = input()
c_ls = []
Ws = collections.deque()
for i in range(n):
    c_ls.append(c[i])
    if c[i] == "W":
        Ws.append(i)
ans = 0
for i in range(n-1,-1,-1):
    if c_ls[i] == "R" and len(Ws):
        w = Ws[0]
        if i > w:
            c_ls[i] = "W"
            c_ls[w] = "R"
            ans += 1
            Ws.popleft()
    elif c_ls[i] == "W" and len(Ws) == 0:
        ans += 1
#print(c_ls)
print(ans)


Measured memory_bytes: 91096
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>

#define inf 0x3f3f3f3f

#define lc k << 1
#define rc k << 1 | 1

using namespace std;

typedef long long ll;

int n, k;
int a[10005];
ll tot = 1, tot2 = 1;
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++){
		scanf("%d", &a[i]);
		tot *= 3ll;
		if(a[i] % 2 == 0) tot2 *= 2ll;
	}
	printf("%lld\n", tot - tot2);
	return 0;
}

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

const int MAX_N = 102;
const int INF = 1<<27;
int N;
int G[MAX_N][MAX_N];

void init() {
  fill(G[0], G[MAX_N], INF);
  for(int i = 0; i < N; ++i) G[i][i] = 0;
}

void wf() {
  for(int k = 0; k < N; ++k)
    for(int i = 0; i < N; ++i)
      for(int j = 0; j < N; ++j)
	G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
}

int solve(int s, int g1, int g2) {
  wf();

  int ans = INF;
  for(int i = 0; i < N; ++i)
    ans = min(ans, G[s][i] + G[i][g1] + G[i][g2]);

  return ans;
}

int main() {
  int m, s, g1, g2;
  while(cin>>N>>m>>s>>g1>>g2&&(N|m|s|g1|g2)) {
    --s; --g1; --g2;
    init();
    for(int i = 0; i < m; ++i) {
      int b1, b2, c;
      cin >> b1 >> b2 >> c;
      --b1; --b2;
      G[b1][b2] = c;
    }
    cout << solve(s,g1,g2) << endl;
  }
  return 0;
}

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

int main() {
  int P, Q, R, ans;
  cin >> P >> Q >> R;
  vector<int> vec = {P, Q, R};
  sort (vec.begin(), vec.end());
  ans = vec.at(0) + vec.at(1);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using FLOAT = double;
struct Point{
    FLOAT x, y;
    FLOAT operator * (const Point& point)const{return x * point.x + y * point.y;}
    FLOAT norm2()const{return x * x + y * y;}
    Point operator - (const Point& point)const{return {x - point.x, y - point.y};}
    Point operator + (const Point& point)const{return {x + point.x, y + point.y};}
    Point operator * (const FLOAT& k)const{return {k * x, k * y};}
};
Point operator * (const FLOAT& k, const Point& point){return point * k;}
struct Line{
    Point A, B;
    Point AB()const{return B - A;}
};
Point projection(const Point& point, const Line& line){
    return line.A + (point - line.A) * line.AB() / line.AB().norm2() * line.AB();
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(20);
    Line line;
    cin >> line.A.x >> line.A.y >> line.B.x >> line.B.y;
    int q;
    cin >> q;
    for(int i = 0; i < q; i += 1){
        Point point;
        cin >> point.x >> point.y;
        auto result = projection(point, line);
        cout << result.x << " " << result.y << "\n";
    }
    return 0;
}


Measured memory_bytes: 3308
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll a,b;
	cin>>a>>b;
	if(a==1 or b==1) {cout<<1;return 0;}
	ll t = (a*b)/2;
	if((a*b)%2) cout<<t+1;
	else cout<<t;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
using namespace std;
const int mod = 1000000007;




int main() {

    int64_t N, ans = 0;
    cin >> N;
    //vector<int> A(N);
    for (int i = 1; i <= N; i++) { if (i % 3 != 0 && i % 5 != 0)ans += i; }
    //vector<vector<int>> A(N,vector<int>(M));
    //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
    //sort(A.begin(),A.end());
    //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
    //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<vector>

#define MN 100000
#define DC -1

using namespace std;

typedef struct{
  int color = DC;
  vector<int> nei;
}Tree;

vector<Tree> trees;
//vector<int> fennec, sunuke;
//vector<int> *player[2] = {&fennec, &sunuke};
vector<int> player[2];
//int cfennec = 0, csunuke = 0;
int cnt[2] = {0, 0};

// 塗れれば1を返す．濡れなければ0を返す．
int explore(int c){
  int m = player[c].size();
  int flag = 0;
  for( int i = cnt[c]; i < m; i++ ){
	int l = trees[player[c][i]].nei.size();
	for( int j = 0; j < l; j++ ){
	  int np = trees[player[c][i]].nei[j];
	  if( trees[np].color != DC ){ continue; }
	  trees[np].color = c;
	  player[c].push_back(np);
	  flag = 1;
	}
  }
  cnt[c] = m;
  return flag;
}

int main(){
  int N;
  int a, b;
  cin >> N;
  trees.resize(N);
  for( int i = 0; i < N-1; i++ ){
	cin >> a >> b;
	a--; b--;
	trees[a].nei.push_back(b);
	trees[b].nei.push_back(a);
  }
  trees[0].color = 0;
  trees[N-1].color = 1;
  player[0].push_back(0);
  player[1].push_back(N-1);
  
  int ff, fs;
  do{
	ff = explore(0);
	fs = explore(1);
  }while( ff != 0 || fs != 0 );
  //cout << player[0].size() << "," << player[1].size() << endl;
  if( player[0].size() > player[1].size() ){
	cout << "Fennec" << endl;
  }else{
	cout << "Snuke" << endl;
  }
  return 0;
}

Measured memory_bytes: 7124
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	int a, b;
	cin >> a >> b;
	if (a > b)
		swap(a, b);
	rep(i, b) {
		cout << (char)((int)('0') + a);
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;


class Main {
    public static void main2(String args[]) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();


        int l= Integer.toString(n,k).length();

        System.out.println(l);


    }
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        List<Integer>x=new ArrayList<>();
        for (int i = 0; i < n; i++) {
            x.add(s.nextInt());
        }
        List<Integer>buf=new ArrayList<>();
        buf.add(Integer.MAX_VALUE);
        for (int i = 1; i <101 ; i++) {
            buf.add(0);
        }

        for (int j = 1; j <=100 ; j++) {
            for (int i = 0; i <n ; i++) {
                int a=buf.get(j)+(int)Math.pow(x.get(i)-j,2);
                buf.set(j,a);
            }
        }

        Collections.sort(buf);
        System.out.println(buf.get(0));




    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	long long A, B, C;
	cin >> A >> B >> C;

	int result = 0;
	while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0)
	{
		result++;
		if (result >= 30)
		{
			cout << -1;
			return 0;
		}

		long long na = A / 2;
		long long nb = B / 2;
		long long nc = C / 2;

		A = nb + nc;
		B = na + nc;
		C = na + nb;
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ManyFunctions
{
	public static class Program
	{
		public static void Main(string[] args)
		{
			var s = Console.ReadLine();

			Console.WriteLine(ManyFunctions(s, ""));
		}

		public static long ManyFunctions(string s, string sp)
		{
			if(s.Length == 1) {
				return (sp + s).Split('+').Select(x => long.Parse(x)).Sum();
			}

			long sum = 0;

			string sFirst = s.Substring(0, 1);

			sp += sFirst;
			s = s.Remove(0, 1);

			//+を挿入する
			sum += ManyFunctions(s, sp + "+");

			//+を挿入しない
			sum += ManyFunctions(s, sp);

			return sum;
		}
	}
}


Measured memory_bytes: 13268
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author iavanish
 */
public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ACirclePond solver = new ACirclePond();
        solver.solve(1, in, out);
        out.close();
    }

    static class ACirclePond {

        private static final double pie = 3.14159265358979323846;

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            double r = in.nextInt();
            out.println(2.0 * pie * r);
        }

    }

    static class FastReader {

        private final int BUFFER_SIZE = 1 << 16;
        private final InputStream inputStream;
        private final byte[] buffer;
        private int bufferPointer;
        private int bytesRead;

        public FastReader() {
            this.inputStream = new DataInputStream(System.in);
            this.buffer = new byte[BUFFER_SIZE];
            this.bufferPointer = bytesRead = 0;
        }

        public FastReader(InputStream inputStream) {
            this.inputStream = inputStream;
            this.buffer = new byte[BUFFER_SIZE];
            this.bufferPointer = bytesRead = 0;
        }

        public FastReader(String fileName) {
            try {
                this.inputStream = new DataInputStream(new FileInputStream(fileName));
                this.buffer = new byte[BUFFER_SIZE];
                this.bufferPointer = bytesRead = 0;
            } catch (FileNotFoundException e) {
                throw new RuntimeException(e);
            }
        }

        public int nextInt() {
            int nextInt = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean negative = (c == '-');
            if (negative) {
                c = read();
            }
            do {
                nextInt = nextInt * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (negative) {
                return -nextInt;
            }
            return nextInt;
        }

        private void fillBuffer() {
            try {
                bytesRead = inputStream.read(buffer, bufferPointer = 0, BUFFER_SIZE);
                if (bytesRead == -1) {
                    buffer[0] = -1;
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        private byte read() {
            if (bufferPointer == bytesRead) {
                fillBuffer();
            }
            return buffer[bufferPointer++];
        }

    }

}



Measured memory_bytes: 25644
# ABC058C - 怪文書 / Dubious Document (ARC071C)
from string import ascii_lowercase


def main():
    n = int(input())
    lst = [input().rstrip() for _ in range(n)]
    ans = ""
    for c in ascii_lowercase:
        cnt = float("inf")
        for i in lst:
            cnt = min(cnt, i.count(c))
        ans += c * cnt
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3772
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		
		if(n<1200) {
			System.out.println("ABC");
			return;
		}else if(n<2800) {
			System.out.println("ARC");
			return;
		}else {
			System.out.println("AGC");
		}
	}
}


Measured memory_bytes: 21972