akhauriyash/Code-Regression huggingface dataset:
/***********************************************************************


    __       ____ ____   ___                 _  __  __           __   
   / /      |  _ \___ \ / _ \               | |/ _|/ _|          \ \  
  / /_____  | |_) |__) | | | |_      ___   _| | |_| |_ ____  _____\ \ 
 < <______| |  _ <|__ <| | | \ \ /\ / / | | | |  _|  _|_  / |______> >
  \ \       | |_) |__) | |_| |\ V  V /| |_| | | | | |  / /        / / 
   \_\      |____/____/ \___/  \_/\_/  \__,_|_|_| |_| /___|      /_/  
                                                                      
                                                                      

************************************************************************/

#include <bits/stdc++.h>

#define loop(i, a, b) for (int i = a; i < b; i++)
#define wh(x) \
    int x;    \
    cin >> x; \
    while (x--)
#define mkar(arr, n) \
    int arr[n];      \
    loop(i, 0, n) { cin >> arr[i]; }
#define print_ar(arr, n)                     \
    loop(i, 0, n) { cout << arr[i] << " "; } \
    cout << endl;
#define pii pair<int, int>
#define mci map<char, int>
#define endl "\n"
#define ll long long
#define ull unsigned long long
#define pb push_back
#define FIO                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define slow(x) this_thread::sleep_for(chrono::milliseconds(x));
#define setbitmsb(x) (int)log2(x)
#define setbitlsb(x) (int)log2(x & -x)
#define OJ                            \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout)

using namespace std;

void setBit(ull &num, int ind)
{
    num |= (1ULL << ind);
}
void unsetBit(ull &num, int ind)
{
    num &= (~(1ULL << ind));
}

