akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <string>

using namespace std;

class cake_comb{
public:
  long long taste;
  long long a;
  long long b;
  long long c;
  cake_comb(long long taste, long long a, long long b, long long c){
    this->taste = taste;
    this->a = a;
    this->b = b;
    this->c = c;
  };
};

bool operator> (const cake_comb cc1, const cake_comb cc2){
  return cc1.taste < cc2.taste;
};

int main(){
  vector<long long> A, B, C;
  long long x, y, z, k;
  int h = 0;
  int i = 0;
  int j = 0;
  long long t = 0;
  map<string, bool> m;
  priority_queue<cake_comb, vector<cake_comb>, greater<cake_comb>> pq;
  cin >> x >> y >> z >> k;
  for (int i=0;i<x;i++) {
    long long tmp;
    cin >> tmp;
    A.push_back(tmp);
  }
  for (int i=0;i<y;i++) {
    long long tmp;
    cin >> tmp;
    B.push_back(tmp);
  }
  for (int i=0;i<z;i++) {
    long long tmp;
    cin >> tmp;
    C.push_back(tmp);
  }
  sort(A.begin(), A.end(), greater<long long>());
  sort(B.begin(), B.end(), greater<long long>());
  sort(C.begin(), C.end(), greater<long long>());
  cake_comb first_cc(A[0]+B[0]+C[0], 0, 0, 0);
  pq.push(first_cc);
  m[string("0:0:0")] = true;
  while (t < k) {
    cake_comb cc_tmp = pq.top();
    pq.pop();
    cout << cc_tmp.taste << endl;
    string keystr = to_string(cc_tmp.a) + string(":") + to_string(cc_tmp.b) + string(":") + to_string(cc_tmp.c);
    string keystr_a = to_string(cc_tmp.a + 1) + string(":") + to_string(cc_tmp.b) + string(":") + to_string(cc_tmp.c);      
    if (cc_tmp.a+1 < x && m.find(keystr_a) == m.end()){
      cake_comb cc_a(A[cc_tmp.a+1] + B[cc_tmp.b] + C[cc_tmp.c], cc_tmp.a+1, cc_tmp.b, cc_tmp.c);
      //      cout << keystr_a << "\t" << A[cc_tmp.a+1] + B[cc_tmp.b] + C[cc_tmp.c] << endl;
      m[keystr_a] = true;
      pq.push(cc_a);
    }
    string keystr_b = to_string(cc_tmp.a) + string(":") + to_string(cc_tmp.b+1) + string(":") + to_string(cc_tmp.c);      
    if (cc_tmp.b+1 < y && m.find(keystr_b) == m.end()){
      cake_comb cc_b(A[cc_tmp.a] + B[cc_tmp.b+1] + C[cc_tmp.c], cc_tmp.a, cc_tmp.b+1, cc_tmp.c);
      //      cout << keystr_b << "\t" << A[cc_tmp.a] + B[cc_tmp.b+1] + C[cc_tmp.c] << endl;
      m[keystr_b] = true;
      pq.push(cc_b);
    }
    string keystr_c = to_string(cc_tmp.a) + string(":") + to_string(cc_tmp.b) + string(":") + to_string(cc_tmp.c+1);      
    if (cc_tmp.c+1 < z && m.find(keystr_c) == m.end()){
      cake_comb cc_c(A[cc_tmp.a] + B[cc_tmp.b] + C[cc_tmp.c+1], cc_tmp.a, cc_tmp.b, cc_tmp.c+1);
      //      cout << keystr_c << "\t" << A[cc_tmp.a] + B[cc_tmp.b] + C[cc_tmp.c+1] << endl;
      m[keystr_c] = true;
      pq.push(cc_c);
    }
    t++;
  }
  return(0);
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YN YES else NO
#define yn Yes else No
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  rep(j, v.size()) i >> v[j];
  return i;
}

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

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;
}

signed main() {
  init();
  ll A, B, K;
  cin >> A >> B >> K;

  ll count = 0;
  while (1) {
    if (A % 2 == 1) A--;
    B += A / 2;
    A /= 2;
    count++;
    if (count == K) break;

    if (B % 2 == 1) B--;
    A += B / 2;
    B /= 2;
    count++;
    if (count == K) break;
  }

  cout << A << " " << B << endl;
  return 0;
}

Measured memory_bytes: 3600
import time

start_time = time.time()

n = str(input())

one = n.count('1')
two = n.count('2') * 2
three = n.count('3') * 3
four = n.count('4') * 4
five = n.count('5') * 5
six = n.count('6') * 6
seven = n.count('7') * 7
eight = n.count('8') * 8
nine = n.count('9') * 9

ans = one + two + three + four + five + six + seven + eight + nine

if ans % 9 == 0:
    print('Yes')
    # print("elapsed_time:{time} sec".format(time=time.time() - start_time))

else:
    print('No')
    # print("elapsed_time:{time} sec".format(time=time.time() - start_time))


Measured memory_bytes: 9284
#include<cstdio>
#include<cctype>
using namespace std;
int main(){
    char x;
    int t=0;
    char P[1201];
    for(int i=0;i<=1200;i++){
        scanf("%c",&x);
        P[i]=tolower(x);
    }
    for(char s='a';s<='z';s++){
        for(int i=0;i<=1200;i++){
            if(P[i]==s) t+=1;
        }
        printf("%c : %d\n",s,t);
        t=0;
    }
}



