akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair

int main(){
	fast;
	int test=1;
	//cin >> test;
	while(test--){
	    int n,W;
	    cin >> n >> W;
	    int v[n+1],w[n+1];
	    for(int i=1 ; i<=n ; i++){
	        cin >> w[i] >> v[i];
	    }
	    ll dp[W+1][n+1]={};
	    ll maxm=-1;
	    dp[0][0]=0;
	    for(int k = 1; k <= n; k++){
	        for (int x = 0; x<=W; x++){
	            if(x>=w[k]){
	                dp[x][k]=max(v[k]+dp[x-w[k]][k-1],dp[x][k-1]);
	            }else{
	                dp[x][k]=dp[x][k-1];
	            }
	        }
	    }
	    for(int i=0 ; i<=W ; i++){
	        maxm=max(dp[i][n],maxm);
	    }
	    cout << maxm;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)

int main(){
	int r, d, x[12] = {};
	cin >> r >> d >> x[0];
	repp(i, 10) {
		x[i] = x[i-1] * r - d;
		cout << x[i] << endl;
	}

	return 0;
}


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

#define sz(x) (int)x.size()
#define ld long double
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

int h1, m1, h2, m2, k;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int tt = h2 * 60 + m2 - m1 - h1 * 60;
    cout << tt - k;
    return 0;
}

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

int A, B, C;
int K;
int sum;

int main() {
	ios::sync_with_stdio(false);
	cin >> A >> B >> C >> K;
	while(A--) {
		K--;
		sum += 1;
		if(!K) {
			cout << sum;
			return 0;
		}
	}
	while(B--) {
		K--;
		if(!K) {
			cout << sum;
			return 0;
		}
	}
	while(C--) {
		K--;
		sum -= 1;
		if(!K) {
			cout << sum;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3640
def keyence20_c():
    N, K, S = map(int, input().split())
    if S < 10**9:
        arr = [S] * K + [S+1] * (N-K)
    else:
        arr = [S] * K + [1] * (N-K)
    ans = ' '.join(map(str, arr))
    print(ans)

keyence20_c()

Measured memory_bytes: 12668
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	char a[101], b[101];
	scanf("%s", a);
	getchar();
	scanf("%s", b);
	getchar();
	char min;
	for(int i = 0; a[i] != '\0'; i++)
	{
		min = a[i];
		for(int j = i + 1; a[j] != '\0'; j++)
		{
			if(a[j] < min)
			{
				min = a[j];
				a[j] = a[i];
				a[i] = min;
			}
		}
	}
	char max;
	for(int k = 0; b[k] != '\0'; k++)
	{
		max = b[k];
		for(int l = k + 1; b[l] != '\0'; l++)
		{
			if(b[l] > max)
			{
				max = b[l];
				b[l] = b[k];
				b[k] = max;
			}
		}
	}
	if(strcmp(a, b) < 0)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
}

Measured memory_bytes: 128
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
s=["KIH","B","R",""]
n=[]
for i in range(1<<5):
 c=""
 for j in range(4):
  if (i>>j)&1==1:
     c+="A"
  c+=s[j]
 n.append(c)
ss=input()
if ss in n:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 38324
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

typedef long double lld;

#define REP(i,n) for(int i=0;i<n;i++)
#define EPS (1e-7)
#define INF (1e9 + 1)
#define PI (acos(-1))
ll MOD = 1000000007;

ll N, M;
ll a[100010];
ll dp[100010] = {};
bool broken[100010] = {};

int main()
{
	cin >> N >> M;
	REP(i, M) {
		cin >> a[i];
		broken[a[i]] = true;
	}

	//dp[N]を用意する
	dp[0] = 1;
	if (broken[1] == false) dp[1] = 1;
	else dp[1] = 0;

	for (ll i = 2; i <= N; i++) {
		if (broken[i] == true) continue;
		if (broken[i - 1] == false) {
			dp[i] += dp[i - 1];
			dp[i] %= MOD;
		}
		if (broken[i - 2] == false) {
			dp[i] += dp[i - 2];
			dp[i] %= MOD;
		}
	}
	cout << dp[N] << endl;
}

Measured memory_bytes: 1536
#include <stdio.h>
int main()
{
    int a=0,b=0,c=0;
    scanf("%d %d %d",&a,&b,&c);
    if((c>b&&c>a)&&(b>a))
     printf("Yes\n");
     else
     printf("No\n");
     return 0;
}


Measured memory_bytes: 2060
#include<iostream>
#include<algorithm>
#define all(c) c.begin(),c.end()
#include<string>
using namespace std;
int main(){
	string s;
	while(getline(cin,s)){
		int cnt=0;
		s.erase(remove(all(s),' '),s.end());
		for(int i=0;i<s.size()/2;i++){
			if(s[i]=='w'||s[i]=='i'||s[i]==' '){
				if(s[i]!=s[s.size()-i-1]){
					cnt++;
					s[s.size()-i-1]=s[i];
				}
			}else{
				if(s[i]=='('){
					if(s[s.size()-i-1]!=')'){
						cnt++;
						s[s.size()-i-1]=')';
					}
				}else{
					if(s[s.size()-i-1]!='('){
						cnt++;
						s[s.size()-i-1]='(';
					}
				}
			}
		}
		if(s.size()%2==1){
			if(s[s.size()/2]=='('||s[s.size()/2]==')'){
				cnt++;
			}
		}
		//cout<<s<<endl;
		cout<<cnt<<endl;
	}
	return 0;
}

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

int main(){
	int n; cin>> n;
	int p[n];
	int prev = 1e9;
	int  ans = 0;
	int flag  = 1;
	for(auto & x : p){
		cin>> x;
		if(x <= prev){
			ans++;
			prev = min(prev, x);
		}
	}
	cout << ans;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

#define MAX_ROW    (100)
#define MAX_COLUMN (100)

using namespace std;

int main()
{
    int c, r;

    do {
        cin >> r >> c;        
    } while ((r < 1 || r > MAX_ROW) || (c < 1 || c > MAX_COLUMN));

    int** table = new int*[r + 1];
       
    for (int i = 0; i < r + 1; i++) {
         table[i] = new int[c + 1];         
    }

    for (int i = 0; i < r + 1; i++) {
         for (int j = 0; j < c + 1; j++) {
	      table[i][j] = 0;
         }
    }

    for (int i = 0; i < r; i++) {          
         for (int j = 0; j < c; j++) {
	      do {
                  cin >> table[i][j];	          
              } while (table[i][j] < 0 || table[i][j] > 100);

              table[r][j] += table[i][j];
              table[i][c] += table[i][j]; 
         }

         table[r][c] += table[i][c];
    }

    for (int i = 0; i < r + 1; i++) {
         for (int j = 0; j < c; j++) {
	      cout << table[i][j] << " ";
         }

         cout << table[i][c] << endl;     
    }

    for (int i = 0; i < r + 1; i++) {
         delete[] table[i];
    }

    delete[] table;
              
    return (0);
}

Measured memory_bytes: 1236
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}
# sumの追加
class Array
  define_method(:sum){self.inject(:+)} unless method_defined?(:sum)
end

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N = gets_i
a_list = gets_i_list
b_list = gets_i_list

negative_diffs = []
positive_diffs = []

0.upto(N-1) do |i|
  if a_list[i] < b_list[i]
    negative_diffs.push(b_list[i] - a_list[i])
  else a_list[i] > b_list[i]
    positive_diffs.push(a_list[i] - b_list[i])
  end
end

diff_total = negative_diffs.sum.to_i

dpp diff_total

if diff_total == 0
  puts "0"
  exit
else
  count = 0
  positive_diffs.sort!
  positive_diffs.reverse_each do |d|
    diff_total -= d
    count += 1
    break if diff_total <= 0
  end

  if diff_total <= 0
    puts count + negative_diffs.size
  else
    puts -1
  end
end

Measured memory_bytes: 19608
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		scan.useDelimiter("[^0-9.]+");
		
		int n = scan.nextInt();

		for(int i=0;i<n;i++){
			double xa = scan.nextDouble();
			double ya = scan.nextDouble();
			double ra = scan.nextDouble();
			double xb = scan.nextDouble();
			double yb = scan.nextDouble();
			double rb = scan.nextDouble();
			
			double d = Math.sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
			
			if(ra+rb<d){
				System.out.println(0);
			}else if(ra>d+rb){
				System.out.println(2);
			}else if(rb>d+ra){
				System.out.println(-2);
			}else
			{
				System.out.println(1);
			}
		}
		
		scan.close();
	}
}