int main()
{
    // FIO;
    // OJ;
    string s, t;
    cin >> s >> t;
    if (s.compare(t.substr(0, t.size() - 1)) == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
constexpr int MAXN = 2000;
vector<int> G[MAXN * 2]; //1 ~ 2N - 1
int height[MAXN * 2], depth[MAXN * 2];
void build(int u, int p, int d) {
	int h = 0;
	for (int v : G[u]) {
		if (v == p) continue;
		build(v, u, d + 1);
		h = max(h, height[v] + 1);
	}
	height[u] = h, depth[u] = d;
}
int uAsCenter(int N, int K, int u) {
	if (G[u].size() == 1) return N - 1;
	vector<int> vh;
	build(u, -1, 0);
	transform(G[u].begin(), G[u].end(), back_inserter<decltype(vh)>(vh), [](int v) {
		return height[v] + 1;
	});
	nth_element(vh.begin(), vh.begin() + 1, vh.end(), greater<int>());
	int _K = min(K, vh[1]);
	return count_if(depth + 1, depth + N + 1, [_K](int d) {
		return d > _K;
	});
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N, K;
	cin >> N >> K;
	for (int i = 1; i < N; i++) {
		int u, v, w = N + i;
		cin >> u >> v;
		G[u].push_back(w), G[w].push_back(v);
		G[v].push_back(w), G[w].push_back(u);
	}
	int ans = N - 1;
	for (int i = 1; i < 2 * N; i++) {
		ans = min(ans, uAsCenter(N, K, i));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;
constexpr int MN = 5005;

ll p[MN], DP[MN][MN];

int main() {
    if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0);

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

	memset(DP, '?', sizeof DP);
	DP[0][0] = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= N; ++j) {
			if (p[i] > j) DP[i+1][j] = min(DP[i][j]+A, DP[i+1][j]), DP[i+1][p[i]] = min(DP[i][j], DP[i+1][p[i]]);
			else DP[i+1][j] = min(DP[i][j]+B, DP[i+1][j]);
		}
	}

	ll ans = 1e18;
	for (int i = 1; i <= N; ++i) ans = min(DP[N][i], ans);
	cout << ans;
}


Measured memory_bytes: 199400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long double a,b,c;
  cin >>a>>b>>c;
  long double kotae1=a+b+2*sqrt(a*b);
  long double kotae2=c;
  if(kotae1<kotae2){
    cout <<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

using namespace std;

bool kaibun(string s){
    size_t len = s.length();
    for(int i = 0; i < len/2; i++){
        if(s[i] != s[len-i-1]) return false;
    }
    return true;
}

int main(){
    vector<vector<int>> bingo(3);
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            int a;
            cin >> a;
            bingo.at(i).push_back(a);
        }
    }
    int N;
    cin >> N;
    for(int k = 0; k < N; k++){
        int num;
        cin >> num;
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if( num == bingo.at(i).at(j)){
                    bingo.at(i).at(j) = -1;
                }
            }
        }
    }
    if(bingo[0][0] == -1 && bingo[1][1] == -1 && bingo[2][2] ==-1){
              cout << "Yes" <<endl;
        return 0;
    }
    if(bingo[0][2] == -1 && bingo[1][1] == -1 && bingo[2][0] ==-1){
        cout << "Yes" <<endl;
        return 0;
    }
    for(int i=0;i<3;i++){
        int tmp = -1;
        for(int j=0;j<3;j++){
           if( bingo[i][j] !=-1) tmp=bingo[i][j];
        }
        if(tmp == -1){
            cout << "Yes" << endl;
            return 0;
        }
    }
    for(int j=0;j<3;j++){
        int tmp = -1;
        for(int i=0;i<3;i++){
           if( bingo[i][j] !=-1) tmp=bingo[i][j];
        }
        if(tmp == -1){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const ll INF = (ll)(1e18);

int N;
vector<pair<int,int>> G[2505];
vector<pair<int,int>> rG[2505];
bool cango[2505];

void dfs(int v){
  cango[v] = true;
  rep(i,rG[v].size()){
    int j = rG[v][i].first;
    if(cango[j]) continue;
    dfs(j);
  }
}

void calc(){
  vector<ll> dist;
  rep(i,N+1){
    dist.push_back(INF);
  }
  dist[1] = 0;
  bool update = true;
  int cnt = 0;
  while(update){
    update = false;
    REP(i,1,N+1){
      if(dist[i] == INF) continue;
      if(!cango[i]) continue;
      rep(j,G[i].size()){
        int ni = G[i][j].first;
        if(!cango[ni]) continue;
        if(dist[ni] > dist[i] + G[i][j].second){
          dist[ni] = dist[i] + G[i][j].second;
          update = true;
        }
      }
    }

    //rep(i,N+1) cout << " " << dist[i]; cout << endl;
    
    if(cnt == N && update){
      cout << -1 << endl;
      return;
    }
    cnt++;
  }

  cout << max(0LL, -dist[N]) << endl;
}

int main(){
  int M, P;
  cin >> N >> M >> P;
  rep(i,M){
    int a, b, c;
    cin >> a >> b >> c;
    G[a].emplace_back(b,-(c-P));
    rG[b].emplace_back(a,-(c-P));
  }
  
  dfs(N);

  calc();
  
  return 0;
}



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

class Main{
    public static void main(String args[])throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
        int N = Integer.parseInt(br.readLine());
        String[] array = br.readLine().split(" ");
        int[] num = new int[N];

        for(int i = 0; i < N; i++){
          num[i] = Integer.parseInt(array[i]);
        }
        
        int result = 0;
        int flag = 0;

        for(int i = 0; i < N; i++){
          if((num[i] % 2) == 0){
            if((num[i] % 3) == 0 || (num[i] % 5) == 0){
              result += 1;
            }else{
              flag += 1;
            }
          }else{
            continue;
          }
        }
    
        if(flag ==  0){
          System.out.println("APPROVED");
        }else{
          System.out.println("DENIED");
        }

      }
    }
}

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

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

    vector<vector<int>> a(n, vector<int> (n, 0));

    for (int i = 0; i < n; i += 1)
        for (int j = 0; j < n; j += 1)
            cin >> a[i][j];

    vector<int64_t> value((1 << n), 0);

    for (int mask = 0; mask < (1 << n); mask += 1) {
        vector<int> rabbits;
        for (int i = 0; i < n; i += 1)
            if ((1 << i) & mask)
                rabbits.push_back(i);

        int k = rabbits.size();
        for (int i = 0; i < k; i += 1)
            for (int j = i + 1; j < k; j += 1)
                value[mask] += a[rabbits[i]][rabbits[j]];
    }

    vector<int64_t> dp((1 << n), 0);

    for (int mask = 0; mask < (1 << n); mask += 1) {
        dp[mask] = value[mask];
        for (int sub = mask; sub > 0; sub = (sub - 1) & mask)
            dp[mask] = max(dp[mask], dp[sub] + dp[mask ^ sub]);
    }

    cout << dp[(1 << n) - 1] << "\n";
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define float long double
typedef vector<int> vi;
#define pb push_back

int mod(int a,int b){
    return (a-b)>0?(a-b):(b-a);
}


int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	int *arr = new int [n];
	for(int i =0 ; i < n ; i++) cin >> arr[i];
	if(n == 1 ) cout << 0;
	else if(n == 2) cout << mod(arr[1],arr[0]);
	else{

        int a = mod(arr[0],arr[1]);
        int b = 0;
        for(int i  = 2 ; i < n ; i++) {
                int x ;
                x = min(a + mod(arr[i],arr[i-1]),b + mod(arr[i],arr[i-2]));
                b = a;
                a = x;
        }
        cout << a ;
	}
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <regex>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include<tuple>

using namespace std;

