akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#include<deque>
#define rep(i,rept)	for(int i = 0; i<(int)rept;++i)
typedef long long ll;
using namespace std;


int main() {
	//19日目 

	cin.tie(0); ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll a[100000], sum = 0, cnt = 0, cnt1 = 0;
	for (int i = 0; i<n; i++) cin >> a[i];
	for (int i = 0; i<n; i++) {//奇数が正
		sum += a[i];
		if (i % 2 != 0) {
			if (sum <= 0) {
				cnt += abs(1 - sum);
				sum = 1;
			}
		}
		else {
			if (sum >= 0) {
				cnt += abs(sum + 1);
				sum = -1;
			}
		}
	}
	sum = 0;
	for (int i = 0; i<n; i++) {//偶数が正
		sum += a[i];
		if (i % 2 == 0) {
			if (sum <= 0) {
				cnt1 += abs(1 - sum);
				sum = 1;
			}
		}
		else {
			if (sum >= 0) {
				cnt1 += abs(sum + 1);
				sum = -1;
			}
		}
	}
	cout << min(cnt, cnt1) << endl;
	return 0;

}


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

int const N = 5000, md = 1e9 + 7, mdi = md - 1;
int n, dp[N + 1][N + 1][2], sz[N + 1], pa[N + 1], y[N + 1], tmp[N + 1][2];
vector<int> tr[N + 1];
vector<pair<int, int> > ed;

void ad(int &x, int y) { if ((x += y) >= md)x -= md; }
void sb(int &x, int y) { if ((x -= y) < 0)x += md; }

int P(int v){
	return pa[v] < 0 ? v : pa[v] = P(pa[v]);
}

void J(int a, int b){
	int x = P(a), y = P(b);
	if (x == y)return;
	pa[x] += pa[y];
	pa[y] = x;
}

void pl(int v = 1, int p = 0){
	sz[v] = 1;
	f(i, 0, tr[v].size()){
		int u = tr[v][i];
		if (u == p)continue;
		pl(u, v);
		if (sz[u] & 1)J(u, v);
		else ed.push_back(make_pair(u, v));
		sz[v] += sz[u];
	}
}

void go(int v, int p = 0){
	int w = -pa[v];
	dp[v][w][0] = 1;
	sz[v] = w;
	f(i, 0, tr[v].size()){
		int u = tr[v][i];
		if (u == p)continue;
		go(u, v);
		f(i, 0, sz[v] + 1)f(j, 0, 2)tmp[i][j] = dp[v][i][j], dp[v][i][j] = 0;
		for (int j = 0; j <= sz[u]; j += 2)for (int k = 0; k <= sz[v]; k += 2)f(a, 0, 2)f(b, 0, 2){
			ad(dp[v][j + k][a ^ b], (ll)dp[u][j][a] * tmp[k][b] % md);
			ad(dp[v][k][a ^ b ^ 1], (ll)dp[u][j][a] * tmp[k][b] % md * y[j] % md);
		}
		sz[v] += sz[u];
	}
}

int main(){
	scanf("%d", &n);
	y[0] = 1;
	for (int i = 2; i <= n; i += 2)y[i] = (ll)y[i - 2] * (i - 1) % md;
	f(i, 1, n + 1)pa[i] = -1;
	f(i, 1, n){
		int a, b;
		scanf("%d%d", &a, &b);
		tr[a].push_back(b);
		tr[b].push_back(a);
	}
	pl();
	f(i, 1, n + 1)tr[i].clear();
	f(i, 0, ed.size()){
		int a = P(ed[i].first), b = P(ed[i].second);
		tr[a].push_back(b);
		tr[b].push_back(a);
	}
	go(P(1));
	int an = 0;
	f(i, 2, n + 1)ad(an, (ll)dp[P(1)][i][0] * y[i] % md);
	f(i, 2, n + 1)sb(an, (ll)dp[P(1)][i][1] * y[i] % md);
	printf("%d\n", an);
}

Measured memory_bytes: 194176
#include <iostream>

#define MOD 2019
using namespace std;

typedef long long ll;
ll N,M;

int main()
{
    cin >> N >> M;
    if((N - 1) / 2019 != M / 2019)
        cout << 0;
    else
    {
        ll Min = (1 << 30);
        for(ll i = N; i <= min(N + 2018,M); ++i)
            for(ll j = i + 1; j <= min(N + 2018,M); ++j)
                Min = min(Min,(i*j)%MOD);
        cout << Min;
    }
    return 0;
}