Measured memory_bytes: 2744
#include <stdio.h>
int main(){
 
  int a,b,i,d;
 
  while(1){
  scanf("%d %d",&a,&b);
if(a==0 && b==0)break;
 
  for(i=0;i<a;i++){

    for(d=0;d<b;d++)
{
    printf("#");
  } 
  printf("\n");
 
  
  }
  printf("\n");
  }
  
 
  return 0;
  }


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int X;
  cin >> X;
  if (X >= 30) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3616
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

#define FOR(i, b, e) for(int i=(b);i<(e);i++)
#define REP(i, n) FOR(i,0,n)

#define ALL(v) (v).begin(),(v).end()

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000007;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }

int main() {
    int N, M;
    int A[1001];
    int S = 0;
    cin >> N >> M;
    REP (i, N) {
        cin >> A[i];
        S += A[i];
    }
    sort(A, A+N);
    REP (i, M) {
        if (A[N - 1 - i] < S / (4.0 * M)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;

vector <string> pat3 = {"aab",
						"c.b",
						"cdd"};
vector <string> pat4 = {"abcc",
						"abdd",
						"eegh",
						"ffgh"};
vector <string> pat5 = {"aabee",
						"c.bff",
						"cddgg",
						"hij..",
						"hij.."};
vector <string> pat6 = {"aabe..",
						"c.be..",
						"cdd.ee",
						"ee.aab",
						"..ec.b",
						"..ecdd"};
vector <string> pat7 = {"aab...e",
						"c.b...e",
						"cdd...f",
						"...aabf",
						"...c.bg",
						"...cddg",
						"eeffgg."};

vector <vector <char> > matrix;
int n;

void print() {
	n = matrix.size();
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cout << matrix[i][j];
		}
		cout << "\n";
	}
}

int main(){
#ifdef LOCAL
	freopen("C_input.txt", "r", stdin);
	//freopen("C_output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	matrix.resize(n, vector <char> (n, '.'));
	if (n < 3) {
		cout << "-1\n";
		return 0;
	}
	if (n == 3) {
		for (int a = 0; a < n; a += 3) {
			for (int i = 0; i < 3; i++) {
				for (int j = 0; j < 3; j++) {
					matrix[i + a][j + a] = pat3[i][j];
				}
			}
		}
		print();
		return 0;
	}
	int nn = n;
	while (n >= 8) {
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				matrix[n - 4 + i][n - 4 + j] = pat4[i][j];
			}
		}
		n -= 4;
	}
	vector <string> pat;
	if (n == 4) pat = pat4;
	if (n == 5) pat = pat5;
	if (n == 6) pat = pat6;
	if (n == 7) pat = pat7;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			matrix[i][j] = pat[i][j];
		}
	}
	print();
}


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

int main() {
  bool flg = false;
  string s;
  cin >> s;

  for (int i = 0; i < 3; i++) if (s[i] == '7') flg = true;
  if (flg) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
#define N 200005
unsigned long long asum[N],axor[N];
int main()
{
	int n,l=1;
	long long ans=0;
	unsigned long long x;
	scanf("%d",&n);
	asum[0]=0;axor[0]=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&x);
		asum[i]=asum[i-1]+x;
		axor[i]=axor[i-1]^x;
	}
	for(int i=1;i<=n;i++)
	{
		while((asum[i]-asum[l-1])!=(axor[i]^axor[l-1]))l++;
        ans=ans+i-l+1;
	}
	printf("%lld\n",ans);
}

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