int main(){
	string s1, s2;

	cin >> s1;
	cin >> s2;

	for (int i = 0; i < s2.length(); i++) {
		if (s1 == s2) {
			cout << "Yes" << endl;
			return 0;
		}
		s2.push_back(s2[0]); s2.erase(0, 1);
	}

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
char map[505][505];
int dx[4] = { 1,-1,0,0};
int dy[4] = { 0,0,1,-1};

vector<int> to[100005];

int main() {
	int n, m;
	cin >> n >> m;
	int a, b;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		a--; b--;
		to[a].push_back(b);
		to[b].push_back(a);
		//なにになにがつながっているか
	}
	queue<int>q;
	vector<int> dist(n, inf);//infにそろえるのは逆流防止
	vector<int> pre(n, -1); //直前の頂点
	dist[0] = 0; //頂点0からみていこう//
	q.push(0);
	while (!q.empty()) {
		int v = q.front(); q.pop();
		for (int u : to[v]) {
			if (dist[u] != inf)continue;
			dist[u] = dist[v] + 1;
			pre[u] = v;
			q.push(u);
		}
	}

	cout << "Yes" << endl;
	for (int i = 0; i < n; i++) {
		if (i == 0)continue;
		int ans = pre[i];
		ans++;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 10664
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define mod 1000000007
#define N 100005
using namespace std;

int h, w, a, b, jc[N << 1], inv[N << 1], ans; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int C(int n, int m)
{
	if(n < 0 || m > n) return 0;
	return 1ll * jc[n] * inv[m] % mod * inv[n - m] % mod; 
}

int main()
{
	h = read <int> (), w = read <int> (), a = read <int> (), b = read <int> ();
	inv[0] = inv[1] = jc[0] = jc[1] = 1; 
	for(int i = 2; i <= 200000; i++)
	{
		jc[i] = 1ll * jc[i - 1] * i % mod;
		inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod; 
	}
	for(int i = 2; i <= 200000; i++)
		inv[i] = 1ll * inv[i] * inv[i - 1] % mod;
	ans = C(h + w - 2, h - 1); 
	for(int i = 1; i <= b; i++)
		ans = 1ll * ((1ll * ans - 1ll * C(h - a + i - 2, i - 1) * C(w - i + a - 1, a - 1) % mod) + mod) % mod; 
	printf("%d\n", ans); 
	return 0; 
}


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

int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	long long n, m;
	cin >> n >> m;
	
	long long arr[n];
	set<int> s;
	long long t;
	for(int i = 0;i < n;i++){
		cin >> arr[i];
		int x = (arr[i]) & (-arr[i]);
		s.insert(x);
		arr[i] /= 2;
	}
	
	
	
	if(s.size() != 1){
		cout << 0 << "\n";
		return 0;
	}
	long long x = arr[0];
	for(int i = 1;i < n;i++){
		long long y = arr[i];
		long long g = __gcd(x,y);
		x /= g;
		x *= y;
		if(x > m){
			cout << 0 << "\n";
			return 0;
		}
	}
	long long ans = (m) / (2 * x);
	m %= (2*x);
	if(m >= x) ans += 1;
	cout << ans;
}


Measured memory_bytes: 1024
N,K=map(int,input().split())
AB=[[0,0]for _ in range(N)]

for i in range(N):
    AB[i]=list(map(int,input().split()))
AB.sort()

ans=0
i=0
while K>0 and i<N:
    K-=AB[i][1]
    ans=AB[i][0]
    i+=1

print(ans)

Measured memory_bytes: 27824
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <iostream>
using namespace std;
int main ()
{
    char s1[101],s2[101];
    scanf("%s%s",&s1,&s2);
    printf("%s%s",s2,s1);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b,c;
    int count = 0;
    scanf("%d %d %d",&a,&b,&c);
    
    for(;a<=b;a++){
        if ( c % a == 0){
            count++;
        }
    }
    
    printf("%d\n",count);
    
    return 0;
}

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

using namespace std;
typedef long long ll;

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

int mypow(int a, int b, int X){
    int ret = 1;
    FOR(i, 0, b){
        ret *= a;
        if(ret > X){
            return -1;
        }
    }
    return ret;
}

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

    // input
    int X;
    cin >> X;

    int max_answer = 0;
    FOR(b, 1, 1000){
        FOR(p, 2, 10){
            int bp = mypow(b, p, X);
            max_answer = max(max_answer, bp);
        }
    }    

    p(max_answer);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vp vector<pi>
#define pb push_back
#define mp map<ll,ll>
#define endl '\n'
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}
int32_t main(){
    fast;
    ll n;
    cin>>n;
    vi v(n,0);
    for(ll i=0;i<n;i++)cin>>v[i];
    ll k=1,c=0;
    for(ll i=0;i<n;i++)
    {
        if(v[i]==k)
        {
            c++;
            k++;
        }
    }
    if(c==0)
    cout<<-1;
    else
    cout<<n-c;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define pi acos(-1.0)
#define maxd 1000000007
typedef long long ll;

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;
}
ll a,b,c;

