akhauriyash/Code-Regression huggingface dataset:
/*
 * Created by KeigoOgawa
 */


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <cmath>
#include <vector>
#include <numeric>

#define INF (int)1e8
#define EPS 1e-10
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define debug(x) cout << #x << ": " << x << endl
#define all(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;

int A, B, C, D, E, F;
double max_p;

double mix(int a, int b) {
    if (b == 0 || a == 0) return 0;
    return 100.0 * b / (a + b);
}


bool check(int water, int sugar) {
    return E * water / 100 >= sugar;
}


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

    cin >> A >> B >> C >> D >> E >> F;

    int x[F], y[F];
    fill(x, x+F, -1);
    fill(y, y+F, -1);

    REP(i, F) {
        REP(j, F) {
            int tx = 100 * A * i + 100 * B * j;
            if (tx <= F) {
                x[tx] = 1;
            }

            int ty = C * i + D * j;
            if (ty <= F) {
                y[ty] = 1;
            }
        }
    }

    int ansx = 0, ansy = 0;
    double ans = 0;
    REP(i, F) {
        REP(j, F) {
            if (x[i] != 1 || y[j] != 1 || i + j > F || !check(i, j)) continue;
            if (mix(i, j) >= ans) {
                ans = mix(i, j);
                ansx = i;
                ansy = j;
            }
        }
    }
    std::cout << ansx + ansy << " " << ansy << std::endl;

    return 0;
}


Measured memory_bytes: 256
input()
l=list(map(int,input().split()))
def f(b):
  c=s=0
  for i in l:
    if b:
      if s+i>0: s+=i
      else: c-=s+i-1; s=1
    else:
      if s+i<0: s+=i
      else: c+=s+i+1; s=-1
    b=1-b
  return c
print(min(f(0),f(1)))

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

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

  int l = 0;
  int r = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == '(') {
      r++;
    }
    if (S[i] == ')') {
      if (r > 0) {
	r--;
      } else {
	l++;
      }
    }
  }

  for (int i = 0; i < l; i++) {
    cout << '(';
  }
  cout << S;
  for (int i = 0; i < r; i++) {
    cout << ')';
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
n,x = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
result = 0
for i in range(1, n):
    re = a[i] + a[i-1]
    k = re - x
    if k > 0:
        result += k
        if k <= a[i]:
            a[i] -= k
        else:
            k -= a[i]
            a[i] = 0
            a[i-1] -= k
    
print(result)

Measured memory_bytes: 14540
#include <iostream>

using namespace std;

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

  int p[N];
  int i;
  for(i=0; i<N; i++)
    cin >> p[i];

  int max = 0;
  for(i=0; i<N; i++)
    if(p[max] < p[i])
      max = i;

  int sum = 0;
  for(i=0; i<N; i++)
    if(max == i)
      sum += p[i]/2;
    else
      sum += p[i];

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}
int comb(int n, int k) {
	k = min(k, n - k);
	int x = 1, y = 1;
	rep(i, k) {
		y *= i + 1;
		y %= MOD;
	}
	for (int i = n - k + 1; i <= n; i++) {
		x *= i;
		x %= MOD;
	}
	return x * modinv(y, MOD) % MOD;
}

