akhauriyash/Code-Regression huggingface dataset:
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
struct unionfind{
  int par[100010]; // 親ノード  必要に応じて要素数を変えよう
  int rank[100010]; // ランク　必要に応じて要素数を変えよう
  unionfind(int n){
    init(n);
  }
  void init(int n){
    for(int i=0;i<=n;i++){
      par[i]=i;
      rank[i]=1;
    }
  }
  int root(int x) {
    if (par[x] == x) {
      return x;
    }
    else {
      return par[x] = root(par[x]);
    }
  }
  int size(int x){
    return rank[root(x)];
  }
  bool same(int x,int y) {
    return root(x) == root(y);
  }
  void unite(int x,int y) {
    x=root(x);
    y=root(y);
    if(x==y){
      return;
    }
    if(rank[x]<rank[y]){
      swap(x,y);
    }
    rank[x]=rank[x]+rank[y];
    par[y]=x;
  }
};
struct edge{
  int from;
  int to;
  double cost;
  edge(int f,int t,double w) : from(f),to(t),cost(w){}
};
bool comp(const edge& e1,const edge& e2){
  return e1.cost<e2.cost;
}
int main(){
  int i,j,n;
  while(1){
    scanf("%d\n",&n);
    if(n==0){
      return 0;
    }
    vector<edge> g;
    double x[110],y[110],z[110],r[110];
    for(i=0;i<n;i++){
      scanf("%lf %lf %lf %lf\n",&x[i],&y[i],&z[i],&r[i]);
    }
    for(i=0;i<n;i++){
      for(j=i+1;j<n;j++){
        double len=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]));
        if(len-r[i]-r[j]<0){
          len=0;
        }
        else{
          len=len-r[i]-r[j];
        }
        g.push_back(edge(i,j,len));
      }
    }
    double ans=0;
    sort(g.begin(),g.end(),comp);
    unionfind tree(110);
    for(i=0;i<g.size();i++){
      if(!tree.same(g[i].from,g[i].to)){
        tree.unite(g[i].from,g[i].to);
        ans+=g[i].cost;
      }
    }
    printf("%.3lf\n",ans);
  }
  return 0;
}


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

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

    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3552
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();
        int N = r.i();
        int[] P = r.ii();

        int[] Q = new int[N+1];
        for(int i = 0; i < N; i++)
          Q[P[i]] = i;

        ArrayList<Integer> list = new ArrayList<>();
        Collections.addAll(list, -1, -1, N, N);

        long ans = 0;
        for(int v = N; v > 0; v--){
          int i = Q[v];
          int j = -Collections.binarySearch(list, i)-1;
          long w = list.get(j-2);
          long x = list.get(j-1);
          long y = list.get(j);
          long z = list.get(j+1);
          long c = (x-w)*(y-i) + (i-x)*(z-y);
          list.add(j, i);
          ans += v*c;
        }
        println(ans);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 44512
N, M, X = map(int, input().split())

A = [int(i) for i in input().split()]

masu = [0 for _ in range(N+1)]

for i in A:
    masu[i] = 1

L = sum(masu[:X])
R = sum(masu[X+1:N+1])

print(min(L, R))


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;



int main()
{
    int N,M;
    cin>>N>>M;
    vector<int> P;
    vector<ll> Y;
    vector<ll> PY[N+1];
    rep(i,M)
    {
        int p;
        ll y;
        cin>>p>>y;
        P.push_back(p);
        Y.push_back(y);
        PY[p].push_back(y);
    }
    for(int i=1;i<=N;i++)
    {
        sort(PY[i].begin(),PY[i].end());
    }

    rep(i,M)
    {
        auto iter=lower_bound(PY[P[i]].begin(),PY[P[i]].end(),Y[i]);

        string birthnum=to_string(1+iter-PY[P[i]].begin());
        string barthzero=string(6-birthnum.size(),'0');
        string recnum=to_string(P[i]);
        string reczero=string(6-recnum.size(),'0');


        string ans=reczero+recnum+barthzero+birthnum;
        cout<<ans<<endl;
    }

}

Measured memory_bytes: 8176
import java.util.Scanner;