int main() {
  int N;
  cin >> N;
  
  vector<string> vec(N);
  
  for (int i; i < N; i++) {
    cin >> vec.at(i);
  }
  
  int AC = 0;
  int WA = 0;
  int TLE = 0;
  int RE = 0;
  
  for(int i; i < N; i++) {
    if(vec.at(i) == "AC") {
      AC++;
    }
    else if(vec.at(i) == "WA") {
      WA++;
    }
    else if(vec.at(i) == "TLE") {
      TLE++;
    }
    else if(vec.at(i) == "RE") {
      RE++;
    }
  }
  
  cout << "AC x " << AC <<endl;
  cout << "WA x " << WA <<endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
   int n;
   cin >> n;
   cout << n*n*n << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll n,m,ans=0;
void Main(){
    cin>>n;
    For(i,1,10){
        For(j,1,10){
            if(j*i==n) ans++;
        }
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
int main(){
    Main();
    return 0;
}


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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    int i = 1;
    for(auto& x : a) {
        cin >> x;
        x -= i++;
    }
    
    sort(begin(a), end(a));
    i = a.size() / 2;
    double median;
    if(a.size() % 2 == 0) {
        median = double(a[i] + a[i - 1]) / 2;
    } else {
        median = a[i];
    }

    using ll = long long;
    ll ans = numeric_limits<ll>::max();
    for(ll j = median - 10; j <= median + 10; ++j) {
        ll tmp = 0;
        for(auto x : a)
            tmp += abs(x - j);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        a[i] = (a[i] - i - 1);
    }

    sort(all(a));
    ll b = a[n/2], ans = 0;
    rep(i,n)ans += abs(a[i] - b);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
n=int(input())
s=list(input() for _ in range(n))

t=['']*n

for i in range(n):
	t[i]=sorted(s[i])

u=sorted(t)

cnt=0

#for i in range(n-1):    
#	for j in range(i+1,n):
#		if u[i]!=u[j]:
#			break
#		else:
#			cnt+=1

cnt_a=0
cnt_b=0

u.append(['0'])

#print(u)


for i in range(n):
	if u[i+1]==u[i]:
		cnt_a+=1
		#print(cnt_a)
	else:
		if cnt_a>0:
			cnt_b+=(cnt_a+1)*cnt_a//2
			#print(cnt_b)
			cnt_a=0

print(cnt_b)

Measured memory_bytes: 110168
N=int(input())
H=list(map(int,input().split()))
c=0
while H!=[0]*N:
  for i in range(N):
    if H[i]!=0:
      l=i
      break
  for j in range(l,N):
    if H[j]!=0:
      H[j]-=1
    else:
      break
  c+=1
print(c)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,a;
	cin>>n;
	set <int> s;
	for(int i=0;i<n;i++) {
		cin>>a;
		if(s.find(a)!=s.end()) s.erase(a);
		else s.insert(a);
	}
	cout<<s.size()<<endl;
	return 0;
}

Measured memory_bytes: 4864
#include<stdio.h>
#include<string.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
int main(){
	char s[100002];
	char *tbl[] = {"dream","dreamer","erase","eraser"};
	int Len[] = {5,7,5,6};
	int len;

	scanf("%s",s);
	len = strlen(s);

	while(len > 0){
		FOR(i,0,4){
			if(strcmp(tbl[i],&s[len - Len[i]]) == 0){
				s[len - Len[i]] = '\0';
				len -= Len[i];
				break;
			}
			if(i == 3){
				printf("NO\n");
				return 0;
			}
		}
	}
	printf("YES\n");
}

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

int main(void) {
	double x1, x2, x3;
	double y1, y2, y3;
	double a1, a2, b1, b2;
	double px, py, r;
	int n;
	double A1, B1, C1, A2, B2, C2;
	scanf("%d", &n);
	
	while (n--){
		scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
		A1 = 2.0*(x2-x1);
		B1 = 2.0*(y2-y1);
		C1 = x1*x1-x2*x2+y1*y1-y2*y2;
		A2 = 2.0*(x3-x1);
		B2 = 2.0*(y3-y1);
		C2 = x1*x1-x3*x3+y1*y1-y3*y3;
		px = (B1*C2-B2*C1)/(A1*B2-A2*B1);
		py = (C1*A2-C2*A1)/(A1*B2-A2*B1);
		r = sqrt((px-x1)*(px-x1)+(py-y1)*(py-y1));
		printf("%.3lf %.3lf %.3lf\n", px, py, r);
	}
	
	return 0;
}

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

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  cout << N / 3 << endl;
  return 0;
}


Measured memory_bytes: 3644
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    a=[[]for _ in range(N)]
    for i in range(N):
        a[i]=LI()
    
    adj=[[]for _ in range(N)]
    for i in range(N):
        for j in range(N):
            if a[i][j]==1:
                adj[i].append(j)
    
        
    M=1
    mm=1
    for i in range(70):
        mm*=2
        M+=1
        if mm>=K:
            break
    
    dab=[[[0]*N for _ in range(N)]for i in range(M)]
    #ダブリング，M回，1~Nの各頂点をスタートして，1~Nそれぞれを終点とする通り数を記憶
    for j in range(N):
        for kk in range(len(adj[j])):
            k=adj[j][kk]
            dab[0][j][k]=1
    
    for i in range(M-1):
        for j in range(N):
            for k in range(N):
                cnt=dab[i][j][k]
                for l in range(N):
                    dab[i+1][j][l]+=cnt*dab[i][k][l]
                    dab[i+1][j][l]%=mod
                    
    ans=[1]*N
    for mm in range(M):#ダブリング
        if K>>mm&1:
            temp=[0]*N
            for i in range(N):#iにいるところから行けるところを探す．
                cnt=ans[i]
                for j in range(N):
                    temp[j]+=dab[mm][i][j]*cnt
                    
            for i in range(N):
                ans[i]=temp[i]
                
    res=0
    for i in range(N):
        res+=ans[i]
        res%=mod
    print(res)
        

main()


Measured memory_bytes: 44636
import bisect


def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    ans = 0
    A_s = [0]
    B_s = [0]
    for a in A:
        A_s.append(A_s[-1]+a)
    tmp = 0
    for b in B:
        B_s.append(B_s[-1]+b)

    ans = 0
    for i in range(0, N+1):
        if A_s[i] > K:
            continue
        tmp = K - A_s[i]
        pos = bisect.bisect(B_s, tmp) - 1 + i
        if pos > ans:
            ans = pos
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 47348
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable mod = 10^^9 + 7;

void main() {
    int h, w;
    scan(h, w);

    auto map = new char[][](h + 2, w + 2);
    iota(h).each!(i => map[i + 1][1 .. w + 1] = readln.chomp.to!(char[]));

    auto dx = [1, 0, -1, 0, 1, 1, -1, -1], dy = [0, 1, 0, -1, 1, -1, 1, -1];

    foreach (i ; 1 .. h + 1) {
        foreach (j ; 1 .. w + 1) {
            if (map[i][j] == '.') {
                int cnt;
                foreach (k ; 0 .. 8) {
                    cnt += (map[i + dx[k]][j + dy[k]] == '#');
                }
                map[i][j] = ('0' + cnt).to!char;
            }
        }
    }

    iota(h).each!(i => writeln(map[i + 1][1 .. w + 1]));
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && a==c){
        cout<<"1"<<endl;
    }else if(a==b ||a==c ||b==c){
        cout<<"2"<<endl;
    }else{
        cout<<"3"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
double d,r,s,z[];main(i){for(;~scanf("%lf",z-i--%6);!i|i%6||puts(d>r+s?"0":r>d+s?"2":s>d+r?"-2":"1",d=hypot(*z-z[3],z[1]-z[4])))r=z[2],s=z[5];}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
int main(void){
	char string[200],res[200][200];
	int len,i,m,h,n,j,k,co=0;
	
	for(j=0;j<10;j++){
		for(i=0;i<200;i++){
			res[j][i]='$';
		}
	}
	for(n=0;n<10;n++){
		scanf("%s",&string);
		if(string[0]=='-')break;
		len=strlen(string);
		char yama[len+1];
		for(i=0;i<len;i++){
			yama[i]=string[i];
		}
		scanf("%d",&m);
		for(i=0;i<m;i++){
			scanf("%d",&h);
			for(j=0;j<h;j++){
			yama[len]=yama[0];
				for(k=0;k<len;k++){
					yama[k]=yama[k+1];
				}
			}
		}
		for(i=0;i<len;i++){
			res[n][i]=yama[i];
		}
		co++;
	}
	
	for(i=0;i<co;i++){
		for(j=0;j<200;j++){
			if(res[i][j]<'A'||res[i][j]>'z')break;
			printf("%c",res[i][j]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
vector<ll> res(0);
void yakusuu(ll n){
	for(ll i=1;i*i<=n;i++){
	    if(n%i==0){
            res.pb(i);
            if(i!=n/i) res.pb(n/i);
	    }
	}
	return ;
}
int main(){
  ll n,m;
  cin>>n>>m;
  yakusuu(m);
  ll ans=1;
  rep(i,sz(res)){
    if(m/res[i]>=n) chmax(ans,res[i]);
  }
  COUT(ans);
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        
        String[] a = sc.nextLine().split(" ");
        int[] men = new int[a.length];
        for (int i = 0; i < a.length; i++) {
            men[i] = Integer.parseInt(a[i]);
        }

        Dice dice = new Dice(men);

        int num = Integer.parseInt(sc.nextLine());
        for ( int i = 0; i < num; i++ ) {
            a = sc.nextLine().split(" ");
            int targetTop = Integer.parseInt(a[0]);
            int targetFront = Integer.parseInt(a[1]);

            if ( targetTop == dice.top ) {
                // nothing
            } else if ( targetTop == dice.front ) {
                dice.turnN();
            } else if ( targetTop == dice.back ) {
                dice.turnN(); dice.turnN(); dice.turnN();
            } else if ( targetTop == dice.left ) {
                dice.turnE();
            } else if ( targetTop == dice.right ) {
                dice.turnE(); dice.turnE(); dice.turnE();
            } else if ( targetTop == dice.bottom ) {
                dice.turnN(); dice.turnN();
            }

            if ( targetFront == dice.front ) {
                // nothing
            } else if ( targetFront == dice.right ) {
                dice.turnR();
            } else if ( targetFront == dice.left ) {
                dice.turnR(); dice.turnR(); dice.turnR();
            } else if ( targetFront == dice.back ) {
                dice.turnR(); dice.turnR();
            }

            System.out.println(dice.right);
 
        }

    }
}

class Dice {
    int top, front, right, left, back, bottom;

    public Dice(int[] men){
        this.top = men[0];
        this.front = men[1];
        this.right = men[2];
        this.left = men[3];
        this.back = men[4];
        this.bottom = men[5];
    }

    void turnN() {
        int tmp = this.top;
        this.top = this.front;
        this.front = this.bottom;
        this.bottom = this.back;
        this.back = tmp;
    }
    void turnE() {
        int tmp = this.top;
        this.top = this.left;
        this.left = this.bottom;
        this.bottom = this.right;
        this.right = tmp;
    }
    void turnR() {
        int tmp = this.front;
        this.front = this.right;
        this.right = this.back;
        this.back = this.left;
        this.left = tmp;
    }
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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 (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll N;
    cin >> N;
    ll val = N%10;
    string res;
    if(val==2 or val==4 or val==5 or val==7 or val==9) res = "hon";
    if(val==0 or val==1 or val==6 or val==8) res = "pon";
    if(val==3) res = "bon";

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3644
import math

A, B, N = map(int, input().split())


ans1 = 0

if N > B - 1:
    x = B-1
    print(int((A * x) / B) - A * int(x / B))
elif N <= B - 1:
    x = N
    print(int((A * x) / B) - A * int(x / B))




Measured memory_bytes: 9164
a, b = map(int, input().split())
if a * b < 0 or a == 0 or b == 0:
  ans = 'Zero'
elif b < 0:
  if (b - a) % 2 == 0:
    ans = 'Negative'
  else:
    ans = 'Positive'
else:
  ans = 'Positive'
print(ans)  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int N;
  cin>>N;
  vector<int> X(N),Y(N);
  rep(i,N) cin>>X[i]>>Y[i];
  vector<pair<ll,ll>> A;
  rep(i,N) rep(j,N) if(i!=j) A.push_back(make_pair(X[i]-X[j],Y[i]-Y[j]));
  sort(all(A));
  int cnt=1,M=1;
  rep(i,A.size()){
    if(i){
      if(A[i].first==A[i-1].first&&A[i].second==A[i-1].second){
        cnt++;
        M=max(M,cnt);
      }else cnt=1;
    }
  }
  if(M!=N) cout<<N-M<<endl;
  else cout<<N-M+1<<endl;
}

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pii pair<int, int>
#define sz size()

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>void __f(const char* name, Arg1&& arg1){cout<<name<<" : "<<arg1<<"\n";}
template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args)
{const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" , ";__f(comma+1, args...);} 
#define traceloop(x,a) { cerr<<#a<<": "; for(ll ix=0;ix<x;ix++) cerr<<a[ix]<<" "; cerr<<endl; }

int main()
{
	ios::sync_with_stdio(0);

	int i, j, k, n;

	cin>>n>>k;
	int a[n];
	vector<bool> dp(k+1, 0);
	for(i=0;i<n;++i)
		cin>>a[i];

	dp[0] = 0;
	for(i=0;i<k;++i)
	{
		for(j=0;j<n;++j)
		{
			if(i + a[j] <= k)
				dp[i + a[j]] = dp[i + a[j]] or !(dp[i]);
		}
	}

	//traceloop(k+1, dp);

	if(dp[k])
		cout << "First\n";
	else
		cout << "Second\n";

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
if 0 in A:
    print(0)
else:
    ans = 1
    MAX = pow(10,18)
    for i in range(N):
        ans *= A[i]
        if ans > MAX:
            ans = -1
            break
    print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef pair<int,ii> iii;
typedef vector<iii> viii;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

const int MOD = 1e9 + 7;
const ll INF = ll(1e18);
const ld eps = ld(1e-8);

ll modpow(ll a, ll b)
{
	if(b < 0) b += (MOD - 1);
	a %= MOD;
	ll r = 1;
	while(b)
	{
		if(b % 2)
		{
			r = (r*a)%MOD;
		}
		a = (a*a)%MOD;
		b /= 2;
	}
	if(r < 0) r += MOD;
	return r;
}

ll inv(ll x)
{
	return modpow(x, MOD - 2);
}

ll choose(ll n, ll r)
{
	if(r == 0)
	{
		return 1;
	}
	if(n == r)
	{
		return 1;
	}
	ll denom = 1;
	for (ll i = 2; i <= r; i++)
	{
		denom = (denom * i) % MOD;
	}
	ll res = 1;
	for (ll i = n; i > n - r; i--) 
	{
		res = (res * i) % MOD;
	}
	res = (res * modpow(denom, MOD - 2)) % MOD;
	if(res < 0) res += MOD;
	return res;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	ll ans = 0;
	swap(a, b);
	ans += choose(w-a+h-2,w-a-1);
	ll cur1, cur2;
	for(int i = 1; i <= h - b - 1; i++)
	{
		if(i == 1)
		{
			cur1 = a;
			cur2 = choose(w-a+h-3,w-a-1);
		}
		//cout << cur1 << ' ' << cur2 << endl;
		ans += (cur1*cur2)%MOD;
		ans %= MOD;
		if(ans < 0) ans += MOD;
		if(i < h - b - 1)
		{
			cur1 = (cur1*(a+i))%MOD;
			cur1 = (cur1*inv(i+1))%MOD;
			cur2 = (cur2*inv(w-a+h-2-i))%MOD;
			cur2 = (cur2*(h-i-1))%MOD;
		}
	}
	ans %= MOD;
	if(ans < 0) ans += MOD;
	cout << ans << '\n';
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

public class Answer {
    private static readonly int minutesIndex = 0;
    private static readonly int sortNumberIndex = 1;
  
    private static void Main(string[] args) {
        var numberOfLines = 5;
        var inputs = new List<string>();
        
        for (int lineIndex = 0; lineIndex < numberOfLines; lineIndex++) {
            inputs.Add(Console.ReadLine().Trim());
        }
        
        Console.WriteLine(GetAnswer(inputs));
    }
  
    private static string GetAnswer(List<string> inputs) {
        var menus = new List<int[]>();

        foreach (var input in inputs) {
            var minutes = int.Parse(input);
            var sortNumber = CalculateSortNumber(minutes);
            menus.Add((new int[2] {minutes, sortNumber}));
        }

        menus.Sort((a, b) => b[sortNumberIndex] - a[sortNumberIndex]);

        var totalMinutes = 0;
        for (int index = 0; index < menus.Count - 1; index++) {
            totalMinutes += CalculateWaitingTime(menus[index][minutesIndex]);
        }
        totalMinutes += menus[menus.Count - 1][minutesIndex];

        return totalMinutes.ToString();
    }

    private static int CalculateSortNumber(int minutes) => minutes % 10 == 0 ? 10 : minutes % 10;
    private static int CalculateWaitingTime(int minutes) => minutes % 10 == 0 ? minutes : minutes + 10 - (minutes % 10);
}

Measured memory_bytes: 13268
#include <algorithm>
#include <climits>
#include <iostream>
#include <random>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using std::cin;
using std::cerr;
using std::cout;
using std::endl;
using std::make_pair;
using std::pair;
using std::stack;
using std::string;
using std::unordered_set;
using std::vector;
using std::lower_bound;
using std::upper_bound;

int main(int argc, char* argv[]) {
  long n;
  int k;
  cin >> n >> k;
  int c = 1;
  while (n >= k) {
    n /= k;
    ++c;
  }
  cout << c;
  return 0;
}


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

using namespace std;

vector<int> adja[10000], cost[10000];

#define INF (1 << 30)

int main() {
	int n, id, k;

	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> id >> k;
		adja[id].resize(k);
		cost[id].resize(k);
		for (int j = 0; j < k; ++j) {
			cin >> adja[id][j] >> cost[id][j];
		}
	}

	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
	que.push(make_pair(0, 0)); //cost, node
	int best[10000];
	fill(best, best + n, INF);
	best[0] = 0;

	while (!que.empty()) {
		pair<int, int> top = que.top();
		que.pop();

		if (best[top.second] < top.first) {
			continue;
		}

		for (int j = 0, len = adja[top.second].size(); j < len; ++j) {
			if (best[adja[top.second][j]] > top.first + cost[top.second][j]) {
				best[adja[top.second][j]] = top.first + cost[top.second][j];
				que.push(make_pair(top.first + cost[top.second][j], adja[top.second][j]));
			}
		}
	}

	for (int i = 0; i < n; ++i) {
		cout << i << " " << best[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 7472
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <cctype>


using namespace std;

typedef string::const_iterator State;
class ParseError {};

int expression(State &begin);

//数字の列をパースして、その数を返す。
int number(State &begin){
	int ret=0;

	while(isdigit(*begin)){
		ret *= 10;
		ret += *begin -'0';
		begin++;
	}

	return ret;
}

// 括弧か数をパースして、その評価結果を返す。
int factor(State &begin) {
	if (*begin == '(') {
	        begin++; // '('を飛ばす。
	        int ret = expression(begin);
	        begin++; // ')'を飛ばす。
		return ret;
	} else {
        	return number(begin);
	}
}

//乗除の式をパースして、その評価結果を返す。
int term(State &begin){
	int ret = factor(begin);

	while(1){
		if(*begin=='*'){
			begin++;
			ret *= factor(begin);
		}else if(*begin=='/'){
			begin++;
			ret /= factor(begin);
		}else{
			break;
		}
	}

	return ret;
}

//四則演算の式をパースして、その評価結果を返す。
int expression(State &begin){
	int ret = term(begin);

	while(1){
		if(*begin=='+'){
			begin++;
			ret += term(begin);
		}else if(*begin=='-'){
			begin++;
			ret -= term(begin);
		}else if(*begin=='='){
			break;
		}else{
			break;
		}
	}

	return ret;
}

int main(){
	int I[100],Ii=0,n;
	string s;

	cin >> n;

	for(int i=0;i<n;i++){
		cin >> s;
		
		State begin = s.begin();
		int ans = expression(begin);
		I[Ii++] = ans;
	}

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

	return 0;
}

Measured memory_bytes: 1204
#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 ab;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() {
	
	string S;
	cin>>S;
	int i=0;
	int k=S.size()-1;
	while(S.at(i)!='A'){
		i++;
	}
	while(S.at(k)!='Z'){
		k--;
	}
	ce(k-i+1)
}

Measured memory_bytes: 640
from collections import deque
N = int(input())
a = list(map(int,input().split(" ")))
b = deque([a[0]])

for i in range(1,N):
	b.appendleft(a[i]) if i % 2 == 1 else b.append(a[i])

if N % 2 == 1:
	b.reverse()

for i in range(N):
	print(b[i],end=" ")

print()





Measured memory_bytes: 25540
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int c[3][3];
    rep(i,3){
        rep(j,3){
            cin>>c[i][j];
        }
    }
    string ans="Yes";
    if(c[1][0]-c[0][0]!=c[1][1]-c[0][1] || c[1][1]-c[0][1]!=c[1][2]-c[0][2]) ans="No";
    if(c[2][0]-c[0][0]!=c[2][1]-c[0][1] || c[2][1]-c[0][1]!=c[2][2]-c[0][2]) ans="No";
    cout << ans << endl;




}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define nMAX 100000
#define INF (1<<30)

typedef struct{char ch; int num;}card;
card in[nMAX],A[nMAX],L[nMAX],R[nMAX];

//{{{ quick
int Partition(int L,int R){
	int x=A[R].num, i=L-1, j;
	card tmp;

	for(j=L;j<R;j++){
		if(A[j].num<=x){
			++i;

			// swap(A[i].A[j])
			tmp=A[i];
			A[i]=A[j];
			A[j]=tmp;
		}
	}
	tmp=A[R];
	A[R]=A[i+1];
	A[i+1]=tmp;

	return i+1;
}

void QuickSort(int L, int R){
	int mid;
	if(L<R){
		mid=Partition(L,R);
		QuickSort(L,mid-1);
		QuickSort(mid+1,R);
	}
}
//}}}
//{{{ merge
void merge(card* A, int l, int mid, int r){
	int n1,n2,i,j,k;
	n1=mid-l;	n2=r-mid;
	for(i=0;i<n1;i++){
		L[i]=A[l+i];
	}
	for(int i=0;i<n2;i++){
		R[i]=A[mid+i];
	}
	L[n1].num=R[n2].num=INF;

	i=j=0;
	for(k=l;k<r;k++){
		if(L[i].num<=R[j].num){
			A[k]=L[i++];
		}else{
			A[k]=R[j++];
		}
	}
}

void MergeSort(card* A, int l, int r){
	int mid;
	if(r-l>1){
		mid=(l+r)/2;
		MergeSort(A,l,mid);
		MergeSort(A,mid,r);
		merge(A,l,mid,r);
	}
}

//}}}

int main(){
	int i,n;	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf(" %c %d",&in[i].ch, &in[i].num);
		//printf("%c %d\n",in[i].ch, in[i].num);
		A[i]=in[i];
	}
	QuickSort(0,n-1);
	MergeSort(in,0,n);

	int flag=1;
	for(i=0;i<n;i++){
		if(!(in[i].ch==A[i].ch && in[i].num==A[i].num)){
			flag=0;	break;
		}
	}

	if(flag==0)printf("Not stable\n");
	else printf("Stable\n");

	for(i=0;i<n;i++){
		//printf("%d: ",i);
		printf("%c %d\n",A[i].ch, A[i].num);
		//printf("in; %c %d\n",in[i].ch, in[i].num);
	}

	return 0;
}



Measured memory_bytes: 4084
#include <cstdio>
#include <algorithm>

using namespace std;
int sohuu[15],n,x;
bool ready[14][14][2];
int memo[14][14][2];
int minZ (int p) {
    for (int i=1;i<=13;i++)
        if (sohuu[i]==p) return i;
}
int maxZ (int p) {
    for (int i=13;i>=1;i--)
        if (sohuu[i]==p) return i;
}
int f(int l, int r, int p) {
    if (l<=minZ(1-p) && maxZ(1-p)<=r) return 0;
    if (ready[l][r][p]) return memo[l][r][p];
    int ans = 0;
    if (sohuu[l-1]==p || sohuu[r+1]==p) {
        if (sohuu[l-1]==p && f(l-1,r,1-p)==0) ans |= 1;
        if (sohuu[r+1]==p && f(l,r+1,1-p)==0) ans |= 1;
    }
    else
        if (f(l,r,1-p) == 0) ans |= 1;
    ready[l][r][p]=1;
    return memo[l][r][p]=ans;
}
int main(){/*
    freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); //*/
    scanf("%d",&n);
    sohuu[0]=sohuu[14]=2;
    for (int i=1;i<=n;i++) {
        fill(sohuu+1, sohuu+14, 1);
        for (int j=1;j<=6;j++) {
            scanf("%d",&x); sohuu[x]=0;
        }
        for (int i1=1; i1<=13; i1++)
            for (int j1=i1; j1<=13; j1++)
            ready[i1][j1][0]=ready[i1][j1][1]=0;
        int ans = f(7,7,0);
        if (ans) printf("yes\n");else printf("no\n");
    }
    return 0;
}



Measured memory_bytes: 2612
import sys

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

#a<=N,b<=N
#a%b>=K
#b>=K+1

#b=4のとき,
#a%b=2,3
#N//b*(b-K)+max(0,N%b-K+1)

if K==0:
    print(N**2)
    sys.exit()

ANS=0
for b in range(K+1,N+1):
    ANS+=N//b*(b-K)+max(0,N%b-K+1)

    #print(b,N//b*(b-K),max(0,N%b-K+1))

print(ANS)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;

bool sq(int n) {
	bool f = 0;
	for (int i = 0; i < sqrt(n) + 1; i++) {
		if (n == i * i)f = 1;
	}
	return f;
}
int main() {
	int n, d;
	int ans = 0;
	cin >> n >> d;
	vector<vector<int>> x(n, vector<int>(d));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> x.at(i).at(j);
		}
	}
	int a=0;
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			for (int k = 0; k < d; k++) {
				
				a +=( x.at(i).at(k) -x.at(j).at(k))* (x.at(i).at(k) - x.at(j).at(k));
				
			}
			if (i != j && sq(a) == 1)ans++;
			a = 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3668
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

int main() {
    int n;
    cin >> n;
    cout << n + n * n + n * n * n << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll num[300005];
ll ans[300005];
int main()
{
	
	int n,i;
	cin>>n;
	cin>>num[1];
	ll ans=num[1];
	for(i=2;i<=n;i++)
	{
		cin>>num[i];
		ans=ans^num[i];
	}
	for(i=1;i<=n;i++)
	{
		ll tmp=ans;
		tmp=tmp^num[i];
		cout<<tmp<<" ";
	}
	return 0;
}

Measured memory_bytes: 5160
n=8**6;P=[0,0]+[1]*n;S=[0]*n
for i in range(2,n):
  for j in range(2*i,n,i):P[j]=0
for i in range(1,n):S[i]+=(P[i]==P[(i+1)//2]==1)+S[i-1]
for _ in "_"*int(input()):l,r=map(int,input().split());print(S[r]-S[l-1])

Measured memory_bytes: 20292
#include<iostream>
using namespace std;
int main(){
	int n,m,p,x,sum=0,sum1;
	cin>>n;
	int t[100005];
	for(int i=0;i<n;i++){
		cin>>t[i];
		sum+=t[i];
	}
	cin>>m;
	for(int i=0;i<m;i++){
		cin>>p>>x;
		sum1=sum+x-t[p-1];
		cout<<sum1<<endl;
	}
}

Measured memory_bytes: 256
import sys
X, N = map(int,input().split())
if N == 0:
  PN = []
else:
  PN = list(map(int,input().split()))
nums = [i for i in range(-10,110)]

for P in PN:
  nums.remove(P)

dist = abs(nums[0]-X)
target = nums[0]
for num in nums[1:]:
  tmp = abs(num-X)
  if tmp >= dist:
    print(target)
    sys.exit()
  else:
    dist = tmp
    target = num
    

Measured memory_bytes: 9136
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
agc012 C
"""


n, m = map(int, input().split())

graph = [[] for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

q = int(input())
qlist = [tuple(map(int, input().split())) for i in range(q)]
qlist.reverse()

dp = [[-1]*11 for i in range(n+1)]
col = [0]


def updatedp(v, t, d):
    if dp[v][d] == -1:
        dp[v][d] = t
        if d > 0:
            updatedp(v, t, d-1)
            for u in graph[v]:
                updatedp(u, t, d-1)


t = 0
for v, d, c in qlist:
    col.append(c)
    updatedp(v, t, d)
    t += 1

for i in range(1, n+1):
    print(col[dp[i][0]+1])


Measured memory_bytes: 53600
#include <stdio.h>
#include <inttypes.h>

int main(void)
{
    uint_fast8_t n, m;
    scanf("%" SCNuFAST8 " %" SCNuFAST8, &n, &m);
    uint_fast8_t r[51] = { 0 };
    for (size_t i = 0; i < m; ++i) {
        uint_fast8_t a, b;
        scanf("%" SCNuFAST8 " %" SCNuFAST8, &a, &b);
        ++r[a - 1];
        ++r[b - 1];
    }
    for (size_t i = 0; i < n; ++i) {
        printf("%" PRIuFAST8 "\n", r[i]);
    }
    return 0;
}


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

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    if(N%K == 0)
        cout << 0;
    else
        cout << 1;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a[3];
  cin >> a[0] >> a[1] >> a[2];
  bool flag = false;
  rep(i,3){
    if(a[i]%2==0) flag = true;
  }

  if(flag){
    cout << 0 << endl;
    return 0;
  }
  ll m = max(a[0],a[1]);
  int idx = a[0] > a[1] ? 0 : 1;
  idx = a[2] > m ? 2 : idx;
  m = max(m,a[2]);

   ll ans=1;
   rep(i,3){
     if(i!=idx) ans *= a[i];
   }
   cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
         
          //素因数分解
        //Copyright (c) 2020 0214sh7
        //https://github.com/0214sh7/library/
        vector<long long> prime_factorization(long long N){
        vector<long long> R;
          if(N<2)return R;
          for(long i=2;i*i<=N;i++){
              while(N%i==0){
                  R.push_back(i);
                  N/=i;
              }
          }
          if(N!=1){
              R.push_back(N);
          }
          return R;
        }
         
        int main(){
         
          long long A;
          cin >> A;
          if(A==1){
            cout << 0 << endl;
            return 0;
          }
          vector<long long> R;
          R = prime_factorization(A);
          int X = R.size();
          int csr=0;
          int Total = 0;
          long long pr = R.at(0);
          while(csr!=X){
            int cnt = lower_bound(R.begin(), R.end(), pr+1) - R.begin() - csr;
            csr = lower_bound(R.begin(), R.end(), pr+1) - R.begin();
            if(csr!=X) pr = R.at(csr);
            
            //cout << cnt << endl;
            
            int j=1;
            while(j<=cnt){
              cnt -= j;
              j++;
            }
            
            Total += j-1;
          }
          
          cout << Total <<endl;
          
        }


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

int main() {
   int n;
   string s;
  cin >> n >> s;
   int count = 0;
  
   
     if(n == 1 || n % 2 == 1){
       cout << "No" << endl;
     }

else{
   for(int i = 0;i < (n / 2);i++){
  

    if(s.at(i) == s.at(i + (n / 2))){
      count++;
    }
   }
  
if(count == (n / 2)){
cout << "Yes" << endl;
}
else{
cout << "No" << endl;
}
}
}


Measured memory_bytes: 256
# yahoo-procon2019-qualB - Path
import sys
input = sys.stdin.readline

def main():
    C = [0] * 4
    for _ in range(3):
        a, b = map(int, input().split())
        C[a - 1] += 1
        C[b - 1] += 1
    print("YES" if set(C) == {1, 2} else "NO")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
n,k=map(int,input().split())
ans=n
nex=n
w=n//k
#print(w)
nex=n-k*w
if ans>nex:
  ans=nex
#print(nex,ans)
while (nex<=k and nex>(k-nex)) and ans!=0:
  nex=k-nex
  if nex<ans:
    ans=nex
  if ans==0:
    break
print(ans)

Measured memory_bytes: 3064