signed main() {
	string s;
	cin >> s;
	if (s[0] == s[1] && s[1] == s[2]) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
N=int(input())
D=[[int(i) for i in input().split()] for i in range(N)]
for i in range(1,N-1):
    if D[i-1][0]==D[i-1][1] and D[i][0]==D[i][1] and D[i+1][0]==D[i+1][1]:
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 62448
N, K=map(int, input().split())
mod=10**9+7
#青K個　赤NーK個
#青をi個に分ける　K-1Ci-1 
#赤１個以上を仕切りに振り分ける  (両端含むが、両端は０でもOK)
#N-KCi-2+N-KCi-1+N-KCi
#1997C1+

from operator import mul
from functools import reduce

def cmb(n,r):
  r = min(n-r,r)
  if r == 0: return 1
  over = reduce(mul, range(n, n - r, -1))
  under = reduce(mul, range(1,r + 1))
  return over // under

for i in range(1,K+1):
  if i==1:
    print((N-K+1)%mod)
  else:
    try:
      a=cmb(N-K-1, i-2)%mod
    except:
      a=0
    try:
      b=cmb(N-K-1, i-1)%mod
    except:
      b=0
    try:
      c=cmb(N-K-1, i)%mod
    except:
      c=0
    try:
      d=cmb(K-1, i-1)%mod
    except:
      d=0
      
    ans=(a+2*b+c)*d
    print(ans%mod)

Measured memory_bytes: 3944
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 4005
#define ll long long
#define mod 924844033
int f[N][N][2], A[N], fac[N];
void Add(int &x, int y)
{
	x += y;
	if (x >= mod)
		x -= y;
}
int n, k;
int main()
{
	scanf("%d%d", &n, &k);
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = (ll)fac[i - 1] * i % mod;
	int cnt = 0;
	for (int i = 1; i <= k; i++)
	{
		for (int j = i; j <= n; j += k)
			A[++cnt] = (i == j);
		for (int j = i; j <= n; j += k)
			A[++cnt] = (i == j);
	}
	f[0][0][0] = 1;
	for (int i = 1; i <= (n << 1); i++)
		for (int j = 0; j <= i; ++j)
		{
			Add(f[i][j][0], (f[i - 1][j][0] + f[i - 1][j][1]) % mod);
			if (!A[i] && j)
				Add(f[i][j][1], f[i - 1][j - 1][0]);
		}
	int ans = 0;
	for (int i = 0; i <= n; i++)
	{
		int res = (f[n << 1][i][0] + f[n << 1][i][1]) % mod;
		if (i & 1)
			ans = (ans - (ll)res * fac[n - i]) % mod;
		else
			ans = (ans + (ll)res * fac[n - i]) % mod;
	}
	if (ans < 0)
		ans += mod;
	printf("%d\n", ans);
}


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

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

int main(){
  int h,w,K,ans=1e9;cin>>h>>w>>K;
  vector<string> s(h);
  REP(i,h)cin>>s[i];
  REP(bit,1<<(h-1)){
    vector<int> v;
    REP(i,h-1)if((bit>>i)&1)v.push_back(i);
    int res=v.size(),n=v.size()+1;
    vector<int> cnt(n,0),tmp(n,0);
    REP(x,w){
      int now=0;
      REP(y,h){
        tmp[now]+=s[y][x]=='1';
        if(now<n-1&&v[now]==y)now++;
      }
      REP(j,n)if(tmp[j]>K)res=1e9;
      bool f=1;
      REP(j,n)if(cnt[j]+tmp[j]>K)f=0;
      REP(j,n)cnt[j]=cnt[j]*f+tmp[j],tmp[j]=0;
      res+=!f;
    }
    if(ans>res)ans=res;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val input = readLine()!!.split(' ').map(String::toInt)
    val n = input[0]
    val (a, b, c, d) = input.takeLast(4).map { it }
    val s = "x" + readLine()!!

    //移動範囲内に石2連が合ったらNO
    for (i in a until c) {
        if (s[i] == '#' && s[i + 1] == '#') {
            println("No")
            return
        }
    }
    for (i in b until d) {
        if (s[i] == '#' && s[i + 1] == '#') {
            println("No")
            return
        }
    }

    //c<dの場合、先にbを動かし、後にaを動かせば必ず移動可能
    if (c < d) {
        println("Yes")
        return
    }

    //a<b<d<cの場合、bからdの間で3連で空いている場所があれば、aが飛び越えることが可能
    var canOver = false
    for (i in b..d) {
        if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
            canOver = true
            break
        }
    }
    if (canOver) {
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 39752
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        s: Chars,
        t: Chars,
    };
    let mut min_count = s.len();
    for i in 0..s.len() {
        let mut is_ok = true;
        let mut count = 0;
        for j in 0..t.len() {
            if i + j >= s.len() {
                is_ok = false;
                break;
            }
            if s[i + j] != t[j] {
                count += 1;
            }
        }
        if is_ok {
            min_count = std::cmp::min(min_count, count);
        }
    }
    let ans = min_count;
    println!("{}", ans);
}


Measured memory_bytes: 2156
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
#include<numeric>
#include<complex>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void printVector(vector<ll> A){
    cout << "[vector]" << endl;
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    // input
    complex<int> A(x1, y1);
    complex<int> B(x2, y2);

    auto AB = B - A;
    complex<int> BC(-AB.imag(), AB.real());

    auto C = B + BC;
    auto D = C - AB;

    cout << C.real() << " " << C.imag() << " " << D.real() << " " << D.imag() << endl;
    
    return 0;
}

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

int main()
{
    int low, high, n, ans=0;
    scanf("%d %d %d", &low, &high, &n);
    if(high%n==0){
        ans+=1;
    } else if(low%n==0){
        ans+=1;
    }
    ans+= (high-low)/n;
    printf("%d", ans);   
    return 0;
}

