akhauriyash/Code-Regression huggingface dataset:
"""


Verified:
    https://onlinejudge.u-aizu.ac.jp/problems/GRL_1_B
"""
from typing import List, Optional, Tuple


def bellman_ford(
    source: int, vertices_count: int, edges: List[Tuple]
) -> Optional[List[float]]:
    """Bellman-Ford algorithm: O(NM)
    Compute the distance of the shortest path from V_source to each vertex.
    Relax edges in N-1 times of loops and detect negative cycles in the last loop.

    Args:
        source: V_source
        edges: Edges info
        vertices_count: Number of vertices
    Returns:
        Return None if the graph has negative cycles.
        If not, return a list of distance from V_source.
    """
    inf = float("inf")
    dist = [inf] * (vertices_count + 1)
    dist[source] = 0
    for i in range(vertices_count):
        for from_, to, weight in edges:
            if dist[from_] + weight < dist[to]:
                dist[to] = dist[from_] + weight
                if i == vertices_count - 1:
                    return None
    return dist


def main():
    V, E, R, *edges = map(int, open(0).read().split())
    dist = bellman_ford(R, V, list(zip(*[iter(edges)] * 3)))
    inf = float("inf")
    if dist:
        print("\n".join(map(str, (i if i != inf else "INF" for i in dist[:-1]))))
    else:
        print("NEGATIVE CYCLE")


if __name__ == "__main__":
    main()



Measured memory_bytes: 7732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {

	int n;
	cin>>n;
	int a[n];
	vector<int> rend(1000003,0);
	//memset(rend,0,sizeof(rend));
	for(int i=0; i<n; i++)
		cin>>a[i];
	vector<int> vis(1000001,0);
	//memset(vis,0,sizeof(vis));
	sort(a,a+n);
	if(a[0] == 1 && a[1] !=1) {
		cout<<1;
	}
	else if(a[0] == 1 && a[1] == 1) {
		cout<<0;
	}

	else {
		int l = 0;
	for(int i=0; i<n; i++) {
		int z = a[i];
		int e = 1000002;
		if(i+1<n) e = a[i+1];
		
		if(vis[z] == 0 && z != e && rend[z] == 0)
			l++;
		else if(vis[z] == 0 && z == e) {
			rend[e] = 1;
		}

		for (int p=z; p<=1000000; p = p+z) 
    	{ 
        	if (vis[p] == 0) 
        	   vis[p] = 1; 
    	}

	}
	cout<<l;
	}
	return 0;
}

Measured memory_bytes: 11972
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n;
int32_t main(){
CODE_START;
cin>>n;
cout<<n*n;
}

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

int main(){
    int n,m,a,b,c,d,s,g,v,p;
    int co[22][22];
    cin >> n >> m;
    for (int i = 0;i < 22; i++)for (int j = 0;j < 22;j++)co[i][j] = INF;
    for (int i = 0;i < m; i++){
        scanf("%d,%d,%d,%d",&a,&b,&c,&d);
        co[a-1][b-1] = c;
        co[b-1][a-1] = d;
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            for(int k = 0; k < n; k++){
                if(co[j][i]+co[i][k] < co[j][k]) co[j][k] = co[j][i]+co[i][k];
            }
        }
    }
    scanf("%d,%d,%d,%d",&s,&g,&v,&p);
    cout << v-p-co[s-1][g-1]-co[g-1][s-1] << endl;;
}


Measured memory_bytes: 3132
#include <stdio.h>

long long int is_gcd(long long int a, long long int b);

int main(void){
  long long int a,b,c,d;
  scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
  long long int lcm;
  long long int left, right;
  long long int c_num, d_num, cd_num;
  
  lcm = c*d/is_gcd(c,d);

  //printf("lcm = %ld\n",lcm);

  left = a/c; right = b/c;
  c_num = right - left + 1;
  if(a%c != 0)
    c_num--;    
  //printf("%ld�Ŋ���؂��̂�%ld��\n",c,c_num);
  
  left = a/d; right = b/d;
  d_num = right - left + 1;
  if(a%d != 0)
    d_num--;
  //printf("%ld�Ŋ���؂��̂�%ld��\n",d,d_num);
  
  left = a/lcm; right = b/lcm;
  cd_num = right - left + 1;
  if(a%lcm != 0)
    cd_num--;
  //printf("%ld�Ŋ���؂��̂�%ld��\n",lcm,cd_num);

  long long int num = b - a + 1;
  
  printf("%lld\n",num - (c_num + d_num - cd_num) );

  return 0;
}