/**
 * Created by LCW on 2016-9-19.
 */

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] x = new int[n];
		int res = 0;
		for (int i = 0; i < n; i++) {
			x[i] = in.nextInt()-1;
		}
		for (int i = 0; i < n; i++) {
			if (x[x[i]] == i) {
				res++;
			}
		}
		System.out.println(res / 2);
	}

}


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

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

  set<int> mochi;

  for (size_t i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    mochi.insert(tmp);
  }

  cout << mochi.size() << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main (void)
{
    char s[200001],t[200001];
    int cnt=0;
    scanf("%s",s);
    scanf("%s",t);
    for(int i=0;i<strlen(s);i++)
    {
        if(s[i]!=t[i])
        {
            cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 2068
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>

using namespace std;

typedef long long ll;


const int INF = 1e9;

int N;
int L[100], sum[100];
vector<int> lb;
int main() {
	cin >> N;
	rep(i, N) {
		cin >> L[i];
	}
	sum[0] = 0;
	rep(i, N) {
		sum[i + 1] = sum[i] + L[i];
	}

	for (int i = 0; i < N; i++) {
		for (int j = i; j < N; j++) {
			lb.push_back(sum[j + 1] - sum[i]);
		}
	}
	sort(lb.begin(), lb.end());
	lb.erase(unique(lb.begin(), lb.end()), lb.end());

	int ans = INF;
	for (int e:lb) {
		vector<int> dp(N + 1, INF);
		dp[0] = 0;
		for (int i = 0; i < N; i++) {
			for (int j = i; j < N; j++) {
				if (i == 0 && j == N - 1) continue;
				int tmp = sum[j + 1] - sum[i];
				if (tmp < e) continue;
				dp[j + 1] = min(dp[j + 1], max(dp[i], tmp));
			}
		}
		ans = min(ans, dp[N] - e);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>

typedef long long ll;

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}

int main()
{
  ll K, A, B;
  std::cin >> K >> A >> B;

  for (ll d = 1; d <= 1000; d++) {
    if (d >= A && d <= B && d % K == 0) {
      print("OK");
      return 0;
    }
  }

  print("NG");
  return 0;
}


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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf 1e18

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

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

    ll test=1;
    // cin>>test;
    while(test--)
    {
        ll n;
        cin>>n;

        string a="AC",b="TLE",c="RE",d="WA";

        ll a1=0;
        ll b1=0;
        ll c1=0;
        ll d1=0;

        for(ll i=0;i<n;i++)
        {
            string str;
            cin>>str;

            if(str==a)
            a1++;
            else if(str==b)
            b1++;
            else if(str==c)
            c1++;
            else
            d1++;
            
        }

        cout<<a<<" x "<<a1<<endl;
        cout<<d<<" x "<<d1<<endl;
        cout<<b<<" x "<<b1<<endl;
        cout<<c<<" x "<<c1<<endl;
    }
}

Measured memory_bytes: 3656
N, M = map(int, input("").split(" "))

A = map(int, input("").split(" "))
A = list(A)
A.sort()

potentials = []
for i in range(M):
    B, C = map(int, input("").split(" "))

    potentials.append((B, C))

potentials.sort(key=lambda x: x[1], reverse=True)

c = 0
for p in potentials:
    for b in range(p[0]):
        if p[1] > A[c]:
            A[c] = p[1]
            c += 1
            if c >= len(A):
                break
        else:
            break
    if c >= len(A):
        break

print(sum(A))


Measured memory_bytes: 74324
def calc(f, q, w, h)
  n = 0
  while q.size > 0
    n += 1
    p = q.shift
    [[-1, 0], [0, -1], [0, 1], [1, 0]].each do |d|
      i, j = p[0] + d[0], p[1] + d[1]
      if i >= 0 && i < h && j >= 0 && j < w && f[i][j] == '.'
        f[i][j] = '#'
        q.push([i, j])
      end
    end
  end
  n
end
loop do
  f, q = [], []
  w, h = gets.split.map(&:to_i)
  break if w + h == 0
  h.times do |i|
    f[i] = gets.chomp.split('')
    j = f[i].index('@')
    q[0] = [i, j] if j
  end
  puts calc(f, q, w, h)
end

Measured memory_bytes: 8980
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();
		int j = 0;
		
		a = Math.abs(a);
		b = Math.abs(b);
		c = Math.abs(c);
		d = Math.abs(d);
		e = Math.abs(e);
		
		if(Math.max(a,b) - Math.min(a,b) > k){
		j += 1;
		}
		if(Math.max(a,c) - Math.min(c,a) > k){
		j += 1;
		}
		if(Math.max(a,d) - Math.min(d,a) > k){
		j += 1;
		}
		if(Math.max(a,e) - Math.min(e,a) > k){
		j += 1;
		}
		if(Math.max(b,c) - Math.min(c,b) > k){
		j += 1;
		}
		if(Math.max(b,d) - Math.min(d,b) > k){
		j += 1;
		}
		if(Math.max(b,e) - Math.min(e,b) > k){
		j += 1;
		}
		if(Math.max(c,d) - Math.min(d,c) > k){
		j += 1;
		}
		if(Math.max(d,e)- Math.min(d,e) > k){
		j += 1;
		}
		
		if( j > 0){
		System.out.println(":(");
		}else{
			System.out.println("Yay!");
		}
	}
}


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

#define f(i,x,y)			for(int i=x; i<y; i++)
#define ll 					long long 
#define mp 					make_pair
#define F 					first
#define S 					second
#define N 					100005
#define inf 				1e9+1

int main()
{
	int n;
	cin>>n;
	int a[n];
	f(i,0,n)
		cin>>a[i];


	ll dp[n][n];
	f(i,0,n)
		dp[i][i] = a[i];

	f(l,1,n)
	{
		f(i,0,n-l)
		{
			int j = i+l;
			dp[i][j] = max(a[i]-dp[i+1][j] , a[j]-dp[i][j-1]);

		}
	}
	cout<<dp[0][n-1];

	return 0;
}

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

#define ll long long int
#define ri register int

using namespace std;

int dp[100003][3];

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

	vector< vector<int> > v(n, vector<int>(3));
	int a, b, c;
	for (int i = 0; i < n; i++)
	{
		cin >> v[i][0] >> v[i][1] >> v[i][2];
		
	}

	for (int i = 0; i < n; i++)
	{
		dp[i][0] = dp[i][1] = dp[i][2] = INT_MIN;
	}
	dp[0][0] = v[0][0];
	dp[0][1] = v[0][1];
	dp[0][2] = v[0][2];

	for (int i = 1; i < n; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 3; k++)
			{
				if (k == j) continue;
				dp[i][j] = max(dp[i][j], v[i][j] + dp[i-1][k]);
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < 3; i++)
	{
		ans = max(ans, dp[n - 1][i]);
	}
	cout << ans << endl;	
	return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    int N; cin>>N;
    if(N/100==7||N%10==7||(N%100-N%10)/10==7)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

ll A, B, M, N, D, K, Q, W, H, T, X, Y;

int main()
{
    cin >> N;

    ll sum = 0, time = 0;
    while (sum < N) {
        time++;
        sum += time;
    }

    cout << time << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <cstring>
using namespace std;
typedef pair<int,int> ii;

int n,m;
vector<ii> al[100];
ii path[100];

bool onpath[100][100];

int depth[100];
int parent[100];
int edge[100];

void dfs(int i,int p){
    for (auto &it:al[i]){
        if (it.first==p) continue;
        depth[it.first]=depth[i]+1;
        parent[it.first]=i;
        edge[it.first]=it.second;
        dfs(it.first,i);
    }
}

void __path(int i,int j,int k){
    if (depth[i]<depth[j]) swap(i,j);
    
    while (depth[i]!=depth[j]){
        onpath[k][edge[i]]=true;
        i=parent[i];
    }
    
    while (i!=j){
        onpath[k][edge[i]]=true;
        i=parent[i];
        onpath[k][edge[j]]=true;
        j=parent[j];
    }
}

long long memo[2][1500000];

int main(){
    cin>>n;
    
    int a,b;
    for (int x=0;x<n-1;x++){
        cin>>a>>b;
        al[a].push_back(ii(b,x));
        al[b].push_back(ii(a,x));
    }
    
    cin>>m;
    for (int x=0;x<m;x++){
        cin>>path[x].first>>path[x].second;
    }
    
    dfs(1,-1);
    
    for (int x=0;x<m;x++){
        __path(path[x].first,path[x].second,x);
    }
    
    memo[0][0]=1;
    a=0,b=1;
    int temp;
    for (int x=0;x<n-1;x++){
        memset(memo[b],0,sizeof(memo[b]));
        
        for (int bm=0;bm<(1<<m);bm++){
            memo[b][bm]+=memo[a][bm];
            
            temp=bm;
            for (int y=0;y<m;y++){
                if (onpath[y][x]) temp|=(1<<y);
            }
            
            memo[b][temp]+=memo[a][bm];
        }
        swap(a,b);
    }
    
    printf("%lld\n",memo[a][(1<<m)-1]);
}

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

#define ALL(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0, __##i##_length = (n); i < __##i##_length; i++)
#define rep_reverse(i, n) for (ll i = (n)-1; 0 < i; i--)
#define FOR(i, from, to)                                                       \
  for (ll i = (from), __##i##_end = (to); i < __##i##_end; i++)
#define FOR_REVERSE(i, from, to)                                               \
  for (ll i = (to)-1, __##i##_end = (from); __##i##_end <= i; i--)
#define foreach(e, v) for (const auto e : (v))
#define vfree(v) std::vector<int>().swap(v)
#define DEBUG(x) cout << #x << " = " << (x) << endl

using namespace std;
typedef int64_t ll;
typedef vector<ll> llv;
typedef vector<ll> llvv;

int main() {
  string str;
  cin >> str;
  ll iter = 0;
  llv x;
  while (iter < str.size()) {
    if (x.size() == 0) {
      x.push_back(str[iter]);
    } else if (x[x.size() - 1] == 'S') {
      if (str[iter] == 'S')
        x.push_back(str[iter]);
      else
        x.pop_back();
    } else {
      x.push_back(str[iter]);
    }
    iter++;
  }
  cout << x.size() << endl;
  // rep(i, x.size()) cout << char(x[i]);
  return 0;
}


Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
string shuffle(string str,int h){
    string head = str.substr(0,h);
    string tail = str.substr(h,str.size()-h);
    return tail + head;
} 
int main() {
    string cards;
    int m,h;
    while(1){
        cin >> cards;
        if(cards == "-")break;
        cin >> m;
        for(int i = 0;i < m;i++){
            cin >> h;
            cards = shuffle(cards,h);
        }
        cout << cards << endl;;
    }
}


Measured memory_bytes: 3168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int countAC = 0;
		int countWA = 0;
		int countTLE = 0;
		int countRE = 0;
		while(n-->=0) {
			String curr = sc.nextLine();
			if(curr.equals("AC")) countAC++;
			if(curr.equals("WA")) countWA++;
			if(curr.equals("TLE")) countTLE++;
			if(curr.equals("RE")) countRE++;

		}
		System.out.println("AC x "+ countAC);
		System.out.println("WA x "+ countWA);
		System.out.println("TLE x "+ countTLE);
		System.out.println("RE x "+ countRE);

	}

}


Measured memory_bytes: 51000
def main():
  N=int(input())
  values=[]
  val=6
  while val<=N:
    values.append(val)
    val*=6
  
  val=9
  while val<=N:
    values.append(val)
    val*=9
  
  values.sort(reverse=True)
  dp=[N]*(N+1)
  dp[0]=0
  for value in values:
    for i in range(0,N-value+1):
      if dp[i] != N:
        dp[i+value]=min(dp[i]+1,dp[i+value])
        #print(i,value,dp[i+value])
  #print(dp)
  ans=10**10
  for index,item in enumerate(dp):
    ans=min(ans,item+N-index)
  print(ans)
  pass
if __name__ == '__main__':
  main()

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

int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    int dp[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
        dp[i]=INT_MAX;
    }
    dp[0] = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=i+k;j++){
            if(j<n){
                dp[j] = min(dp[j], dp[i] + abs(arr[i] - arr[j]));
            }
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    char ch[4];
    int count, i;
    gets(ch);
    if(ch[0]=='S' && ch[1]=='S' && ch[2]=='S') count=0;
    else if(ch[0]=='S' && ch[1]=='R' && ch[2]=='S') count=1;
    else if(ch[0]=='S' && ch[1]=='S' && ch[2]=='R') count=1;
    else if(ch[0]=='R' && ch[1]=='S' && ch[2]=='S') count=1;
    else if(ch[0]=='R' && ch[1]=='S' && ch[2]=='R') count=1;
    else if(ch[0]=='R' && ch[1]=='S' && ch[2]=='S') count=1;
    else if(ch[0]=='S' && ch[1]=='R' && ch[2]=='R') count=2;
    else if(ch[0]=='R' && ch[1]=='R' && ch[2]=='S') count=2;
    else if(ch[0]=='R' && ch[1]=='R' && ch[2]=='R') count=3;
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 1612
using System;
class Program{
  static void Main(string[] args){
    string a = Console.ReadLine();
    string p="";
    switch(a){
      case "A":
        p="T";break;
      case "T":
        p="A";break;
      case "G":
        p="C";break;
      case "C":
        p="G";break;
    }
    Console.WriteLine(p);
  }
}

Measured memory_bytes: 11092
from fractions import *
n = int(input())
a = [0] + list(map(int, input().split())) + [0]
b = [0] * (n+2)
c = [0] * (n+2)

for i in range(1, n+1):
    b[i] = gcd(b[i-1], a[i])
for i in range(n,0,-1):
    c[i] = gcd(c[i+1], a[i])

ans = 1
for i in range(1, n+1):
    if ans < gcd(b[i-1], c[i+1]):
        ans = gcd(b[i-1], c[i+1])
print(ans)

Measured memory_bytes: 16132
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    ll N, K, S;
    cin >> N >> K >> S;

    vector<int> ans(N);
    REP(i, K) {
        ans[i] = S;
    }

    if(S < 1e9)
        for(ll i=K; i<N; i++) ans[i] = S+1;
    else
        for(ll i=K; i<N; i++) ans[i] = 1;
    REP(i, N) cout << ans[i] << " "; cout << endl;
    return 0;
}

Measured memory_bytes: 1664
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def build_grid(H, W, intv, _type, space=True, padding=False):
    # 入力がスペース区切りかどうか
    if space:
        _input = lambda: input().split()
    else:
        _input = lambda: input()
    _list = lambda: list(map(_type, _input()))
    # 余白の有無
    if padding:
        offset = 1
    else:
        offset = 0
    grid = list2d(H+offset*2, W+offset*2, intv)
    for i in range(offset, H+offset):
        row = _list()
        for j in range(offset, W+offset):
            grid[i][j] = row[j-offset]
    return grid

H, W = MAP()
grid = build_grid(H, W, 0, int)

ans = []
moving = False
for i in range(H):
    for j in range(W):
        # 各行ジグザグに進めば切れ間なく移動できる
        if i % 2 == 1:
            j = W - j - 1
        # 1つ前から持ってきてるなら置く
        if moving:
            grid[i][j] += 1
            moving = False
            t = (i, j)
            ans.append((s, t))
        # 奇数枚の場所に来たら動かす
        if grid[i][j] % 2 == 1:
            moving = True
            grid[i][j] -= 1
            s = (i, j)

print(len(ans))
for (h1, w1), (h2, w2) in ans:
    print(h1+1, w1+1, h2+1, w2+1)


Measured memory_bytes: 36176
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,m,i,a;
  pair<int,int>w[1000];
  while(1){
    cin>>n>>m>>a;if(n==0)break;
    for(i=0;i<m;i++)cin>>w[i].first>>w[i].second>>n;
    sort(w,w+m);
    for(i=m-1;i>=0;i--){
      n=w[i].second;
      if(n==a)a++;
      else if(n+1==a)a--;
    }
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long long ll;

vector<ll> primes;
bool prime[5549993];

void SieveOfEratosthenes(ll n){
    for(ll p=2; p*p <= n; p++){
            if(prime[p] == false){
                for(ll i = p*p; i <= n; i += p)
                    prime[i] = true;
            }
    }
    for(ll p=2; p <= n; p++)
       if(!prime[p]) primes.push_back(p);
}

bool isPrime(ll n){
  if(n == 1) return false;
  ll i = 2;
  while (i*i <= n){
      if (n % i == 0) return false;
      ++i;
  }
  return true;
}

ll fast_pow(ll base, ll n){
    if(n == 0) return 1;
    if(n == 1)  return base;
    ll halfn = fast_pow(base, n/2);
    if(n % 2 == 0) return halfn * halfn;
    else return halfn * halfn * base;
}
 
int main(){
    ios;
    ll n; cin >> n;
    if(isPrime(n)){cout << 1; return 0;}
    SieveOfEratosthenes(5549993);
    ll ans = 0, check = 0;
    for(ll i = 0; i < primes.size(); ++i){
        for(ll j = 1; j <= 40; ++j){
            check = fast_pow(primes[i],j);
            if(n % check == 0) {++ans; n/=check;}
        }
    }
    if(isPrime(n) && n > 5549993) ++ans;
    cout << ans;
    return 0;
}


Measured memory_bytes: 12844
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < int(n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i,m,n) for (int i = (n)-1; (i) >= int(m); --(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define debug(x) #x << " = " << (x) << " "
using ll = long long;
using namespace std;
template <class T> void setmax(T & a, T const & b) { if (a < b) a = b; }
template <class T> void setmin(T & a, T const & b) { if (b < a) a = b; }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
const int mod = 1e9+7;
 
ll powmod(ll x, ll y) { // O(log y)
    assert (y >= 0);
    x %= mod; if (x < 0) x += mod;
    ll z = 1;
    for (ll i = 1; i <= y; i <<= 1) {
        if (y & i) z = z *(ll) x % mod;
        x = x *(ll) x % mod;
    }
    return z;
}
ll inv(ll x) { // p must be a prime, O(log p)
    assert ((x % mod + mod) % mod != 0);
    return powmod(x, mod-2);
}
ll fact(ll n) {
    static vector<ll> memo(1,1);
    if (memo.size() <= n) {
        ll l = memo.size();
        memo.resize(n+1);
        repeat_from (i,l,n+1) memo[i] = memo[i-1] *(ll) i % mod;
    }
    return memo[n];
}
ll choose(ll n, ll r) { // O(n) at first time, otherwise O(1)
    if (n < r) return 0;
    r = min(r, n - r);
    return fact(n) *(ll) inv(fact(n-r)) % mod *(ll) inv(fact(r)) % mod;
}
 
int main() {
    ll n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    vector<ll> cur(n+1), prv;
    cur[0] = 1;
    repeat_from (size,a,b+1) {
        prv = cur;
        repeat_from (count,c,d+1) {
            ll k = fact(size*count) *(ll) inv(powmod(fact(size), count)) % mod * inv(fact(count)) % mod;
            repeat (i,n) if (i + size*count < n+1 and prv[i]) {
                cur[i + size*count] += prv[i] *(ll) choose(n-i, size*count) % mod * k % mod;
            }
        }
        repeat (i,n+1) cur[i] %= mod;
    }
    cout << cur[n] << endl;
    return 0;
}

Measured memory_bytes: 8408
from heapq import heappop as pop
from heapq import heappush as push
INF = 1000000000000

def bfs(lst, used, que, w, h):
  v, y, x  = pop(que)

  if not used[y - 1][x]:
    push(que, (lst[y - 2][x - 1], y - 1, x))
    used[y - 1][x] = True

  if not used[y + 1][x]:
    push(que, (lst[y][x - 1], y + 1, x))
    used[y + 1][x] = True

  if not used[y][x - 1]:
    push(que, (lst[y - 1][x - 2], y, x - 1))
    used[y][x - 1] = True

  if not used[y][x + 1]:
    push(que, (lst[y - 1][x], y, x + 1))
    used[y][x + 1] = True

  return v

def make_dic(lst, w, h, x, y):
  que = [(1, y, x)]

  used = [[True] * (w + 2)]
  for i in range(h):
    used.append([True] + [False] * w + [True])
  used.append([True] * (w + 2))
  used[y][x] = True

  dic = [[0, 0]]
  app = dic.append
  Max = 0
  acc = 0

  while que:
    v = bfs(lst, used, que, w, h)
    acc += 1
    if v > Max:
      app([v, acc])
      Max = v
    else:
      dic[-1][1] += 1
  return dic

def solve():
  while True:

    R = int(input())
    if not R:
      break

    w1, h1, x1, y1 = map(int, input().split())
    lst1 = [list(map(int, input().split())) for _ in range(h1)]
  
    w2, h2, x2, y2 = map(int, input().split())
    lst2 = [list(map(int, input().split())) for _ in range(h2)]
  
    dic1 = make_dic(lst1, w1, h1, x1, y1)
    dic2 = make_dic(lst2, w2, h2, x2, y2)
  
    end1 = len(dic1)
    end2 = len(dic2)
    ind1 = 0
    ind2 = end2 - 1
    ans = INF
  
    while ind1 < end1 and ind2 > 0:
      r1, sum1 = dic1[ind1]
      r2, sum2 = dic2[ind2]
  
      if sum1 + sum2 < R:
        ind1 += 1
        continue
  
      while ind2 > 0 and sum1 + sum2 >= R:
        ind2 -= 1
        r2, sum2 = dic2[ind2]
  
      if ind2 == 0 and sum1 + sum2 >= R:
        rs = r1 + r2
        if rs < ans:
          ans = rs
        break
  
      else:
        ind2 += 1
        r2 = dic2[ind2][0]
        rs = r1 + r2
        if rs < ans:
          ans = rs
  
      ind1 += 1
    print(ans)
 
solve()


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

using namespace std;

const int N=1e5+10;
long long int n,arr[N][4],dp[N][4];

long long int calc(int day,int last){
    if (day>=n)
        return 0;
    if (dp[day][last])
        return dp[day][last];
    for (int i=0;i<3;i++){
        if (last==i)
            continue;
        dp[day][last]=max(arr[day][i]+calc(day+1,i),dp[day][last]);
    }
    return dp[day][last];
}

int main(){
    cin>>n;
    for (int i=0;i<n;i++)
        for (int j=0;j<3;j++)
            cin>>arr[i][j];
    cout<<(long long int)calc(0,-1);
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  pair<int, int> g;
  int p;
  pair< pair<int, int>, pair<int, int> > stop[100];  //初期化漏れないように
  int route[16][16];
  for(int l=0;l<n;l++){
    cin >> g.first >> g.second;
    cin >> p;
    for(int i=0;i<p;i++){
      cin >> stop[i].first.first >> stop[i].first.second;
      cin >> stop[i].second.first >> stop[i].second.second;
      if(stop[i].first > stop[i].second)
	swap(stop[i].first, stop[i].second);
    }
    for(int i=0;i<=g.first;i++){
      for(int j=0;j<=g.second;j++){
	bool xb=true, yb=true;
	if(i == 0 && j == 0)
	  route[i][j] = 1;
	else if(i == 0){
	  for(int k=0;k<p;k++)
	    if(stop[k].second == make_pair(i, j) && stop[k].first == make_pair(i, j-1))
	       yb = false;
	  route[i][j] = (yb) ? route[i][j-1] : 0;
	}
	else if(j == 0){
	  for(int k=0;k<p;k++)
	    if(stop[k].second == make_pair(i, j) && stop[k].first == make_pair(i-1, j))
	       xb = false;
	  route[i][j] = (xb) ? route[i-1][j] : 0;
	}
	else{
	  for(int k=0;k<p;k++){
	    if(stop[k].second == make_pair(i, j)){
	      if(stop[k].first == make_pair(i-1, j))
		xb = false;
	      else
		yb = false;
	    }
	  }
	  route[i][j] = (xb) ? route[i-1][j] : 0;
	  if(yb)
	    route[i][j] += route[i][j-1];
	}
      }
    }
    if(route[g.first][g.second] == 0)
      cout << "Miserable Hokusai!" << endl;
    else
      cout << route[g.first][g.second] << endl;
  }
  
}


Measured memory_bytes: 3076
N = int(input())
from math import sqrt
def get_divs(n):
  divs = []
  for i in range(1, int(sqrt(n)) + 1):
    if n % i == 0:
      divs.append((i, n // i))
  return divs
d = get_divs(N)
ans = float('inf')
for x, y in d:
  ans = min(x + y - 2, ans)
print(ans)

Measured memory_bytes: 3444
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    public class Prog
    {
        const int MOD = 1000000007;
        public static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Prog().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var x = cin.ReadInt;
            var l = cin.ReadIntArray(n);

            var line = 0;
            var ans = 1;

            for (int i = 0; i < n; i++)
            {
                line += l[i];
                if (line <= x)
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; } }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 200005
#define eps 1e-10
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
struct node {
	int to,next;
}E[MAXN];
int deg[MAXN],head[MAXN],sumE,N,M;
int cnt[2],col[MAXN];
void add(int u,int v) {
	E[++sumE].to = v;
	E[sumE].next = head[u];
	head[u] = sumE;
}
bool dfs(int u) {
	if(col[u] == -1) col[u] = 0;
	++cnt[col[u]];
	for(int i = head[u] ; i ; i = E[i].next) {
		int v = E[i].to;
		if(col[v] == -1) {
			col[v] = col[u] ^ 1;
			if(!dfs(v)) return false;
		}
		else if(col[v] == col[u]) return false;
	}
	return true;
}
void Solve() {
	read(N);read(M);
	int a,b;
	for(int i = 1 ; i <= M ; ++i) {
		read(a);read(b);
		deg[a]++;deg[b]++;
		add(a,b);add(b,a);
	}
	memset(col,-1,sizeof(col));
	if(!dfs(1)) {
		out(1LL * N * (N - 1) / 2 - M);enter;
	}
	else {
		int64 ans = 0;
		for(int i = 1 ; i <= N ; ++i) {
			if(col[i]) ans += cnt[col[i] ^ 1] - deg[i];
		}
		out(ans);enter;
	}
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <cassert>

using namespace std;
typedef long long ll;

ll range_total(const vector<ll>& cs, ll i, ll j){
    assert(i <= j);
    return cs.at(j) - cs.at(i);
}

pair<ll, ll> search(const vector<ll>& cs, ll s, ll e){
    assert(s + 1 < e);
    ll lo = s + 1;
    ll hi = e - 1;

    ll best_idx = lo;
    ll best = abs(range_total(cs, s, lo) - range_total(cs, lo, e));

    while(lo <= hi){
        ll mid = (lo + hi) / 2;
        ll diff = abs(range_total(cs, s, mid) - range_total(cs, mid, e));
        if(best > diff){
            best_idx = mid;
            best = diff;
        }
        if(range_total(cs, s, mid) < range_total(cs, mid, e)){
            lo = mid + 1;
        }else if(range_total(cs, s, mid) > range_total(cs, mid, e)){
            hi = mid - 1;
        }else{
            break;
        }
    }
    assert(s < best_idx && best_idx < e);
    ll x1 = range_total(cs, s, best_idx);
    ll x2 = range_total(cs, best_idx, e);
    return make_pair(x1, x2);
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a.at(i);
    }

    vector<ll> cs(n + 1, 0);
    for(int i = 0; i < n; ++i){
        cs.at(i + 1) = a.at(i) + cs.at(i);
    }

    ll ans = cs.back();
    for(int i = 2; i < n - 1; ++i){
        ll l1, l2, r1, r2;
        tie(l1, l2) = search(cs, 0, i);
        tie(r1, r2) = search(cs, i, n);
        ans = min(
            ans,
            abs(max({l1, l2, r1, r2}) - min({l1, l2, r1, r2}))
        );
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

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

  struct node_t {
    bool is_a;
    int index;
    int key;

    bool operator<(const node_t& r) const { return key < r.key; }
  };

  std::vector<node_t> a(n), b(n);
  for (int i = 0; i != n; ++i) {
    a[i].is_a = true;
    a[i].index = i;
    std::cin >> a[i].key;
  }
  for (int i = 0; i != n; ++i) {
    b[i].is_a = false;
    b[i].index = i;
    std::cin >> b[i].key;
  }
  std::vector<node_t> c(2 * n);
  std::merge(a.begin(), a.end(), b.begin(), b.end(), c.begin());

  std::vector<int> rem;
  for (int i = 0; i != n; ++i) {
    auto& x = c[i];
    auto& y = c[n + i];
    if (x.key == y.key) {
      std::cout << "No\n";
      return 0;
    }
    if (x.is_a != y.is_a) {
      continue;
    }
    if (rem.empty() || c[rem.back()].is_a == x.is_a) {
      rem.push_back(i);
      continue;
    }
    auto& s = c[rem.back()];
    auto& t = c[n + rem.back()];
    rem.pop_back();
    std::swap(s, x);
    if (s.key == t.key || x.key == y.key) {
      std::swap(s, y);
    }
  }
  std::vector<int> ans(n);
  for (int i = 0; i != n; ++i) {
    auto& x = c[i];
    auto& y = c[n + i];
    if (!x.is_a) {
      std::swap(x, y);
    }
    ans[x.index] = y.key;
  }

  std::cout << "Yes\n";
  for (int e : ans) {
    std::cout << e << " ";
  }

  return 0;
}


Measured memory_bytes: 13708
#include<bits/stdc++.h>
#define dl long double
#define pii pair<dl,dl>
#define x first
#define y second
using namespace std;
int n;
dl h=1;
vector<pii> v;
dl dist(pii a,pii b){
    dl ans=sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
    return ans;
}
dl ans;
void DFS(int w,int pr,vector<int> used,dl wina){

    used[w]=1;
    int ind=0;
for(int k=1;k<=n;k++){
    if(used[k]==0){
            ind=1;
        DFS(k,w,used,wina+(dist(v[w-1],v[k-1]))/h);
    }
}
if(ind==0)
ans+=wina;
}
int main(){
//freopen("test.in","r",stdin);
cin>>n;
for(int k=1;k<=n;k++){
        h*=k;
    dl a,b;
    cin>>a>>b;
    v.push_back({a,b});
}
for(int k=1;k<=n;k++){
        vector<int> used(n+1,0);
    DFS(k,k,used,0);
}
cout<<fixed;
cout<<setprecision(8)<<ans;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    string f="No\n";
    while(n)
    {
        if(n%10==7)
        {
            f="Yes\n";
            break;
        }    
        n/=10;
    }
    cout<<f;
	return 0;
}

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

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

//cout << ans?"Yes":"No" << endl;

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

int main() 
{
  char s[12];
  cin >> s;
  for (int i = 0; i <4;i++)
    cout<<s[i];
  cout<<" ";
  for(int i=4;i<12;i++)
    cout<<s[i];
  cout<<endl;
  
}


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

int main(void) {
  int N, M, sum=0, ans;
  cin >> N >> M;
  int A[M];
  
  for(int i=0; i<M; i++){
    cin >> A[i];
    sum += A[i];
  }
  
  ans = N - sum;
  
  if(ans >= 0) cout << ans << endl;
  else cout << -1 << endl;
  
  return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int e = 12;
        int t[] = new int[e];
        for (int i = 0; i < e; i++) {
            t[i] = scanner.nextInt();
        }
        for (int x = 0; x < 11; x++) {
            for (int j = 0; j < 11 - x; j++) {
                if (t[j] < t[j + 1]) {
                    int temp = t[j];
                    t[j] = t[j + 1];
                    t[j + 1] = temp;
                }
            }
        }

        if (t[0] == t[1] && t[1] == t[2] && t[2] == t[3] && t[4] == t[5] && t[5] == t[6] && t[6] == t[7] && t[8] == t[9] && t[9] == t[10] && t[10] == t[11]) {
            System.out.println("yes");
        } else {
            System.out.println("no");
        }
    }
}



Measured memory_bytes: 26256
#include <cstdio>
#include <iostream>

using namespace std;

bool check(int i, int q, int v, int A[], int n) {
	if (v == q) {
		return true;
	}
	if (i == n) {
		return false;
	}

	return check(i + 1, q, v, A, n) || check(i + 1, q, v + A[i], A, n);
}

//????????????
int main() {

	int n;
	scanf("%d", &n);
	int A[n];
	for (int i = 0; i < n; ++i) {
		scanf("%d", &A[i]);
	}

	int q;
	scanf("%d", &q);
	int m[q];
	for (int i = 0; i < q; ++i) {
		scanf("%d", &m[i]);
	}

	for (int i = 0; i < q; ++i) {
		if (check(0, m[i], 0, A, n)) {
			cout << "yes" << endl;
		} else {
			cout << "no" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3192
import Control.Monad
main = do
  n <- readLn
  unless (n == 0) $ do
    print.numOfContinuasZero $ n
    main

numOfContinuasZero n = fiveFactor
  where fiveFactor = sum $ map (factorPiece 5) [1..n]

factorPiece f n
  | n < f = 0
  | n `mod` f == 0 = 1 + factorPiece f (n `div` f)
  | otherwise = 0

Measured memory_bytes: 6720
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#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 <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int cnt = 0;
    for( int i = 0; i <= 3000; ++i ) {
        for( int j = 0; j <= 3000; ++j ) {
            int num = i * r + j * g;
            if( n < num ) break;
            num = n - num;
            if( num % b == 0 ) {
                ++cnt;

            }
        }
    }

    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff { ios_base::sync_with_stdio(false);cin.tie(NULL);}
using namespace std;

typedef long long int ll;
 ll  p=1e9+7; 

 int  main() {
        ff;
       
       
       ll s,w;
       cin>>s>>w;
       if(w>=s){
           cout<<"unsafe"<<endl;
       }else{
           cout<<"safe"<<endl;
       }
      
    return 0;
}

Measured memory_bytes: 3636
if __name__ == '__main__':

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

	Y = Y // 1000

	x1 = min( Y // 10,N)
	y1 = min( Y // 5,N)

	Hit = False
	for x2 in range(0,x1+1):
		if Hit == True:
			break
		for y2 in range(0,y1-x2+1):
			sm = ( 10 * x2 ) + ( 5 * y2 )
			h = N - ( x2 + y2)
			if sm > Y:
				break
			elif sm + h == Y:
				print(x2,y2,h)
				Hit = True
				break

	if Hit == False:
		print(-1,-1,-1)



Measured memory_bytes: 3064
n,q = map(int, input().split())
name = []
time = []
for i in range(n):
    x = input().split()
    name.append(x[0])
    time.append(int(x[1]))

t = 0
n_end = []
t_end = []
while(len(time) > 0):
    if time[0] <= q:
        t += time[0]
        n_end.append(name.pop(0))
        time.pop(0)
        t_end.append(t)
    else :
        t += q
        time[0] -= q
        a = time.pop(0)
        b = name.pop(0)
        time.append(a)
        name.append(b)

for i in range(len(n_end)):
    print(n_end[i],t_end[i])



Measured memory_bytes: 11108
/**
*    author:  yuya1234
*    created: 11.07.2020 21:04:55
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SORT(x) sort(x.begin(),x.end())
#define SORTD(x) sort(x.rbegin(),x.rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SZ(x) ll(x.size())

#define MEMSET(v, h) memset((v), h, sizeof(v))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

  int n;
  cin>>n;

  ll a[1000000];
  MEMSET(a,0);
  ll ans;

  for(int i=1;i<=500;i++)
  {
    for(int j=1;j<=500;j++)
    {
      for(int k=1;k<=500;k++)
      {
        ans=pow(i,2)+pow(j,2)+pow(k,2)+i*j+j*k+k*i;
        if(1000000>=ans)a[ans]++;
      }
    }
  }

  REP(i,n)
  {
    cout<<a[i+1]<<endl;
  }

  return 0;
}

Measured memory_bytes: 11460