Measured memory_bytes: 3812
#include <iostream>
using namespace std;
int N, M,answer[10];
int sub(){
  int S,C;
	for (int i = 0; i < M; ++i)
	{
		cin >> S >> C;
		if(answer[S-1] == -1){
			answer[S-1] = C;
		}else if(answer[S-1] != C){
			return -1;
		}
	}
	return 0;
}
int main(){
	cin >> N >> M;
	for (int i = 0; i < N; ++i)
	{
		answer[i] = -1;
	}
	int real = sub();
	if(real == -1){
		cout << "-1\n";
	}else if(real == 0){
		if(N == 1){
			cout << max(answer[0],0) << endl;
			return 0;
		}
		for (int i = 0; i < N; ++i)
		{
			if(i == 0 && answer[i] == 0){
				cout << "-1\n";
				return 0;
			}else if(i == 0){
				cout << max(answer[i],1);
			}else{
				cout << max(answer[i],0);
			}
		}
		cout << endl;
	}
	return 0;
}

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

int main() {
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	long long int ans=0;
	for(int i=0;i<n-1;i++){
		if(a[i]<=a[i+1])
			continue;
		else{
			ans+=abs(a[i]-a[i+1]);
			a[i+1]+=abs(a[i]-a[i+1]);
			
		}
		
	}
	cout<<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 4368
# 2019-11-12 22:21:08(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    s = sys.stdin.readline().rstrip()
    
    all_words = []
    for i in range(1, len(s) + 1):
        for letters in itertools.product('ATCG', repeat=i):
            word = ''.join(letters)
            all_words.append(word)
    
    for i in range(len(all_words)-1, 0-1, -1):
        if all_words[i] in s:
            print(len(all_words[i]))
            sys.exit()
    print(0)




if __name__ == "__main__":
    main()


Measured memory_bytes: 102680
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
constexpr int INF = 1 << 30;
constexpr int MOD = 1e9 + 7;

int n;
string s;


vector<int> z_algorithm(const string &s) {
  int n = (int)s.size();
  vector<int> a(n);

  a[0] = n;
  int i = 1, j = 0;
  while (i < n) {
    while (i + j < n && s[j] == s[i+j]) ++j;
    a[i] = j;
    if (j == 0) { ++i; continue;}
    int k = 1;
    while (i+k < n && k+a[k] < j) a[i+k] = a[k], ++k;
    i += k; j -= k;
  }
  return a;
}

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

  int ans = 0;
  for(int i = 0; i < n; ++i) {
    auto res = z_algorithm(s.substr(i, n));
    for(int i = 1; i < (int)res.size(); ++i) {
      ans = max(ans, min(i, res[i]));
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <set>
#include <map>
#include <ctime>
#include <cmath>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define PII pair<int,int>
#define sqr(x) (x)*(x)
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,b,a) for (int i=(b);i>=(a);--i)
typedef long long LL;
inline int read(){
	int x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}

const int MAXN=400005;
int n,m,a[MAXN];
struct List{
	int l,lt[MAXN],nt[MAXN],x[MAXN];
	void clear(){ l=0; memset(lt,0,sizeof(lt)); }
	void add(int a,int b){ l++; nt[l]=lt[a]; lt[a]=l; x[l]=b; }
}E;
int main(){
	n=read(); m=read(); E.clear();
	FOR(i,1,m) {
		int x,y;
		x=read(); y=read();
		E.add(x,y); E.add(y,x);
	}
	memset(a,0,sizeof(a));
	FOR(i,1,n) {
		a[i]=i;
		for (int j=E.lt[i];j;j=E.nt[j]) {
			int k=E.x[j];
			a[k]=i;
		}
		if (a[1]==i&&a[n]==i) { printf("POSSIBLE\n"); return 0; }
	}
	printf("IMPOSSIBLE\n");
	return 0;
}

/*
*/


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,d;
  cin>>n>>d;

  cout<<(n+2*d)/(2*d+1)<<endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 9999999;
using namespace std;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
string ss;
int tot;
int main()
{
    cin>>ss;
int sa;
    int i=0;
    int j=ss.size()-1;
    while(i<=j)
     {
        if(ss[i]==ss[j])
         {
            i++;
            j--;
            continue;
         }
        if(ss[i]=='x')
         {
            i++;
            tot++;
            continue;
         }
        if(ss[j]=='x')
         {
            j--;
            tot++;
            continue;
         }
        else
        {
         cout<<"-1\n";
         return 0;
       }
     }
    cout<<tot<<'\n';
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define MAX 100000
#define NIL -1

struct Node{ int p, l, r;};

struct Node T[MAX];

int n;
int H, D[MAX];

int getDepth(int);
void print(int);



int main(){
  
  int i, j;
  int d, v;
  int c, l;

  
  scanf("%d", &n);

  
  for ( i = 0; i < n; i++ ) {
    
    T[i].p = NIL;
    T[i].l = NIL;
    T[i].r = NIL;
    
  }

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

    for ( j = 0; j < d; j++ ){
      
      scanf("%d", &c);
      
      if ( j == 0 ) {
	T[v].l = c;
      }
      else{
	T[l].r = c;
      }
      
      l = c;
      T[c].p = v;
      
    }
  }
  
  H = 0;
  
  for ( i = 0; i < n; i++ ){
    
    D[i] = getDepth(i);
    
    if ( D[i] > H ) {
      H = D[i];
    }
    
  }

  for ( i = 0; i < n; i++ ) {
    print(i);
  }
  
  return 0;
}





int getDepth(int u){
  
  int d = 0;
  
  while(1){
    
    u = T[u].p;
    if ( u == NIL ) break;
    d++;
    
  }
  return d;
  
}

void print(int u){
  
  int i, c;
  
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  printf("depth = %d, ", D[u]);

  if ( T[u].p == NIL ) {
    printf("root, ");
  }
  else if ( T[u].l == NIL ) {
    printf("leaf, ");
  }
  else{
    printf("internal node, ");
  }
  
  printf("[");
  
  for(i = 0, c = T[u].l; c != NIL; i++, c = T[c].r){

    if (i) printf(", ");

    printf("%d", c);

  }
  
  printf("]\n");
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r, c;
  cin >> r >> c;
  vector<vector<int>> sheet(r+1, vector<int>(c+1, 0));
  
  for(int i = 0; i < r; i++){
    for(int j = 0; j < c; j++){
      cin >> sheet.at(i).at(j);
    sheet.at(i).at(c) += sheet.at(i).at(j);
    }
  }
  for(int j = 0; j < c + 1; j++){
    for(int i = 0; i < r; i++){
    sheet.at(r).at(j) += sheet.at(i).at(j);
    }
  }
  
  
  
  for(int i = 0; i < r + 1; i++){
    for(int j = 0; j < c; j++){
      cout << sheet.at(i).at(j) << " ";
    }
    cout << sheet.at(i).at(c) << endl;
  }
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int a[20];
int main(){
    int n;
    cin>>n;
    int sum=0;
    for(int j=0;j<n;j++){
        cin>>a[j];
    }
    for(int k=0;k<n;k++){
        sum+=a[k];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
        if(a[n-1]*2>=sum){
            cout<<"No"<<endl;
            return 0;
        }
        else{
            cout<<"Yes"<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v) cout << i << ' ' << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vin2(v, w) for (ll i = 0; i < v.size(); ++i) cin >> v[i] >> w[i];
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; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(18);

	int N;
	cin >> N;
	if(N == 1) {
		cout << 0;
		return 0;
	}
	if(N == 2) {
		cout << 2;
		return 0;
	}
	long long int x = 1, y = -2, z = 1;

	rep(i, N){
		if(i == 0) y += mod;

		x *= 10;
		if(x > mod) x %= mod;
		y *= 9;
		if(y > mod) y %= mod;
		z *= 8;
		if(z > mod) z %= mod;
	}
	if(x + y + z >= 0){
		cout << (x + y + z) % mod;
		return 0;
	}
	else{
		long long int w = x + y + z;
		while(true){
			w += mod;
			if(w >= 0){
				cout << w;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 3640
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        int H,N,A=0;
        Scanner sc=new Scanner(System.in);
        H=sc.nextInt();
        N=sc.nextInt();
        for(int i=0;i<N;i++){
            A+=sc.nextInt();
        }
        if(H<=A)
        System.out.print("Yes");
        else
        System.out.print("No");
        sc.close();
    }
}

Measured memory_bytes: 48372
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using 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 SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  Vi V(3);
  VIN(V)
  IN(x);
  RSORT(V);
  V[0] *= ((int)pow(2,x));
  OUT(VSUM(V));
}

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

#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int N = 1000010;

int a , b;

int main() {
	cin >> a >> b;
	if(a+b == 15){
		puts("+");
		return 0;
	}
	if(a*b==15){
		puts("*");
		return 0;
	}
	puts("x");
	return 0;
}

Measured memory_bytes: 256
# スペース区切りの文字列の入力
K, N = (int(x) for x in input().split())
A = [int(x) for x in input().split()]

# 最も離れた場所を求める(通常)
max_val = 0
for i in range(N-1):
  max_val = max(max_val, A[i+1] - A[i])
# 最も離れた場所を求める(先頭と終端)
max_val = max(max_val, K - A[N-1] + A[0])

print(K-max_val)

Measured memory_bytes: 26420
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;

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

// int gcd(int a, int b){
//   if (a%b==0){
//     return(b);
//   }
//   else{
//     return(gcd(b,a%b));
//   }
// }

ll dp[100010][13];

int main(){
  string s;
  cin >> s;
  const int N = 13;
  int size = s.size();
  dp[0][0] = 1;
  rep(i,size){
    if(s[i] == '?'){
      int k = (int)(s[i] - '0');
      rep(l,10){
	rep(j,13){
	  dp[i+1][(j*10+l)%N] += dp[i][j];
	  dp[i+1][(j*10+l)%13] %= mod;
	}
      }
    }
    else{
      int k = (int)(s[i] - '0');
      rep(j,13){
	dp[i+1][(j*10+k)%13] += dp[i][j];
	dp[i+1][(j*10+k)%13] %= mod;
      }
    }
  }
  cout << dp[size][5] << endl;
}



Measured memory_bytes: 10624
import java.util.Scanner;

public class Main
{

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

		String s = sc.next();
		//int num = Integer.parseInt(s, 2);

		int whitefirst = 0;

		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) - '0' == i % 2) {
				whitefirst++;
			}
		}

		int blackfirst = 0;

		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) - '0' != i % 2) {
				blackfirst++;
			}
		}

		System.out.println(Math.min(whitefirst, blackfirst));
		sc.close();
	}
}

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

