akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{

    class Program
    {
        class Node {
            internal bool visted;
            internal List<int> adj;
            internal int d, f;
            public Node() {
                d = f = 0;
                adj = new List<int>();
                visted = false;
                
            }
        }
        static int cnt;
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            Node[] nodes = new Node[n + 1];
            for (int i = 0; i < n; i++)
            {
                int[] temp = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                nodes[temp[0]] = new Node();
                for (int k = 0; k < temp[1]; k++)
                {
                    nodes[temp[0]].adj.Add(temp[k + 2]);
                }
            }

            cnt = 1;
            for (int i = 1; i <= n; i++)
                if(!nodes[i].visted) DFS(nodes, nodes[i]);

            for (int i = 1; i <= n; i++)
                Console.WriteLine(i + " " + nodes[i].d + " " + nodes[i].f);

        }

        static void DFS(Node[] nodes, Node node) {
            node.d = cnt++; node.visted = true;
            for (int i = 0; i < node.adj.Count; i++) {
                if (!nodes[node.adj[i]].visted) DFS(nodes, nodes[node.adj[i]]);
            }
            node.f = cnt++;
        }
		
    }
}




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

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}


int main()
{
    char str;
    cin >> str;
    str += 1;
    cout << str << endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const ll B = 1000000007;
ll calcHash(string s){
  int n = s.length();
  ll key = 0;
  FOR(i,0,n){
    key = key * B + s[i];
  }
  return key;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<ll> v1[n+1];
  FOR(i,0,1<<n){
    string t="", tb="";
    int cnt = 0;
    FOR(j,0,n){
      if(i & (1 << j)){
        t += s[j];
        cnt++;
      } else {
        tb += s[j];
      }
    }
    reverse(tb.begin(), tb.end());
    t += tb;
    v1[cnt].push_back(calcHash(t));
  }
  FOR(i,0,n+1) sort(v1[i].begin(), v1[i].end());
  ll ans = 0;
  reverse(s.begin(), s.end());
  FOR(i,0,1<<n){
    string t="", tb="";
    int cnt = 0;
    FOR(j,0,n){
      if(i & (1 << j)){
        t += s[j];
        cnt++;
      } else {
        tb += s[j];
      }
    }
    reverse(tb.begin(), tb.end());
    t += tb;
    ll hs = calcHash(t);
    ans += max(0LL, (ll)(upper_bound(v1[cnt].begin(), v1[cnt].end(), hs) - lower_bound(v1[cnt].begin(), v1[cnt].end(), hs)));
  }
  cout << ans << endl;
}

Measured memory_bytes: 2784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
#define _GLIBCXX_DEBUG
     
int main() {
  int n, count=0, ans=0;
  cin >> n;

for (int i=1; i<=n; i+=2) {
  for (int j=1; j<=i; ++j) {
    if (i%j == 0) ++count;
  }
  if (count == 8) ++ans;
  count = 0;
}

cout << ans << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e5+5;
int n,pre[N][2],suf[N][2];
char s[N];
int main()
{
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	cin>>n;
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)
	{
		pre[i][0]=pre[i-1][0];
		pre[i][1]=pre[i-1][1];
		if(s[i]=='W')
			pre[i][0]++;
		else
			pre[i][1]++;
	}
	for(int i=n;i>=1;i--)
	{
		suf[i][0]=suf[i+1][0];
		suf[i][1]=suf[i+1][1];
		if(s[i]=='W')
			suf[i][0]++;
		else
			suf[i][1]++;
	}
	int res=2e9;
	for(int i=1;i<=n;i++)
		res=min(res,pre[i-1][0]+suf[i+1][1]);
	cout<<res<<'\n';
	return 0;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)


int N, K; string S;
//-----------------------------------------------------------------
inline char getrev(char c, int m) {
	int cc = c - 'A';
	if (m % 2 == 1) cc = 1 - cc;
	return char('A' + cc);
}
//-----------------------------------------------------------------
int main() {
	cin >> N >> K >> S;

	deque<char> deq;
	string ans = "";
	rep(i, 0, N) deq.push_back(S[i]);
	int cnt = 0, rev = 0, done = 0;
	while (!deq.empty()) {
		// 右側を詰める
		while (!deq.empty()) {
			if (getrev(deq.back(), rev) == getrev('A', done)) {
				deq.pop_back();
				ans = getrev('A', done) + ans;
				done++;
			} else {
				break;
			}
		}
		if (deq.empty()) break;

		// 変換
		if (getrev(deq.front(), rev) == 'A') {
			// パターン1
			cnt++;
			char c = deq.front(); deq.pop_front();
			deq.push_front(getrev(c, 1));
		} else {
			// パターン2
			cnt++;
			deq.pop_front();
			rev++;
			ans = getrev('A', done) + ans;
			done++;
		}

		if (cnt == K) break;
	}

	if (!deq.empty()) {
		while (!deq.empty()) {
			ans = getrev(deq.back(), rev) + ans;
			deq.pop_back();
		}
		cout << ans << endl;
		return 0;
	}

	int d = K - cnt;
	if (N % 2 && d % 2) ans[0] = 'B';
	cout << ans << endl;
}

Measured memory_bytes: 1296
a=input()
if a=="SUN":
  print(7)
elif a=="MON":
  print(6)
elif a=="TUE":
  print(5)
elif a=="WED":
  print(4)
elif a=="THU":
  print(3)
elif a=="FRI":
  print(2)
else:
  print(1)

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;

const int M = 256;

int main()
{
  while(1){
    int N;
    cin >> N;
    if(N == 0) break;
    int I[N+1];
    for(int i = 1; i <= N; i++)
      cin >> I[i];
    int R[N+1], O[N+1], S, A, C;
    double H = 1.0;
    set<int> s;
    for(int i = 0; i <= 15; i++){
      R[0] = i;
      for(int j = 0; j <= 15; j++){
        for(int k = 0; k <= 15; k++){
          s.clear();
          for(int l = 1; l <= N; l++){
            R[l] = (j*R[l-1]+k) % M;
            O[l] = (I[l]+R[l]) % M;
            s.insert(O[l]);
          }
          double h = 0.0;
          for(set<int>::iterator ite = s.begin(); ite != s.end(); ite++){
            double a = (double)count(O+1,O+N+1,*ite);
            h -= a*log(a);
          }
          h /= (double)N;
          if(H > h){
            H = h;
            S = i;
            A = j;
            C = k;
          }
        }
      }
    }
    cout << S << " " << A << " " << C << endl;
  }
}

Measured memory_bytes: 1248
import numpy as np
import sys
input = sys.stdin.readline
N, W = map(int, input().split())
vmax = 1000*100+1
wmax = 100*10**9
dp = np.ones(vmax, dtype='int64') * wmax
dp[0] = 0

for i in range(N):
    wi, vi = map(int, input().split())
    ndp = np.copy(dp)
    ndp[vi:] = np.fmin(dp[vi:], dp[:-vi] + wi)
    dp = ndp

print(np.where(dp<=W)[0][-1])



Measured memory_bytes: 25420
#include<stdio.h>
int main(){
  int a,b,i,n,m,h[100010],c[100010]={};
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)scanf("%d",&h[i+1]);
  while(m--){
    scanf("%d %d",&a,&b);
    if(h[a]==h[b])c[b]=c[a]=1;
    if(h[a]>h[b])c[b]=1;
    if(h[a]<h[b])c[a]=1;
  }
  //for(i=0;i<n;i++)printf("%d\n",c[i+1]);
  for(i=a=0;i<n;i++)a+=1-c[i+1];
  printf("%d\n",a);
  return 0;
}