Measured memory_bytes: 28132
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<unsigned char, unsigned char> pcc;
typedef pair<double, double> pdd;
typedef vector<vector<ll>> matrix;

// if x is a value and you have k, the next number is (kx)/(k-1) + 1

ll getNimber(ll n, ll k) {
  while(n%k && n > k) {
    // cout << n << " " << k << " " << n/k << endl;
    // want mid * k / (k-1) + 1 == n
    // want mid * k == (n-1) * (k-1)
    ll mid = (n-1) * (k-1) / k;
    if((mid * k) / (k-1) + 1 != n) mid++;
    ll decrement = n - mid;
    for(ll dec = 1 << 30; dec > 0; dec /= 2) {
      ll candNext = n - dec * decrement;
      if(candNext / k == n / k || (dec == 1 && n%k != 0)) {
        n = candNext;
      }
    }
  }
  return n/k;
}

void solve() {
  int n;
  cin >> n;
  ll curr = 0;
  while(n--) {
    ll a, k;
    cin >> a >> k;
    curr ^= getNimber(a, k);
  }
  if(curr) cout << "Takahashi\n";
  else cout << "Aoki\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ":" << "\n";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 384
#include <stdio.h>
int main(){
    int x,y,m;
    scanf("%x%x",&x,&y);

    if(x<y){
        printf("<\n");
    }
    else if(x>y) {
        printf(">\n");
    }else if(x==y){
        printf("=\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstring>

bool a(const std::string& S,size_t P){  
  if(P == S.size()){
  	return true;
  }
  for(auto s: {"dream","dreamer","erase","eraser"}){
    auto l = strlen(s);
    if(l + P > S.size()){
    	continue;
    }
  	if(std::equal(s,s+l,S.begin() + P) && a(S,P + l)){
      return true;
    }
  }
  return false;
}

int main(){
  std::string S;
  std::cin >> S;
  
  std::string T;

  if(a(S,0)){
  	std::cout << "YES";
  }else{
  	std::cout << "NO";   
  }
}

Measured memory_bytes: 1792
using System;
using System.Linq;

namespace ITP1_7_B
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] input = Console.ReadLine().Split(' ');
                int n = int.Parse(input[0]);
                int x = int.Parse(input[1]);
                if (n == 0)
                    break;
                Console.WriteLine(CountCombi(n, x));
            }
        }

        static int CountCombi(int n,int x)
        {
            int ret = 0;
            for(int i = 1; i < n - 1; i++)
            {
                for(int j = i + 1; j < n; j++)
                {
                    int temp = x - (i + j);
                    if (j < temp && temp <= n)
                        ret++;
                }
            }
            return ret;
        }
    }
}

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