int main(){

  int a[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
  int n,m,d;

  while(cin >> n >> m, n, m){

    d = 0;

    for(int i=0;i<n-1;i++) d = a[i] + d;
 
    d = d + m;

    while(d > 6) d -= 7;
   
    if(d == 5) cout << "Monday" << endl;
    else if(d == 6) cout << "Tuesday" << endl;
    else if(d == 0) cout << "Wednesday" << endl;
    else if(d == 1) cout << "Thursday" << endl;
    else if(d == 2) cout << "Friday" << endl;
    else if(d == 3) cout << "Saturday" << endl;
    else if(d == 4) cout << "Sunday" << endl;

  }
}

Measured memory_bytes: 1156
/**
 *	 Code by b21
 *	 Time: 19:35 Sat 14/03/2020
**/

#include <bits/stdc++.h>

using namespace std;

const int mn = 1 * (int)(1e5) + 10;
const int mod = 1 * (int)(1e9) + 7;
const int mm = 1 * (int)(1e3) + 10;
const int base = 1 * (int)(1e9);
const bool aNs = 0;

int tt, ntest = 1;
void docfile()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    if (ifstream("test.inp"))
    {
       freopen("test.inp", "r", stdin);
       if (!aNs) freopen("test.out", "w", stdout);
       else freopen ("test.ans", "w", stdout);
    }
   else if (ifstream("panasonic2020a.inp"))
    {
        freopen("panasonic2020a.inp", "r", stdin);
        freopen("panasonic2020a.out", "w", stdout);
    }
}