int main()
{
	cin >> a >> b >> c;
	if (a+b>=c) cout << b+c;
	else cout << a+b+1+b;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> p(n);
    int sum = 0;
    rep(i, 0, n){
        cin >> p[i];
        sum += p[i];
    }
    int MAX = *max_element(p.begin(), p.end());
    cout << sum - MAX / 2 << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
res = 1

if 0 not in a:

    for i in range(n):
        res = res * a[i]
        
        if res > 1000000000000000000:
            res = -1
            break
else:
    res = 0

print(res)

Measured memory_bytes: 21780
import itertools
import math
import sys


def input():
    return sys.stdin.readline()[:-1]


N = int(input())
XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append([x, y])

sum_distance = 0
for x, y in list(itertools.combinations(range(N), 2)):
    sum_distance += math.sqrt(abs(XY[x][0]-XY[y][0])**2+abs(XY[x][1]-XY[y][1])**2)
print(sum_distance/(N/2))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

const ll MAX=505000;
const ll INF=0x3f3f3f3f3f3f3f;
ll N;
double L;
double v[MAX],t[MAX];
double v_sum=0,vt_sum=0;
deque<pdd> graph;
int modify(){
    pdd t1,t2,t3;
    if(graph.size()<3) return 0;
    t1=graph.front(); graph.pop_front();
    t2=graph.front(); graph.pop_front();
    t3=graph.front();
    if((t3.x-t2.x)*(t2.y-t1.y)<=(t3.y-t2.y)*(t2.x-t1.x)){
        graph.push_front(t1);
        return 1;
    }
    graph.push_front(t2); graph.push_front(t1);
    return 0;
}
int dcut(){
    pdd t1=graph.back(),t2;
    if(t1.x+v_sum>L){
        graph.pop_back();
        t2=graph.back();
        if(t2.x+v_sum<L){
            graph.push_back(make_pair(L-v_sum,(L-v_sum-t2.x)/(t1.x-t2.x)*(t1.y-t2.y)+t2.y));
            return 0;
        }
        return 1;
    }
    return 0;
}
int main(){
    scanf("%lld%lf",&N,&L);
    for(ll i=0;i<N;i++) scanf("%lf%lf",&t[i],&v[i]);
    graph.push_front(make_pair(v_sum,vt_sum));
    for(ll i=0;i<N;i++){
        v_sum+=v[i],vt_sum+=v[i]*t[i];
        graph.push_front(make_pair(-v_sum,-vt_sum));
        while(dcut());
        while(modify());
        //printf("%d\t%.10f\t%.10f\n",graph.size(),graph.back().x,graph.back().y);
        printf("%.10f\n",(graph.back().y+vt_sum)/(graph.back().x+v_sum));
    }
    return 0;
}


Measured memory_bytes: 26516
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>

using namespace std;

int main(void){
	int n;
	cin >> n;
	vector<double> v(n);
	auto sum = 0;
	for(int i=0;i<n;i++){
		cin >> v[i];
		sum += v[i];
	}
	double ave = (double)sum / (double)n;
	for(int i=0;i<n;i++){
		v[i] -= ave;
		v[i] = abs(v[i]);
	}
	auto iter = min_element(v.begin(), v.end());
	cout << distance(v.begin(), iter) << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-26 20:40:00
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << (vec.empty() ? "{}" : "}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << (st.empty() ? "{}" : "}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << (mp.empty() ? "{}" : "}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

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

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

  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

int main(){
	int n=read(),k=read();
	printf("%d\n",n-k+1);
}

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

#define int long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(), (x).end()
#define pb push_back
#define pf push_front
#define fori(i, a, n) for(int i = a; i < n; ++i)
#define MAX(x) (*max_element(all(x)))
#define MIN(x) (*min_element(all(x)))
#define sortarr(a,n) sort(a, a+n)
#define sortvec(V) sort(all(V))

typedef vector<int> V;
typedef pair<int , int> pairi;
typedef set<int> seti;
typedef deque<int> deqi;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;
const int N = 1e5;
void solve()
{
    int n;
    cin >> n;
    map<int, int> mp;
    for(int i = 1; i <= 100; i++){
        for(int j = 1; j <= 100; j++){
            for(int k = 1; k <= 100; k++){
                int ans = (i * i + j * j + k * k + i * j + i * k + j * k);
                mp[ans]++;
            }
        }
    }
    for(int i = 1; i <= n; i++)
        cout << mp[i] << "\n";
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n ";
}

Measured memory_bytes: 6232
import sys

# import bisect
# import numpy as np
from collections import deque
# map(int, sys.stdin.read().split())



def input():
    return sys.stdin.readline().rstrip()


def main():
    mod =998244353
    N, S = map(int, input().split())
    A = list(map(int, input().split()))

    dp =[[0]*(S+1) for _ in range(N+1)]
    dp[0][0]=1
    for i in range(0,N):
        for j in range(S+1):
            if A[i]>j:
                dp[i+1][j] =dp[i][j]*2
                dp[i+1][j] %= mod
            else:
                dp[i+1][j] = dp[i][j]*2 + dp[i][j-A[i]]
                dp[i+1][j] %= mod
    print(dp[N][S])
    pass



if __name__ == "__main__":
    main()


Measured memory_bytes: 133000
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	if s[0] != 'A' {
		fmt.Println("WA")
		return
	}

	ok := false
	for i := 2; i <= len(s)-2; i++ {
		if s[i] == 'C' {
			ok = true
		}
	}
	if !ok {
		fmt.Println("WA")
		return
	}

	var ct int
	for i := 0; i < len(s); i++ {
		if 'A' <= s[i] && s[i] <= 'Z' {
			ct++
		}
	}
	if ct > 2 {
		fmt.Println("WA")
		return
	}

	fmt.Println("AC")
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    int N,M; cin >> N >> M;
    vector<int> G[200005];

    for(int i = 0; i < M; i++){
        int a,b; cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    for (int i = 0;i < G[1].size();i++){
        int node = G[1][i];
        for (int j = 0;j < G[node].size();j++){
            if(G[node][j] == N){
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }

    cout << "IMPOSSIBLE" << endl;

    return 0;

}

Measured memory_bytes: 12016
#include <stdio.h>

int main(void)
{
	int N, i, count = 0;
	float vote = 0, M;
	int A[100];
	
	scanf("%d %f", &N, &M);
	
	for(i = 0; i < N; i++){
	
		scanf("%d", &A[i]);
		vote = vote + A[i];
	}
	
	for(i = 0; i < N; i++){
	
		if(A[i] >= vote/((4*M))) count++;
	
	}
	
	if(count >= M) printf("\nYes");
	else printf("\nNo");
	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void){
	int a,b,c,x,y,i=0;
	scanf("%d %d %d",&a,&b,&c);
	for(x=a;x<=b;x++){
		y=c%x;
		if(y==0){
			i++;
		}
	}
	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 596
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] str = Console.ReadLine().Split(' ');

            int a, b;
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);

            if (a < b)
            {
                Console.WriteLine("a < b");
            }
            else if (a > b)
            {
                Console.WriteLine("a > b");
            }
            else
            {
                Console.WriteLine("a == b");
            }
        }
    }
}

Measured memory_bytes: 8820
#include <iostream>

using namespace std;
int main(){
  
  long long int ans;
  long long int X;
  long long int happy1;
  long long int happy2;

  cin >> X;

  happy1 = X/500;
  happy2 = X%500/5;

  ans = happy1 * 1000 + happy2 * 5;

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll N, a[100010];

ll solve(bool ev){
    ll ret = 0, sum = 0;
    REP(i, N){
        if(i % 2 == ev){
            ret += max(0LL, 1 - sum - a[i]);
            sum += a[i] + max(0LL, 1 - sum - a[i]);
        }else{
            ret += max(0LL, sum + a[i] + 1);
            sum += a[i] + min(0LL, -1 - sum - a[i]);
        }
    }
    return ret;
}

signed main(){
    cin >> N;
    REP(i, N) cin >> a[i];
    PRINT(min(solve(0), solve(1)));
    return 0;
}

Measured memory_bytes: 4356
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

struct Node {
  int color;
  int weight;
  vi acc;
  Node() {
    color = 0;
    weight = 0;
    acc = vi(2, 0);
  }
};

int INF = INT_MAX / 2;
vi X;

vi par;
vvi child;

vvi acc;

bool possible(int u) {
  if (child[u].size() == 0) {
    acc[u][0] = X[u];
    return true;
  }

  int all_sum = 0;
  map<int, bool> mp;
  mp[0] = true;

  for (int v : child[u]) {
    possible(v);
    all_sum += acc[v][0];
    all_sum += acc[v][1];
    map<int, bool> mp_;
    for (auto elm : mp) {
      mp_[elm.first + acc[v][0]] = true;
      mp_[elm.first + acc[v][1]] = true;
    }
    swap(mp, mp_);
  }

  auto itr = mp.upper_bound(X[u]);
  if (itr == begin(mp)) {
    printf("IMPOSSIBLE\n");
    exit(0);
  }

  itr --;
  acc[u][0] = all_sum - (*itr).first;
  acc[u][1] = X[u];

  return true;
}

int main() {
  int n;
  scanf("%d", &n);
  par.assign(n, -1);
  child.resize(n);
  FOR (i, 1, n) {
    int p;
    scanf("%d", &p);
    p -= 1;
    par[i] = p;
    child[p].push_back(i);
  }

  X.resize(n);
  rep (i, n) {
    scanf("%d", &X[i]);
  }

  acc.assign(n, vi(2, 0));

  possible(0);
  printf("POSSIBLE\n");

  return 0;
}


Measured memory_bytes: 5504
n = int(input())
a = list(map(int, input().split()))

x = 0
z = 0

for i in range(n):
    if a[i]<0:
        x +=1
    if a[i]==0:
        z += 1

b = []
for i in range(n):
    b.append(abs(a[i]))

if z ==0 and x%2 ==1:
    print(sum(b)-min(b)*2)
else:
    print(sum(b))

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

int main(){
  int A,B,K;
  cin >>A>>B>>K;
  
  vector<int> C(max(A,B),0);
  rep(i,1,B){
    if(A%i==0 and B%i==0){
      C[i-1] = i;
    }
  }  
  
  sort(C.begin(),C.end(),greater<int>());
  int ans = C[K-1];
  cout <<ans<<endl;
}

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

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    int a[q];
    int b[n] = {};
    rep(i,q) {
        cin >> a[i];
        b[a[i]-1]++;
    }
    rep(i,n){
        if(k -(q-b[i]) > 0) cout << "Yes" << endl;
        else cout << "No" << endl; 
    }
    return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		int tate = 0;
		int yoko = 0;
		int tyohuku = 0;

		tate = h * W;
		yoko = w * H;
		tyohuku = h * w;

		System.out.println(H * W - (tate + yoko - tyohuku));
	}
}