int main()
{
	int ary[45];
	ary[0] = 1;
	ary[1] = 1;
	for (int i = 2; i < 45; i++)
	{
		ary[i] = ary[i - 1] + ary[i - 2];
	}

	int n;
	cin >> n;
	cout << ary[n] << endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define FORR(i, a, b)  for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b)  for (int i = (b); i >= (a); --i)
#define REPP(i, a, b)  for (int i = (a); i < (b); ++i)
#define REPD(i, a, b)  for (int i = (b); i > (a); --i)
#define fi             first
#define se             second
#define mp             make_pair
#define pb             push_back
#define pf             push_front
#define cmin(a, b)     if ((a) > (b)) (a) = (b)
#define cmax(a, b)     if ((a) < (b)) (a) = (b)
#define BIT(x, i)      (((x) >> (i)) & 1)
#define MASK(i)        (1LL << (i))
#define debug(x)       cout << (x) << "\n"
#define endl           "\n"
#define ii             pair <int, int>
#define ll             long long
#define reset(x)       memset(x, 0, sizeof(x))
#define mem(a, x)      memset(x, (a), sizeof(x))
#define task           ""
#define IO             freopen (task".inp","r",stdin),freopen (task".out","w",stdout);

using namespace std;

const int mod = 1007050321;
const int base = 521;
const int MOD = 1e9 + 7;
const int inf = 2e9;
const int N = 1e5 + 5;

int main() {
    ios_base :: sync_with_stdio(0),cin.tie(0),cout.tie(0);

    int x, d[6];
    for (int i = 1; i <= 5; ++i) d[i] = 0;
    for (int i = 0; i < 5; ++i) {
        cin >> x;
        d[x] = 1;
    }
    for (int i = 1; i <= 5; ++i)
        if (!d[i]) cout << i;

    return 0;
}


Measured memory_bytes: 3632
n = int(input())
p = list(map(int, input().split(" ")))
a = 0
for i in range(n - 2):
    p1 = p[i]
    p2 = p[i+1]
    p3 = p[i+2]
    l = [p1, p2, p3]
    l.sort()
    if l[1] == p2:
        a += 1
print(a)

Measured memory_bytes: 3060
use std::io::*;
use std::str::*;

fn read_from_stdin<T: FromStr>() -> T {
    let temp = stdin();
    let mut temp = temp.lock();
    read(&mut temp).unwrap()
}

fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s.by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let n: usize = read_from_stdin();
    let mut array = Vec::new();
    for i in 1..n + 1 {
        let a: i64 = read_from_stdin();
        array.push(a - i as i64);
    }
    array.sort();

    if n % 2 != 0 {
        let b = array[n / 2];
        let res: i64 = array.iter().map(|x| (x - b).abs()).sum::<i64>();
        println!("{}", res);
    } else {
        let (b_pre, b_suc) = (array[n / 2 - 1], array[n / 2]);
        let res_pre: i64 = array.iter().map(|x| (x - b_pre).abs()).sum::<i64>();
        let res_suc: i64 = array.iter().map(|x| (x - b_suc).abs()).sum::<i64>();
        println!("{}", std::cmp::min(res_pre, res_suc));
    }
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll INF=999999999999999;
ll cost[501][10002];
int main(){
    ll m,n,a,b,ans=0,now=0,sum=0;
    vector<ll> p;
    vector<ll> c;
    vector<ll> e;
    cin>>m>>n;

    for(int i=0;i<m;i++){
        cin>>a;
        p.push_back(a);
    }

    for(int i=0;i<n;i++){
        cin>>a>>b;
        c.push_back(a);
        e.push_back(b);
    }

    sort(p.rbegin(),p.rend());

    for(int j=0;j<n+1;j++){
    for(int i=0;i<10002;i++){
        cost[j][i]=INF;
    }
    }
      cost[0][0]=0;
    for(int i=1;i<n+1;i++){
        for(int j=0;j<c[i-1];j++){
            cost[i][j]=cost[i-1][j];
        }
        for(int j=c[i-1];j<10001;j++){
            cost[i][j]=min(cost[i-1][j],cost[i-1][j-c[i-1]]+e[i-1]);
        }
        for(int j=10001-c[i-1];j<10002;j++){
        cost[i][10001]=min(min(cost[i-1][10001],cost[i-1][j]+e[i-1]),cost[i][10001]);
            
    }
    }
  



    for(int i=10001;i>0;i--){
        cost[n][i-1]=min(cost[n][i],cost[n][i-1]);
    }
  
    for(int i=0;i<m+1;i++){
        now=sum-cost[n][i];
        if(now>ans)ans=now;
      if(i!=m)sum+=p[i];
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 42436
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using lint = long long;
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  map<string,int> memo;
  string buf;cin>>buf;
  memo[buf]+=1;
  char last=buf[buf.size()-1];
  bool flag=true;
  rep(i,n-1){
      cin>>buf;
      if(last!=buf[0]||memo[buf]>0){
          flag=false;
      }
      last=buf[buf.size()-1];
      memo[buf]+=1;
  }
  	if(flag){
          cout<<"Yes"<<endl;
      }
      else{
          cout<<"No"<<endl;
      }
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
#define all(v) v.begin(),v.end()
using namespace std;

int gcd(int x,int y){
	return y?gcd(y,x%y):x;
}
int main(){
	int x;
	cin>>x;
	cout<<(360/gcd(360,x));
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int r,g;
  cin>>r>>g;
  cout<<g*2-r<<endl;

  return 0;
}




Measured memory_bytes: 256
/*

*/
#include<bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  cout<<min(a,k)-max(k-a-b,0)<<endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;




int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int x, a;
    cin >> x >> a;
    cout << (x < a ? 0 : 10);
}



Measured memory_bytes: 256
import itertools
N,M=map(int,input().split())
ki=[[]for i in range(N)]
for i in range(M):
 a,b=map(int,input().split())
 ki[a-1].append(b-1)
 ki[b-1].append(a-1)
ans=0
for v in itertools.permutations(range(1,N), N-1):
 path=0
 if v[0] in ki[0]:
  path+=1
 if N>2:
  for i in range(N-2):
   if v[i+1] in ki[v[i]]:
    path+=1
 if path==N-1:
  ans+=1
print(ans)

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

using namespace std;

int main()
{
  int n,k;
  scanf("%d%d",&n,&k);
  int d[k];
  int i,j,o,flag=0;
  for(i=0;i<k;++i)
       scanf("%d",&d[i]);
  
  for(i=n;;++i)
  { flag=0;
     o=i;
    while(o!=0)
    {
       for(j=0;j<k;++j)
       {
         if(d[j]==(o%10))
         {  flag=1;
           break;
         }
       }
      
      if(flag==1)
          break;
      
      o/=10;
    }
   
   if(flag==0)
        break;
  }
  
  printf("%d",i);
     
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include<string>
#include <set>
#include <map>
#include <queue>
#include <limits.h>
#include <bitset>
#include <cmath>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < ( int )( n ); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> da(n);
    rip(i,n,0){
        cin >> da[i].first;
        da[i].second=i;
    }
    sort(all(da));
    vector<int> ans(n);
    rip(i,n,0){
        ans[i]=da[i].second+1;
    }
    rip(i,n,0){
        if(i==n-1){
            cout << ans[i] << endl;
        }
        else{
            cout << ans[i] << ' ';
        }
    }
}

Measured memory_bytes: 2048
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: u64,
        a: u64,
        b: u64
    }

    let rep = n / (a + b);
    let md = (n + (a + b)) % (a + b);

    let ans = rep * a + std::cmp::min(a, md);
    println!("{}", ans);
}



Measured memory_bytes: 4352
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

typedef vector<double> vd;
typedef vector<vd> vvd;
typedef complex<double> Point;
const double EPS=1e-10;
const double INFTY=1e10;