Measured memory_bytes: 2468
import java.util.Scanner;

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

   int a = sc.nextInt();
   int b = sc.nextInt();
   int area = a*b;
   int length = 2*a+2*b;
   System.out.println(area+" "+length);
  }
}

Measured memory_bytes: 26308
n, m = list(map(int, input().split()))
ab, cd = [], []
for _ in range(n):
    ab.append(list(map(int, input().split())))
for _ in range(m):
    cd.append(list(map(int, input().split())))

for a, b in ab:
    dist = 10 ** 9
    for i, (c, d) in enumerate(cd, 1):
        tmp = abs(a - c) + abs(b - d)
        if tmp < dist:
            dist = tmp
            ans = i
    print(ans)


Measured memory_bytes: 3064
/*
 _____ ____ _____   ___   ___  __  ___  
|_   _/ __ \_   _| |__ \ / _ \/_ |/ _ \ 
  | || |  | || |      ) | | | || | (_) |
  | || |  | || |     / /| | | || |\__, |
 _| || |__| || |_   / /_| |_| || |  / / 
|_____\____/_____| |____|\___/ |_| /_/   
*/
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (long long i = (a); i > (b); i--)
#define a(x) (x.begin(), x.end())
#define ar(x) (x.rbegin(), x.rend())
#define pb push_back
#define Pb() pop_back()
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sc scanf
#define scin(x) sc("%d", &(x))
#define scln(x) sc("%lld", &(x))
#define pf prllf
#define ms(a, b) memset(a, b, sizeof(a))
#define mp make_pair
#define db double
#define EPS 10E-10
#define ff first
#define ss second
#define sqr(x) (x) * (x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define DBG pf("HI\n")
#define MOD 1000000007
#define CIN                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++)
#define CASE(t) prllf("Case %d: ", t)
#define CASEL(t) prllf("Case %d:\n", t)
#define intlimit 2147483647
#define longlimit 9223372036854775807
#define infinity (1 << 28)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 2 * acos(0.0)
using namespace std;
int main()
{
    CIN;
    int n;
    cin >> n;
    vi v(n);
    int maxin=0,sum=0;
    rep(i,0,n){
        cin >> v[i];
    }
    int temp = v[0],coco=0;
    rep(i,1,n){
        if(v[i]<=temp){
            sum++;
            temp = v[i];
        }else{
            coco++;
            maxin = max(maxin,sum);
            sum = 0;
            temp = v[i];
        }
    }
    maxin = max(maxin,sum);
    if(coco==n-1){
        cout << 0;
        return 0;
    }
    cout << maxin;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
main()
{
    char s[111] , a[111];
    while (~scanf("%s%s", s , a)){
        if (s[0]==a[2] && s[1]==a[1] && s[2]==a[0])  puts("YES");
        else  puts("NO");
    }
    return 0;
}

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

    using namespace std;
    typedef long long ll;
    # define M_PI  3.14159265358979323846

    void solve(){
        int a;
        cin>>a;
        int k=a + (a*a) + (a*a*a);
        cout<<k;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <unordered_map>
using namespace std;

#define ll long long

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

    vector<ll> sum(N);
    unordered_map<ll, ll> backmap;
    for (ll i = 0; i < N; i++)
    {
        ll A;
        scanf("%lld", &A);
        if (i - A > 0)
            backmap[i - A]++;
        sum[i] = i + A;
    }

    ll ans = 0;
    for (ll i = 0; i < N; i++)
        ans += backmap[sum[i]];
    printf("%lld\n", ans);
}


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

int main(){
	int n;cin>>n;
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(to_string(i).size()%2==1)cnt++;
	}
	cout<<cnt<<endl;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    char large_square[n][n+1], small_square[m][m+1];
    
    for(int i=0; i<n; i++){
        cin >> large_square[i];
    }
    for(int i=0; i<m; i++){
        cin >> small_square[i];
    }
    int flag;
    for(int i=0; i<n-m+1; i++){
        for(int j=0; j<n-m+1; j++){
            flag=0;
            for(int k=0; k<m; k++){
                for(int l=0; l<m; l++){
                    if(large_square[i+k][j+l]!=small_square[k][l]){
                        flag=1;
                        break;
                    }
                }
            }
            if(flag==0){
                break;
            }
        }
        if(flag==0){
            break;
        }
    }
    if(flag==0){
        cout << "Yes";
    }else{
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        long k=sc.nextLong();
        if(s.length()>1){
            if(s.charAt(0)=='1'){
                int count=0;
                for(int i=0;i<s.length();i++){
                    if(s.charAt(i)!='1'){
                        break;
                    }
                    else{
                        count++;
                    }
                }
                //System.out.println("count="+count);
                if(k>count){
                    System.out.println(s.charAt(count));
                }
                else{
                    System.out.println(s.charAt(0));
                }
            }
            else{
                System.out.println(s.charAt(0));
            }
        }
        else{
            System.out.println(s.charAt(0));
        }
    }    
}