Measured memory_bytes: 24148
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        
        int[] x = new int[4];
        int[] y = new int[4];
        
        x[0] = sc.nextInt();
        y[0] = sc.nextInt();
        x[1] = sc.nextInt();
        y[1] = sc.nextInt();
        
        int dx = x[1] - x[0];
        int dy = y[1] - y[0];
        
        x[2] = x[1] - dy;
        y[2] = y[1] + dx;
        x[3] = x[0] - dy;
        y[3] = y[0] + dx;
        
        System.out.println( x[2] + " " + y[2] + " " + x[3] + " " + y[3] );
        
    }
}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c;
  while(cin>>a>>b>>c,a){
    if(c==0){
      if(a==1&&b<0)cout<<a<<' '<<0<<' '<<1<<' '<<b<<endl;
      else cout<<a<<' '<<b<<' '<<1<<' '<<0<<endl;
    }
    else{for(int j=1;j<=a;j++){
	if(a%j==0){
	  if(a/j>=j)
	    for(int i=10000;i>=-10000;i--){
	      long long t,p=0;
	      if(i*j+a/j*p==b&&p*i==c){
		cout<<a/j<<' '<<i<<' '<<j<<' '<<p<<endl;
		goto L;
	      }
	      if(i!=0){
		if(c%abs(i)==0)t=c/i;
		else continue;
	      }
	      else continue;
	      if(i*j+a/j*t==b&&t*i==c){
		if(j*j==a&&i<t)	  cout<<a/j<<' '<<t<<' '<<j<<' '<<i<<endl;
		else cout<<a/j<<' '<<i<<' '<<j<<' '<<t<<endl;
		goto L;
	      }
	    }
	  else break;
	}
      }
      cout<<"Impossible"<<endl;L:;
    }

  }
}