int main()
{
	for(int n;cin>>n,n;){
		vi b(n);
		vector<Point> p(n);
		rep(i,n)
			cin>>b[i]>>real(p[i])>>imag(p[i]);

		vvd dist(n,vd(n,INFTY));
		rep(i,n) rep(j,n)
			if(abs(p[i]-p[j])<50+EPS)
				dist[i][j]=abs(p[i]-p[j]);

		vvi next(n,vi(n));
		rep(i,n) rep(j,n)
			next[i][j]=j;

		rep(k,n) rep(i,n) rep(j,n){
			if(dist[i][j]>dist[i][k]+dist[k][j]){
				dist[i][j]=dist[i][k]+dist[k][j];
				next[i][j]=next[i][k];
			}
		}
		
		int m; cin>>m;
		rep(i,m){
			int s,g; cin>>s>>g;
			int si=-1,gi=-1;
			rep(i,n){
				if(b[i]==s) si=i;
				if(b[i]==g) gi=i;
			}
			if(abs(dist[si][gi]-INFTY)<EPS){
				cout<<"NA"<<endl;
			}
			else{
				for(int j=si;j!=gi;j=next[j][gi])
					cout<<b[j]<<" ";
				cout<<g<<endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
N,M,C = map(int,input().split())
B = list(map(int,input().split()))

ans = 0
for i in range(N):
    A = list(map(int,input().split()))
    temp = C
    for j in range(M):
        temp += A[j]*B[j]
    
    if temp>0:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

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

const int MOD=1000000007;
int INF=100100100100100;
map<int,int> ma;
int a[100010];
signed main(){
  int n;cin>>n;
  int sum=0;
  rep(i,n){
    cin>>a[i];ma[a[i]]++;
    sum+=a[i];
  }
  int q;cin>>q;
  rep(ima,q){
    int b,c;cin>>b>>c;
    int t=ma[b];
    ma[b]=0,ma[c]+=t;
    sum+=t*(c-b);
    cout<<sum<<endl;
  }
  return 0;
}


Measured memory_bytes: 10120
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

int main() {
   Int n;
   std::cin >> n;
   std::vector<Int> cs(n-1), ss(n-1), fs(n-1);
   rep(i,n-1)
      std::cin >> cs[i] >> ss[i] >> fs[i];
   for(Int i = 0; i < n; ++i) {
      Int t = 0;
      for(Int k = i; k < n-1; ++k) {
         if( t < ss[k] ) {
            t = ss[k];
         }
         t = (t + fs[k] - 1) / fs[k] * fs[k];
         t += cs[k];
      }
      printf("%ld\n", t);
   }
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	char[] s=sc.next().toCharArray(),t=sc.next().toCharArray();
    int ans=0;
    for(int i=0;i<s.length;i++){
      if(s[i]!=t[i]){
        ans++;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 42024
#include <cstdio>
using namespace std;

int main() {
	int S;
	scanf("%d", &S);
	
	int S1, S2;
	S1 = S / 100;
	S2 = S % 100;
	
	bool month1 = (1 <= S1 && S1 <= 12)? true : false;
	bool month2 = (1 <= S2 && S2 <= 12)? true : false;
	
	if(month1) {
		if(month2) printf("AMBIGUOUS");
		else printf("MMYY");
	} else {
		if(month2) printf("YYMM");
		else printf("NA");
	}
	
	return 0;
}

Measured memory_bytes: 128
from collections import Counter
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

DC = Counter(D)
for i in range(M):
  if T[i] in DC and DC[T[i]] > 0:
    DC[T[i]] -= 1
  else:
    print("NO")
    exit(0)
    
print("YES")

Measured memory_bytes: 41692
#include <iostream>
#include <queue>
#include <assert.h>   
#include <vector>
#include <algorithm>
#include <time.h>
#include <numeric>
#include <string>
#include <cstring>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <numeric>
#include <deque>
#include <iomanip>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <cstdio>
using namespace std;


//#define double long double
#define int long long
//#define int unsigned long long

#define ll long long
#define ld long double 
#define pi pair<int, int> 
#define pl pair<ll,ll>  
#define pd pair<ld,ld> 
#define str string  
#define mp make_pair
#define vi vector<int> 
#define vl vector<ll> 
#define vd vector<ld> 
#define vs vector<str> 
#define vpi vector<pi> 
#define vpl vector<pl> 
#define vpd vector<pd> 
#define si set<int> 
#define FF(i,j,n) for(signed i=j;i<=n;i++)  
#define DD(i,j,n) for(signed i=j;i>=n;i--) 
#define F(i,j,n) for(signed i=j;i<n;i++)   
#define D(i,j,n) for(signed i=j;i>n;i--) 
#define mem(a,b) memset(a,b,sizeof(a))
#define ndl cout << endl
#define ull unsigned long long 

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;


#define sz(x) (signed)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back() 
#define X first
#define Y second
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


const int mod = 1e9 + 7;

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int pct(int x) { return __builtin_popcount(x); } 
int bit(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 


//DEBUG, compile with -DLOCAL
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
  cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
  DBG(t...); }
#ifdef LOCAL 
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#define HERE cout << "===GOTHERE===" << endl
#else
#define dbg(...) 42
#define HERE 42
#endif


 /* ============== END OF HEADER ============== */





const int maxn = 1e5*3+20;

int n,_,q,k;

vector<pair<ll,ll> > prime_fac(ll n){
  vector<pair<ll,ll> >ret;
  for(ll p = 2; p * p <= n; ++p){
    if (n % p != 0) continue;
    int divc = 0;
    while(n % p == 0){
      ++divc;
      n /= p;
    }
    ret.eb(mp(p,divc));
  }
  if (n != 1) ret.eb(mp(n,1));
 
  return ret;
}

void solve(){
 int x,y;
 cin >> x >> y;
 int z = gcd(x,y);
 dbg(z);
 if(z == 1){
  cout << 1 << endl;
  exit(0);
 }
 vector<pair<ll,ll> > fact = prime_fac(z);
 cout << sz(fact) + 1<< endl;
}

signed main(){
  //clock_t t1 = clock();  
  IOS
  solve();
  
  //cout << "THE ALGORITHM TOOK: " << (clock() - t1) * 1.0 / CLOCKS_PER_SEC * 1000 << "ms"<< endl;
  return 0;
}

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

int main(void){
	int n,i;
	scanf("%d",&n);

	for(i=0;i<n;i++){
		char judge[8];
		char exm[3][8]={"HIT","HOMERUN","OUT"};
		int base=0,point=0,out=0;
		while(1){
			scanf("%s",judge);
			if(strcmp(exm[0],judge) == 0){
				base++;
				if(base == 4){
					point++;
					base=3;
				}
			}
			if(strcmp(exm[1],judge)==0){
				point+=base+1;
				base=0;
			}
			if(strcmp(exm[2],judge)==0)
				out++;
			if(out == 3)
				break;
		}
		printf("%d\n",point);
	}
	return 0;
}

Measured memory_bytes: 604
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7

N = int(input())
INF = 10**10
cost = [[INF]*N for _ in range(N)]

for i in range(N):
    C = list(map(int, input().split()))
    for j in range(N):
        cost[i][j] = C[j]
    cost[i][i] = INF

ans = 0
for j in range(N):
    for k in range(j+1,N):
        mn = INF
        for i in range(N):
            mn = min(mn, cost[j][i]+cost[i][k])    
        if (cost[j][k] > mn):
            print (-1)
            exit()
        elif (cost[j][k] < mn):
            ans += cost[j][k]                      
print (ans)

Measured memory_bytes: 44124
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }

    let mut ans = 0;

    for i in 0..s.len() / 2 {
        if s[i] != s[s.len() - 1 - i] {
            ans += 1;
        }
    }

    println!("{}", ans);
}


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

using namespace std;

using ll = long long;

template<int MOD>
struct ModInt {
   using Mint = ModInt;
   int val;
   ModInt(ll __val = 0) { fix(__val % MOD + MOD); }
   Mint& fix(int __val) { val = __val; if (val >= MOD) val -= MOD; return *this; }
   explicit operator int() { return val; }
   Mint operator + (const Mint &mt) const { return Mint().fix(val + mt.val); }
   Mint operator - (const Mint &mt) const { return Mint().fix(val - mt.val + MOD); }
   Mint operator * (const Mint &mt) const { return Mint().fix(ll(val) * mt.val % MOD + MOD); }
   Mint& operator += (const Mint &mt) { return *this = *this + mt; }
   Mint& operator -= (const Mint &mt) { return *this = *this - mt; }
   Mint& operator *= (const Mint &mt) { return *this = *this * mt; }
   Mint pow(int y) const {
      Mint x = *this;
      Mint ans(1);
      for (; y > 0; y >>= 1, x *= x) {
         if (y & 1) ans *= x;
      }
      return ans;
   }
   Mint operator -() const { return Mint().fix(MOD - val); }
   Mint inv() const { return pow(MOD - 2); }
   Mint operator / (const Mint &mt) const { return *this * mt.inv(); }
   Mint& operator /= (const Mint &mt) const { return *this / mt; }
   friend ostream& operator<<(ostream& os, const Mint& mt) { return os << mt.val; }
};

using Mint = ModInt<998244353>;

bool can[330][330][330];
Mint dp[330][330][330];

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   string S; cin >> S;
   int N = S.size();
   for (int i = 0; i < N; ++i) {
      can[i][0][0] = true;
      for (int n0 = 0; n0 <= i; ++n0) {
         for (int n1 = 0; n1 <= i; ++n1) {
            if (!can[i][n0][n1]) continue;
            if (i) can[i + 1][n0][n1] = true;
            if (n0) {
               int nn0 = n0 - 1 + (S[i] == '0');
               int nn1 = n1 + (S[i] == '1');
               can[i + 1][nn0][nn1] = true;
            }
            if (n1) {
               int nn0 = n0 + (S[i] == '0');
               int nn1 = n1 - 1 + (S[i] == '1');
               can[i + 1][nn0][nn1] = true;
            }
            if (i + 1 < N) {
               can[i + 2][n0 + (S[i] == '0')][n1 + (S[i] == '1')] = true;
               can[i + 2][n0 + (S[i + 1] == '0')][n1 + (S[i + 1] == '1')] = true;
            }
         }
      }
   }
   can[N][0][0] = false;
   Mint ans = 0;
   dp[N][0][0] = 1;
   for (int i = N; i >= 0; --i) {
      for (int n0 = 0; n0 <= N; ++n0) {
         for (int n1 = 0; n1 <= N; ++n1) {
            // if (dp[i][n0][n1].val == 0) continue;
            if (can[i][n0][n1]) ans += dp[i][n0][n1];

            if (i > 0 && S[i - 1] == '0') {
               dp[i - 1][n0][n1] += dp[i][n0][n1];
            } else {
               dp[i][n0 + 1][n1] += dp[i][n0][n1];
            }

            if (i > 0 && S[i - 1] == '1') {
               dp[i - 1][n0][n1] += dp[i][n0][n1];
            } else {
               dp[i][n0][n1 + 1] += dp[i][n0][n1];
            }
         }
      }
   }
   cout << ans << "\n";
   return 0;
}


Measured memory_bytes: 152436
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  cin >> S >> T;
  for (int i; i < S.size(); i++){
    if (S.at(i)!=T.at(i)) {
      cout << "No" << endl;
      break;
    }
    if (i == S.size()-1){
      cout << "Yes" <<endl;
    }
  }
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int h = sc.nextInt();
	int n = sc.nextInt();
	int count = 0;
	for (int i=0; i<n; i++) {
	    count += sc.nextInt();
	    if (count >= h) break;
	}
	System.out.print(count >= h ? "Yes" : "No");
    }
}


Measured memory_bytes: 58644
import math
[a, b, x] = list(map(int, input().split()))
lim = (a**2 * b) / 2
if lim < x:
  tan = 2 * (b / a - x / a**3)
else:
  tan = (a * b**2) / (2 * x)
ans = math.degrees(math.atan(tan))
print(ans)

Measured memory_bytes: 3060
m10 = [10]
m9 = [9]
m8 = [8]
N = int(input())
mod = 10**9 + 7

i = 0
while 2**i<N:
  i += 1
  m10.append((m10[-1]**2)%mod)
  m9.append((m9[-1]**2)%mod)
  m8.append((m8[-1]**2)%mod)

#print(m10, i)
ans8 = 1
ans9 = 1
ans10 = 1
for j in range(i+1):
  if N>>j & 1:
    ans8  = (ans8*m8[j])%mod
    ans9  = (ans9*m9[j])%mod
    ans10  = (ans10*m10[j])%mod
ans = ans8 + ans10 - 2*ans9
ans %= mod
print(ans)


Measured memory_bytes: 61912
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
const int MAX = 1e5 + 10;
struct node
{
    int x, y, h;
} py[MAX];
int n;
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d%d%d", &py[i].x, &py[i].y, &py[i].h);
    int cnt = 1;
    while (py[cnt].h == 0)
        cnt++;
    for (int x = 0; x <= 100; x++)
        for (int y = 0; y <= 100; y++)
        {
            int H = py[cnt].h + abs(y - py[cnt].y) + abs(x - py[cnt].x);
            int flag = 1;
            for (int i = 1; i <= n; i++)
            {
                int hh = max(H - abs(x - py[i].x) - abs(y - py[i].y),0);
                if (hh != py[i].h)
                {
                    flag = 0;
                    break;
                }
            }
            if (flag)
            {
                printf("%d %d %d\n", x, y, H);
                return 0;
            }
        }
}


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

string kansu( long long int n ) {

  string s = "";
  string b = "0";
  while( true ) {
    b[0] = '0' + ( n % 10 );
    s = b + s;
    n /= 10;
    if ( n == 0 ) break;
  }
  return s;

}

int main() {

  while( true ) {

    long long int m;
    cin >> m;
    if ( m == 0 ) break;

    string s;
    cin >> s;

    for ( long long int i = 0; i < m; i++ ) {

      string b = "";
      s += "!";

      long long int cnt = 1;
      char k = s[0];

      for ( long long int j = 1; j < s.size(); j++ ) {
	if ( s[j] != k ) {
	  b += kansu( cnt ) + k;
	  cnt = 1;
	  k = s[j];
	}else {
	  cnt++;
	}
      }

      s = b;

    }

    cout << s << endl;

  }

  return 0;

}

Measured memory_bytes: 1344
#include <iostream>
#include <string.h>
#define maxn 101
#define maxv 100005
#define int long long
using namespace std;
int w[maxn], v[maxn], dp[maxv];
main() {
	ios::sync_with_stdio(false);
	//   sync_with_YinHsuan(true);
	cin.tie(0);
	int n, W;
	cin >> n >> W;
	memset(dp,0x7f,sizeof(dp));
	int inf = dp[0], sumv = 0;
	dp[0] = 0;
	for ( int i=0; i<n; ++i ) {
		cin >> w[i] >> v[i];
		sumv += v[i];
	}
	for ( int i=0; i<n; ++i )
		for ( int j=sumv; j>=v[i]; --j )
			if ( dp[j-v[i]] != inf && dp[j-v[i]]+w[i] <= W )
				dp[j] = min(dp[j],dp[j-v[i]]+w[i]);
	int ans = inf;
	for ( int i=sumv; i>=0; --i ) {
		if ( dp[i] <= W ) {
			ans = i;
			break;
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <string.h>

#define rep(i,n)    for(ll i=0;i<n;i++)
#define repu(i,k,n) for(ll i=k;i<=n;i++)
#define repd(i,k,n) for(ll i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define endl "\n"
#define INF (ll)ll_MAX

typedef long long ll;
typedef long double ld;
typedef std::pair<ll, ll> pii;
typedef std::vector<ll> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, ll > > vpp;

const ll N = 3*1e5 +5 ;
const long long MOD = 1000000007;
const long long MOD2 = 998244353;
const long long inf = 1e18;

using namespace std;

void solve()
{    
    string s ; 
    cin>>s ;
    int n = s.size() ;
    int sum = 0 ;
    rep(i , n){
        sum += s[i] - '0' ;
    }
    if(sum%9){
        cout<<"No\n";
    }
    else{
        cout<<"Yes\n";  
    }
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    //cout<<"helo";
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll t = 1;
    //  cin>>t;

    while(t--)
    {
        solve();    
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

}

Measured memory_bytes: 3904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, k;
    cin >> n >> k;
    vector<vector<int>> e(n);
    rep(i, 0, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    queue<int> que;
    que.push(0);
    bool visited[n] = {};
    visited[0] = true;
    ll ans = k;
    while (!que.empty()) {
        int now = que.front();
        que.pop();
        int color_num;
        if (now == 0) color_num = k - 1;
        else color_num = k - 2;
        for (auto i : e[now]) {
            if (visited[i]) continue;
            que.push(i);
            visited[i] = true;
            ans *= color_num;
            ans %= MOD;
            color_num--;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

long long dfs(string, int, int, int);
long long calc(string);

int main(){
    string s;
    cin >> s;
    int n = s.size();
    long long sum;
    sum = dfs(s, n, 0, 0);
    cout << sum << endl;
    return 0;
}

// あり得る候補の総和を返す
long long dfs(string s, int n, int pos, int depth){
    long long sum = 0;
    if (depth + 1> n - 1){
        return calc(s);
    }else{
        depth++;
        pos++;
        sum += dfs(s, n, pos, depth);
        s.insert(pos, "+");
        pos++;
        sum += dfs(s, n, pos, depth);
    }
    return sum;
}

long long calc(string s){
    long long pos;
    int len_s = s.size();
    vector<long long> sum;
    while(1){
        pos = s.find("+");
        if (pos > len_s - 1 || pos < 0){
            if (!s.empty()){
                sum.push_back(stoll(s));
            }
            break;
        }
        sum.push_back(stoll(s.substr(0, pos)));
        s = s.substr(pos + 1);
    }
    
    long long sum_2 = 0;
    for (auto i = 0; i < sum.size(); i++){
        sum_2 += sum.at(i);
    }
    return sum_2;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>

using namespace std;

int main(){

        int n,min,max,tmp;
        int i = 1;
        long sum;
        cin >> n;

        for(int i = 1; i <= n; i++){
                cin >> tmp;
                sum += (long)tmp;
                if(i == 1){
                        min = tmp;
                        max = tmp;
                }

                if(tmp < min) min = tmp;
                else if(tmp > max) max = tmp;
        }
        
        cout << min << " " << max << " " << sum << "\n";
        return 0;
}

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

char s[200010];

int main(){
    cin >> s;
    int len=strlen(s);

    int sum=0;
    for(int i=0;i<len;i++)sum+=s[i]-'0';

    if(sum%9==0){
        puts("Yes");
    }else{
        puts("No");
    }
}

Measured memory_bytes: 3816
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//Midnight Teatime
public class Main{

	class R{
		int id, x;
		char ch;
		R l, r;
		boolean leaf;
		public R(int id, boolean leaf) {
			this.id = id;
			this.leaf = leaf;
			l = r = null;
			x = 0;
		}
		int get(){
			if(leaf)return x;
			if(ch=='A')return l.get()&r.get();
			else if(ch=='O')return l.get()|r.get();
			else return l.get()^r.get();
		}
	}
	
	int ID, c;
	R[] v;
	R root;
	List<R> leafs;
	
	char[] s;
	int id;
	char get(){
		return s[id++];
	}
	
	R exp(){
		char ch = get();
		if(ch!='('){
			int x = ch-'0';
			R res = new R(x, true);
			leafs.add(res);
			return res;
		}
		R res = new R(ID, false);
		v[ID++] = res;
		res.l = exp();
		get();
		res.r = exp();
		get();
		return res;
	}
	
	void dfs(int k){
		if(k==ID){
			int x = root.get();
			if(x==15)c++;
			return;
		}
		v[k].ch = 'A'; dfs(k+1);
		v[k].ch = 'O'; dfs(k+1);
		v[k].ch = 'X'; dfs(k+1);
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			s = (sc.nextLine()+"$").toCharArray();
			if(s[0]=='E')break;
			id = 0;
			v = new R[8];
			leafs = new ArrayList<R>();
			ID = 0;
			root = exp();
			int n = sc.nextInt();
			for(int i=1;i<=n;i++){
				int x = 0;
				for(int j=0;j<4;j++){
					x += sc.nextInt()<<j;
				}
				for(R r:leafs)if(r.id==i)r.x = x;
			}
			sc.nextLine();
			c = 0;
			dfs(0);
			System.out.println(c);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
import sys
import itertools
import math
import fractions
def FRAC(a):
    ans = a[0]
    for i in range(1, len(a)):
        ans = ans * a[i] // fractions.gcd(ans, a[i])
    return ans

def main():

    N,M=list(map(int,sys.stdin.readline().split()))
    AL=list(map(int,sys.stdin.readline().split()))
    if any([a%2 for a in AL]):
        print(0)
        return

    HAL=[x//2 for x in AL]
    fr=FRAC(HAL)
    if not all([(fr//x)%2 for x in HAL]):
        print(0)
        return

    print(math.ceil((M//fr)/2))

main()


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

class Main
{
	public static void main(String[] args) {
		BufferedReader in = null;
		try {
			in = new BufferedReader(
				new InputStreamReader(System.in)
				);
			String[] inputs = in.readLine().split(" ");
			long a = Long.parseLong(inputs[0]);
			long b = Long.parseLong(inputs[1]);
			long d = a / b;
			long r = a % b;
			double f = (double)a / (double)b;
			System.out.printf("%d %d %f\n", d, r, f);
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (in != null) {
				try {
					in.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
				
			}
		}
		
	}
}

Measured memory_bytes: 16980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return (rand()<<16|rand())%x;
}
const int N=100005;
#define lowbit(i) i&-i
int n,m,tong[N],c[N];
vector<int> f[N],g[N];
inline int get(int pos){
	int ans=0;
	for(int i=pos;i<=n;i+=lowbit(i))ans+=c[i];
	return ans;
}
inline void change(int pos,int de){
	for(int i=pos;i;i-=lowbit(i))c[i]+=de;
}
int main(){
	m=read(); n=read();
	for(int i=1;i<=m;i++){
		int l=read(),r=read();
		tong[r-l+2]++;
		f[r-l+2].push_back(r); g[r-l+2].push_back(l-1);
	}
	int jb=m;
	for(int i=1;i<=n;i++){
		for(unsigned j=0;j<f[i].size();j++)change(f[i][j],1);
		for(unsigned j=0;j<g[i].size();j++)change(g[i][j],-1);
		jb-=tong[i]; int ans=jb;
		for(int j=i;j<=n;j+=i)ans+=get(j);
		writeln(ans);
	}
}

Measured memory_bytes: 12672