template <typename T>
void read(T& x)
{
    x = 0; T f = 1;
    char ch = getchar();
    while (!isdigit(ch)) f = ch == '-' ? - f : f, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
    x *= f;
}

template <typename T>
void write (T a)
{
    if (a < 0)
    {
        putchar ('-');
        write (-a);
        return;
    }
    if (a < 10)
    {
        putchar ('0' + a);
        return;
    }
    write (a / 10);
    putchar ((char)('0' + (a % 10)));
}

int n;
vector<char> v;
vector<string> sol;
string s;

void genString (int k) {
    if (k == n) {
        sol.emplace_back(s);
        return;
    }
    for (char c = ((k && v[k] != v[k - 1]) ? v[k] : 'a'); c <= v[k]; ++ c) {
        s.push_back(c);
        genString(k + 1);
        s.pop_back();
    }
}

void genArr(int k) {
    if (k == n) {
        genString(0);
        return;
    }
    for (int j = 0; j < 2; ++ j) {
        if (j)
        v.emplace_back(v.back() + 1);
        else
        v.emplace_back(v.back());
        genArr(k + 1);
        v.pop_back();
    }
}

void enter()
{
    cin >> n;
    v.emplace_back('a');
    genArr (1);
    sort (sol.begin(), sol.end());
    for (auto i : sol)
    cout << i << "\n";
}

void solve()
{

}

void print_result()
{

}

main()
{
    docfile();
    //cin>>ntest;
    for (tt = 1; tt <= ntest; ++ tt)
    {
        enter();
        solve();
        print_result();
    }
}

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