Measured memory_bytes: 3076
n = int(input())
pt, px, py = 0,0,0
f = 0
for i in range(n):
    t,x,y = map(int, input().split())
    gt = t-pt
    gx, gy = abs(x-px), abs(y-py)
    gt -= gx+gy
    if gt < 0 or gt%2==1:
        f=1
    pt,px,py = t,x,y
if f:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9208
//https://atcoder.jp/contests/abc143/tasks/abc143_a
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a, b ;
  cin >> a >> b ;
  if(2*b >= a) cout << 0 ;
  else cout << abs(2*b -a) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string pres = ".";
  map<string, int> mp;
  REP(i, N){
    string s;
    cin >> s;
    if((i && pres.back() != s.front()) || mp[s] != 0){
      cout << "No" << endl;
      return 0;
    }
    pres = s;
    mp[s] = 1;
  }
  cout << "Yes" << endl; 
  return 0;
}


Measured memory_bytes: 888
def swap(a, i, j)
  tmp = a[i]
  a[i] = a[j]
  a[j] = tmp
end

def partition(a, p, r)
  ans = p
  p.upto(r - 1) do |i|
    if a[i] <= a[r]
      swap(a, ans, i)
      ans += 1
    end
  end
  swap(a, ans, r)
  ans
end

n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

idx = partition(a, 0, a.size - 1)
ans = []
a.each.with_index do |ai, i|
  ans <<
    if i == idx
      "[" + ai.to_s + "]"
    else
      ai.to_s
    end
end
puts ans.join(' ')


Measured memory_bytes: 18008
import java.util.Scanner;

