akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ipair = pair<int, int>;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

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 ll INF = 1LL<<58;

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};


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

    vector<ipair> bridge(M);
    rep(i, M) cin >> bridge[i].first >> bridge[i].second;
    rep(i, M) {bridge[i].first--; bridge[i].second--;}

    UnionFind uf(N);

    vector<ll> ans(M);
    ans[M-1] = (ll)N*(N-1)/2;

    for(int i=M-1; i>=1; --i){
        int a = bridge[i].first;
        int b = bridge[i].second;

        ll tmp_ans = ans[i];

        if(uf.find(a) != uf.find(b)){
            tmp_ans -= uf.size(a) * uf.size(b);
            uf.unite(a, b);
        }
        ans[i-1] = tmp_ans;
    }

    rep(i, M) cout << ans[i] << endl;


    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <queue>
#include <utility>
using namespace std;

int main() {
    string button[] = {
        " ", "\',.!?", "abcABC", "defDEF", "ghiGHI", "jklJKL", "mnoMNO", "pqrsPQRS", "tuvTUV", "wxyzWXYZ",
    };
    string str;
    while (cin >> str) {
        queue<pair<int, int> > qu;
        int count = 1;
        for (int i = 0, n = str.size(); i < n; i++) {
            if (str[i] != str[i + 1]) {
                qu.push(make_pair(str[i] - '0', count));
                count = 1;
            } else {
                count++;
            }
        }
        string result;
        while (qu.empty() == false) {
            int num = qu.front().first, count = qu.front().second;
            if (num != 0) {
                result += button[num][(count - 1) % (int) button[num].size()];
            } else {
                result.append(count - 1, ' ');
            }
            qu.pop();
        }
        cout << result << endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n, m;
  cin >> n >> m;
  if(n*2 >= m){
    cout << m/2 << endl;
  }
  else{
    cout << n+(m-2*n)/4 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#include <math.h>
#include <map>
#include <vector>
#include <iomanip>
#include <set>
#include <deque>
#define ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define ll long long
#define pb push_back
using namespace std;

const int N = 2e6, PI = 3.14159265359, M = 1e9 + 7;
typedef pair <ll, ll> pii;
map <ll, ll> dp;
ll a[N], ans = 0;
map <pii, ll> ma;
vector <pii> v, v1;

int main() {
	ll n, p;
	cin >> n >> p;
	for(ll int i = 2; i * i <= p; i++) {
		if(p % i == 0) {
			ll cnt = 0;
			while(p % i == 0) {
				p /= i;
				cnt++;
			}
			v.pb({i, cnt});
		}
	}
	if(p != 1) {
		v.pb({p, 1});
	} 
	ll ans = 1;
	for(int i = 0; i < v.size(); i++) {
		ll t = v[i].ss / n;
		while(t--) {
			ans *= v[i].ff;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
r,c = [int(i) for i in input().split()]

table = [[0 for j in range(c+1)] for i in range(r+1)]

for i in range(r):
    temp = [int(x) for x in input().split()]
    for j in range(c+1):
        if not j == c:
            table[i][j] = temp[j]
            table[i][c] += temp[j]
        table[r][j] += table[i][j]

for i in range(r+1):
    for j in range(c+1):
        if j != c:
            print(table[i][j],end=' ')
        else:
            print(table[i][j])



Measured memory_bytes: 6212
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
vector <pii> G[N],T[N];
int n,m,ans[N],x[N],y[N];
bool vis[N];
void dfs0 (int u)
{
	vis[u]=1;
	for (pii x:G[u])
		if (!vis[x.fi]) dfs0 (x.fi);
}
int p[N],q[N];
void dfs00 (int u,int rt,bool fg)
{
	if (!fg) { if (!p[u]) p[u]=rt; }
	else { if (!q[u]) q[u]=rt; }
	vis[u]=1;
	for (pii x:G[u])
		if (!vis[x.fi]) dfs00 (x.fi,rt,fg);
}
int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	sc(n),sc(m);
	for (int i=1; i<=m; i++)
	{
		sc(x[i]),sc(y[i]);
		G[x[i]].pb (mp(y[i],i));
		T[y[i]].pb (mp(x[i],i));
	}
	for (int u=1; u<=n; u++)
	{
		memset (vis,0,sizeof (bool)*(n+1));
		dfs0 (u);
		for (pii x:T[u])
			if (vis[x.fi]) ans[x.se]=1;
	}
	for (int u=1; u<=n; u++)
	{
		memset (p,0,sizeof (int)*(n+1)),memset (q,0,sizeof (int)*(n+1));
		memset (vis,0,sizeof (bool)*(n+1)),vis[u]=1;
		for (pii x:G[u])
			dfs00 (x.fi,x.fi,0);
		reverse (G[u].begin (),G[u].end ());
		memset (vis,0,sizeof (bool)*(n+1)),vis[u]=1;
		for (pii x:G[u])
			dfs00 (x.fi,x.fi,1);
		for (pii x:G[u])
			if (p[x.fi]!=q[x.fi]) ans[x.se]^=1;
	}
	for (int i=1; i<=m; i++)
		puts(ans[i]?"diff":"same");

    return 0;
}

Measured memory_bytes: 65152
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main() {
	string S,T;
	cin >> S;
	vector<int>kug(1, 0);
	for (int i = 0; i < S.size(); ++i) {
		if (S[i] != 'x') {
			T.push_back(S[i]);
			kug.push_back(0);
		}
		else {
			kug.back()++;
		}
	}
	for (int i = 0; i < T.size(); ++i) {
		if (T[i] != T[T.size() - 1 - i]) {
			cout << "-1\n";
			return 0;
		}
	}
	int ans = 0;
	for (int i = 0; i < kug.size(); ++i) {
		ans += abs(kug[i] - kug[kug.size() - 1 - i]);
		
	}
	cout << ans / 2 << endl;
	return 0;
}


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

#define int long long

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

string s;

signed main() {
    cin >> s;
    int ans = LLONG_MAX;
    for (int i = 0; i < 26; i++) {
        int cur = 0, cc = 0;
        for (int j = s.length() - 1; j >= 0; j--) {
            if (s[j] == (char)('a' + i)) {
                cc = 0;
            } else {
                cc++;
            }
            cur = max(cur, cc);
        }
        ans = min(ans, cur);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import bisect

N=int(input())
L1=list(map(int,input().split()))
L2=list(map(int,input().split()))
L3=list(map(int,input().split()))

L1.sort()
L2.sort()
L3.sort()

ans=0
for l2 in L2:
    l1_idx=bisect.bisect_left(L1,l2)
    l3_idx=bisect.bisect_right(L3,l2)
    
    ans+=l1_idx*(N-l3_idx)
print(ans)

Measured memory_bytes: 105544
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (b >= a)
    {
        cout << a << endl;
    }
    else
    {
        cout << a - 1 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int a,b,c,d[1000],ans,an;
int main(void){

    cin>>a>>b>>c;
    for(int i=0;i<b;i++){
        cin>>d[i];
        if(d[i]<c && d[i]>0){
            ans++;
        }else if(d[i]>c && d[i]<a){
            an++;
        }
    }
    if(ans<an){
        cout<<ans<<endl;
    }else{
        cout<<an<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> d(n);
	for(int i=0;i<n;i++){
		cin >> d[i];
	}
	int now=0;
	for(int i=0;i<n;i++){
		if(now<i){
			cout << "no" << endl;
			return 0;
		}
		now=max(now,i+d[i]/10);
	}
	now=0;
	reverse(d.begin(),d.end());
	for(int i=0;i<n;i++){
		if(now<i){
			cout << "no" << endl;
			return 0;
		}
		now=max(now,i+d[i]/10);
	}
	cout << "yes" << endl;
}



Measured memory_bytes: 4140
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
#define lo long
const int lmax=1999999999;
const long long lmx=1999999999999999999;
int d;
double a[11],s;
int main(){std::ios::sync_with_stdio(false);
cin>>d;
for(int i=0;i<d;i++)
{
	cin>>a[i];
}
sort(a,a+d);
for(int i=0;i<d-1;i++)
s+=a[i];
s+=a[d-1]/2;
cout<<s<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





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

int main()
{
	std::vector<int> hist(100, 0);

	int index = 0;
	int max = 0;
	while (std::cin >> index)
	{
		hist[index - 1]++;
		if (max < hist[index - 1])
		{
			max = hist[index - 1];
		}
	}

	int i = 1;
	for (const auto& h : hist)
	{
		if (h == max)
		{
			std::cout << i << std::endl;
		}
		++i;
	}

	return 0;
}

Measured memory_bytes: 3060
N=int(input())
S=[input() for i in range(N)]
ac_count=0
wa_count=0
tle_count=0
re_count=0
for i in range(len(S)):
    if S[i]=="AC":
        ac_count+=1
    if S[i]=="WA":
        wa_count+=1
    if S[i]=="TLE":
        tle_count+=1
    if S[i]=="RE":
        re_count+=1
print("AC x",ac_count)
print("WA x",wa_count)
print("TLE x",tle_count)
print("RE x",re_count)

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

const int H=1000+5,W=1000+5;

char a[H][W];

int h,w;

int mem[H][W];

int mod=1e9+7;

int dp(int i,int j){

if(i==h-1&&j==w-1)
    return 1;

if(i==h||j==w)
    return 0;

if(a[i][j]=='#')
    return 0;

    if (mem[i][j]!=-1)
        return mem[i][j];

        int p1=dp(i+1,j)%mod;
        int p2=dp(i,j+1)%mod;

        return mem[i][j]=(p1+p2)%mod;



}

int main(){

scanf("%d%d",&h,&w);

for (int i=0;i<h;i++)
   scanf("%s",&a[i]);

    memset(mem,-1,sizeof mem);

    printf("%d\n",dp(0,0));
}


Measured memory_bytes: 5248
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int n;
VI l;

void init() {

}

void input() {
  cin >> n;
  REP(i, n) {
    int a;
    cin >> a;
    l.PB(a);
  }
}

void solve() {
  sort(ALL(l));
  int sum = 0;
  FOR(i, 0, n-1) {
    sum += l[i];
  }
  if (sum <= l[n-1]) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

int main() {
	init();
	input();
	solve();
	return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

int cand[20];
bool dp[25][4000];

int main(){
  int n;
  cin >> n;
  dp[0][0] = true;
  REP(i, n) cin >> cand[i];
  int q, m;
  REP(i, n) REP(j, 2000){
    dp[i+1][j] |= dp[i][j];
    dp[i+1][j+cand[i]] |= dp[i][j];
  }
  cin >> q;
  REP(i, q){
    cin >> m;
    cout << (dp[n][m]? "yes": "no") << endl;
  }
  return 0;
}


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

import sys


def is_himan(weight, height):
    bmi = weight / (height ** 2)
    himan = False
    if bmi >= 25:
        himan = True
    return himan


def main():
    params = [line.rstrip().split(",") for line in sys.stdin.readlines()]
    for param in params:
        weight = float(param[1])
        height = float(param[2])

        if is_himan(weight, height):
            print param[0]

if __name__ == '__main__':
    main()

Measured memory_bytes: 4268
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int MAX_P = 2000 * 2000 + 1;
const int MOD = (int)1e9 + 7;

ll fact[MAX_P], rfact[MAX_P];

ll extgcd (ll a, ll b, ll &x, ll &y){
	if (b == 0){x = 1LL; y = 0LL; return a;}
	ll g = extgcd (b, a%b, y, x); y -= a/b*x;
	return g;
}

ll mod_inv(ll a, ll M){
	ll x, y;
	extgcd (a, M, x, y);
	return (M+x%M)%M;
}

void init(void){
	fact[0] = rfact[0] = 1LL;
	for (int i = 1; i < MAX_P; i++ ){
		fact[i] = (fact[i-1]*(ll)i)%(ll)MOD;
		rfact[i] = (rfact[i-1]*mod_inv((ll)i,(ll)MOD))%(ll)MOD;
	} // end for
}
	
ll comb(int n, int k){
	if (n < k) return 0LL;
	return ((fact[n]*rfact[n-k])%(ll)MOD)*rfact[k]%(ll)MOD;
}

ll dp[2001][2001];

int main()
{
	memset(dp, 0LL, sizeof(dp));
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, K; cin >> N >> K;
	init();

	rep (i, N+1) dp[i][0] = 1LL;
	if (N != 1 && K != 1){
		for (int i = 1; i <= N; ++i){
			for (int j = 1; j <= i; ++j){
				dp[i][j] = (dp[i-1][j] + comb(N - i + (N - j + 1)*(K - 1) - 1, K - 2) * dp[i][j-1]) % (ll)MOD;
			} // end for
		} // end for
		ll res = (dp[N][N] * fact[N]) % (ll)MOD;
		cout << res << endl;			
	}else{
		cout << 1 << endl;
	} // end if

	return 0;
}

Measured memory_bytes: 94080
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
using namespace std;
int n,x,y,ans=1e9;
inline int read()
{
	int x=0,w=1;
	char c=getchar();
	while (!isdigit(c)&&c!='-') c=getchar();
	if (c=='-') c=getchar(),w=-1;
	while (isdigit(c))
	{
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*w;
}
inline int split(int x,int y)
{
	int res=0;
	while (x)
	{
		res+=x%10; x/=10;
	}
	while (y)
	{
		res+=y%10; y/=10;
	}
	return res;
}
int main()
{
	n=read();
	for (int i=1;i<n;i++)
	{
		x=i; y=n-i;
		ans=min(ans,split(x,y));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    # 数値取得サンプル
    #   1行1項目 n = int(input())
    #   1行2項目 x, y = map(int, input().split())
    #   1行N項目 x = [list(map(int, input().split()))]
    #   N行1項目 x = [int(input()) for i in range(n)]
    #   N行N項目 x = [list(map(int, input().split())) for i in range(n)]

    # 文字取得サンプル
    #   1行1項目 x = input()
    #   1行1項目(1文字ずつリストに入れる場合) x = list(input())
    a = input()
    if a == a.upper():
        print("A")
    else:
        print("a")


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """B"""
        output = """A"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """a"""
        output = """a"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 70808
M = int(input())
ans = 0
hoge = 0
for _ in range(M):
    d,c = map(int,input().split())
    while c:
        if c % 2 == 1:
            hoge += d
            ans += 1
            if hoge > 9:
                hoge = (hoge%10)+1
                ans += 1
        c //= 2
        ans += c
        d = d*2
        if d > 9:
            ans += c
            d = d%10+1

print(ans-1)

Measured memory_bytes: 48712
#include<stdio.h>
#include<math.h>
int main(){
	int N;
	double D,x,y;
	int n=0;
	scanf("%d %lf",&N,&D);
	for(int i=0;i<N;i++){
		scanf("%lf %lf",&x,&y);
		if(sqrt(x*x+y*y)<=D)
		n++;
	}
	printf("%d\n",n);
}

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

ll d[2501][51];

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	d[0][0] = 1;
	f(i, 0, n) {
		int t;
		scanf("%d", &t);
		for (int j = 50; j > 0; --j) {
			f(i, t, 2501)d[i][j] += d[i - t][j - 1];
		}
	}
	ll an = 0;
	int i = 1, t = k;
	while (i < 51 && k < 2501) {
		an += d[k][i];
		k += t;
		++i;
	}
	printf("%lld", an);
}

Measured memory_bytes: 1280
N = int(input())
W = list(map(int, input().split()))
f = [0 for _ in range(N+1)]
for i in range(1, N+1):
  f[i] = f[i-1] + W[i-1]
ans = 10e9
for i in range(1, N+1):
  ans = min(ans, abs(f[N] - 2 * f[i]))
print(ans)


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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define pow(x,y) round(pow(x,y))
#define vi vector<int>

#define ll long long int

int ctoi(char c) {return c-'0';}
int ord(char c) {return c-'a';}
int len(string s) {return s.length();}
int itoc(int i) {return i+'a';}
float dnum(int N) {return floor(log10(N))+1;}
int fibnth(int N) {
    int p = (pow(1+sqrt(5),N)) - (pow(1-sqrt(5),N)); //first part (upper part)
    int p2 = pow(2,N)*(sqrt(5)); //second part (lower part)
    return p/p2;
}

int main() {
int N,minSum=0;
cin>>N;
vector<int> v(N);
for(auto& x: v) cin>>x;
sort(all(v));
int temp = v.back();
for(int i=N-2;i>=0;i--) {
    minSum += temp-v[i];
    temp = v[i];
}
cout<<minSum<<endl;
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		/*
		Character[] alp = new Character[26];
		char c ='a';
		for(int i=0;i<26;i++) {
			alp[i]=c;
			c++;
		}*/
		//StringBuilder alpSB = new StringBuilder();
		String alp = "abcdefghijklmnopqrstuvwxyz";
		//alpSB.append(alp);
		String hyozi ="";
		for(int i=0;i<alp.length();i++) {
			//aから順に調べて、ｓ内に存在するか
				if(s.contains(String.valueOf(alp.charAt(i)))) {
				}else {
					hyozi=String.valueOf(alp.charAt(i));
					break;
			}
		}
		if(hyozi.equals("")) {
			System.out.println("None");
		}else {
			System.out.println(hyozi);
		}

	}

}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define LL long long
using namespace std;
inline LL gi () {
	LL x=0, w=0; char ch=0;
	while (! (ch>='0' && ch<='9') ) {
		if (ch=='-') w=1;
		ch=getchar ();
	}
	while (ch>='0' && ch<='9') {
		x= (x<<3) + (x<<1) +  (ch^48);
		ch=getchar ();
	}
	return w?-x:x;
}

const int N=1e5+10;
LL n,a,b,x[N],Ans;

int main ()
{
	n=gi (), a=gi (), b=gi ();
	for (LL i=1;i<=n;++i) x[i]=gi ();
	for (LL i=2;i<=n;++i)
		Ans+=min ( (x[i]-x[i-1]) *a, b);
	printf ("%lld\n", Ans);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5;
const ll MOD=1e9+7;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    set<ll> st;
    for(ll i=1;i<=3;i++)st.insert(i);
    for(ll i=1;i<=2;i++){
        ll x;
        cin>>x;
        st.erase(x);
    }
    cout<<(*st.begin());
}


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

int main(void) {
  int x, y, z;
  cin >> x >> y >> z;
  
  int a = 0;
  a = y;
  y = x;
  x = a;
  
  a = z;
  z = x;
  x = a;
  
  cout << x << " " << y << " " << z << endl;
  
  return 0;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int a, b, c, k;
   cin >> a >> b >> c >> k;
   rep(i,k){
      if (a >= b)
         b *= 2;
      else if (b >= c)
         c *= 2;
   }
   if (a < b && b < c)cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 3600
""" A
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return [lambda _: readIntegerSet(m) for _ in range(0, n)]

def main(D, T, S):
    return "Yes" if T * S >= D else "No"

if __name__ == "__main__":
    _D, _T, _S = readIntegerSet(3)

    print(main(_D, _T, _S))

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

int main(){
    long long int X, Y;
    cin >> X >> Y;
    long long int ar=0;
    long int count=1;
    ar = X;
    for(long long int i=X; i<Y+1; i++){
        ar *= 2;
        if(ar>Y){
            break;
        }
        count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_right
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
for i in range(n-1):
    a[i+1]+=a[i]
for i in range(m-1):
    b[i+1]+=b[i]
a=[0]+a
ans=0
for i in range(n+1):
    if a[i]>k:
        continue
    idx=bisect_right(b,k-a[i])
    ans=max(ans,idx+i)
print(ans)

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

int main(){
    vector<int> dice(7);
    vector<int> tmp(7);
    for(int i=1; i<=6; i++){
        cin >> dice[i];
        //cout << dice[i] << endl;
    }
    string com;
    cin >> com;
   // cout << com << endl;
    for(int i=0; i<com.size(); i++){
        for(int j=1; j<=6; j++){
            tmp[j]=dice[j];
        }
        if(com[i]=='E'){
            dice[1]=tmp[4];
            dice[3]=tmp[1];
            dice[4]=tmp[6];
            dice[6]=tmp[3];
        }
        else if(com[i]=='N'){
            dice[1]=tmp[2];
            dice[2]=tmp[6];
            dice[5]=tmp[1];
            dice[6]=tmp[5];
        }
        else if(com[i]=='S'){
            dice[1]=tmp[5];
            dice[2]=tmp[1];
            dice[5]=tmp[6];
            dice[6]=tmp[2];
        }
        else if(com[i]=='W'){
            dice[1]=tmp[3];
            dice[3]=tmp[6];
            dice[4]=tmp[1];
            dice[6]=tmp[4];
        }
    }
    cout << dice[1] << endl;
    return 0;
}


Measured memory_bytes: 3232
#pragma GCC optimize("O3") 

#include <bits/stdc++.h>
using namespace std;

typedef long long int           ll;
typedef unsigned long long int  ull;
typedef long double             ld;

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

#define test(t)		        int t; cin >> t; while(t--)
#define f(i, a, b)	        for(int (i) = (a); (i) < (b); ++(i))
#define all(a)		        (a).begin(), (a).end()
#define endl 		        "\n"
#define maxvec(vec)             *max_element(all(vec))
#define minvec(vec)             *min_element(all(vec))
#define maxarr(arr)             *max_element(arr, arr + n)
#define minarr(arr)             *min_element(arr, arr + n)
#define deb(x)		        cout << #x << "--" << x << "--" << endl;
#define deb2(x,y)	        cout << #x << "-" << x << "-" << " ~~ " <<  #y << "-" << y << "-" << endl;
#define deba(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n << " "; cout << "]" << endl;
#define debap(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n.first << "-" << n.second << " "; cout << "]" << endl;
#define fast 		        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define mx9		1000000007
#define mx7		10000007
#define mx6		1000006
#define mx5		200005
#define inf		1<<30                                 
#define eps		1e-9
#define mod		1000000007
#define PI		3.141592653589793238462643383279502884L

void solve()
{
  ll l, r, d;
  cin >> l >> r >> d;
  ll cnt = 0;
  f(i, l, r + 1)
    if(i % d == 0)
      cnt += 1;
  cout << cnt << endl;
}

int main()
{
    fast;
    //test(t)
        solve();
    return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int isprime(int);

int main(){
  int n,i,x,ip,count=0;

  scanf("%d",&n);
  //constraint
  if(n<1 || n>10000){
    exit(1);
  }

  for(i=0;i<n;i++){
    scanf("%d",&x);
    
    ip=isprime(x);

    if(ip==1){ //prime
      count++;
    }
  }

  printf("%d\n",count);

  return 0;
}

//primality test
int isprime(int x){
  int i;

  if(x==2){
    return 1; //true
  }else if(x<2 || x%2==0){
    return 0; //false
  }

  i=3;

  while(i<=sqrt(x)){
    if(x%i==0){
      return 0; //false
    }

    i=i+2;
  }

  return 1; //true
}

Measured memory_bytes: 596
import math
import sys
(A, B) = list(map(int, input().split()))

price_A = 0
price_B = 0

price_A = math.ceil(A / 0.08)
price_B = math.ceil(B / 0.1)

min_price = min(price_A, price_B)
max_price = max(price_A, price_B)

for i in range(min_price, max_price+1, 1):
    tax_A = int(i * 0.08)
    tax_B = int(i * 0.1)
#    print(" ", i, tax_A,tax_B)
    if tax_A == A and tax_B == B:
        print(i)
        sys.exit()

print(-1)

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

struct Card{
  char a;
  int b;
};

bool compare_as_ints(Card i, Card j)
{
  return (i.b<j.b);
}

int partition(Card A[], int p, int r){
  Card x=A[r];
  int i=p-1;
  for(int j=p; j<=r-1;  j++){
    if(A[j].b<=x.b){
      i++;
      swap(A[i], A[j]);
    }
  }
  swap(A[i+1], A[r]);
  return i+1;
}

void quickSort(Card A[], int p, int r){
  if(p<r){
    int q=partition(A, p, r);
    quickSort(A, p, q-1);
    quickSort(A, q+1, r);
  }
}

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

  Card A[100000], B[100000];
  for(int i=0; i<n; i++){
    cin>>A[i].a>>A[i].b;
    B[i]=A[i];
  }

  quickSort(A, 0, n-1);
  stable_sort(B, B+n, compare_as_ints);
  int checker=0;
  for(int i=0; i<n; i++){
    if(A[i].b!=B[i].b){
      checker++;
    }
    if(A[i].a!=B[i].a){
      checker++;
    }
  }
  if(checker==0){
    cout<<"Stable"<<endl;
  }
  else{
    cout<<"Not stable"<<endl;
  }
  for(int i=0; i<n; i++){
    cout<<A[i].a<<' '<<A[i].b<<endl;
  }

  return 0;
}



Measured memory_bytes: 4696
S = input()
s = len(S)-1
ans=0
for bit in range(1 << s):
    a = S[0]
    for i in range(s):
        if bit & (1<<i):
            a += "+"
        a += S[i+1]
    ans += sum(map(int,a.split("+")))
print(ans)


Measured memory_bytes: 41452
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int c = 0;
	for(int i=1;i<=n;i++) {
		if(i % 2 == 1) c++;
	}
	long double ans = c * 1.0 / n;
	cout << fixed << setprecision(50) << ans;
	return 0;
}


Measured memory_bytes: 256
///
// File:  alds1_6_a.cpp
// Author: ymiyamoto
//
// Created on Tue Oct 10 23:31:16 2017
//

#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

static vector<uint32_t> array;
static vector<uint32_t> nums(2000000, 0);
static vector<uint32_t> out_array;
int32_t main()
{
  uint32_t n;
  cin >> n;

  for (uint32_t i = 0; i < n; i++) {
    uint32_t val;
    cin >> val;
    array.push_back(val);
    nums[val]++;
  }

  for (uint32_t i = 0; i < nums.size() - 1; i++) {
    nums[i + 1] += nums[i];
  }

  out_array.resize(array.size(), 0);
  for (int32_t i = array.size() - 1; i >= 0; i--) {
    out_array[nums[array[i]] - 1] = array[i];
    nums[array[i]]--;
  }

  for (uint32_t i = 0; i < out_array.size(); i++) {
    if (i != 0) cout << " ";
    cout << out_array[i];
  }
  cout << endl;

  return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
int K, T;
	cin >> K >> T;
	int ans = 0;
	fx(T) {
		int a;
		cin >> a;
		ans = max(ans,a);
	}
	if (T==1) {
		ce(K-1)
	}
	else {
			ce(max(ans-1-(K-ans),0))
	}
    return 0;
}



Measured memory_bytes: 256
import functools
import fractions
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = []
d = []
co = 0
for i in range(a[0]):
	c.append(abs(b[i]-a[1]))
	if b[i]-a[1] > 0 and co == 0:
		c.insert(i,0)
		co += 1
if co == 0:
	c.append(0)

for i in range(len(c)-1):
	d.append(abs(c[i+1]-c[i]))
print(functools.reduce(fractions.gcd, d))

Measured memory_bytes: 17032
#include <iostream>

using namespace std;

int main()
{
    int a, b;

    cin >> a >> b;

    if(a + b == 15) {
        cout << "+" << endl;
    } else if(a * b == 15) {
        cout << "*" << endl;
    } else {
        cout << "x" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int  main(){
ll n,k;
cin >> n>> k;
vector<pair<ll,ll>>a(n);
for(int i=0;i<n;i++){
    ll z,zz;
    cin >>z>>zz;
    a.at(i)=make_pair(z,zz);
}
sort(a.begin(),a.end());
ll now=0;
for(int i=0;i<n;i++){
    now+=a.at(i).second;
    if(now>=k){
    ll che = a.at(i).first;
        cout << che<<endl;
        break;
    }
}
}





Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  cout << a[0] << b[0] << c[0] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  char A[1000];
  int i,k=0;
  scanf("%s",&A);
  for(i=0;i<=2;i++)
  {
    if(A[i]==A[i+1])
      k++;
  }
   if(k==0)
     printf("Good");
  else
    printf("Bad");
}

Measured memory_bytes: 128
S = input()
Q = int(input())
I = 0
L = ''
R = ''
for i in range(Q):
    Query = input().split()
    if Query[0] == "1":
        I = I + 1
    else:
        if (int(Query[1]) + I) % 2 == 0:
            R = R + Query[2]
        else:
            L = L + Query[2]
L = L[::-1]
S = L + S + R

if I % 2:
    S = S[::-1]
print(S)


Measured memory_bytes: 4304
n = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for i, a in enumerate(L[2:]):
    k = i + 1
    for j, b in enumerate(L[:i + 2]):
        while j < k and a - b < L[k]:
            k -= 1
        ans += i - max(k, j) + 1

print(ans)


Measured memory_bytes: 9320
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define MAX(a,b) (a > b) ? a : b
#define MIN(a,b) (a < b) ? a : b
const int inf = 1000000000; // 10^9

int Amax(int *p,int size){
   int _max = 0;
   for(int i = 0;i < size;i++)
      if(p[i] > _max)_max = p[i];
   return _max;
}
int Amin(int *p,int size){
   int _min = 0;
   for(int i = 0;i < size;i++)
      if(p[i] < _min)_min = p[i];
   return _min;
}
int main(){
   int n;scanf("%d",&n);
   int a[100];
   for(int i = 0;i < n;i++)scanf("%d",&a[i]);
   int ans = inf;
   for(int i = Amin(a,n);i < Amax(a,n)+1;i++){
      int _ans = 0;
      for(int j = 0;j < n;j++){
         _ans += pow(abs(a[j] - i),2);
      }
      //printf("MIN(%d,%d)\n",ans,_ans);
      ans = MIN(ans,_ans); 
      //printf("%d:%d\n",i,ans);
   }
   printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <cstring>
#include <queue>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N = 1009;
const double PI = acos(-1.0);

LL mod = 1e9+7;
int main()
{
    int a;
    cin >> a;
    LL sum = 1;
    for(int i = 1; i <= a; i++)
        sum = (sum*i)%mod;
    cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] l = new int[n*2];
		for(int i=0;i<n*2;i++){
			l[i] = scanner.nextInt();
		}
		Arrays.sort(l);
		int sum = 0;
		for(int i=0;i<n*2;i+=2){
			sum += Math.min(l[i], l[i+1]);
		}
		System.out.println(sum);
	}

}


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

using namespace std;

string f(vector<char> arr) {
    set<char> s;
    for (int i = 0; i < arr.size(); i++) {
        s.insert(arr[i]);
    }

    if (s.size() == 4) {
        return "Four";
    }

    return "Three";
}

int main() {

    int n;
    cin >> n;

    vector<char> s;
    for (int i = 0; i < n; i++) {
        char tmp;
        cin >> tmp;
        s.push_back(tmp);
    }

    string result = f(s);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
t,a = map(int,input().split())
ls = list(map(int,input().split()))
p = 0
j = 0
for i in range(n):
    if i ==0:
        tem = t - 0.006*ls[i]
        ans = abs(tem-a)
        j = 1
    else:
        tem = t - 0.006*ls[i]
        if ans - abs(tem-a) >0:
            ans = abs(tem-a)
            j = i + 1
print(j)


    

Measured memory_bytes: 3064
import java.util.Scanner;
import java.math.BigInteger;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		for(int i = 0; i < n; i++) {
			BigInteger a = scan.nextBigInteger();
			BigInteger b = scan.nextBigInteger();
			BigInteger c = a.add(b);
			if(c.toString().length() > 80 ) {
				System.out.println("overflow");
			}
			else {
				System.out.println(c);
			}
		}
	}
}

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

int main() {
	std::string str;
	std::getline(std::cin, str);
	for(int i=0; i<str.size(); i++){
		if('a' <= str[i] && str[i] <= 'z'){
			str[i] = str[i] - 'a' + 'A';
		}
	}
	std::cout << str << std::endl;
	return 0;
}

Measured memory_bytes: 1172
class Dice:
    def __init__(self, label):
        self.label = label.copy()
    
    def rotateS(self):
        """[1, 2, 6, 5] -> [5, 1, 2, 6]"""
        t = self.label[1]
        self.label[1] = self.label[5]
        self.label[5] = self.label[6]
        self.label[6] = self.label[2]
        self.label[2] = t

    def rotateN(self):
        t = self.label[1]
        self.label[1] = self.label[2]
        self.label[2] = self.label[6]
        self.label[6] = self.label[5]
        self.label[5] = t
    
    def rotateW(self):
        t = self.label[1]
        self.label[1] = self.label[3]
        self.label[3] = self.label[6]
        self.label[6] = self.label[4]
        self.label[4] = t
    
    def rotateE(self):
        t = self.label[1]
        self.label[1] = self.label[4]
        self.label[4] = self.label[6]
        self.label[6] = self.label[3]
        self.label[3] = t

    def rotateR(self):
        'SWN = R'
        t = self.label[3]
        self.label[3] = self.label[2]
        self.label[2] = self.label[4]
        self.label[4] = self.label[5]
        self.label[5] = t

    def rotateL(self):
        'SEN = L'
        t = self.label[3]
        self.label[3] = self.label[5]
        self.label[5] = self.label[4]
        self.label[4] = self.label[2]
        self.label[2] = t


def compare(dice1, dice2):
    if (dice1.label == dice2.label):
        return True
    else:
        return False

def verify(dice1, dice2):
    dice_t = Dice(dice2.label)
    numS = 0
    for i in range(0,4):
        numR = 0
        for _ in range(0,4):
            debugprint(dice1, dice_t)
            if (compare(dice1, dice_t)):
                return True
            dice_t.rotateR()
            numR += 1
        #print(numR)
        dice_t.rotateS()
        numS += 1
    #print(numS)

    dice_t.rotateE()
    for _ in range(0,4):
        debugprint(dice1, dice_t)
        if (compare(dice1, dice_t)):
            return True
        dice_t.rotateR()

    dice_t.rotateE()
    dice_t.rotateE()
    for _ in range(0,4):
        debugprint(dice1, dice_t)
        if (compare(dice1, dice_t)):
            return True
        dice_t.rotateR()

    return False

def debugprint(dice1, dice2, label=''):
    debug=False
    if (debug):
        print(label)
        print('dice1: {}'.format(dice1.label))
        print('dice2: {}'.format(dice2.label))
        print('')

## Main

ndice = int(input())
dices = []
for i in range(0,ndice):
    label = []
    label.append(-1)
    label[1:] = map(int,input().split())
    dice = Dice(label)
    dices.append(dice)

for i in range(0,ndice-1):
    for j in range(i+1, ndice):
        if (verify(dices[i], dices[j])):
            print('No')
            exit()
print('Yes')



Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

ll f(int n){
    return (ll)n * n * n;
}

int main(){
    int n,k;
    cin >> n >> k;
    ll ans = 0;
    if(k%2!=0){
        ans = f(n/k);
    }else{
        int cnt = 0;
        for(int i=1;i<=n;i++){
            if(i%k==k/2) cnt++;
        }
        ans = f(n/k) + f(cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

		boolean[][] s = new boolean[200][200];
		int[] num = new int[200];

		for(int i = 0 ; i < n ; i++){
			String tmp = sc.next();
			for(int j = 0 ; j < n ; j++){
				s[i][j] = (tmp.charAt(j) == '1');
			}
		}

		int ans = -1;

		for(int k = 0 ; k < n ; k++){
			LinkedList<Integer> que = new LinkedList<Integer>();
			int kans = -1;

			for(int i = 0 ; i < n ; i++){
				num[i] = 0;
			}

			que.add(k);
			num[k] = 1;

			while(que.size() > 0){
				Integer vNum = que.poll();
				for(int i = 0 ; i < n ; i++){
					if(num[i] == 0){
						if(s[vNum][i]){
							num[i] = num[vNum]+1;
							que.add(i);
						}
					}
				}
			}

			for(int i = 0 ; i < n ; i++){
				if(kans < num[i]){
					kans = num[i];
				}
			}

			for(int i = 0 ; i < n-1 ; i++){
				for(int j = i+1 ; j < n ; j++){
					if(s[i][j]){
						if((num[i] - num[j] != 1) && (num[j] - num[i] != 1)){
							kans = -1;
							break;
						}
					}
				}
			}

			if(ans < kans){
				ans = kans;
			}
		}

		System.out.println(ans);
	}
}

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

using namespace std;

int main() {
    int x;
    int y;
    cin >> x >> y;
    int a;
    for(int i=0;i<y;i++){
        cin >> a;
        x = x - a;
        if(x <=0){
            i = y;
        }
    }
    if(x > 0){
        cout << "No";
        
    }
    else{
        cout << "Yes";
        
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

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

// MOD確認

ll N;

int main(){
   cin >> N;
   vector<ll> A(N);
   rep(i,N) cin >> A[i];
   sort(ALL(A));
   reverse(ALL(A));
   ll ans = 0;
   FOR(i,1,N){
      ans += A[i/2];
   }
   cout << ans << endl;
}

Measured memory_bytes: 4840
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		while(in.hasNext()) {
			int L=in.nextInt();
			int R=in.nextInt();
			int d=in.nextInt();
			int count=0;
			for(int i=L;i<=R;i++) {
				if(i%d==0) {
					count++;
				}
			}
			System.out.println(count);
		}
	}
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(int i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a) memset(a,0,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    string str;
    set<int>st;
    cin>>str;
    rep(i,0,str.size())
    st.insert(str[i]);
    if(st.size()==1)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

#ifndef LOCAL
#define cerr _cer
struct _cert
{
    template <typename T> _cert& operator << (T) { return *this; }
};
_cert _cer;
#endif

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
		cerr << (*i) << " ";
    }
    cerr << "\n";
}

int cl[120000];
int lst[120000];
vector<int> eds[120000];
int n, m, q;

void dfs1(int v, int d, int c) {
	if (!cl[v])
		cl[v] = c;
	if (lst[v] >= d)
		return;
	lst[v] = d;
	if (d == 0)
		return;
	for (int u: eds[v])
		dfs1(u, d - 1, c);
}


vector<tuple<int, int, int >> vv;
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		--a, --b;
		eds[a].push_back(b);
		eds[b].push_back(a);
	}
	scanf("%d", &q);
	for (int i = 0; i < q; ++i) {
		int v, d, c;
		scanf("%d%d%d", &v, &d, &c);
		--v;
		vv.push_back(make_tuple(v, d, c));
	}
	reverse(vv.begin(), vv.end());
	for (int i = 0; i < q; ++i) {
		int v, d, c;
		tie(v, d, c) = vv[i];
		dfs1(v, d, c);
	}
	for (int i = 0; i < n; ++i)
		printf("%d\n", cl[i]);
	return 0;
}




Measured memory_bytes: 9328
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong(),b=sc.nextLong(),c=sc.nextLong(),k=sc.nextLong();
        if(Math.abs(a-c)>10e18){
            System.out.println("Unfair");
        } else {
            if(k%2==0){
                System.out.println(a-b);
            } else {
                System.out.println(b-a);
            }
        }
    }
}


Measured memory_bytes: 22996