Measured memory_bytes: 256
/**
* Copyright(c)
* Author : tiketiskte
* Date : 2020-04-27-11.56.25
*/
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(false);cin.tie(0);}
using namespace std;
int a, b, c, d;
int main()
{
    IOS
    cin >> a >> b >>c >>d;
    while(1) {
        c -= b;
        if(c <= 0) {
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if(a <= 0) {
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3652
function Main(input) {
  let temp = input.split('\n');
  let temp2 = temp[1].split(' ');
  const K = parseInt(temp[0]);
  const A = parseInt(temp2[0])
  const B = parseInt(temp2[1])

  let ans = 'NG';
  if (!(A % K) || Math.floor(A / K) * K + K <= B){
    ans = 'OK'
  }

  // OK or NG
  console.log(ans)
}

// Main('7\n500 600')

// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30128
#include<stdio.h>

int main(){
int i,temp,j;
int A[10];

for(i=0;i<10;i++){
 scanf("%d",&A[i]);}

for(j=9;j>=1;j--){
for(i=0;i<j;i++){
 if(A[i]>A[i+1]){temp=A[i];A[i]=A[i+1];A[i+1]=temp;}}}

for(i=9;i>=7;i--){
printf("%d\n",A[i]);
}

return 0;
}

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

int main() {
  int n;
  cin >> n;
  std::vector<int> vec(n);
  std::vector<int>a(n);
  rep(i,n) {
    int x;
    cin >> x;
    vec.at(i) = x;
    a.at(i) = x;
  }
  sort(a.begin(), a.end());
  int cnt = 0;
  rep(i,n) {
    if (a.at(i) != vec.at(i)) cnt++;
  }
  if (cnt <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 3632
#include<cstdio>

int main() {
    int a,b,c;
    scanf ("%d %d %d",&a,&b,&c);
    int h,m;
    if (a < b)
   {h = a , m = b;}
    else 
    {h = b , m = a;}

    int p,q;
    if (m < c)
    {p = m,q = c;}
    else 
    {p = c , q = m;}

    int x,y;
    if (h < p)
    {x = h,y = p;}
    else 
    {x = p,y = h;}

    printf ("%d %d %d\n",x,y,q);
}


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

int main(){
  int claim[15][15];
  int N;
  cin >> N;

  rep(i,N){
    rep(j,N){
      claim[i][j] = -1;
    }
  }

  rep(i,N){
    int A;
    cin >> A;
    rep(j,A){
      int x,y;
      cin >> x >> y;
      --x;
      claim[i][x] = y;
    }
  }

  int ans = 0;

//2^n通りを全探索
  rep(i,1<<N){
    vector<int> d(N);
    rep(j,N){
    if (i>>j&1){//j番目にフラグが立っている（j番目の人が正直なら）
      d[j] = 1;//
    }
  }
    bool ok = true;
    //dとclaimで矛盾していないかどうかチェックする。（j番目の人の証言が矛盾していないかどうかチェック）
    rep(j,N){
      if (d[j]){
        rep(k,N){
          if (claim[j][k] == -1) {
          continue;
          }
          if (claim[j][k] != d[k]) {
          ok = false;
          }
        }
      }
    }
    if (ok) {
    ans = max(ans, __builtin_popcount(i));
  }
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    char str[12];
    while(cin>>str){
        for(int i=0;i<strlen(str);i++){
            if(i==3)cout<<"8";
            else cout<<str[i];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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 (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int counter(int x) {
	if (x == 0) return 0;
	return (x & 1) + counter(x >> 1);
}

void solve() {
		int n; cin >> n;
		vector<int> a(n + 1);
		vector<vector<int>> x(n + 1, vector<int>(n + 1));
		vector<vector<int>> y(n + 1, vector<int>(n + 1));
		for (int i = 1; i <= n; ++i) {
			cin >> a[i];
			for (int j = 1; j <= a[i]; ++j) {
				cin >> x[i][j] >> y[i][j];
			}
		}
		int ans = 0;
		for (int bits = 0; bits < (1 << n); ++bits) {
			bool ok = true;
			for (int i = 1; i <= n; ++i) {
				if (!(bits & (1 << (i - 1)))) continue;
				for (int j = 1; j <= a[i]; ++j) {
					if (((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]) ok = false;
				}
			}
			if (ok) ans = max(ans, counter(bits));
		}
		cout << ans << endl;
    return;
}

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



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int n;
	cin >> n;
	vi p(n);
	rep(i, n) cin >> p[i];
	sort(all(p));

	ll ans = 0;
	rep(i, n-1) {
		ans += p[i];
	}
	ans += p[p.size() - 1] / 2;

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	public static void main(String[] args) {
		int R=sc.nextInt();
		int G=sc.nextInt();
		int B=sc.nextInt();
		int N=sc.nextInt();
		
		int ans=0;
		
		for(int a=0;a*R<=N;a++) {
			
			
			
			for(int b=0;a*R+b*G<=N;b++) {
				
				
					int t=N-a*R-b*G;
					if(t%B==0) {
						ans++;
					}
				
				
				
			}
			
			
		}
		p(ans);
		
		
		
	}
	
	
	
	
	/*static boolean v(int i,long sum1,long sum2) {
		if(i==N) {
			long b=Math.abs(sum1-sum2);
			if(b==0) {
				if(sum1<=K) {
					return true;
				}else return false;
			}else if(b%D==0) {
				if(Math.max(sum1, sum2)<=K)return true;
				else return false;
			}
			else return false;
		}
		
		if(v(i+1,sum1,sum2+v[i]%D))return true;
		
		if(v(i+1,sum1+D-v[i]%D,sum2))return true;
		return false;
		
	}*/
	
	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 21844
N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))

A.sort()
a=0
count=0
total=0
for i in A:
    if i==a:
        count+=1
    else:
        if count%2==1:
            total+=1
        a=i
        count=1
if count%2==1:
    total+=1
print(total)


Measured memory_bytes: 7388
A,B,C = list(map(int,input().split()))
K = int(input())
out = "No"
while K > 0:
    if B<=A:
        B = B*2
    elif C<=B:
        C = C*2
    if C>B>A:
        out = "Yes"
    K = K-1

print(out)

Measured memory_bytes: 61628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+7;
int main(){
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]==a[1]&&a[1]!=a[2]) puts("Yes");
	else if(a[0]!=a[1]&&a[1]==a[2]) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define f first
#define s second
#define MAXN 201010

ll MOD = 1e9+7;
ll N,K;
string S;
ll dp[5010][5010];

ll E(ll a, ll K){
	if (K==0)return 1;
	ll h = E(a,K/2);
	h=(h*h)%MOD;
	if(K%2)h=(h*a)%MOD;
	return h;
}

ll inv(ll x){
	return E(x, 1e9+5);
}

int main(){
	cin>>N>>S;
	K=SZ(S);
	dp[1][0] = 1;
	dp[1][1] = 2;
	for (int i=1;i<=N;++i){
		for (int j=0;j<=N;++j){
			// cout<<i<<' '<<j<<' '<<dp[i][j]<<'\n';
			if (j == 0){
				dp[i+1][j] = (dp[i+1][j] + dp[i][j])%MOD;
				dp[i+1][j+1] = (2*dp[i][j] + dp[i+1][j+1])%MOD;
			}else{
				dp[i+1][j-1] = (dp[i+1][j-1] + dp[i][j])%MOD;
				dp[i+1][j+1] = (2*dp[i][j] + dp[i+1][j+1])%MOD;
			}
		}
	}
	cout<<dp[N][K]*inv(E(2,K))%MOD<<'\n';
}

Measured memory_bytes: 195968
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T> using G = greater<T>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), G<type>())
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n, PER) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(roop, n) a[idx][roop] = v[roop]; idx++;} while(next_permutation(ALL(v))); PER = a;} while(0); // int fact(), VVI PERを宣言しておく、n=10が限界(500 ms)
#define ENDL cout << endl;

const int INF = 2e9;
const LL MOD = 1e9 + 7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, G<T> >;
template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I "; else cout << A[i] << " ";}}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  LL x, y;
  cin >> x;
  y = 100;
  int ans = 0;
  while(y < x)
  {
    y *= 1.01;
    ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624
def solve(x, k, d):
    x = abs(x)
    n, m = divmod(x, d)

    if n >= k:
        return x - k * d

    if n % 2 == k % 2:
        return m

    return abs(m - d)


x, k, d = map(int, input().split())

print(solve(x, k, d))


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

#define ll             long long
#define LL             long long
#define pii            pair<int, int>
#define pll            pair<ll, ll>
#define pil            pair<int, ll>
#define pli            pair<ll, int>
#define vi             vector<int>
#define vl             vector<ll>
#define vii            vector<pii>
#define vll            vector<pll>
#define vil            vector<pil>
#define vli            vector<pli>
#define pb             push_back
#define ppb            pop_back
#define mp             make_pair
#define ff             first
#define ss             second
#define TN             typename
#define all(v)         v.begin(), v.end()
#define endl           '\n'

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> T lcm(T a, T b) {return a * (b / gcd(a, b));}
template <TN T> T sqr(T a) {return a * a;}
template <TN T> T cube(T a) {return a * a * a;}
template <TN T> inline void smin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void smax(T &a, T b) {a = a > b ? a : b;}
template <TN T> void fill(T a[], T n, T b) {for (int i = 0; i <= n; i++) a[i] = b;}

int in() {int n; scanf("%d", &n); return n;}
ll Lin() {ll n; scanf("%lld", &n); return n;}
double Din() {double n; scanf("%lf", &n); return n;}

const ll inf = (ll)1e17;
const ll mod = (ll)1e9 + 7;
const int N = 2e5 + 5;



int solve() {
	string s;
	cin >> s;
	int n = (int)s.size();
	int res = 0, res2 = 0;
	for (int i = 1; i <= n; i++) {
		if (i & 1) {
			if (s[i - 1] == '0') res++;
			else res2++;
		}
		else {
			if (s[i - 1] == '1') res++;
			else res2++;
		}
	}
	cout << min(res, res2) << endl;
	return 0;
}

int main() {
	int test = 1, tc = 0;
	//scanf("%d", &test);
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
	return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> W(N);
    for(int i = 0; i < N; i++) {
        cin >> W.at(i);
    }

    int Wmin = 100000;

    for(int i = 0; i < N; i++) {
        int Sum1 = 0; int Sum2 = 0; int Sub = 0;
        if(i == 0) {
            Sum1 = W.at(0);
            for(int j = i+1; j < N; j++) {
                Sum2 += W.at(j);
            }
        }else if(i == N-1) {
            for(int j = 0; j < N-1; j++) {
                Sum1 += W.at(j);
            }
            Sum2 = W.at(N-1);
        }else {
            for(int j = 0; j <= i; j++) {
                Sum1 += W.at(j);
            }
            for(int j = i+1; j < N; j++) {
                Sum2 += W.at(j);
            }
        }
        Sub = abs(Sum1 - Sum2);
        if(Wmin > Sub) {
            Wmin = Sub;
        }
    }
    cout << Wmin << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cassert>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>
#include <memory.h>

using namespace std;

#define all(c) begin(c), end(c)
#define dump(c) cerr << "> " << #c << " = " << (c) << endl
#define REP(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1001001001;
const double EPS = 1e-10;


template<typename T1,typename T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){
  return os << '(' << p.first <<',' << p.second << ')';
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& a){
  os << '[';
  rep(i,a.size()) os << (i ? " " : "") << a[i];
  return os << ']';
}

int cnt[10010], st[10010], acc[10010][1300];

int main() {
  for(int N, M; cin >> N >> M, (N | M) != 0; ) {
    memset(cnt, 0, sizeof(cnt));
    memset(st, 0, sizeof(st));
    memset(acc, 0, sizeof(acc));
    int r; cin >> r;
    rep(i, r) {
      int t, n, m, s; cin >> t >> n >> m >> s;
      if (s) {
        if(cnt[m] == 0) st[m] = t;
        cnt[m]++;
      }
      else {
        cnt[m]--;
        if(cnt[m] == 0) {
          REP(j, st[m], t) acc[m][j] = 1;
        }
      }
    }

    int q; cin >> q;
    rep(i, q) {
      int s, e, m; cin >> s >> e >> m;
      int cnt = 0;
      REP(i, s, e) cnt += acc[m][i];
      cout << cnt << endl;
    }
  }
  
  
  return 0;
}

Measured memory_bytes: 52076
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

constexpr ll mod = 1000000007;
constexpr ll modsize = 0;
vector<ll> fac(modsize);
vector<ll> inv(modsize);
vector<ll> facinv(modsize);

void modcalc() {
	if (modsize == 0) abort();
	fac[0] = 1; fac[1] = 1; inv[1] = 1;
	facinv[0] = 1; facinv[1] = 1;
	for (ll i = 2; i < modsize; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		facinv[i] = facinv[i - 1] * inv[i] % mod;
	}
}

ll modinv(ll a) {
	if (a == 0) abort();
	ll b = mod, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}

ll modpow(ll a, ll b) {
	ll ans = 1;
	a %= mod;
	while (b) {
		if (b & 1) ans = ans * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return ans;
}

ll modcomb(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[k] % mod * facinv[n - k] % mod;
}

ll modperm(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[n - k] % mod;
}

ll modhom(ll n, ll k) {
	if (n < 0 || k < 0 || n == 0 && k > 0) return 0;
	if (n == 0 && k == 0) return 1;
	return fac[n + k - 1] * facinv[k] % mod * facinv[n - 1] % mod;
}

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

	int n;
	cin >> n;
	map<P, ll> mp;
	int z = 0;
	rep(_, n) {
		ll x, y;
		cin >> x >> y;
		ll g = gcd(abs(x), abs(y));
		if (g) { x /= g; y /= g; }
		if (x < 0) {
			x *= -1; y *= -1;
		}
		if (x == 0 && y == 0) z++;
		else if (x == 0) mp[P(0, -1)]++;
		else if (y == 0) mp[P(1, 0)]++;
		else mp[P(x, y)]++;
	}
	ll ans = 1;
	for (auto i : mp) {
		if (i.second == 0) continue;
		ll x = i.first.first; ll y = i.first.second;
		if (x == 0 && y == 0) continue;
		//cerr << x << ' ' << y << '\n';
		if (y < 0 && mp[P(-y, x)]) continue;
		ll cnt = modpow(2, i.second) + modpow(2, mp[P(y, -x)]) - 1;
		cnt %= mod;
		//cerr << cnt << '\n';
		ans *= cnt;
		ans %= mod;
	}
	cout << (ans + z + mod - 1) % mod << '\n';
}

Measured memory_bytes: 34804
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

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

for h in range(H):
    l = ""
    for w in range(W):
        if S[h][w] == '#':
            l += '#'
            continue
        num = 0
        for d in range(8):
            nx = h + dx[d]
            ny = w + dy[d]
            if nx < 0 or ny < 0 or nx >= H or ny >= W: continue
            if S[nx][ny] == '#' : num+=1
        l+=str(num)
    S[h] = l


for i in range(H):
    print(S[i])


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;
typedef pair<string,vector<pair<int,int> > > psv;


int main(){
    int N;cin >> N;
    map<string,vector<pair<int,int> > > ma;
    rep(i,N){
        string s;int P;
        cin >> s >> P;
        ma[s].push_back(make_pair(P,i+1));
    } 

    for(auto x:ma){
        sort(All(x.second));
        reverse(All(x.second));
        for(auto y:x.second){
            cout << y.second << endl;
        }   
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
char PS(char a) {
 if(a=='Z') {
return 'A';
 }
  else {
    return a+0X01;
  }
}

const ll dx[4]={0,-1,0,1};
int main() {
  int N;
  string S;
  cin >>N>>S;
  int x=S.size();
 rep(i,x) {
rep(k,N) {
  S.at(i)=PS(S.at(i));
}
 }  
  cout <<S<< endl;
 }
  
  

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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<1000000007>;

//--------------------------- Solve ---------------------------//

void solve() {
    int n; cin >> n;
    mint ans = 0;
    ans += modpow((mint)10, n) - modpow((mint)9, n)*2 + modpow((mint)8, n);
    cout << ans << '\n';
}

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

    solve();

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) { cin >> h[i]; }
  sort(h.begin(), h.end());
  int ans = INT_MAX;
  rep(i, n - k + 1) { ans = min(ans, h[i + k - 1] - h[i]); }
  cout << ans;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;

int main() {
   

    long long N;
    long long h,n,w;
    cin >> N;
    for (int i=1;i<=3500;i++){
        for (int j=1;j<=3500;j++){
            if((4*i*j - N*j - N*i) != 0) {
                if ((N * i * j) % (4 * i * j - N * j - N * i) == 0 and (4 * i * j - N * j - N * i) > 0) {
                    n = (N * i * j) / (4 * i * j - N * j - N * i);
                    cout << i << " " << n << " " << j << endl;
                    goto Exit;
                }
            }
        }
    }
    Exit:
    ;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  ll n;
  cin >> n;
  n--;
  cout << n * (n + 1) / 2 << endl;
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <stddef.h>
#include <stack>
#include <queue>

using namespace std;

int main() {
	int x, y;
	while (1) {
		cin >> x >> y;
		if (x == 0 && y == 0) break;
		if (x < y) cout << x << ' ' << y << endl;
		else cout << y << ' ' << x << endl;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<ll>())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 11711711

int main()
{
    int n,x,y;
    cin >> n >> x >> y;
    vector<int> dist(n);
    rep(i,n){
        dist[i]=0;
    }
    int dist_val;
    FOR(i,n+1,1){
        FOR(j,n+1,1){
            dist_val=min(abs(j-i),abs(j-x)+1+abs(i-y));
            dist_val=min(dist_val,abs(i-x)+1+abs(j-y));
            dist[dist_val]++;
        }
    }
    rep(i,n){
        dist[i]/=2;
    }
    FOR(i,n,1){
        cout << dist[i] << endl;
    }
}

Measured memory_bytes: 3636
#include<iostream>

using namespace std;

int main(){
  int i;
  cin>>i;
  
  if(i<105)
    cout<<"0"<<endl;
  else if(i<135)
    cout<<"1"<<endl;
  else if(i<165)
    cout<<"2"<<endl;
  else if(i<189)
    cout<<"3"<<endl;
  else if(i<195)
    cout<<"4"<<endl;
  else
    cout<<"5"<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int main(){
	long i, n; long m = 1000000; long l = -1000000; long s = 0;
	scanf("%ld", &i);
	while(i--){
		scanf("%ld", &n);
		if(m > n) m = n;
		if(l < n) l = n;
		s += n;
	}
	printf("%ld %ld %ld\n", m, l, s);
	return 0;
}


Measured memory_bytes: 2748
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);
	
	std::set<int> X, Y, Z;
	int x; scanf("%d", &x);
	for(int i = 0; i < x; i++) {
		int p; scanf("%d", &p);
		X.insert(p);
	}
	scanf("%d", &x);
	for(int i = 0; i < x; i++) {
		int p; scanf("%d", &p);
		Y.insert(p);
	}
	scanf("%d", &x);
	for(int i = 0; i < x; i++) {
		int p; scanf("%d", &p);
		Z.insert(p);
	}
	
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		if((!X.count(i) and Z.count(i)) or (Y.count(i) and Z.count(i))) ans++;
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> a(m);
    int k;
    int b;
    int cnt = 0;
    for(int i = 0;i<m;i++){
        cin >> k;
        for(int j = 0;j<k;j++){
            cin >> b;
            a.at(i).push_back(b);
        }
    }
    vector<int> s(m);
    vector<bool> on(m,false);
    for(int i = 0;i<m;i++){
        cin >> s.at(i);
    }
    int ans = 0;
    bool ikeru = true;
    for(int i = 0; i<(1<<n);i++){
        for(int j = 0; j < m;j++){
            cnt = 0;
            for(int l:a.at(j)){
                if((i>>(n-l))&1) cnt++;
            }
            
            if(s.at(j)%2 == cnt%2) on.at(j) = true;

        }
        
        for(bool g:on){
            ikeru = ikeru && g;
        }
        if(ikeru) ans++;
        for(int i = 0;i<m;i++){
            on.at(i) = false;
        }
        ikeru = true;
    }
    cout << ans << endl;
}

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

int main()
{
	int H, N;	
	cin >> H >> N;
  
	vector<int> vec(N);
	for (int i = 0; i < N; i++) {
		cin >> vec.at(i);
	}
	for (int j = 0; j < N; j++) {
		H -= vec.at(j);
	}
	if (H > 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

typedef struct{
  char name[10];
  int time;
}Process;

void enqueue(Process , int);
Process dequeue();

Process p[100000];
int Q_tail=0;
int Q_head=0;
int length=0;
int count=0;
int n=0;

int main(){ 
  int calc_time=0;
  int sum_time=0;
  int q=0;
  int i=0;
  Process rp;
  scanf("%d%d",&n,&q);

  for(i=0;i<n;i++)
    {
      scanf("%s%d",p[i].name,&p[i].time);
    }
  while(count<n){
    for(i=0;i<n;i++){
      if(count==n)break;
      rp=dequeue();
      if(rp.time>q){
	sum_time+=q;
	enqueue(rp,rp.time-q);
      }
      else{
	sum_time+=rp.time;
	printf("%s %d\n",p[i].name,sum_time);
	count++;
      }
    }
  }
  
  return 0;
}

Process dequeue(){
  Process x;
  x=p[Q_head];
  if(Q_head+1==n)
    Q_head=0;
  else Q_head++;
  return x;
}

void enqueue(Process Q, int t){
  p[Q_tail].time=t;
  strcpy(p[Q_tail].name,Q.name);
  if(Q_tail + 1 == n)
    Q_tail=0;
  else Q_tail++;
}



Measured memory_bytes: 2572
n=int(input())
l=[]
for i in range(n):
    l.append(int(input()))
l.sort()
res=0
l1=l[:len(l)//2]
l2=l[len(l)//2:]
if len(l)%2==0:
    print(sum(l2)*2-l2[0]-sum(l1)*2+l1[-1])
else:
    res=sum(l2)*2-l2[0]-l2[1]-sum(l1)*2
    l1=l[:len(l)//2+1]
    l2=l[len(l)//2+1:]
    res=max(res,sum(l2)*2-sum(l1)*2+l1[-1]+l1[-2])
    print(res)


Measured memory_bytes: 53464
#include <iostream>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int len=s.length();
	int sum=0;
    for(int i=0;i<len;i++)sum+=s[i]-'0';
    if(sum%9==0)
    {
        cout<<"Yes"<<'\n';
    }
    else
    {
        cout<<"No"<<'\n';
    }
	return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;

int main() {
    ll N,Min=3*10000000000;
    cin>>N;
    vel a(N),s(N+1);
    rep0(i,N){cin>>a[i];}
    s[0]=0;
    rep0(i,N){s[i+1]=s[i]+a[i];}
    for(ll i=1;i<=N-1;i++){Min=min(Min,abs(s[i]-(s[N]-s[i])));}
    cout<<Min<<endl;
}


Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  int sum=0;
  int A;
  for(int i=0;i<M;i++){
    cin>>A;
    sum+=A;
  }
  if(sum>N) cout<<-1<<endl;
  else cout<<N-sum<<endl;
  return 0;
}

Measured memory_bytes: 3588
#include<stdio.h>
bool table[10001];
int now[10001];
int count[10001];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<=10000;i++){
			table[i]=false;
			now[i]=0;
			count[i]=0;
		}
		int index=0;
		for(int i=1;i<a;i++){
			int val=i*i%a;
			if(!table[val]){
				table[val]=true;
				now[index++]=val;
			}
		}
		for(int i=0;i<index;i++){
			for(int j=i+1;j<index;j++){
				int t=now[i]-now[j];
				if(t<0)t+=a;
				if(t>(a-1)/2)t=a-t;
				count[t]++;
			}
		}
		for(int i=1;i<=a/2;i++)printf("%d\n",count[i]*2);
	}
}

Measured memory_bytes: 844
#include <bits/stdc++.h>
#define N 1000000000
using namespace std;
bool f[N+5];
int i,n;
int main()
{
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d",&i);
		if(f[i]==1)
		{
			printf("NO");
			return 0;
		}
		else f[i]=1;
	}
	printf("YES");
	return 0;
} 

Measured memory_bytes: 975360
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
char a[1001][1001];
int wi[8]={1,1,0,-1,-1,-1,0,1};
int wj[8]={0,-1,-1,-1,0,1,1,1},n=0,m=0;
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(a[i][j]=='#')
            {
                cout<<'#';
            }
            else
            {
                int num=0;
                for(int m=0;m<8;m++)
                {
                    if(a[i][j]!='.')
                    {
                        continue;
                    }
                    if(a[i+wi[m]][j+wj[m]]=='#')
                    {
                        num++;
                    }
                }
                cout<<num;
            }
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
include Math

def manhattan(x, y)
    dist = 0
    x.zip(y) do |xi, yi|
        dist += (xi  - yi).abs
    end
    return dist
end

def euclid(x, y)
    dist = 0
    x.zip(y) do |xi, yi|
        dist += (xi - yi) ** 2
    end
    return sqrt(dist)
end

def p3(x, y)
    dist = 0
    x.zip(y) do |xi, yi|
        dist += (xi - yi).abs ** 3
    end
    return cbrt(dist)
end

def chebyshev(x, y)
    dist = -1
    x.zip(y) do |xi, yi|
        dist = [dist, (xi - yi).abs].max
    end
    return dist
end

dim = gets.chomp.to_i

x = gets.chomp.split.map(&:to_i)
y = gets.chomp.split.map(&:to_i)

puts manhattan(x, y)
puts euclid(x, y)
puts p3(x, y)
puts chebyshev(x, y)

Measured memory_bytes: 6168
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int a, b; cin >> a >> b;
    int sum = 0;
    for (int i = 1; i < b - a; ++i) sum += i;
    cout << (sum - a) << endl;
}


Measured memory_bytes: 256
n,m,k = map(int,input().split())
mod = 998244353

fact = [1,1]
finv = [1,1]
inv = [0,1]

for i in range(2,n+5):
    fact.append((fact[-1]*i)%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)

def nCr(n,r,mod):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[r]*finv[n-r]%mod

x = m%mod

a = pow(m-1,n-1,mod)
x = (a*x)%mod

ans = x%mod
for i in range(1,k+1):
    x = m*pow(m-1,n-1-i,mod)
    a = nCr(n-1,i,mod)
    ans += (a*x)%mod
    ans %= mod
print(ans)


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

int main ()
{
    int n, Taro = 0, Hanako = 0;
    cin >> n;
    while(n--)
    {
        string t, h;
        cin >> t >> h;
        for (int i = 0;i < t.size() || i < h.size();i++)
        {
            if (t[i] > h[i] || h[i] == '\0')
            {
                 Taro += 3;
                 break;
            }
            else if (t[i] < h[i] || t[i] == '\0')
            {
                 Hanako += 3;
                 break;
            }
            else if (t == h)
            {
                Taro++;
                Hanako++;
                break;
            }
        }
    }
    cout << Taro << " " << Hanako << endl;
    
    return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int k,t;cin>>k>>t;
	vector<int> a(t);
	for(int i = 0; i < t; i++) {
		cin>>a[i];
	}
	sort(ALL(a),greater<int>());
	if (a[0] <= (k +1) / 2){
		cout << 0 << endl;
	}
	else{
		cout << a[0] - 1 - (k - a[0]) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back 
#define mp make_pair
#define sp ": "
#define cs "Case "
#define fi first
#define sn second 
#define po(x) x*x
/* STL */
#define vi vector<int>v
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxa(a) *max_element(a, a.size())
#define r(a) reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n)i=1;i<=(n);i++)
#define fa(i,a,n) for(__typeof(a)i=(a);i<=(b);i++)
/*Special*/
#define Ezio ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define db(something)   cerr<<#something<<" - "<<something<<"\n";         
int main()
{
  
   Ezio
   /*Variables*/
   /*Code*/
   int a;
   cin>>a;
   cout<<360/(__gcd(a,360))<<endl;
   return 0;
}
    

Measured memory_bytes: 3532
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		int res = 0;
		if (c[0] =='1') res++;
		if (c[1] =='1') res++;
		if (c[2] =='1') res++;
		System.out.println(res);
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
bool a[500][500] = {};
char c[500][500];
bool search(int x,int w,int h,int y) {
	if (x < 0 || x >= w || y < 0 || y >= h) {
		return false;

	}
	else if (c[y][x] == '#') {
		return false;
	}
	if (a[y][x] == true) {
		return false;
	}
	if (c[y][x] == 'g') {
		return true;
	}
	a[y][x] = true;
	if (search(x + 1, w, h, y) || search(x - 1, w, h, y) || search(x, w, h, y + 1) || search(x, w, h, y - 1)) {
		return true;
	}
	else {
		return false;
	}

}

//小文字=大文字+32
int main() {
	ll x,k,d;
	cin >> x>>k>>d;
	ll ans;
	if (x < 0) {
		x = -x;
	}
	if (x/d >=k ) {
		ans = x - d * k;

	}
	else {
		
		
		if ((k-(x/ d)) % 2 == 0) {
			ans = x % d;
			

		}
		else {
			ans = -(x%d - d);
			
		}
	}
	cout << ans;

}
	



Measured memory_bytes: 3556