public class Main{
	//N問出題　M回提出　
	//i回目はp[i]番の問題　結果はS[i]="AC"or"WA"
	//正答数はS[i]=ACの問題数の合計
	//ペナルティ数は↑でACになるまでに出したWAの合計
	//正答数とペナルティ数を答える
	//
	//iのときにACが出るまでforでPにカウント、
	//ACが出たらSにカウントしてi++→i+1の数字の場合、同様の処理を行う
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int M = scan.nextInt();
    int p = 0;
    String S= null;
    String check[] = new String[N+1];
    for(int i=1; i<=N; i++){
      check[i]="";
    }
    int sumP[] = new int[N+1];
    for(int i=1; i<=N; i++){
      sumP[i]=0;
    }
    int resultP = 0;
    int resultS = 0;

    if(M>0){
    for(int i=1; i<=M; i++){
    	p = scan.nextInt();
    	S = scan.next();
    	if(!(check[p].equals("AC")) && S.equals("WA")) {
    		sumP[p]++;
    	}else if(!(check[p].equals("AC")) && S.equals("AC")){
    		resultS++;
    		check[p] = "AC";
    	}
    }
      for(p=1; p<=N; p++){
        if(check[p].equals("AC")){
        	resultP = resultP + sumP[p];
        }
      }
    }
    System.out.println(resultS+" "+resultP);
  }
}

Measured memory_bytes: 65332
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int N=62;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
//inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int len=1e9,ttt,q[N];string s[N];
inline char Get(int x){return x<10?x+'0':x<10+26?x-10+'a':x-10-26+'A';}
inline int Query(string a){if(a.length()>128)return 0x3f3f3f3f;cout<<"? "<<a<<endl;return read();}
inline string Merge(string sa,string sb){
	int i=0,j=0,la=sa.size(),lb=sb.size();string fir=string();
	for(;i<la&&j<lb;){
		string Que=fir;Que+=sa[i];Rep(k,j,lb-1)Que+=sb[k];
		if(Query(Que)+Que.size()==len)fir+=sa[i++];else fir+=sb[j++];
	}for(;i<la;)fir+=sa[i++];for(;j<lb;)fir+=sb[j++];return fir;
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	for(int i=0;i<N;i++)s[i]+=Get(i),q[i]=Query(s[i])+1,len=min(len,q[i]);
	for(int i=0;i<N;i++)if(q[i]==len)for(;Query(s[i]+Get(i))+s[i].size()+1==len;s[i]+=Get(i));else s[i]=string();
	while(1){
		for(int i=0;i<N;i++)for(int j=i+1;j<N;j++)if(s[i].size()>s[j].size())swap(s[i],s[j]);
		int t=0;for(;!s[t].size();t++);if(t+1==N)break;string nw=Merge(s[t],s[t+1]);s[t+1]=nw,s[t]=string();
	}cout<<"! "<<s[N-1]<<endl;return 0;
}