int main(){
    int n,m,c,tmp;
    int i,j;
    int ans=0;
    int a[21][21],b[21];
        cin >> n >>m>>c;
    for(i=0;i<m;i++){
        cin >> b[i];
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    for(i=0;i<n;i++){
        tmp = c;
        for(j=0;j<m;j++){
            tmp += a[i][j] * b[j];
        }
        if(tmp >0){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  ITP1_3-C
//
//  Created by Saicj on 2015/07/14.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>
using namespace std;
//int main(int argc, const char * argv[])
//{
//
//    // insert code here...
//    std::cout << "Hello, World!\n";
//    return 0;
//}


int main(){
    
    while (true) {
        int a,b;
        
        cin >> a >> b;
        
        if (a == 0 && b == 0){
            break;
        }
        
        if (a > b){
            int temp = a;
            a = b;
            b = temp;
        }
        
        cout << a << " " << b << "\n";
        
    }
    
    
    return 0;
}

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

int ans[540000];

typedef class TrieNode {
	public:
		TrieNode *ch[3];
		bool swp12;
		int id;

		void swap12() {
			swp12 ^= 1;
			swap(ch[1], ch[2]);
		}
		bool leaf() {
			return !ch[0];
		}
		void push_down() {
			if (swp12) {
				ch[0]->swap12();
				ch[1]->swap12();
				ch[2]->swap12();
				swp12 = false;
			}
		}

		void get_ans(int base, int v) {
			if (leaf()) {
				ans[id] = v;
				return;
			}
			push_down();
			ch[0]->get_ans(base * 3, v);
			ch[1]->get_ans(base * 3, v += base);
			ch[2]->get_ans(base * 3, v += base);
		}
} TrieNode;

TrieNode pool[1000000];
TrieNode *_top = pool;

TrieNode *newnode() {
	return _top++;
}

typedef class Trie {
	public:
		TrieNode* rt;

		void build(TrieNode*& p, int r, int base, int v) {
			p = newnode();
			if (r == 0) {
				p->id = v;
				return;
			}
			build(p->ch[0], r - 1, base * 3, v);
			build(p->ch[1], r - 1, base * 3, v += base);
			build(p->ch[2], r - 1, base * 3, v += base);
		}
		void build(int n) {
			build(rt, n, 1, 0);
		}

		void swap12() {
			rt->swap12();
		}
		
		void update(TrieNode*& p) {
			if (p->leaf()) {
				return;
			}
			p->push_down();
			swap(p->ch[0], p->ch[1]);
			swap(p->ch[0], p->ch[2]);
			update(p->ch[0]);
		}
		void update() {
			update(rt);
		}

		void get_ans() {
			rt->get_ans(1, 0);
		}
} Trie;

int n;
char T[200005];
Trie tr;

int main() {
	scanf("%d", &n);
	scanf("%s", T + 1);
	int m = strlen(T + 1);
	tr.build(n);
	for (int i = 1; i <= m; i++) {
		char c = T[i];
		if (c == 'S') {
			tr.swap12();
		} else {
			tr.update();
		}
	}
	tr.get_ans();
	int all = 1;
	for (int i = 1; i <= n; i++) {
		all *= 3;
	}
	for (int i = 0; i < all; i++) {
		printf("%d ", ans[i]);
	}
	return 0;
}


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

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

int main() {
//    freopen("test.txt", "r", stdin);
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int> nums(n, 0);
    for (int i = 0; i < n; i++) scanf("%d", &nums[i]);
    sort(nums.begin(), nums.end());
    if (k > nums.back()) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    if (nums[0] == 1 || nums[0] == k) {
        cout << "POSSIBLE" << endl;
        return 0;
    }
    int pre = nums[0];
    int i = 1;
    while (i < n && nums[i] == pre) i++;
    if (i == n) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    int delta = nums[i] - pre;
    pre = nums[i];
    if (delta == 1 || delta == k) {
        cout << "POSSIBLE" << endl;
        return 0;
    }
    while (i < n) {
        while (i < n && nums[i] == pre) i++;
        if (i == n) {
            break;
        }
        int tmp = nums[i] - pre;
        pre = nums[i];
        if (tmp == 1 || tmp == k || nums[i] == k) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
        delta = gcd(delta, tmp);
        if (k % delta == 0) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    if (k % delta == 0) {
        cout << "POSSIBLE" << endl;
        return 0;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>
#include <fstream>
#include <ctime>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

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

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

template<typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool is_integer(T x) {
    return std::floor(x) == x;
}

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};


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

    int N, H;
    cin >> N >> H;
    vector<int> A(N);
    cin >> A;

    int ans = 0;
    REP(i, N) {
        if (A[i] >= H)ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int a[7] = {1,3,5,7,8,10,12};
const int b[4] = {4,6,9,11};
 
bool check(const int *a,int N,int key){
    for(int i=0;i<N;i++){
        if(key==a[i])return true;
    }
    return false;
}
 
int main(){
    int x,y;
    cin >> x >> y;
    if(x==2&y==2){
        cout << "Yes" << endl;
    }else if(check(&a[0],7,x)&&check(&a[0],7,y)){
        cout << "Yes" << endl;
    }else if(check(&b[0],4,x)&&check(&b[0],4,y)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

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

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

	if (a*c <= b)
	{
		cout << c << endl;
	}
	else
	{
		cout << b / a << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC90(void);
void ABC91(void);
void ABC92(void);
void ABC93(void);
void ABC94(void);
void ABC95(void);
void ABC96(void);
void ABC97(void);
void ABC98(void);
void ABC99(void);

int main(void){
    ABC93();
}

void ABC93(){
    int a,b,k,i,j,x;
    cin>>a>>b>>k;
    vector<int> vec;
    for(i=0;i<k;i++){
        x=a+i;
        if(x<=b&&count(vec.begin(),vec.end(),x)==0)vec.push_back(x);
        x=b-i;
        if(x>=a&&count(vec.begin(),vec.end(),x)==0)vec.push_back(x);
    }
    sort(vec.begin(),vec.end());
    for(i=0;i<vec.size();i++){
        cout<<vec[i]<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <time.h>
// #define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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


  int a,b,k;
  cin>>a>>b>>k;
  int cnt = 0;
  int ans;
  repr(i,1000) {
    if(a%i == 0 && b % i == 0) {
      cnt++;
    }
    if(cnt == k) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && b == c && c == a){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
//平方数判定
#include <iostream>
#include <string>

using namespace std;

int main(void){
  string s1;
  int count = 0;
  cin >> s1;
  //cout << s1<<s2<<s3;
  for(int i =0;i<3;i++){
    if(s1[i] == '1') count++;
  }
  cout <<count;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>

using namespace std;

typedef long long ll;

#define rep(i, N) for (ll i = 0; i < (ll)(N); ++i)

const ll inf = 1e18+7;
const ll mod = 1e9+7;

int main(){
	ll N,ans=0,msan=0;
	cin >> N;
	for(ll i=1;i<=N;i+=2){
		ans=0;
		for(ll j=1;j<=i;j++){
			if(i % j == 0){
			ans++;
			}
		}
		if(ans==8){
			msan++;
		}
	}

	cout << msan << endl;
	return 0;
}

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

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

	int i = 0, c = 0;
	while (s[i] != 0) {
		if (s[i] != t[i]) {
			s[i] = t[i];
			c++;
		}
		i++;
	}
	cout << c << endl;
}

Measured memory_bytes: 3916
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    private static int fact(int n) { int ans=1; for(int i=2;i<=n;i++) ans*=i; return ans; }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    private static void solve(FastScanner in, PrintWriter out){
        int n = in.nextInt();
        int a[][] = new int[n][2];
        for(int i=0;i<n;i++){
            a[i][0] = in.nextInt();
            a[i][1] = i+1;
        }
        Arrays.sort(a, new Comparator<int []>(){
            public int compare(int a[],int b[]){
                return a[0]-b[0];
            }
        });
        for(int i=0;i<n;i++) out.print(a[i][1]+" ");out.println();
    }
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 45424
N, M = gets.split.map(&:to_i)
edge_list = (N - 1 + M).times.map { gets.split.map(&:to_i) }
graph = Array.new(N) { [] }
indegree = Array.new(N) { 0 }
edge_list.each do |(u, v)|
  u -= 1; v -= 1
  graph[u].push(v)
  indegree[v] += 1
end

sorted = []
queue = []
indegree.each.with_index do |c, v|
  queue.push(v) if c == 0
end
while !queue.empty?
  v = queue.shift
  (graph[v]).each do |v2|
    indegree[v2] -= 1
    if indegree[v2] == 0
      queue.push(v2)
      sorted.push(v)
    end
  end
end

v_to_order = sorted.map.with_index { |v, i| [v, i] }.to_h
ans = Array.new(N) { sorted[0] }
ans[sorted[0]] = 0
edge_list.each do |(u, v)|
  u -= 1
  v -= 1
  ans[v] = u if v_to_order[u] > v_to_order[ans[v]]
end
ans.each.with_index do |v, i|
  if i == sorted[0]
    puts 0
  else
    puts(v + 1)
  end
end


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

int main()
{
  int n;
  cin>>n;
  int a[n+1];
  int i,f[n+1];
  for(i=1;i<=n;i++){
    cin>>a[i];
    f[i]=0;
  }
  int j,m=0,sum;
  for(i=n;i>=1;i--){
    j=2;sum=0;
    while(i*j<=n){
      sum+=f[i*j];
      j++;
    }
    if(sum%2!=a[i]){
      f[i]=1;m++;
    }
  }
  cout<<m<<endl;
  int b[m+1],l=1;
  if(m!=0){
    for(i=1;i<=n;i++){
      if(f[i]==1){
        cout<<i<<' ';
      }
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
string s,num;
map<string,string>m;
vector<string>v;
int p;
int b1();
int b3(){
  int res=0;
  if(s[p]=='(')
    p++,res=b1(),p++;
  else{
    while(isdigit(s[p]))
      res=res*10+(s[p++]-'0');
  }
  return res;
}
int b2(){
  int res=b3();
  while(s[p]=='*')p++,res*=b3();
  return res;
}
int b1(){
  int res=b2();
  while(s[p]=='+')p++,res+=b2();
  return res;
}
int dfs(){
  while(p<s.size()){
    if(isalpha(s[p])){
      int st=p;
      string t;
      while(isalpha(s[p]))t+=s[p++];p--;
      while(1){
        if(t=="")return 0;
        if(m[t]!=""){
          v.push_back(m[t]);
          break;
        }
        t.erase(t.end()-1);
        p--;
      }
    }
    else if(isdigit(s[p])){
      string t;
      while(isdigit(s[p]))t+=s[p++];
      v.push_back('*'+t);
      p--;
    }
    else v.push_back(s.substr(p,1));
    p++;
  }
  return 1;
}
main(){
  while(cin>>s,s!="END_OF_FIRST_PART"){
    cin>>num;
    m[s]=num;
  }
  while(cin>>s,s!="0"){
    s+=')';
    v.clear();
    int ans;
    p=0;
    ans=dfs();
    if(!ans)cout<<"UNKNOWN"<<endl;
    else{
      v.erase(v.end()-1);
      r(i,v.size()-1){
        if(isdigit(v[i][0])&&(isdigit(v[i+1][0])||v[i+1]=="("))v[i]+='+';
        else if(v[i][0]=='*'&&(isdigit(v[i+1][0])||v[i+1]=="("))v[i]+='+';
      }
      s="";
      r(i,v.size())s+=v[i];
      p=0;
      cout<<b1()<<endl;
    }
  }
}

Measured memory_bytes: 3192
import collections
import sys

S1 = collections.deque()
S2 = collections.deque()
S3 = collections.deque()

for i, j in enumerate(sys.stdin.readline()):
    if j == '\\':
        S1.append(i)
    elif j == '/':
        if S1:
            left_edge = S1.pop()
            new_puddle = i - left_edge
            while True:
                if S2:
                    if S2[-1] > left_edge:
                        S2.pop()
                        new_puddle += S3.pop()
                    else:
                        break
                else:
                    break
            S2.append(left_edge)
            S3.append(new_puddle)
        else:
            pass


print(sum(S3))

print(len(S3), *S3)

Measured memory_bytes: 8352
#include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 500000;
const int INFTY  = 1000000010;
int cnt = 0;
int L[maxn/2 + 2],R[maxn/2 + 2];
void Merge(int *A,int left,int mid,int right)//归并 
{
	int n1 = mid - left;
	int n2 = right - mid;
	for(int i = 0;i < n1;i++){
		L[i] = A[left + i];
	}
	for(int i = 0;i < n2;i++){
		R[i] = A[mid + i];
	}
	L[n1] = R[n2] = INFTY;
	
	int i = 0,j = 0; 
	for(int k = left;k < right ;k++){
		cnt++;
		if(L[i] <= R[j]){
			A[k] = L[i++];
			//i++;
		}
		else {
			A[k] = R[j++];
			//j++;
		}
	}
}
void Merge_sort(int *A,int left,int right)//归并排序 
{
	if(left < right - 1){
		int mid = (right - left)/2 + left;
		//int mid = (right + left) / 2;
		Merge_sort(A,left,mid);				//分治递归 
		Merge_sort(A,mid,right);		//分治递归 
		Merge(A,left,mid,right);			//归并 
	}
}
int main()
{
	//freopen("guibing1.txt","r",stdin);
	int num = 0;
	int A[maxn];
	scanf("%d",&num);
	for(int i = 0;i < num;i++){
		scanf("%d",&A[i]);
	}
	Merge_sort(A,0,num);
	for(int i = 0 ;i < num;i++){
		if(i > 0){
			printf(" ");
		}
		printf("%d",A[i]);
	}
	printf("\n");
	printf("%d\n",cnt);
	return 0;
 } 


Measured memory_bytes: 7052
import java.util.*;

class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}
	
	Scanner in = new Scanner(System.in);

	void solve(){
		int[] a = new int[10];
		for(int i = 0; i < 10; i++){
			a[i] = in.nextInt();
		}
		Arrays.sort(a);
		int b = a[9] + a[8] + a[7];
		System.out.print(b + " ");
		for(int i = 0; i < 10; i++){
			a[i] = in.nextInt();
		}
		Arrays.sort(a);
		b = a[9] + a[8] + a[7];
		System.out.println(b);
	}

}

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


int main(void) {
  int x;
  cin >> x;
  if (x < 1200) cout << "ABC" << endl;
  else cout << "ARC" << endl;
  
  return 0;
}

Measured memory_bytes: 3628