Measured memory_bytes: 22740
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <limits>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define print_double(val,a) cout << fixed << setprecision(a) << val << endl;
ll mod = 1e9 + 7;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin>>n;
  if(n==3||n==5||n==7){cout<<"YES"<<endl;}
  else{cout<<"NO"<<endl;}
	return 0;
}


Measured memory_bytes: 256
I=input;n,m=map(int,I().split());a=[I()for _ in[0]*n];b=[I()for _ in[0]*m];print('YNeos'[all(b!=[t[j:j+m]for t in a[i:i+m]]for i in range(n-m+1)for j in range(n-m+1))::2])

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

#define _overload3(_1,_2,_3,name,...) name
#define all(a,n) (a),(a)+n
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define out(v) cout<<v<<"\n"

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

  int L[N];
  rep(i, N) {
    cin >> L[i];
  }
  sort(all(L, N));
  int ans = 0;
  rep(i, N) rep(j, i+1, N) {
    int l = upper_bound(all(L, N), abs(L[j] - L[i])) - L;
    int r = lower_bound(all(L, N), L[i] + L[j]) - L;
    // [l, r)
    l = max(l, j+1);
    ans += max(0, r - l);
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

ll N,K;
int main() {
  cin >> N >> K;
  vll C(N), P(N);
  rep(i,N) {
    cin >> P[i];
    P[i]--;
  }
  rep(i,N) cin >> C[i];

  ll ans =-LINF;
  // if sum of loop is positive, go K/sizeofloop loops and go as much as possible in addition
  // else go as much as possible
  rep(s,N) {
    vi score;
    int v = s;
    ll tot = 0;
    while (1) {
      v = P[v];
      score.push_back(C[v]);
      tot += C[v];
      if (v == s) break;
    } 
    int len = score.size();
    ll t = 0;
    rep(i,len) {
      if (i+1 > K) break;
      t += score[i];
      ll now = t;
      if (tot > 0) {
        int rest = (K-i-1)/len;
        now += rest*tot;
      }
      chmax(ans,now);
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 3816
#include<iostream>
#include<vector>
#include<map>
using namespace std;
 
int main()
{
    // get two integers separated with half-width break
    int N; long int M;
    cin >> N >> M;

    // get a string
    map<int, long int> v2c;
    for(int i = 0; i < N; ++i){
      int a,b;
      cin >> a >> b;

      v2c[a] += b;
    }
    // output
    map<int, long int> ::iterator mit = v2c.begin();
    while(mit != v2c.end() && M > 0){
      M -= mit->second;
      ++mit;
    }
    --mit;
    cout << mit->first << endl;
    return 0;
}

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

void solve()
{
    	   
 int n; cin>>n;
 int a[n][3];   for(int i=0;i<n;i++)cin>>a[i][0]>>a[i][1]>>a[i][2];
 
 int dp[n][3];
 dp[0][0]=a[0][0];
 dp[0][1]=a[0][1];
 dp[0][2]=a[0][2];
 
 for(int i=1;i<n;i++)
 {
     dp[i][0]=max(a[i][0]+dp[i-1][1],a[i][0]+dp[i-1][2]);
     dp[i][1]=max(a[i][1]+dp[i-1][0],a[i][1]+dp[i-1][2]);
     dp[i][2]=max(a[i][2]+dp[i-1][0],a[i][2]+dp[i-1][1]);
 }
 
 int ans=max(dp[n-1][0],dp[n-1][1]);
 ans=max(ans,dp[n-1][2]);
 cout<<ans;
}
 
 
 signed main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    
    
    
    int T; 
    T=1;
    //cin>>T;
    while(T--)
    {
          solve();
    }
    
    
        return 0;
	
}

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 90000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

int main(){
  //cout <<'1'<< endl;
  ll A,B,q;
  cin >> A >> B >> q;
  vector<ll> S(A+2);
  vector<ll> T(B+2);
  vector<ll> Q(q);
  S[0] = -INF;S[A+1] = INF;
  T[0] = -INF;T[B+1] = INF;
  for(int i = 1;i <= A;i++){
    cin >> S[i];
  }
  for(int i = 1;i <= B;i++){
    cin >> T[i];
  }
  /*for(int i = 1;i <= A;i++){
    cout << S[i] << ' ';
  }
  cout << endl;
  for(int i = 1;i <= B;i++){
    cout << T[i] << ' ';
  }
  cout << endl;*/
  for(int i = 0;i < q;i++){
    cin >> Q[i];
  }

  for(int i = 0;i < q;i++){
    ll a = 0,b = 0;
    ll l = 0,r = A+1;
    while(r-l > 1){
      ll mid = (r+l)/2;
      if(S[mid] >= Q[i]){
        r = mid;
      }else{
        l = mid;
      }
    }
    a = r;
    l = 0,r = B+1;
    while(r-l > 1){
      ll mid = (r+l)/2;
      if(T[mid] >= Q[i]){
        r = mid;
      }else{
        l = mid;
      }
    }
    b = r;
    //cout << a << ' ' << b << endl;
    ll d = abs(Q[i]-max(S[a],T[b]));
    ll e = abs(Q[i]-min(S[a-1],T[b-1]));
    ll f = abs(Q[i]-S[a])*2+abs(Q[i]-T[b-1]);
    ll g = abs(Q[i]-T[b])*2+abs(Q[i]-S[a-1]);
    ll h = abs(Q[i]-S[a-1])*2+abs(Q[i]-T[b]);
    ll k = abs(Q[i]-T[b-1])*2+abs(Q[i]-S[a]);
    //cout << d << ' ' << e << ' ' << f << ' ' << g << ' ' << h << ' ' << k << endl;
    cout << min({d,e,f,g,h,k}) << endl;
  }
}



Measured memory_bytes: 3712
#include<stdio.h>
int main()
{
	int a,b,c,i;
	scanf("%d%d%d",&a,&b,&c);
	if(a<b){i=a; a=b; b=i;}
	if(b<c){i=b; b=c; c=i;}
	if(a<b){i=a; a=b; b=i;}
	i=a*10+b+c;
	printf("%d\n",i);
}

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

int main(){
        string N;
        cin >> N;
        bool flagA = false;
        bool flagB = false;
        for(char x :N) {
                if(x == 'A') flagA = true;
                else flagB = true;
        }
        if(flagA && flagB) cout << "Yes" << endl;
        else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long dparr[105][100005];
int arr1[105];
int arr2[105];
int w,n;
int max(int x, int y)
{
    if(x>y)
        return x;
    else 
        return y;
}
long long solve(int index, int weight)
{
    if(weight>w)
        return 0;
    else if(index<1)
        return 0;
    else if(dparr[index][weight]==-1)
    {
        dparr[index][weight]=max(solve(index-1,weight),solve(index-1,weight+arr1[index])+arr2[index]);
        if(weight+arr1[index]>w)
            dparr[index][weight]=solve(index-1,weight);
        return dparr[index][weight];
    }
    else 
        return dparr[index][weight];
}
int main()
{
    cin >> n >> w;
    for(int i=1;i<=n;i++)
    {
        cin >> arr1[i];
        cin >> arr2[i];
    }
    // for(int i=1;i<=n;i++)
    // {
    //     cout << arr2[i];
    // }
    for(int i=0;i<105;i++)
    {
        for(int j=0;j<100005;j++)
        {
            dparr[i][j]=-1;
        }
    }
    long long ans=solve(n,0);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 82432
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

    List<Integer> numList = new ArrayList<Integer>();
    int count = 0;
		for(int i = 1;i<=n;i++){
		  //1からnまでのすべての整数に対して実行
		  if(i%2==0){
		    continue;
		  }
		  for(int j = 1;j<=i;j++){
		    if(i%j==0){
		      //約数があればカウントを増やす
		      count++;
		    }
  		  if(count>8){
  		    //8個以上見つかった段階で次へ
	  	    break;
		    }
		  }
		  if(count==8){
		    numList.add(i);
		  }
		  count = 0;
		}
		System.out.println(numList.size());
	}
}

Measured memory_bytes: 20820
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x7f
#define MAX_INF_VAL 0x7f7f7f7f
#define pi 3.141592653589
#define eps 1e-10
//#define p 2173412051LL
#define sz 2

using namespace std;

int main() {
	int n, m, x;
	scanf( "%d%d", &n, &m );
	x = n / m;
	if( n % m )
		++x;
	printf( "%d", x );
	return 0;
}

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

int main(){
  int S, h, m, s;

  cin >> S;

  h = S / 3600;
  m = (S - h*3600) / 60;
  s = (S - h*3600 - m*60);
  
  cout << h << ":" << m << ":" << s << endl;

  return 0;
}



Measured memory_bytes: 3096
import math
n = int(input())
x = list(map(float, input().split()))
y = list(map(float, input().split()))

D1 = 0.0
for i in range(n):
    D1 += abs(x[i] - y[i])

D2 = 0.0
for i in range(n):
    D2 += (x[i] - y[i])**2
D2 = math.sqrt(D2)

D3 = 0.0
for i in range(n):
    D3 += (abs(x[i] - y[i]))**3
D3 = D3**(1 / 3)

Dinf = 0.0
for i in range(n):
    Dinf = max(Dinf, abs(x[i] - y[i]))

print("{:10f}".format(D1))
print("{:10f}".format(D2))
print("{:10f}".format(D3))
print("{:10f}".format(Dinf))



Measured memory_bytes: 5724
#include<stdio.h>
int main(void){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(a*b<c*d){
    printf("%d",c*d);
  }
  else{
    printf("%d",a*b);
  }
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 10000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   ll n, ans = INF, sum_less_b = 0, sum_c = 0;
   cin >> n;
   vector<ll> a(n, 0LL), c(n, 0LL);
   for (ll i = 0LL; i < n; i++)
   {
      cin >> a[i];
      c[i] = a[i] - i - 1LL;
   }
   sort(c.begin(), c.end());
   for (ll i = 0LL; i < n; i++)
      sum_c += c[i];
   ans = sum_c - n * c[0];
   for (ll i = 0LL; i < n - 1LL; i++)
   {
      sum_less_b += c[i];
      ll tmp = sum_c - 2LL * sum_less_b;
      if (2LL * (i + 1LL) >= n)
         tmp += (2LL * (i + 1LL) - n) * c[i];
      else
         tmp += (2LL * (i + 1LL) - n) * c[i + 1LL];
      ans = min(ans, tmp);
   }
   cout << ans << endl;
   return 0;
}


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




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

  int no1=0,no2=0,no3=0;
  for(int i=0;i<N;++i){
      if(P[i]<=A) no1++;
      else if(P[i]<=B) no2++;
      else no3++;
  }
  int ans = min(no1,min(no2,no3));
  cout << ans << endl;

  return 0;
}

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

int main()
{
	int A, B, C, D;

	cin >> A >> B >> C >> D;

	if (A + B > C + D) {
		cout << "Left";
	}
	else if (A + B < C + D) {
		cout << "Right";
	}
	else {
		cout << "Balanced";
	}

	return 0;
}

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

int main()
{
    int a,b,c,k;
    cin >> a >> b >> c >> k;

    if ( k <= a ) {
        cout << k << endl;
    } else if ( k > a && k <= a + b) {
        cout << a << endl;
    } else {
        cout << a + (a + b - k) << endl; 
    }
    return 0;
}

Measured memory_bytes: 3636
A,B,C,X,Y = map(int,input().split())

if A+B<=2*C:
    print(A*X+B*Y)
else:
    if X>=Y:
        print(2*C*min(X,Y)+min(2*C*(X-Y),A*(X-Y)))
    else:
        print(2*C*min(X,Y)+min(2*C*(Y-X),B*(Y-X)))

Measured memory_bytes: 3060
//Kriti Verma
#include<bits/stdc++.h>
#define     ll          long long
#define     MOD         1000000007
#define     pb          push_back
#define     vll         vector<long long>
#define     vi          vector<int>
#define     vl          vector<long>
#define     pii         pair<int, int>
#define     pll         pair<ll,ll>
#define     mp          make_pair
#define     all(a)      (a).begin(),(a).end()
#define     rep(i,a,b)  for(int i=a;i<b;i++)
#define     lcm(a,b)    (a*b)/__gcd(a,b)
#define     MAX         100002 
#define     ios          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;


int main() {
    
    ios
    string str;
    cin >> str;
    ll n=str.length();
    if(str[n-1]=='s')str+="es";
    else str+="s";
    cout << str;
    return 0;
}



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

int main()
{
  int64_t N, a, od = 0;
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> a;
    if (a % 2)
      od++;
  }
  cout << ((od % 2) ? "NO" : "YES") << endl;
}

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

#define int long long
int T , A , B , C , D , now;

void add(int numa , int numb , int cnt = 1){
	if((!numa && !numb) || now > D) return;
	int len = numa + numb , tms = min(cnt , max(0ll , (C - now - 1) / len));
	cnt -= tms; now += len * tms;
	while(now <= D && cnt--){
		int len = numa , lft = max(C - now - 1 , 0ll);
		now += min(len , lft); len -= min(len , lft);
		while(len-- && ++now <= D) putchar('A');
		len = numb; lft = max(C - now - 1 , 0ll);
		now += min(len , lft); len -= min(len , lft);
		while(len-- && ++now <= D) putchar('B');
	}
}

signed main(){
	for(cin >> T ; T ; --T){
		cin >> A >> B >> C >> D; now = 0;
		int t = (A + B) / min(A + 1 , B + 1) , l = 0 , r = A / t;
		while(l < r){int mid = (l + r + 1) >> 1; t * (A - t * mid) >= B - mid ? l = mid : r = mid - 1;}
		add(t , 1 , l); A -= l * t; B -= l;
		if(!B){add(A , 0); putchar('\n'); continue;}
		int numa = ((A + 1) * t - B) / t; A -= numa; add(numa , B - t * A); add(1 , t , A);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a,n) sort(a, a + n)
#define vi vector<int>
#define vd vector<double>

//ここからAtCoder向けdefine
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    int n;
    if(a + b + 1 != s.size()){
        no;
        return 0;
    }
    rep(i, s.size()){
        if(i < a){
            n = (int)s.at(i);
            if(n < 48 || n > 57){
                no;
                return 0;
            }
        }
        else if(i == a){
            if(s.at(i) != '-'){
                no;
                return 0;
            }
        }else{
            n = (int)s.at(i);
            if(n < 48 || n > 57){
                no;
                return 0;
            }
        }
    }
    yes;

    return 0;
}

Measured memory_bytes: 888
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

// End of template.


int main(){
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    int a[30];
    int b[30];
    int c[30];
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n) a[i]--;
    rep(i, n) cin >> b[i];
    rep(i, n - 1) cin >> c[i];

    int ans = 0;

    int p = -100;
    rep(i, n) {
        ans += b[a[i]];
        if (p == a[i] - 1) {
            ans += c[a[i] - 1];
        }
        p = a[i];
    }

    print(ans);

    return 0;
}



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