Measured memory_bytes: 3772
#include<stdio.h>
int main()
{
	int N,i,candes=0;
	while(scanf("%d",&N)!=EOF){
	candes =0;
	for(i=1 ; i<=N ; i++){

	candes=candes+i;

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

	}
	 return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> s(N);
  int sum=0;
  for (int i=0;i<N;i++){
    cin >> s[i];
    sum+=s[i];
  }
  if (sum%10==0){
    int x=101;
    for (int i=0;i<N;i++){
      if (s[i]%10!=0){
        x=min(x,s[i]);
      }
    }
    if (x==101){
      sum=0;
    }
    else {
      sum-=x;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
int main()
{
  int N;
  cin >> N;
  map<char, int> mp;
  for (int i = 0; i < N; i++)
  {
    char S;
    cin >> S;
    mp[S]++;
  }
  if (0 < mp['Y'])
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
  return 0;
}

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

ll check(string str) 
{ 
	ll n = str.length(); 
	ll digitSum = 0; 
	for (ll i=0; i<n; i++) {
		digitSum += ((str[i]-'0')%9);
							}
	return (digitSum % 9 == 0); 
} 

int main() 
{	
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	string str = "";
	cin>>str;
	check(str)? cout << "Yes" : cout << "No "; 
	return 0; 
} 


Measured memory_bytes: 3692
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    const double Inf=1e9;
    vector<pair<double,string> >vegi;
    for(int i=0;i<n;i++){
      string str;cin>>str;
      double a,b,c,d,e,f,g,h,m;
      cin>>a>>b>>c>>d>>e>>f>>g>>h>>m;
      double time=b+c+d+m*(e+f);
      int value=m*h*g-a;
      vegi.pb(mp(Inf-(value/time),str));
    }
    sort(vegi.begin(),vegi.end());
    for(int i=0;i<n;i++)
      cout<<vegi[i].S<<endl;
    cout<<"#"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ll((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
#define roF(i,a,b) for(ll i = ll(a); i >= ll(b); i--)
using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const ll N=1e6;

int ans[N];

int main(){
	fastio;
	int n, x, y; cin>>n>>x>>y;
	For(i,1,n+1){
		For(j,i+1,n+1){
			ans[min(j-i,abs(i-x)+abs(y-j)+1)]++;
		}
	}
	For(i,1,n) cout << ans[i] << endl;
	return 0;
}


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

using namespace std;

int main()
{

	int a = 0, b = 0, c = 0, d = 0, e = 0, maxy = 0, max = -1, ans = 1, count = 0, min = 0,give1=0,give2=0;

	int yoko = 0, tate = 0;
	std::string output, output2, output3, input = {};
	bool okada = false;
	int array[30][30],array2[30][30];
	int nearbydis;


	cin >> a>>b>>c;
	for (int i = 1; i <= c; i++) {
		if (i % 2 == 1) {
			if (a % 2 != 0) {

				a -= 1;
			}
			give1 = a / 2;
			a /= 2;
			b += give1;
		}
	
	else {
		if (b % 2 != 0) {

			b -= 1;
		}
		give1 = b / 2;
		b /= 2;
		a +=give1;
	}
	}
	cout << a << " " << b << endl;
}







Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn =2e5+5;
int n,k,ans;
int mxr[maxn];
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		int temp;
		scanf("%d",&temp);
		mxr[temp]++;
	}
	sort(mxr,mxr+maxn,cmp);
	for(int i=0;i<k;i++)
	{
		ans+=mxr[i];
	}
	printf("%d\n",n-ans);
	return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

int main()
{
    int n; cin >> n;
    int mat[n][n];
    rep(i,n) rep(j,n) mat[i][j] = 0;
    rep(i, n){
        int u; cin >> u;
        int k; cin >> k;
        rep(j,k){
            int vj; cin >> vj;
            mat[u-1][vj-1] = 1;
        }
    }
    // 出力
    rep(i,n){
        rep(j,n){
            cout << mat[i][j];
            if(j != n-1) cout << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#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()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}



int n,a,b,c,d;
string s;
bool ans1,ans2;

void f(int x,int g,bool fl[]){
  //cout<<x<<' '<<g<<endl;
  if(x>=n||s[x]=='#'||fl[x]) return;
  fl[x]=true;
  
  if(x==g){
    //cout<<g<<endl;
    if(g==c) ans1=true;
    else ans2=true;
    s[g]='#';
    return;
  }

  f(x+2,g,fl);
  f(x+1,g,fl);
}



main(){
  cin>>n>>a>>b>>c>>d;
  cin>>s;
  a--;
  b--;
  c--;
  d--;

  bool h[210000]={};
  bool g[210000]={};

  s[a]='#';
  f(b,d,h);
  s[a]='.';
  f(a,c,g);
  if(ans1&&ans2){
    cout<<"Yes"<<endl;
    return 0;
  }

  s[a]='.';
  s[b]='#';
  s[c]='.';
  s[d]='.';
  ans1=false;
  ans2=false;
  bool r[2100000]={};
  bool t[2100000]={};
  f(a,c,r);
  s[b]='.';
  f(b,d,t);
  if(ans1&&ans2){
    cout<<"Yes"<<endl;
    return 0;
  }
  s[a]='.';
  s[b]='.';
  s[c]='.';
  s[d]='.';

  for(int i=max(a,b);i<min(n-2,min(c,d));i++){
    if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'){
      cout<<"Yes"<<endl;
      return 0;
    }
  }

  cout<<"No"<<endl;


}


Measured memory_bytes: 7428
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;

    if(m1 != m2){
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}

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

int main(){

    int N;
    cin >> N;
    vector<string> s(N);
    for(int i = 0; i < N; i++) cin >> s[i];

    int M;
    cin >> M;
    vector<string> t(M);
    for(int i = 0; i < M; i++) cin >> t[i];

    int ans = 0;
    for(int i = 0; i < N; i++){
        int sum = 1;
        for(int j = 0; j < N; j++){
            if(i == j) continue;
            if(s[i] == s[j]) sum++;
        }
        for(int j = 0; j < M; j++){
            if(s[i] == t[j]) sum--;
        }
        ans = max(ans, sum);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    char[] n = reader.readLine().toCharArray();
    if(n[0]=='7'|| n[1]=='7'|| n[2]=='7')
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}

Measured memory_bytes: 32688
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i <= n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

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

  rep(i,A,B){
    if(i%K==0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" <<endl;
  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String str = sc.next();
		int a[] = new int[n];
		int x = 0;
		boolean hantei = false;
		
		for(int i = 0; i < n; i++){
			char c = str.charAt(i);
			if(c == 'A'){
				a[i] = x;
				hantei = true;
			}else if(hantei && (c == 'C')){
				x += 1;
				a[i] = x;
				hantei = false;
			}else{
				a[i] = x;
				hantei = false;
			}
		}
		
		for(int i = 0; i < q; i++){
			int kekka = 0;
			int l = sc.nextInt();
			int r = sc.nextInt();
			kekka = a[r-1] - a[l-1];
			System.out.println(kekka);
		}
	}
}

Measured memory_bytes: 66332