long long int is_gcd(long long int x, long long int y){
  long long int tmp,z;
  if(x<y){
    tmp = x;
    x = y;
    y = tmp;
  }
  z = x % y;
  while(z != 0){
    //printf("x=%ld    \ty=%ld    \tz=%ld\n",x,y,z);
    x = y;
    y = z;
    z = x % y;
  }
  return y;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC40(void);
void ABC41(void);
void ABC42(void);
void ABC43(void);
void ABC44(void);
void ABC45(void);
void ABC46(void);
void ABC47(void);
void ABC48(void);
void ABC49(void);

int main(void){
    ABC43();
}

void ABC43(){
    string s;
    cin>>s;
    vector<char> vec;
    int i;
    for(i=0;i<s.length();i++){
        if(s[i]=='0')vec.push_back('0');
        if(s[i]=='1')vec.push_back('1');
        if(s[i]=='B'){
            if(vec.size()==0)continue;
            else{
                vec.pop_back();
            }
        }
    }
    for(i=0;i<vec.size();i++){
        cout<<vec[i];
    }
    cout<<endl;
}

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

#https://atcoder.jp/contests/abc052/tasks/abc052_b

def main():
    x = 0
    N = input()
    S = raw_input()
    
    # アルゴリズムを考えるよりも、 1 <= N <= 100 であるからすべてなめたほうが早い
    x_max = x
    for ope  in S:
        if ope == 'I':
            x = x + 1
        elif ope == 'D':
            x = x -1
        x_max = max(x,x_max)

    print(x_max)

if __name__ == "__main__":
    main()


Measured memory_bytes: 2696
N, *H = [gets, *gets.split].map(&:to_i)

dp = [0, (H[0]-H[1]).abs]
2.step(N-1) do |i|
  jmp1 = dp[i-1] + (H[i-1] - H[i]).abs
  jmp2 = dp[i-2]+(H[i-2] - H[i]).abs
  dp[i] = jmp1 < jmp2 ? jmp1 : jmp2
end
puts dp.last


Measured memory_bytes: 10444
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
int ctoi(char a) {
	return (int)a - '0';
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n, m;
int x[100000], y[100000];
signed main() {
	cin >> n >> m;
	int a = 0, b = 0;
	for (int i = 0; i < n; i++) 
		cin >> x[i];
	for (int i = 0; i < m; i++) 
		cin >> y[i];
	for (int i = 0; i < n - 1; i++) {
		x[i] = x[i + 1] - x[i];
		a += abs(x[i]) * (i + 1)*(n - i - 1);
		a %= Mod;
	}
	for (int i = 0; i < m - 1; i++) {
		y[i] = y[i + 1] - y[i];
		b += abs(y[i]) * (i + 1)*(m - i - 1);
		b %= Mod;
	}
	cout << a*b%Mod << endl;
	getchar(); getchar();
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n;
    cin >> n;

    vll a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());


    ll cnt = 0;


    rep(j, n){
        ll first_index=0, first_num=n, second_index=0, second_num=0;
        auto first = lower_bound(a.begin(), a.end(), b[j]);
        if(first != a.end()){
            first_index = first - a.begin();
            first_num = first_index;
        }
        auto second = upper_bound(c.begin(), c.end(), b[j]);
        if(second != c.end()){
            second_index = second - c.begin();
            second_num = n - second_index;

        }

        cnt += first_num * second_num;

    }


    ppp(cnt);


    return 0;
}


Measured memory_bytes: 2560
#define _CRT_SECURE_NO_WARNINGS

//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(){
#ifdef DEBUG
	
#endif
	int N, K;
	scanf("%d", &N);
	scanf("%d", &K);

	int ans = 0;
	int x;
	int i,tmp;
	for (i = 0; i < N; i++) {
		scanf("%d", &x);
		tmp = abs(x - K)*2;
		ans += (tmp > x*2 ? x*2 : tmp);
	}

	printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define MOD 1000000007
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LLI long long int
#define LI long int 
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//               When something is important enough, you do it even if the odds are not in your favor.
LLI ans[100004][3];
int main(){   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    // code goes here
    int t=1;//cin>>t;
    while(t--){
      LI n,i;cin>>n;
      LI a[n][3];
      fo(i,0,n) cin>>a[i][0]>>a[i][1]>>a[i][2];
      ans[0][0]=a[0][0],ans[0][1]=a[0][1],ans[0][2]=a[0][2];
      fo(i,1,n){
        ans[i][0]=a[i][0]+max(ans[i-1][1],ans[i-1][2]);
        ans[i][1]=a[i][1]+max(ans[i-1][0],ans[i-1][2]);
        ans[i][2]=a[i][2]+max(ans[i-1][0],ans[i-1][1]);
      }
      cout<<max(ans[n-1][0],max(ans[n-1][1],ans[n-1][2]));
    }
    return 0;
}

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

int main() {
  int n,p;
  int sum=0;
  int hp1=0;
  int hp2=0;
  int hp3=0;
  cin>>n;
  vector<int> x(n);
  for (int i=0;i<n;i++){
    cin>>x[i];
    sum=sum+x[i];
  }
  p=sum/n;
  for (int i=0;i<n;i++){
    hp1=hp1+pow((x[i]-p),2);
  }
   for (int i=0;i<n;i++){
    hp2=hp2+pow((x[i]-p-1),2);
  }
   for (int i=0;i<n;i++){
    hp3=hp3+pow((x[i]-p+1),2);
  }
  cout <<min({hp1,hp2,hp3})<<endl;
    
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N=input()

#約数列挙
def make_divisors(n):
    divisors=[]
    for i in range(1, int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n/i:
                divisors.append(n/i)
    return divisors

#整数N-1の約数は全て答えにカウントして良い
ans=set(make_divisors(N-1))

K=make_divisors(N)  #Nの約数の集合
#整数Nの約数について条件にマッチングするかを1つ1つ調べる
for k in K:
    if k==1: continue
    n=N
    while n%k==0:
        n/=k
    else:
        #print "n,k :: ",n,k
        if n%k==1:
        #if n==1 or n%k==1:
            ans.add(k)
print len(ans)-1

Measured memory_bytes: 30700
#include <iostream>
#include <map>
#include <vector>
using namespace std;



int main(void){
    
    int n,d,x;
    cin >> n >> d >> x;
    int i,a[n+1];
    for(i=0;i<n;++i) {
        cin >> a[i];
        //cout << a[i]<<" ";
    }
    int j;
    int ans[n+1],cnt=0;
    for(i=0;i<n;++i){
        for(j=0;j<d;++j){
            ans[i]=j*a[i]+1;
            //cout<<ans[i]<<" ";
            if(ans[i]<=d)cnt++;
        }
        //cout<<cnt;
    }
    
    
    cout<<cnt+x;
    
    return 0;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

struct Point {
	i64 x, y;
	
	Point operator-(const Point r) const {
		return Point{x - r.x, y - r.y};
	}
	
	bool operator<(const Point r) const {
		if(x == r.x) return y < r.y;
		return x < r.x;
	}
};

double abs(const Point a) {
	return std::sqrt(a.x * a.x + a.y * a.y);
}

double cross(const Point a, const Point b) {
	return a.x * b.y - a.y * b.x;
}

double dot(const Point a, const Point b) {
	return a.x * b.x + a.y * b.y;
}

double angle(const Point a, const Point b) {
	return acos(-dot(a, b) / abs(a) / abs(b));
}

std::vector<Point> Convex_Hull(std::vector<Point> p){
  int n = p.size(), k = 0;
  if(n >= 3){
    sort(p.begin(), p.end());
    std::vector< Point > ch(2 * n);
    for(int i = 0; i < n; ch[k++] = p[i++]){
      while(k >= 2 && cross(ch[k - 1] - ch[k - 2], p[i] - ch[k - 1]) < 0) --k;
    }
    for(int i = n - 2, t = k + 1; i >= 0; ch[k++] = p[i--]){
      while(k >= t && cross(ch[k - 1] - ch[k - 2], p[i] - ch[k - 1]) < 0) --k;
    }
    ch.resize(k - 1);
    return ch;
  } else {
    return p;
  }
}

/*
std::vector<Point> convexHull(std::vector<Point> p) {
	int n = p.size(), k = 0;
	if(2 < n) {
		sort(begin(p), end(p));
		std::vector<Point> ch(2 * n);
		for(int i = 0; i < n; ch[k++] = p[i++]) {
			while(k > 1 and cross(ch[k - 1] - ch[k - 2], p[i] - ch[k - 1]) < 0) --k;
		}
		for(int i = n - 2, t = k + 1; i >= 0; ch[k++] = p[i--]) {
			if(k >= t and cross(ch[k - 1] - ch[k - 2], p[i] - ch[k - 1])  < 0) --k;
		}
		ch.resize(k - 1);
		return ch;
	} else {
		return p;
	}
}
*/

int main() {
	int n; cin >> n;
	std::vector<Point> vec(n);
	std::map<Point, int> mp;
	for(int i = 0; i < n; i++) {
		i64 a, b; cin >> a >> b;
		
		vec[i] = Point{a, b};
		mp[vec[i]] = i;
	}
	
	auto ch = Convex_Hull(vec);
	std::vector<double> ans(n, 0);
	const double Pi = std::acos(-1);
	for(int i = 0; i < ch.size(); i++) {
		Point u = ch[(i + ch.size() - 1) % ch.size()] - ch[i];
		Point v = ch[(i + 1) % ch.size()] - ch[i];
		ans[mp[ch[i]]] = angle(u, v) / 2.0 / Pi;
	}
	
	for(auto v : ans) cout << std::fixed << std::setprecision(10) << v << endl;
	return 0;
}


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

#define D_N 0
#define D_E 1
#define D_S 2
#define D_W 3

using namespace std;

class Dice {
private:
  int side_values[6];

public:
  void set_values(vector<int> v) {
    for(int i=0; i<6; i++) {
      this->side_values[i] = v[i];
    }
  }

  void roll(int dir) {
    int side_temp[6];
    switch(dir) {
    case D_N:
      side_temp[0] = this->side_values[1];
      side_temp[1] = this->side_values[5];
      side_temp[2] = this->side_values[2];
      side_temp[3] = this->side_values[3];
      side_temp[4] = this->side_values[0];
      side_temp[5] = this->side_values[4];
      break;
    case D_E:
      side_temp[0] = this->side_values[3];
      side_temp[1] = this->side_values[1];
      side_temp[2] = this->side_values[0];
      side_temp[3] = this->side_values[5];
      side_temp[4] = this->side_values[4];
      side_temp[5] = this->side_values[2];
      break;
    case D_S:
      side_temp[0] = this->side_values[4];
      side_temp[1] = this->side_values[0];
      side_temp[2] = this->side_values[2];
      side_temp[3] = this->side_values[3];
      side_temp[4] = this->side_values[5];
      side_temp[5] = this->side_values[1];
      break;
    case D_W:
      side_temp[0] = this->side_values[2];
      side_temp[1] = this->side_values[1];
      side_temp[2] = this->side_values[5];
      side_temp[3] = this->side_values[0];
      side_temp[4] = this->side_values[4];
      side_temp[5] = this->side_values[3];
      break;
    default:
      break;
    }

    for(int i=0; i<6; i++) {
      this->side_values[i] = side_temp[i];
    }
  }

  int get_value() {
    return this->side_values[0];
  }
};
      
int main() {
  // Put your favorite codes here
  vector<int> v;
  Dice d;
  string q;
  for(int i=0; i<6; i++) {
    int temp;
    cin >> temp;
    v.push_back(temp);
  }
  d.set_values(v);

  cin >> q;
  for(auto c=q.begin(); c!=q.end(); c++) {
    switch(*c) {
    case 'N':
      d.roll(D_N);
      break;
    case 'E':
      d.roll(D_E);
      break;
    case 'S':
      d.roll(D_S);
      break;
    case 'W':
      d.roll(D_W);
      break;
    default:
      break;
    }
  }

  cout << d.get_value() << endl;
  
  return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <string>
#include <vector>        // 可変長配列
#include <algorithm>
using namespace std;

//example
//s = "ab1023cd4"
//return : {a, b, 1023, c, d, 4}
//a -> 'a' + 10^9
vector<int> toNumArray(string s) {
    int i, j;
    vector<int> ret;
    int GETA = 1e+9;
    
    for (i = 0; i < s.length(); ) {
        if ('0' <= s[i] && s[i] <= '9') {
            int num = 0;
            for (j = i; j < s.length(); j++) {
                if (!('0' <= s[j] && s[j] <= '9')) {
                    break;
                }
                //s[j]は数字'0'～'9'
                num *= 10;
                num += s[j] - '0';
            }
            ret.push_back(num);
            i = j;
        }
        else {
            ret.push_back(s[i] + GETA);
            i++;
        }
    }
    return ret;
}

bool before(string key, string base) {
    vector<int> a = toNumArray(key);
    vector<int> b = toNumArray(base);
    int loopCnt = min(a.size(), b.size());
    int i;
    
    for (i = 0; i < loopCnt; i++) {
        if (a[i] != b[i]) {
            if (a[i] < b[i]) {
                return true;
            }
            else {
                return false;
            }
        }
    }
    if (a.size() < b.size()) {
        return true;
    }
    if (a.size() > b.size()) {
        return false;
    }
    //key == base (otherwise ~ +)
    return false;
}

int n;
string s[1001];

int main() {
    int i;
    
    cin >> n;
    for (i = 0; i <= n; i++) {
        cin >> s[i];
    }
    
    for (i = 1; i <= n; i++) {
        if (before(s[i], s[0]) == true) {
            cout << "-" << endl;
        }
        else {
            cout << "+" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3264
import java.util.*;
import java.io.*;
public class Main{
public static int getMin(int N,int[]height){
    int[]dp=new int[N+1];
    dp[2]=Math.abs(height[0]-height[1]);
    for(int i=3;i<=N;i++){
      dp[i]=Math.min(dp[i-2]+Math.abs(height[i-3]-height[i-1]),dp[i-1]+Math.abs(height[i-2]-height[i-1]));
    }
    return dp[N];
  }
public static void main(String[] args){
    int N;
    Scanner in=new Scanner(System.in);
    N=in.nextInt();
    int[] height=new int[N];
    for(int i=0;i<N;i++)height[i]=in.nextInt();
    System.out.println(getMin(N,height));
    }
}
  
  

Measured memory_bytes: 48292
# 自分の回答
n = int(input())
array = list(map(int, input().split()))
flg = 0
count = 0
while(flg == 0):
    j = 0
    for j in range(n):
        if(array[j] % 2 == 0):
            array[j] /= 2
            j += 1
            if(j == (n -1)):
                count += 1
        else:
            flg = 1
            break
print(count)

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

int main() {
  int N, A;
  cin >> N >> A;
  if (N<1 || N>10000 || 
      A<0 || A>1000){
    return 0;
  }
  if(N%500 <= A){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

int main()
{
    int d,g;
    cin>>d>>g;
    vector<int> p(d);
    vector<int> c(d);
    for(int i=0;i<d;i++){
        cin>>p.at(i)>>c.at(i);
    }

    ll res=1<<29;
    for(int bit=0;bit<(1<<d);bit++){
        ll sum=0;
        ll num=0;
        for(int i=0;i<d;i++){
            if(bit&(1<<i)){
                sum+=c[i]+p[i]*100*(i+1);
                num+=p[i];
            }
        }
        if(sum>=g){
            res=min(res,num);
        }
        else{
            for(int i=d-1;i>=0;i--){
                if(bit&(1<<i)){
                    continue;
                }
                for(int j=0;j<p[i];j++){
                    if(sum>=g){
                        break;
                    }
                    sum+=100*(i+1);
                    num++;
                }
            }
            res=min(res,num);
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		String turn = s.next();
		Integer tarou = 0;
		Integer hanako = 0;
		for(int i = 0; i < Integer.parseInt(turn); i++){
			String tarou_card = s.next();
			String hanako_card = s.next();
			Integer result = tarou_card.compareTo(hanako_card);
			if(result == 0){
			if(tarou_card.equals(hanako_card)){
				tarou += 1;
				hanako += 1;
			}
			}
			else if(result > 0){
				tarou += 3;
			}
			else{
				hanako += 3;
			}
		}
		System.out.println(tarou + " " + hanako);
	}
}

Measured memory_bytes: 20808
#%%
n, k = map(int, input().split())
k = ['0'] * (42 - len(list(bin(k)[2:]))) + list(bin(k)[2:])
a = list(map(int, input().split()))

b = [[0] for _ in range(n)]
for i in range(n):
    b[i] = ['0'] * (42 - len(list(bin(a[i])[2:]))) + list(bin(a[i])[2:])

count = [[0, 0] for _ in range(42)]
for j in range(42):
    c_0, c_1 = 0, 0
    for i in range(n):
        if b[i][j] == '0':
            c_0 += 1
        else:
            c_1 += 1
    count[j] = c_0, c_1
        
ans = []
for i in range(42):
    if count[i][1] >= count[i][0]:
        ans.append('0')
    else:
        ans.append('1')

flag = False
for i in range(42):
    if ans[i] == '1' and k[i] == '0':
        ans[i] = '0'
    elif ans[i] == '0' and k[i] == '1':
        flag = True
    
    if flag:
        break

tmp = 0
ans = ans[::-1]
for i in range(42):
    if ans[i] == '1':
        tmp += 2**i

ans = 0
for i in range(n):
    ans += a[i] ^ tmp
print(ans)



Measured memory_bytes: 201548
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
const int maxn=1e5+10;
const int N=1e3+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
int n,m,k,t,s,cnt;
int main()
{
    int i,j;
    scanf("%d%d",&k,&s);
    rep(i,0,k)rep(j,0,k)if(s-i-j>=0&&s-i-j<=k)cnt++;
    printf("%d\n",cnt);
    return 0;
}


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

#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define pb push_back
#define pp pop_back
#define scan(t) scanf("%d",&t)
#define sscan(t) scanf("%lld",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define LL long long
#define ull unsigned long long
#define rock(cont) cont.begin(), cont.end()
#define roll(a,n) arr,arr+n
#define rep(i,n) for(int i=0 ; i<n ; i++)
#define repp(i, n) for(int i=1 ; i<=n ; i++)
#define print(t) printf("%d",t)
#define pprint(t) printf("%lld",t)
#define co(x) cout<<x
#define nl printf("\n")
#define el cout<<endl
#define INF (int)1e9

const int RT = 10000000;

vector<int>prime;
vector<LL>factor;
bitset<10000003> status;



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

vector<int> Divisors(int n)
{
    vector<int> v;
    int limit=sqrt(n);
    for (int i=1; i<=limit; i++)
    {
        if (n%i==0)
        {
            if (n/i == i)
                v.push_back(i);
            else
            {
                v.push_back(i);
                v.push_back(n/i);
            }
        }
    }
    return v;
}

void sieve()
{
    int rt = sqrt(RT);
    //for(int i = 4; i <= rt; i+=2) status[i]=true;
    for(int i = 3; i <= rt; i+=2)
        if(!status[i])
            for(int j = i*i; j < RT; j+=(i<<1))
                status[j] = true;

    prime.push_back(2);

    for(int i = 3; i <= RT; i+=2)
        if(!status[i])
            prime.push_back(i);
}

LL primefac(LL n)
{
    int pf_idx=0,pf=prime[pf_idx],SIZE=prime.size();
    LL ANS=1,step=0;
    while(pf*pf<=n&&pf<SIZE)
    {
        if(n%pf==0)
        {
            while(n%pf==0) {n/=pf;}
            ANS=pf;
            step++;
        }
        pf=prime[++pf_idx];
        //cout<<pf<<" "<<n<<" "<<ANS<<endl;
    }
    if(n!=1) { ANS=max(ANS,n); step++; }
    if(step>1)
    {
      return ANS;
    }
    else
    {
        return -1;
    }
}

int main()
{
    fast;
    int a,b,c,d,temp=0;
    cin>>a>>b>>c>>d;
    while(1)
    {
        if(temp==0)
        {
            c-=b;
            if(c<=0)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
            temp=1;
        }
        else
        {
            a-=d;
            if(a<=0)
            {
                cout<<"No"<<endl;
                return 0;
            }
            temp=0;
        }
    }
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    vector<int> v(4);
    REP(i, 6){
        int a;
        cin >> a;
        v[a-1]++;
    }

    sort(all(v));

    if(v[0] == 1 && v[1] == 1 && v[2] == 2 && v[3] == 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
	char c=getchar();int t=0,f=1;
	while((!isdigit(c))&&(c!=EOF)){if(c=='-')f=-1;c=getchar();}
	while((isdigit(c))&&(c!=EOF)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n,k;
map<int,int> mp;
signed main(){
	n=read(),k=read();
	int mn=n%k;
	mn=min(mn,k-n%k);
	printf("%lld\n",mn);
	return 0;
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int r,c; cin>>r>>c; 
    string s; 
    for (int i=0;i<=c+1;i++) cout << "#";
    cout << endl;
    while (r--){
      cin>>s;
      cout << "#";
      for (int i=0;i<c;i++) cout << s[i];
      cout << "#"<<endl;
    }
    for (int i=0;i<=c+1;i++) cout << "#";
    cout << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3624
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
MAP=[input().strip() for i in range(N)]

# vertex 0～N*M
# egg N*M～N*M+100
# start N*M+101
# goal N*M+102

start = N*M+101
goal = N*M+102
V=N*M+110
 
EDGE=[set() for i in range(V)]

EGGS=[]

for i in range(N):
    for j in range(M):
        if MAP[i][j]=="o":
            EGGS.append((i,j))

EGGNUM=len(EGGS)

for i in range(EGGNUM):
    x,y=EGGS[i]
    USE=[[0]*M for i in range(N)]
    Q=[(x,y)]

    while Q:
        x,y=Q.pop()
        EDGE[N*M+i].add(M*x+y)
        for z,w in [(x+1,y),(x,y+1)]:
            if 0<=z<N and 0<=w<M and USE[z][w]==0 and MAP[z][w]!="#":
                USE[z][w]=1
                Q.append((z,w))

for i in range(EGGNUM):
    EDGE[start].add(N*M+i)

for i in range(N):
    for j in range(M):
        if MAP[i][j]!="#":
            EDGE[M*i+j].add(goal)
 
BACK=[-1]*V
LA=0
 
import heapq
OVER=3000

def cost(x,y):
    #print(x,y)
    
    if N*M<=x<N*M+100 and y<N*M:
        z0,w0=EGGS[x-N*M]
        z1,w1=divmod(y,M)

        return 3000-(z1-z0+w1-w0)

    elif N*M<=y<N*M+100 and x<N*M:
        z0,w0=EGGS[y-N*M]
        z1,w1=divmod(x,M)

        return -(3000-(z1-z0+w1-w0))

    else:
        return 0
    
for flow in range(EGGNUM):
    ANS=[float("inf")]*V
    Q=[(0,start)]
    ANS[start]=0
 
    while Q:
        time,fr=heapq.heappop(Q)
        if time>ANS[fr]:
            continue
 
        for to in EDGE[fr]:
            c = cost(fr,to)
            if ANS[to]>ANS[fr]+c:
                ANS[to]=ANS[fr]+c
                BACK[to]=fr
                heapq.heappush(Q,(ANS[to],to))

    #print(ANS)
 
    LA+=ANS[goal]
 
    NOW=goal
    while NOW!=start:
        fr=BACK[NOW]
        EDGE[fr].remove(NOW)
        EDGE[NOW].add(fr)
 
        NOW=fr
 
print(3000*EGGNUM-LA)



Measured memory_bytes: 81096
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)

 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    struct UnionFind {
    vector<lint> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<lint> siz;

    UnionFind(lint N) : par(N),siz(N,1LL) { //最初は全てが根であるとして初期化
        for(lint i = 0; i < N; i++) par[i] = i;
    }

    lint root(lint x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(lint x, lint y) { // xとyの木を併合
        lint rx = root(x); //xの根をrx
        lint ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        siz[ry]+=siz[rx];
    }

    bool same(lint x, lint y) { // 2つのデータx, yが属する木が同じならtrueを返す
        lint rx = root(x);
        lint ry = root(y);
        return rx == ry;
    }
    lint size(lint x){
        return siz[root(x)];
    }
    void init(lint N){
        for(lint i = 0; i < N; i++) par[i] = i;
        for(lint i = 0; i < N; i++) siz[i] = 1;
    
    }
};
    int main(){
        lint n,m;
        cin>>n>>m;
        UnionFind uf(n);
        rep(i,m){
            lint a,b;
            cin>>a>>b;
            --a;--b;
            uf.unite(a,b);
        }
        set<lint> st;
        rep(i,n)st.insert(uf.root(i));
        cout<<st.size()-1<<endl;
        
    }
      

Measured memory_bytes: 8416
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;

long long a,b;
long long s=0;
int main()
{
    cin>>a;
    b=a;
	while (b!=0)
	{
	    s+=b%10;
	    b/=10;
	}
	if (a%s==0)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
    return 0;
}



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


int isPrime(int x){

  if(x==2){
    return 1;
  }
  else if(x<2||x%2==0){
    return 0;
  }
  int i=3;
  while(i<=sqrt(x)){
    if(x%i==0)
      return 0;
    i=i+2;
  }
  return true;
}


int main(){

  int n;
  cin>>n;
  int a,cnt=0;
  for(int i=0;i<n;i++){
    cin>>a;
    if(isPrime(a)){
      cnt++;
    }
  }
  cout<<cnt<<endl;

  return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>
int main(){
  long n,d,x,y,i;
  int count=0;
  
  scanf("%ld %ld",&n,&d);
  for(i=0;i<n;i++){
    scanf("%ld %ld",&x,&y);
    if((x*x+y*y)<=(d*d)){
      count++;
    }
  }
  
  printf("%d",count);
}

Measured memory_bytes: 1728
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>

using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<int> scoreA = {0};
	vector<int> scoreB = {0};
	vector<int> scoreC = {0};
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		int A = scoreA.back();
		int B = scoreB.back();
		int C = scoreC.back();
		scoreA.push_back(a + max(B, C));
		scoreB.push_back(b + max(C, A));
		scoreC.push_back(c + max(A, B));
	}
	cout << max(scoreA.back(), max(scoreB.back(), scoreC.back()));
	return 0;
}

Measured memory_bytes: 1644
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  bool z = false;
  for (int a = 1; a < 10; a++) {
    if (N % a == 0) {
      int b = N / a;
      if (b >= 1 && b <= 9) {
        z = true;
      }
    }
  }
  if (z) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main() {
	int a, b;
	while(1){
		cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		}
		for(int y = 0 ; y < a ; y++){
			for (int x = 0 ; x < b ; x++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3088
#include <iostream>

int main() {
  unsigned max_len;
  std::cin >> max_len;
  std::string s0, s1;
  std::cin >> s0 >> s1;
  unsigned max = 0;
  unsigned cnt = 0;
  for (auto i = s0.rbegin(); i < s0.rend(); ++i) {
    auto i2 = i;
    auto tmp = true;
    for (auto j : s1) {
      if (*i2-- != j) {
        tmp = false;
        break;
      }
      if (i2 < s0.rbegin()) {
        tmp = true;
        break;
      }
    }
    ++cnt;
    if (tmp) {
      max = cnt;
    }
  }
  int len0 = (int) s0.size();
  int len1 = (int) s1.size();
  std::cout << std::max(len0 + len1 - max, max_len);
  return 0;
}

Measured memory_bytes: 256
from collections import deque
n, q = map(int, input().split())
Q = []
for i in range(n): Q.append(deque())
for i in range(q):
    a = input().split()
    t = int(a[1])
    if   a[0] == '0': Q[t].append(a[2])        # push
    elif a[0] == '1' and Q[t]: print(Q[t][-1]) # top
    elif a[0] == '2' and Q[t]: Q[t].pop()      # pop


Measured memory_bytes: 20832
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	vector<int> x, sorted_x;

	cin >> n;

	for (int i = 0; i < n; ++i) {
		int xx;
		cin >> xx;
		x.emplace_back(xx);
	}

	sorted_x = x;

	sort(sorted_x.begin(), sorted_x.end());

	for (int i = 0; i < n; ++i) {
		int l = sorted_x[x.size() / 2 - 1];
		int r = sorted_x[x.size() / 2];

		if (x[i] <= l) {
			cout << r << endl;
		} else {
			cout << l << endl;
		}
	}


	return 0;
}

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

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

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll n;
  cin >> n;

  map<string, ll> m;
  rep(i, n) {
    string s;
    cin >> s;
    m[s]++;
  }

  cout << "AC x " << m["AC"] << endl;
  cout << "WA x " << m["WA"] << endl;
  cout << "TLE x " << m["TLE"] << endl;
  cout << "RE x " << m["RE"] << endl;

  return 0;
}


Measured memory_bytes: 3652
/* An ACEASH Source code  */
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double

#define vi vector<int>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>

#define vvi vector< vector < int > >
#define vvl vector< vector < ll > >

#define pii pair< int , int >
#define pll pair< ll , ll >

#define vpl vector< pll >
#define vpi vector< pii >

#define MOD 1000000007

#define mp make_pair
#define pb push_back

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

#define F first
#define S second

#define tez  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const ld pie = 3.1415926535897932384626 ;



int main()
{

       string s;
       cin>>s;
       ll sum=0;
       for(ll i=0;i<s.length();i++)
       {
           sum+=(s[i]-'0');
       }
       if(sum%9==0){cout<<"Yes";}
       else{cout<<"No";}







    return 0;
}




Measured memory_bytes: 3712
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AtCoder solver = new AtCoder();
        solver.solve(1, in, out);
        out.close();
    }

    static class AtCoder {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int current = 1;

            for (int i = 0; i < n; i++) {
                if (current * 2 > current + k) {
                    current += k;
                } else {
                    current *= 2;
                }
            }
            out.println(current);
        }
    }
}


Measured memory_bytes: 21716
import sys
from io import StringIO
import unittest


def resolve():
    h1, m1, h2, m2, k = map(int, input().split())
    ans = (h2 - h1) * 60 + (m2 - m1) - k

    if ans <= 0:
        print(0)
    else:
        print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """10 0 15 0 30"""
        output = """270"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10 0 12 0 120"""
        output = """0"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 70860
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

double expectation(int p);

int main() {
    string s, t;
    bool ans = false;
    cin >> s >> t;

    int x = s.size(), y = t.size();

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<>());


    for (int i = 0; i < min(x, y); i++) {
        if(s[i] < t[i]){
            ans = true;
            goto Ans;
        }
        else if (s[i] == t[i]) {
            continue;
        }
        else {
            ans = false;
            goto Ans;
        }
    }

    if (x > y) {
        ans = false;
    }
    else if(x < y) {
        ans = true;
    }


Ans:
    if (ans) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 3100
from collections import Counter
n,k=map(int,input().split())

a=[int(i) for i in input().split()]
d=Counter(a)
a=sorted(list(d.items()),key=lambda x:x[1],reverse=True)
if len(a)<=k:
    print(0)
else:
    ans=0
    for i in range(k,len(a)):
        ans+=a[i][1]
    print(ans)
    



Measured memory_bytes: 102856
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    VEC(int) A(N);
    READVEC(A);
    int sum = 0;
    FOR(i, 0, N)
        sum += A[i];

    int M;
    cin >> M;
    FOR(i, 0, M) {
        int p, x;
        cin >> p >> x;
        p--;
        cout << (sum - A[p] + x) << endl;
    }

    return 0;
};


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

public class AtCoderC
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        Tuple<int, int>[] map = new Tuple<int, int>[n];
        for (int i = 0; i < n; i++)
        {
            string line = Console.ReadLine();
            var words = line.Split(' ');
            map[i] = Tuple.Create(int.Parse(words[0]), int.Parse(words[1]));
        }

        double np = 1;
        for (int i = 1; i <= n; i++)
        {
            np += i;
        }

        double answer = 0;
        for (int i = 0; i < n; i++)
        {
            int x1 = map[i].Item1;
            int y1 = map[i].Item2;
            for (int j = i; j < n; j++)
            {
                int x2 = map[j].Item1;
                int y2 = map[j].Item2;
                double distance = Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
                answer += distance * 2 / n;
            }
        }

        Console.WriteLine(answer);
    }
}

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

int main() {
  int s1s2s3;
  cin >> s1s2s3;
  int s1, s2, s3;
  s1 = s1s2s3 / 100;
  s2 = (s1s2s3 - s1 * 100) / 10;
  s3 = s1s2s3 - s1 * 100 -s2 * 10;
  cout << s1 + s2 + s3 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,M;
  cin >> N >> M;
  int AC = 0;
  int WA = 0;
  vector<int> p(M);
  vector<string> S(M);
  if(M==0)
  {
    cout << 0 << " " << 0 << endl;
    return 0;
  }
  rep(i,M) cin >> p[i] >> S[i];
  rep(i,M) p[i] --;
  vector<pair<int,string>> vec(M);
  rep(i,M)
  {
    vec.push_back(make_pair(p[i],S[i]));
  }
  vector<int> ACcount(N,0);
  rep(i,M)
  {
    if(S[i]=="AC"&&ACcount[p[i]]!=-1)
    {
      AC ++;
      WA += ACcount[p[i]];
      ACcount[p[i]] = -1;
    }
    else if(S[i]=="WA"&&ACcount[p[i]]!=-1)
    {
      ACcount[p[i]] ++;
    }
  }
  cout << AC << " " << WA << endl;
  return 0;
}


Measured memory_bytes: 15024
#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
using namespace std;
int main() {
	string s;
	cin>>s;
	if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]) puts("Bad");
	else puts("Good");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

const int MAXN = 3000;

int a[MAXN];
int poly_para[MAXN];   // Polynomial parameter, output data
int comb[MAXN][MAXN];  // comb[i][j] = C(i, j) % p

void init(int p) {
  for (int i = 0; i < p; ++i) {
    comb[i][0] = comb[i][i] = 1;
    for (int j = 1; j < i; ++j) {
      comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % p;
    }
  }
}

// Calc i^j
int pow(int i, int j, int p) {
  int res = 1;
  while (j > 0) {
    if (j & 1) res = res * i % p;
    i = i * i % p;
    j >>= 1;
  }
  return res;
}

// Calc 'poly_para'
void solve(int p) {
  init(p);
  for (int i = 0; i < p; ++i) {
    int cur = 0;
    for (int k = 0; k < p; ++k) {
      if (a[k] == 0) continue;
      cur += (-1) * pow(p - k, p - 1 - i, p);
    }
    cur = (cur % p + p) % p;
    poly_para[i] = cur * comb[p - 1][i] % p;
  }
  
  for (int i = 0; i < p; ++i) {
    poly_para[0] += a[i];
  }
  poly_para[0] = (poly_para[0] + p) % p;
}

int main() {
  int p;
  std::cin >> p;
  for (int i = 0; i < p; ++i) std::cin >> a[i];
  solve(p);
  for (int i = 0; i < p; ++i) std::cout << poly_para[i] << std::endl;
  return 0;
}


Measured memory_bytes: 34176