# def
def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return x

def str_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return x

def int_map():
    return map(int,input().split())

def int_list():
    return list(map(int,input().split()))

def print_space(l):
    return print(" ".join([str(x) for x in l]))

# import
import numpy as np



# main code
X,K,D = int_map()

if X == 0:
    if K%2 == 0:
        print(0)
        exit()
    else:
        print(D)
        exit()
elif X>0:
    if D*K < X:
        print(X-D*K)
        exit()
    else:
        a = X%D
        N = X//D
        if (K-N)%2 == 0:
            print(a)
            exit()
        else:
            print(D-a)
            exit()
else:
    X = abs(X)
    if D*K < X:
        print(X-D*K)
        exit()
    else:
        a = X%D
        N = X//D
        if (K-N)%2 == 0:
            print(a)
            exit()
        else:
            print(D-a)
            exit()




Measured memory_bytes: 27132
//in the name of GOD//

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define sz(s) s.size()
int main(){
  int n,k;
  cin >> n >> k;
  int a[n],ans = 0;
  for(int i = 0;i < n;i++){
    cin >> a[i];
    if(a[i] >= k){
      ans++;
    }
  }
  cout << ans;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String s = sc.nextLine();
			char[] carray = s.toCharArray();

			boolean flg = true;
			for (char c : carray) {
				if (flg) {
					System.out.print(c);
				}
				flg = !flg;
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 28596
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
#define N 500050
#define M 200020
int mx=0,n,m,b[N],ans[N],tree[N<<1],last[N],h[N<<1];
struct node{int x,y,num;}a[M];
bool cmp(node x,node y){return x.y<y.y || (x.y==y.y && x.x<y.x);}
void insert(int x,int y){for(;x<=n;x+=x&-x) tree[x]+=y;}
int query(int x){
    int y=0;for(;x;x-=x&-x) y+=tree[x];
    return y;
}
int main(){
    scanf("%d",&n);
    scanf("%d",&m);int q=sqrt(n);
    for(int i=1;i<=n;i++) scanf("%d",&b[i]),last[i]=h[b[i]],h[b[i]]=i,mx=max(mx,b[i]);
    for(int i=1;i<=m;i++) scanf("%d%d",&a[i].x,&a[i].y),a[i].num=i;
    sort(a+1,a+m+1,cmp);int tmp=0;
    for(int i=1;i<=m;i++){
        while(tmp<a[i].y){
            tmp++;if(last[tmp]) insert(last[tmp],-1);
            insert(tmp,1);
        }ans[a[i].num]=query(tmp)-query(a[i].x-1);
    }for(int i=1;i<=m;i++) printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 17284
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


int main() {

  int tmp,num;
  string S;
  
  cin >> S;
  num=S.length();
  int r,b;
  for(int i=0;i<num;i++){
      if(S[i]=='0') r++;
      if(S[i]=='1') b++;
  }
  int answer;
  if(r==b){
    answer=num;
    cout <<answer <<endl;
    return 0;
  }
  if(r>b){
    answer=num-(r-b);
    cout << answer <<endl;
    return 0;
  }
  if(r<b){
    answer=num-(b-r);
    cout << answer <<endl;
    return 0;
  }
  
   
}


Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace kyoupuro
{
    class MainClass
    {
        public static void Main()
        {
            MainClass mainClass = new MainClass();
            //var myarray = mainClass.IntInit();
            //var myarray = new List<int>(Console.ReadLine().Split(' ').Select(int.Parse));
            mainClass.Start();
        }

        List<List<String>> Init() {
            int maxindex = int.Parse(Console.ReadLine());

            List<List<String>> array = new List<List<String>>();

            for (int i = 0; i < maxindex; i++)
                array.Add(new List<String>(Console.ReadLine().Split(' ')));

            return array;
        }

        List<List<int>> IntInit() {
            int maxindex = int.Parse(Console.ReadLine());

            List<List<int>> array = new List<List<int>>();

            for (int i = 0; i < maxindex; i++) {
                array.Add(new List<int>(
                    Console.ReadLine().Split(' ').Select(int.Parse)));
            }

            return array;
        }

        void Start() {
            var nm = new List<int>(Console.ReadLine().Split(' ').Select(int.Parse));
            var array = new int[nm[1]+1];
            foreach(var i in array) {
                array[i] = 0;
            }

            for (int i = 0; i < nm[0]; i++){
                var tmp = new List<int>(Console.ReadLine().Split(' ').Select(int.Parse));
                for (int j = 1; j < tmp[0]+1; j++){
                    array[tmp[j]]++;
                }
            }

            Console.WriteLine(array.Where(e => e == nm[0]).Count());
        }
    }
}


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

#define LL long long

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

	int a,b;
	cin>>a>>b;

	for(int i=1;i<=3;i++){
		if((a*b*i)%2 == 1){cout<<"Yes"<<endl;return 0;}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<double> a(n);
  rep(i, n) cin >> a[i];
  double sum = 0;
  rep(i, n) {
    sum+= 1/a[i];
  }
  cout << 1/sum << endl;
  return 0;
}

Measured memory_bytes: 3796
#include <cstdio>
#include <vector>
using namespace std;

typedef long long ll;
const int N = 1 << 18;
vector <pair <int, int> > s;
int a[N];
int n;

void dbg() {
	for (int j = 0; j < (int) s.size(); ++ j)
		printf("(%d, %d) ", s[j].first, s[j].second);
	puts("");
}

bool plus(int lim) {
	int i;
	for (i = (int) s.size() - 1; ~i && s[i].first == lim; -- i);
	if (!~i) return 0;
	if (!s[i].second) return 0;
	s[i].second --;
	int nw = s[i].first;
	if (!s[i].second) {
		for (int j = i; j < (int) s.size() - 1; ++ j) s[j] = s[j + 1];
		s.pop_back();
	}
	else ++ i;
	s.push_back({0, 0});
	for (int j = (int) s.size() - 1; j > i; -- j) s[j] = s[j - 1];
	s[i] = {nw + 1, 1};
	int x = 0;
	for (int j = (int) s.size() - 1; j > i; -- j) {
		x += s.back().second;
		s.pop_back();
	}
	if (x) s.push_back(make_pair(1, x));
	return 1;
}

bool chk(int lim) {
	s.clear();
	int len = 0;
	for (int i = 0; i < n; ++ i) {
		if (len > a[i]) {
			for (int j = (int) s.size() - 1; len > a[i]; -- j) {
				if (len - s[j].second < a[i]) {
					s[j].second -= len - a[i];
					len = a[i];
					break;
				}
				len -= s[j].second;
				s.pop_back();
			}
			if (!plus(lim)) return 0;
		}
		else if (len < a[i]) { s.push_back({1, a[i] - len}); len = a[i]; }
		else if (!plus(lim)) return 0;
//		dbg();
	}
	return 1;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i) scanf("%d", &a[i]);
	int lb = 1, rb = 1 << 30;
	while (lb < rb) {
		int md = (lb + rb) >> 1;
		if (chk(md)) rb = md;
		else lb = md + 1;
	}
	printf("%d\n", lb);
	return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <string>

using namespace std;

int main(){
  string s;
  cin >> s;
  int len = s.size();
  int cnt = 0;
  for(int i = 0; i < len/2; i++){
    if(s[i] != s[len -i-1]) {
      s[i] = s[len -i-1];
      cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
} 


Measured memory_bytes: 3628
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include <iomanip>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  string S;
  cin>>S>>S;
  cout<<"A"<<S[0]<<"C";
return 0;}


Measured memory_bytes: 3580
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    var N = nextLong()
    val ans = ArrayList<Char>()
    while (true) {
        val d = ((N - 1) % 26).toInt()
        ans.add(d.toChar() + 97)
        N = (N - 1) / 26
        if (N == 0L) break
    }
    println(ans.reversed().joinToString(""))
}

Measured memory_bytes: 36508
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,x,y;
vector<ll>v[100009];
ll dp[100009];

ll f(ll N){
	if (v[N].empty())return 0;
	if(dp[N]!=-1)return dp[N];
	ll z=0;
	for(int i=0; i<v[N].size(); i++){
		z=max(z,f(v[N][i])+1);
	}
	dp[N]=z;
	return dp[N];
}

int main(){
	cin >> n >> m;
	memset(dp,-1,sizeof dp);
	for(int i=1; i<=m; i++){
		cin >> x >> y;
		v[x].push_back(y);
	}
	ll jwb=0;
	for(int i=1; i<=n; i++){
		jwb=max(jwb,f(i));
	}
	cout << jwb << endl;
}//j

Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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; }
const long double PI = acos(-1.0);
// cout << fixed << setprecision(14);

set<int> st[26];
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
 
	int N;
	cin >> N;
	int A[N];
	rep(i,N) cin >> A[i];
	sort(A, A+N);
	reverse(A, A+N);
	int ans = -A[0];
	for(int i=0;i<N;i++){
		ans += A[i/2];
	}
	cout << ans << endl;
}

Measured memory_bytes: 5212
class UnionFind
    attr_reader :set_size
    def initialize(n)
        @par = Array.new(n)
        n.times{ |i| @par[i] = i }
        @rank = Array.new(n, 0)
        @set_size = Array.new(n, 0)
    end

    def find(x)
        if @par[x] == x
            x
        else
            @par[x] = find(@par[x])
        end
    end

    def unite(x,y)
        x = find(x)
        y = find(y)
        return if x == y

        if @rank[x] < @rank[y]
            @par[x] = y
            @set_size[y] += @set_size[x]
        else
            @par[y] = x
            @set_size[x] += @set_size[y]
            @rank[x] += 1 if @rank[x] == @rank[y]
        end
    end

    def same?(x, y)
        find(x) == find(y)
    end
end

N, M = gets.split.map(&:to_i)
uf = UnionFind.new(N+M)
N.times do |i|
    ls = gets.split.map(&:to_i)
    ls.shift
    ls.each do |j|
        uf.unite(i, N-1+j)
    end
end

puts (2...N).all?{|i|uf.same?(1, i)} ? 'YES' : 'NO'

Measured memory_bytes: 8972
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep(i,j,n) for(int i=(j);i<(n);i++)
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	cout << (a + b) * c / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
N,M=map(int,input().split())
SC=[]

for _ in range(M):
    s,c=map(int,input().split())
    SC.append([s,c])

ans=-1
for i in range(10**N):
    if(len(str(i)) == N):
        for j in range(M):
            s=SC[j][0] - 1
            c=SC[j][1]
            tmp=list(str(i))
            if(tmp[s] != str(c) ):
                break
        else:
            if(ans == -1):
                ans=i
            else:
                ans=min(ans,i)
print(ans)


Measured memory_bytes: 3064
x1, y1, x2, y2 = map(int, input().split())

x3 = x2 + (y1-y2)
y3 = y2 + (x2-x1)
x4 = x3 + (y2-y3)
y4 = y3 + (x3-x2)
print(x3, y3, x4, y4)

Measured memory_bytes: 9008
#include <iostream>
using namespace std;
 
int main(){
    //入力を受け取る
    int N;
    cin >> N;
  
  if (N % 1000 == 0) {
    cout << "0" << endl;
  }
  else {
    cout << ((N+1000)/1000)*1000-N << endl;
  } 
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		string S; cin >> S;
		UL p = 0;
		rep(i, S.size()) {
			if (p == 0) { if (S[i] == 'C') p++; }
			else if (p == 1) { if (S[i] == 'F') p++; }
		}
		if (p == 2) cout << "Yes" << endl;
		else cout << "No" << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(s: String);
    let vs: Vec<char> = s.chars().collect();

    let mut count_even = 0;
    let mut count_odd = 0;

    for (i, cvs) in vs.iter().enumerate() {
        let is_odd = i % 2 == 0;

        if (*cvs == '0') == is_odd {
            count_even += 1;
        } else {
            count_odd += 1;
        }
    }
    let ans = if count_even < count_odd {
        count_even
    } else {
        count_odd
    };

    println!("{}", ans);
}


Measured memory_bytes: 2608