akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){

int a,b,c,d,e;
cin >>a>>b>>c>>d>>e;
if(a==0){
    cout <<1;
}else if(b==0){
    cout <<2;
}else if(c==0){
    cout <<3;
}else if(d==0){
    cout <<4;
}else if(e==0){
    cout <<5;
}
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
 
#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
 
long long mod = 1000000007;
 
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}
 
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
int main() {
    long long a, b, c;
    cin >> a;
    string s = to_string(a);
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '7') {
            yes();
            return 0;
        }
    }
    no();
}

Measured memory_bytes: 3720
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
    auto N = readln.split[0].to!ulong;
    auto A = readln.split.to!(ulong[]);
    N = A.length;
    auto grps = sort(A.dup).group;
    size_t[ulong] nums;
    
    //grps.array.writeln;
    
    foreach (tup; grps) {
        nums[tup[0]] = tup[1];
    }
    //nums.writeln; 
    
    ulong all_num = grps.map!(a => a[1] * (a[1]-1)).sum / 2;
    ulong all_num_true = nums.values.dup.map!(a => a*(a-1)).sum / 2;
    
    int[] re; re.length = N;
    if (
        all_num != all_num_true || (
            equal( sort(grps.map!(a => a[1]).array), sort(nums.values) ) &&
            !equal( sort(grps.map!(a => a[1] * (a[1]-1)).array), sort(nums.values.map!(a => a * (a-1)).array) )
        )
    ) {
        if (all_num_true > all_num) re[N+1] = 1;  // RE
        else if (all_num_true < all_num) writeln("aaa");   // WA
        else while (true) { N++; }    // TLE
    }
    
    foreach (k; 0 .. N) {
        writeln( all_num_true - (nums[A[k]] - 1) );
    }
}



Measured memory_bytes: 26384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
#define ALL(V) V.begin(), V.end()
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}


string Main(int K, int X)
{
    return (500*K >= X) ? "Yes" : "No";
}

int main(void){
    int K, X;
    cin >> K >> X;
    cout << Main(K, X) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define exists(s,x) (s).find(x)!=(s).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
#define fi first
#define se second
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}
inline ll modpow(ll x, ll y) {
    ll res = 1;
    while(y) {
        if(y&1) res = mul(res,x);
        y >>= 1;
        x = mul(x,x);
    }
    return res;
}

int main(){
    int N; ll K; cin >> N >> K;
    vector<ll> A(N);
    REP(i,N) {
        cin >> A[i];
    }
    sort(all(A));
    ll ub = INF;
    ll lb = -INF;
    ll mid;
    while(ub-lb>1) {
        mid = (ub + lb) / 2;
        ll cnt = 0;
        REP(i,N) {
            if(A[i]<0) {
                int ok = N;
                int ng = i;
                int tmp;
                while(ok-ng>1) {
                    tmp = (ok+ng) /2;
                    if(A[tmp]*A[i]<=mid) ok = tmp;
                    else ng = tmp;
                }
                cnt += N - ok;
            }
            if(A[i]>=0) {
                int ok = i;
                int ng = N;
                int tmp;
                while(ng-ok>1) {
                    tmp = (ok+ng) / 2;
                    if(A[tmp]*A[i]<=mid) ok = tmp;
                    else ng = tmp;
                }
                cnt += ok - i;
            }
        }
        if (cnt>=K) ub = mid;
        else lb = mid;
    }
    cout << ub << endl;
    return 0;
}

Measured memory_bytes: 1792
#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>;

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> m(n);
    rep(i,n) cin >> m[i];
    sort(m.begin(), m.end());
    rep(i,n) x -= m[i];
    int ans = n;
    ans += x/m[0];
    cout << ans << endl;
}

Measured memory_bytes: 3628
<?php
fscanf(STDIN, "%d %d %d", $x, $k, $d);
$x = abs($x);
$rem = $k;

if (intdiv($x, $d) < $k) {
    $rem -= intdiv($x, $d);
    $x %= $d;
    if ($rem % 2 == 0) {
        echo abs($x) . "\n";
    } else {
        echo abs($x - $d) . "\n";
    }
    exit;
}

$rem -= intdiv($x, $d);
$min_x = $x % $d;
$x = $min_x + $d * abs($rem);

// echo $rem . "\n";
// echo $min_x . "\n";
echo $x . "\n";

Measured memory_bytes: 16032
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>

ll INF = 1000000007;


//-----------------//
  #define amin main
//-----------------//


int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,x,t;
	cin>>n;
	ll arr[n];
	for(ll i=0;i<n;i++)
		cin>>arr[i];
	ll sum = 0;
	for(ll i=0;i<n-1;i++)
	{
		if(arr[i]>arr[i+1])
		{
			sum += abs(arr[i]-arr[i+1]);
			arr[i+1]= arr[i];
		}
	}
	cout<<sum<<endl;

	
	return 0;
}

Measured memory_bytes: 5176
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

ll pow(ll x, ll n) {
  if ( n == 0 ) return 1;
  ll res = pow(x*x,n/2);
  if(n&1) res = res*x;
  return res;
}

int A[50];
ll cntodd = 0;
ll cnteven = 0;
int main() {
  int N; cin >> N;
  int P; cin >> P;
  for ( int i = 0; i < N; i++ ) {
    cin >> A[i];
    if ( A[i] % 2 == 0 ) cnteven++;
    else cntodd++;
  }
  ll ans = 0;
  if ( P == 0 ) {
    if ( cntodd == 0 ) ans = pow(2,N);
    else if (cnteven ==  0) ans = pow(2,N)-pow(2,cntodd)/2;
    
    else ans = pow(2,N)-(pow(2,cnteven)*pow(2,cntodd)/2);    
  } else if ( P == 1 ) {
    if ( cnteven == 0 ) ans = pow(2,N)-pow(2,cntodd)/2;
    else if ( cntodd == 0 ) ans = pow(2,N)-pow(2,cnteven);
    else ans = pow(2,N)-(pow(2,cnteven)*pow(2,cntodd)/2);
  }
  cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    H, W = LI()
    g = []
    for _ in range(H):
        g.append(S())
    dp = [[inf for _ in range(W)] for __ in range(H)]

    if g[0][0] == '#':
        dp[0][0] = 1
    else:
        dp[0][0] = 0

    for r in range(H):
        for c in range(W):
            cand1, cand2 = inf, inf
            if r-1 >= 0:
                if g[r-1][c] == '.' and g[r][c] == '#':
                    dp[r][c] = min(dp[r][c], dp[r-1][c] + 1)
                else:
                    dp[r][c] = min(dp[r][c], dp[r-1][c])
            if c-1 >= 0:
                if g[r][c-1] == '.' and g[r][c] == '#':
                    dp[r][c] = min(dp[r][c], dp[r][c-1] + 1)
                else:
                    dp[r][c] = min(dp[r][c], dp[r][c-1])
    print(dp[-1][-1])
main()



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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

int K, Q;
vector<int> D;

int solve() {
    int n, x, m;
    cin >> n >> x >> m;
    x %= m;
    vector<int> DM(K);
    REP(i, K) {
        DM[i] = D[i] % m;
    }

    // ai -> ai+1 で ai == ai+1 のケース
    // d が 0 の時のみ
    int zero_cnt = 0;
    REP(i, K) {
        if(DM[i] == 0) { zero_cnt++; } 
    }
    int zero_case = (n - 1) / K * zero_cnt;
    for(int i = 0; i < ((n - 1) % K); ++i) {
        if(DM[i] == 0) { zero_case++; }
    }
    //DBG("zero_case: %lld\n", zero_case);

    // ai -> ai+1 で ai > ai+1 のケース
    // / m したときの値が +1 されている
    int dm_sum = 0;
    REP(i, K) {
        dm_sum += DM[i];
    }
    int lb = x / m;
    int div = (n - 1) / K;
    int ub = x + dm_sum * div;
    for(int i = 0; i < ((n - 1) % K); ++i) {
        ub += DM[i];
    }
    ub /= m;
    int down_case = ub - lb;

    int ret = n - 1 - zero_case - down_case;

    return ret;
}

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

    cin >> K >> Q;
    D.resize(K);
    REP(i, K) {
        cin >> D[i];
    }

    REP(i, Q) {
        int ans = solve();
        printf("%lld\n", ans);
    }

    return 0;
}


Measured memory_bytes: 384
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut a = vec![vec![0; 10]; 10];
    for i in 1..n + 1 {
        let matsu = i % 10;
        let mut sento = i;
        while sento >= 10 {
            sento /= 10;
        }
        a[sento][matsu] += 1;
    }

    let mut ans = 0;
    for i in 0..10 {
        for j in 0..10 {
            ans += a[i][j] * a[j][i];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <fstream>
#include <cassert>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;



int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	int m = INT32_MAX, ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] < m)ans++;
		m = min(m, a[i]);
	}
	cout << ans;
}

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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

bool CompareX_smaller(pll a, pll b){
    if(a.first == b.first)return a.second < b.second;
    else return a.first < b.first;
}

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

    vector<pll> red(n), blue(n);
    rep(i, n)cin >> red[i].first >> red[i].second;
    rep(i, n)cin >> blue[i].first >> blue[i].second;

    sort(ALL(blue), CompareX_smaller);

    ll ans = 0;
    bool used[1000] = {};
    rep(i, n){
        ll max_y_pos = -1;
        ll max_y = -1;
        rep(j, n)if(!used[j]){
            if(blue[i].first > red[j].first && blue[i].second > red[j].second){
                if(red[j].second >= max_y){
                    max_y = red[j].second;
                    max_y_pos = j;
                }
            }
        }

        if(max_y_pos >= 0){
            ans++;
            used[max_y_pos] = true;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
char joi[1001][1001];
int jj[1001][1001],oo[1001][1001],ii[1001][1001];
int main(void)
{
	int m,n;
	int k;
	int i,j,l;
	int jun,oce,ice;
	int jc,oc,ic;
	int flg;
	int a,b,c,d;
	
	scanf("%d %d",&m,&n);
	scanf("%d",&k);
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			scanf(" %c",&joi[i][j]);
		}
	}
	for(i=0;i<m;i++){
		jc=oc=ic=0;
		for(j=0;j<n;j++){
			if(joi[i][j]=='J'){
				jc++;
			}
			else if(joi[i][j]=='O'){
				oc++;
			}
			else {
				ic++;
			}
			jj[i][j]=jc;
			oo[i][j]=oc;
			ii[i][j]=ic;
		}
	}
	for(i=0;i<n;i++){
		for(j=1;j<m;j++){
			jj[j][i]+=jj[j-1][i];
			oo[j][i]+=oo[j-1][i];
			ii[j][i]+=ii[j-1][i];
		}
	}
/*	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			printf("%2d ",jj[i][j]);
		}
		printf("  ");	
		for(j=0;j<n;j++){
			printf("%2d ",oo[i][j]);
		}
		printf("  ");	
		for(j=0;j<n;j++){
			printf("%2d ",ii[i][j]);
		}
		printf("  ");	
	printf("\n");	
	}*/
	for(l=0;l<k;l++){
		scanf("%d %d %d %d",&a,&b,&c,&d);
		jun=jj[c-1][d-1];
		if(a-2>=0){
			jun-=jj[a-2][d-1];
		}
		if(b-2>=0){
			jun-=jj[c-1][b-2];
		}
		if(a-2>=0 && b-2>=0){
			jun+=jj[a-2][b-2];
		}
		oce=oo[c-1][d-1];
		if(a-2>=0){
			oce-=oo[a-2][d-1];
		}
		if(b-2>=0){
			oce-=oo[c-1][b-2];
		}
		if(a-2>=0 && b-2>=0){
			oce+=oo[a-2][b-2];
		}
		ice=ii[c-1][d-1];
		if(a-2>=0){
			ice-=ii[a-2][d-1];
		}
		if(b-2>=0){
			ice-=ii[c-1][b-2];
		}
		if(a-2>=0 && b-2>=0){
			ice+=ii[a-2][b-2];
		}
		printf("%d %d %d\n",jun,oce,ice);
	}
	return 0;
}

Measured memory_bytes: 13732
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,q=map(int,readline().split())
s=readline().decode('utf-8')
dic={1:0}
c=0
for idx, (a,b) in enumerate(zip(s,s[1:]),1):
  if a=='A' and b=='C':
    c+=1
  dic[idx+1]=c
lst=map(int,read().split())
lr=list(zip(lst,lst))
for l,r in lr:
  print(dic[r]-dic[l])
  

Measured memory_bytes: 38688
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int n;
int ct[MAXN];
int d[MAXN];

ll rec(int x)
{
	if(ct[d[x]] == 0 or x == n-1) return ct[d[x]];

	int t = ct[d[x]];

	ct[d[x]]--;
	ct[d[x]+1]++;

	ll res = (t * rec(x+1)) % MOD;

	ct[d[x]]++;
	ct[d[x]]--;

	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> d[i];

	ct[0] = 3;

	ll ans = rec(0);

	cout << ans << endl;
}

Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N= sc.nextInt(),R=sc.nextInt();
		if(N>=10) {
			System.out.println(R);
		}else {
			System.out.println(R+100*(10-N));
		}

	}

}

Measured memory_bytes: 22868
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "Yes"
#define NO  "No"

using namespace std;

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

  int num = 0;

  string s; cin >> s;
  int n = s.length();
  vector<int> v1(n);
  vector<int> v2(n);
  int tmp1 = 0; // i % 2 0, 1, 0, 1
  int tmp2 = 0; // (i % 2 + 1) % 2 1, 0, 1, 0

  for (int i = 0; i < n; ++i) {
    int c = s[i] - '0';
    if (i % 2 == 0) {
      v1[i] = 0;
      v2[i] = 1;
    } else {
      v1[i] = 1;
      v2[i] = 0;
    }
    v1[i] = abs(v1[i] - c);
    v2[i] = abs(v2[i] - c);

    tmp1 += abs(v1[i]);
    tmp2 += abs(v2[i]);
  }

  num = min(tmp1, tmp2);

  
  cout << num << endl;
  
  return 0;
}


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

cnt = 0
X = []
for i in range(H):
    for j in range(W):
        if a[i][j] % 2:
            cnt += 1
            a[i][j] -= 1
            if j == W-1:
                if i == H-1:
                    cnt -= 1
                    break
                a[i+1][j] += 1
                X.append([i+1, j+1, i+2, j+1])
            else:
                a[i][j+1] += 1
                X.append([i+1, j+1, i+1, j+2])

print(cnt)    
for i in range(cnt):
    print(*X[i])

Measured memory_bytes: 30276
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
const int inf=1001001001;
const long long INF=1001001001001001001;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
using priority_queue_small = priority_queue<int, vector<int>, greater<int> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

int n;
int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n;
  vii a(n);
  rep(i, 0, n) cin >> a[i];
  deque<int> b;
  rep(i, 0, n) {
    if (n % 2) {
      if (i % 2) b.push_back(a[i]);
      else b.push_front(a[i]);
    } else {
      if (i % 2) b.push_front(a[i]);
      else b.push_back(a[i]);
    }
  }
  rep(i, 0, n) { 
    cout << b[i] << (i != n-1 ? " " : "\n");
  }
  return 0;
}



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

using namespace std;

//void func(vector<vector<int>>& inf, int b, int f, int r, int v, int i)
//{
//	inf.at(i).at(0) = b;
//	inf.at(i).at(1) = f;
//	inf.at(i).at(2) = r;
//	inf.at(i).at(3) += v;
//}

int main()
{
	int n;
	cin >> n;
	vector<vector<int>> inf(n, vector<int>(4));

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 4; j++)
		{
			cin >> inf.at(i).at(j);
		}
	}

	for (int i = 0; i < 4; i++)
	{
		vector<vector<vector<int>>> room(4, vector<vector<int>>(3, vector<int>(10)));

		for (int i = 0; i < n; i++)
		{
			int b = inf.at(i).at(0);	//b棟
			int f = inf.at(i).at(1);	//f階
			int r = inf.at(i).at(2);	//r番目
			int v = inf.at(i).at(3);	//v人

			room.at(b - 1).at(f - 1).at(r - 1) += v;
		}
		
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 10; k++)
			{
				cout << " " << room.at(i).at(j).at(k);
			}
			cout << endl;
		}
		if (i != 3)
		{
			cout << "####################" << endl;
		}
	}
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
  int n,m;
  cin >> n >> m;
  if(n == m) cout << "Yes" << endl;
  else cout << "No" << endl;
return 0;
}

Measured memory_bytes: 3592
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <utility>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int result = 0;
    for (int i = 0; i < n; i += 2) {
        if (a[i] % 2 == 1) {
            result += 1;
        }
    }
    cout << result << endl;
}


Measured memory_bytes: 3592
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int a, b,c,i;
	char op;

	for (;;){
		cin >> a >> op >> b;
		if (op == '?'){
			break;
		}
	
		else if (op == '+'){
		c=	a + b;
		}
	
		else if (op == '*'){
			c = a*b;
		}

		else if (op == '-'){
			c = a - b;
		}

		else if (op == '/'){
			c = a / b;
		}
		cout << c << endl;
	}




	return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>
#include <math.h>
#define swap(a,b) a^=b^=a^=b

int main(){
	
	int n, i, a, b, A=0, B=0;
	
	while(1){
		scanf("%d", &n);
		if(n == 0) break;
		
		A=0, B=0;
		
		for(i=0; i<n; i++){
			scanf("%d %d", &a, &b);
			if(a > b) A += a+b;
			if(a < b) B += a+b;
			if(a == b){
				A += a;
				B += b;		
			}
		}
		printf("%d %d\n", A, B);
	}
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll a,b,k; cin >> a >> b >> k;
  if(k>=a+b) cout << 0 << " " << 0 << endl;
  else if(a<k && k<a+b) cout << 0 << " " <<  b-k+a << endl;
  else cout << a-k << " " << b << endl;
  return 0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

const int MX = 81*81;
bool dp[81][81][MX];

int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W));
    vector<vector<int>> B(H, vector<int>(W));
    vector<vector<int>> C(H, vector<int>(W));
    REP(i, H) REP(j, W) cin >> A[i][j];
    REP(i, H) REP(j, W) cin >> B[i][j];
    REP(i, H) REP(j, W) C[i][j] = abs(A[i][j] - B[i][j]);

    dp[0][0][C[0][0]] = true;

    REP(i, H) REP(j, W) REP(k, MX){
        if(i > 0){
            if(dp[i-1][j][k]){
                {
                    int to = k + C[i][j];
                    if(to < MX) dp[i][j][to] = true;
                }
                {
                    int to = k - C[i][j];
                    if(to >= 0) dp[i][j][to] = true;
                    else dp[i][j][-to] = true;
                }
            }
        }
        if(j > 0){
            if(dp[i][j-1][k]){
                {
                    int to = k + C[i][j];
                    if(to < MX) dp[i][j][to] = true;
                }
                {
                    int to = k - C[i][j];
                    if(to >= 0) dp[i][j][to] = true;
                    else dp[i][j][-to] = true;
                }
            }
        }
    }
    REP(k, MX)
        if(dp[H-1][W-1][k]){
            cout << k << endl;
            break;
        }
    return 0;
}

Measured memory_bytes: 41728
using System;
using System.Collections.Generic;
using System.Linq;

namespace PaizaTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var xy = Console.ReadLine().Split().Select(int.Parse).ToList();

            var headCount = xy[0];
            var footCount = xy[1];

            // 亀の数を増やしながら数える

            var result = "No";

            for (int i = 0; i <= headCount; i++)
            {
                var turtleNum = i;
                var craneNum = headCount - i;

                if (turtleNum * 4 + craneNum * 2 == footCount)
                {
                    result = "Yes";
                    break;
                }
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 19020
# N = input()
# sum = 0
# for n in N:
#     sum += int(n)
#     sum %= 9
# if sum == 0:
#     print("Yes")
# else:
#     print("No")
N = int(input())
if N % 9 == 0:
    print("Yes")
else:
    print("No")


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

const int MOD = 1000000007;

int main() {
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    for (ll i = k; i <= n + 1; i++) {
        ll mi = i * (i - 1) / 2;
        ll ma = i * (2 * n - i + 1) / 2;
        ans = (ans + (ma - mi + 1)) % MOD;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

  int n, m;
  cin >> n >> m;
  unordered_set<int> to_n, from_one;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    if (a == 1) {
      from_one.insert(b);
    }
    if (b == 1) {
      from_one.insert(a);
    }
    if (a == n) {
      to_n.insert(b);
    }
    if (b == n) {
      to_n.insert(a);
    }
  }
  for (auto& from : from_one) {
    auto b = to_n.find(from);
    if (b != to_n.end()) {
      cout << "POSSIBLE\n";
      return 0;
    }
  }
  cout << "IMPOSSIBLE\n";
}


Measured memory_bytes: 8520
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	map<string, int> cnt;

	for (int i=0; i<n; i++) cin >> s[i];

	for (int i=0; i<n; i++) cnt[s[i]]++;

	cout << cnt.size() << endl;

	return 0;
}

Measured memory_bytes: 23044
from time import time
import random
random.seed(0)

now = time()

MAX = 26

d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
t = [i % MAX + 1 for i in range(d)]

last = [0] * MAX

score = 0
for day, e in enumerate(t, 1):
    score += s[day-1][e-1]
    last[e-1] = day

    for ec, elast in zip(c, last):
        score -= ec * (day - elast)

while time() - now <= 1.8:
    prev_score = score

    ed = random.randint(1, d)
    eq = random.randint(1, MAX)

    q_old = t[ed-1]
    d_prev = {q_old: 0, eq: 0}

    c_old = c[q_old-1]
    c_new = c[eq-1]

    for day, e in enumerate(t, 1):
        if e in d_prev.keys():
            d_prev[e] = day

        score += c_old * (day - d_prev[q_old])
        score += c_new * (day - d_prev[eq])

    score -= s[ed-1][q_old-1]
    score += s[ed-1][eq-1]

    t[ed-1] = eq

    d_prev = {q_old: 0, eq: 0}

    for day, e in enumerate(t, 1):
        if e in d_prev.keys():
            d_prev[e] = day

        score -= c_old * (day - d_prev[q_old])
        score -= c_new * (day - d_prev[eq])

    if prev_score > score:
        t[ed-1] = q_old
        score = prev_score

print(*t, sep="\n")


Measured memory_bytes: 80516
class Point
  attr_reader :x, :y

  def initialize(x, y)
    @x=x
    @y=y
  end

end

# 1次関数(2点標準形)
def linear(p1, p2)
  lambda { |p| (p2.y-p1.y)*(p.x-p1.x)-(p2.x-p1.x)*(p.y-p1.y) }
end

# 包含判定
def inner?(p, polygon)
  a=linear(polygon[0], polygon[1]).call(p)
  b=linear(polygon[1], polygon[2]).call(p)
  c=linear(polygon[2], polygon[0]).call(p)

  if a<0&&b<0&&c<0
    return true
  end

  if a>0&&b>0&&c>0
    return true
  end

  false

end

gets.to_i.times do

  ps = gets.split.map(&:to_f)

  p1=Point.new(ps[0], ps[1])
  p2=Point.new(ps[2], ps[3])
  p3=Point.new(ps[4], ps[5])
  poly=[p1, p2, p3]

  pa=Point.new(ps[6], ps[7]) # altair
  pv=Point.new(ps[8], ps[9]) # vega

  if inner?(pv, poly)
    unless inner?(pa, poly)
      puts :OK
      next
    end
  else
    if inner?(pa, poly)
      puts :OK
      next
    end
  end

  puts :NG

end

Measured memory_bytes: 6216
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;


int main(){
    //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
    
    int n;
    
    cin>>n;
    vector<int> d(n);
    
    for(int i=0;i<n-1;++i){
        int j;
        cin>>j;
        --j;
        d[j]++;
    }
    
    for(int x : d) cout<<x<<endl;
    
    
    return 0;
}


Measured memory_bytes: 3992
N = int(input())
A = [int(i) for i in input().split()]

choice = []
candidate = set()
for i in range(N):
    if A[i] not in candidate:
        candidate.add(A[i])
    else:
        choice.append(A[i])
        candidate.remove(A[i])

try:
    side1 = max(choice)
except:
    side1 = 0

try:
    choice.remove(side1)
except:
    a = 0

try:
    side2 = max(choice)
except:
    side2 = 0
    
    
ans = side1*side2

print(ans)

Measured memory_bytes: 14672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

ll inf=ll(1e18)+1;

int main() {
  ll n,k;
  ll zero=0;
  cin >> n >> k;
  vector<ll> a(n);
  ll mnum=0,znum=0;
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  ll l=-inf,r=inf;
  ll x=(l+r)/2;
  while(l+1<r) {
    ll count=0;
    for(ll i=0;i<n;i++) {
      if(a[i]<0) {
        ll l=-1,r=n;
        ll c=(l+r)/2;
        while(l+1<r) {
          if(a[i]*a[c]<x) {
            r=c;
          }
          else {
            l=c;
          }
          c=(l+r)/2;
        }
        count+=n-r;
      }
      else {
        ll l=-1,r=n;
        ll c=(l+r)/2;
        while(l+1<r) {
          if(a[i]*a[c]<x) {
            l=c;
          }
          else {
            r=c;
          }
          c=(l+r)/2;
        }
        count+=r;
      }
      if(a[i]*a[i]<x) {
        count--;
      }
    }
    count/=2;
    if(count<k) {
      l=x;
    }
    else {
      r=x;
    }
    x=(l+r)/2;
  }
  cout << l << endl; 
}

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

const int INF = 1e9;

int main() {
  int max_n = 1e5;
  int n;
  cin>>n;
  int cnt[max_n+1];
  int ans=0;
  for(int i=0;i<max_n+1;i++){
     cnt[i]=0;
  }
  for(int i=0;i<n;i++){
    int ai;
    cin>>ai;
    if(ai>max_n){
      ++ans;
      continue;
    }
    ++cnt[ai];
  }
  for(int i=1;i<max_n+1;i++){
    if(cnt[i]>=i){
      ans+=cnt[i]-i;
      continue;
    }
    if(cnt[i]==0){
      continue;
    }
    ans+=cnt[i];
  }
  cout<<ans<<endl;


}

Measured memory_bytes: 768
#include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std;

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

	int kurai[6];
	bool flag = true;
	int i = 0;
	do
	{
		kurai[i] = N % 10;
		N = N /10;
		if (flag)
		{
			if(kurai[i] != 0)
			{
				if ( !(N == 0 && kurai[i] == 1))
					flag = false;
			}
		}
		i++;
	} while (N > 0);

	if (flag)
	{
		cout << 10 << endl;
	}
	else
	{
		int result = 0;
		for (int ii = 0; ii < i; ii++)
		{
			result += kurai[ii];
		}
		cout << result;
	}

	return 0;
}

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

int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int main()
{
    int s,h,l;
    cin >> s;
    h = s/100;
    l = s%100;

    if(0 < l && l <= 12)
    {
        if(0 < h && h <= 12)
        {
            cout << ("AMBIGUOUS");
        }
        else
        {
            cout << ("YYMM");
        }
        
    }
    if(l == 0)
    {
        if(h == 0){
        cout << ("NA");
        }else if(h > 12){
            cout << ("NA");
        }else{
            cout << ("MMYY");
        }
    }
    if(l > 12){
        if(0 < h && h <= 12){
            cout << ("MMYY");
        }else{
            cout << ("NA");
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000
//#define int long long int

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

vector<vector<int>> vv;
map<int, map<int, int>> mm;

int dfs(int point, vector<bool> visited) {
  visited[point] = true;
  if(count(ALL(visited), true) == visited.size()) {
    return 1;
  }
  int result = 0;
  REP(dest, vv[point].size()) {
    if(visited[dest] == false && vv[point][dest] == 1) {
      result += dfs(dest, visited);
    }
  }
  return result;
}

int main() {
  int n, m;
  cin >> n >> m;
  //map<int, map<int, int>> mm;
  REP(i, n) {
    vv.push_back(vector<int>(n));
  }
  int a, b;
  REP(i, m) {
    cin >> a >> b;
    vv[a-1][b-1] = 1;
    vv[b-1][a-1] = 1;
  }

  int ans = 0;
  vector<int> visited_orig(n, 0);
  ans += dfs(0, vector<bool>(n));
  cout << ans << endl;

  return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int A, B, X; cin >> A >> B >> X;
    if(X < A || A + B < X) cout << "NO" << endl;
    else cout << "YES" << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
public class Main{
 
  public static int findCost(int arr[],int i,int dp[])
  {
	int n=arr.length;
 
    if(i>=n-1)
      return 0;
    int ans1=Integer.MAX_VALUE,ans2=Integer.MAX_VALUE;
    if(dp[i]==Integer.MAX_VALUE) {
    if((i+1)<n)
    ans1=Math.abs(arr[i]-arr[i+1])+findCost(arr,i+1,dp);
    if((i+2)<n)
    ans2=Math.abs(arr[i]-arr[i+2])+findCost(arr,i+2,dp);
    dp[i]=Math.min(ans1, ans2);}
    return dp[i];
    
  }
  
  public static void main(String[] args) throws IOException
  {
     
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int n=Integer.parseInt(br.readLine());
    String line=br.readLine();
    String str[]=line.trim().split("\\s+");
    int arr[]=new int[n];
    for(int i=0;i<n;i++)
    {
      arr[i]=Integer.parseInt(str[i]);
     // System.out.println(arr[i]);
    }
    int dp[]=new int[n];
    for(int i=0;i<n;i++)
    	dp[i]=Integer.MAX_VALUE;
    System.out.print(findCost(arr,0,dp));
    
  }
}

Measured memory_bytes: 47560
#include <iostream>

using namespace std;

int main() {
    int A, B;
    bool result = false;
    cin >> A >> B;
    for (int C = 1; C <= 3; C++)
        if((A*B*C) % 2 == 1)
            result = true;

    if(result)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<atcoder/all>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long Int;
#define INF (1LL <<30)
int main(){
    int n, k;
    cin >> n >> k;
    
    vector<vector<int>> num(n,vector<int>(n));
    atcoder::mcf_graph<int, Int> mcf(2*n+2);
    int S = 2 * n, T = 2 * n + 1;

    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            cin >> num[i][j];
            mcf.add_edge(i, j + n, 1, INF-num[i][j]);
        }
        mcf.add_edge(S, i, k, 0);
        mcf.add_edge(n+i, T, k, 0);
    }

    auto mcf2 = mcf;
    
    Int flow = 0, cost = 0;
    for(auto p:mcf2.slope(S, T)){
        Int tmp = p.first * INF - p.second;
        if(tmp > cost){
            cost = tmp;
            flow = p.first;
        }
    }
    mcf.flow(S, T, flow);
    
    vector<string> field(n, string(n,'.'));
    
    
    for(auto e:mcf.edges())
        if(e.from != S && e.to != T && e.flow == 1)
            field[e.from][e.to - n] = 'X';
    
    cout << cost << endl;
    for(auto row:field)cout << row << endl;
    return 0;
} 

Measured memory_bytes: 3620
class UnionFind():
    def __init__(self, n):
        self.n = n
        #親の添字、親自身は木の要素数*-1をもつ
        self.root = [-1]*(n)
        #枝の最大長さ
        self.rank = [0]*(n)

    def find_root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.find_root(self.root[x])
            return self.root[x]
    #高さによる合併    
    def unite(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return 
        elif self.rank[x] > self.rank[y]:
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rank[x] == self.rank[y]):
                self.rank[y] += 1
    def same(self, x, y):
        return self.find_root(x) == self.find_root(y)
    
    def count(self, x):
        return -self.root[self.find_root(x)]    
    
    def members(self, x):
        root = self.find_root(x)
        return [i for i in range(self.n) if self.find_root(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.root) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

n, m = map(int,input().rstrip().split())
AB=[list(map(int,input().rstrip().split()))for _ in range(m)]
u = UnionFind(n)
for a,b in AB:
    u.unite(a-1,b-1)
print(u.group_count()-1)

Measured memory_bytes: 30208
while True:
    hit=0
    bur=0
    a,una=(input().split())
    if a=='0' and una=='0':
        break
    a=list(a)
    una=list(una)
    for k in range(4):
        if a[k]==una[k]:
            hit+=1
    for d in range(4):
        for s in range(4):
            if a[d]==una[s]:
                bur+=1
    print(str(hit)+' '+str(bur-hit))


Measured memory_bytes: 5576
#include <iostream>

using namespace std;

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

    int SN = N;
    int ans = 0;

    while (SN > 0){
        ans += SN % 10;
        SN /= 10;
    }

    if (N % ans == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

set<string> S;

void dfs(int n, string s) {
    if (n == 0) return;
    if (s != "") S.insert(s);
    dfs(n - 1, s + "3");
    dfs(n - 1, s + "5");
    dfs(n - 1, s + "7");
}

void Main() {
    ll N;
    cin >> N;
    dfs(10, "");
    ll ans = 0;
    for (string s : S) {
        ll x = stoll(s);
        vector<bool> check(10, false);
        for (char c : s) {
            int y = c - '0';
            check[y] = true;
        }
        if (x <= N && check[3] && check[5] && check[7]) {
            ans++;
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3328
#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include "bits/stdc++.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
//typedef tree<int, null_type, less<int>, rb_tree_tag, 
//             tree_order_statistics_node_update> 
//    ost;
#define rep(i,l,r)   for (int i = (l); i < (r); i++)
#define here cout << " Hey!!\n";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
template <typename T>
void etch(T V) {
	for (auto x : V)	cout << x << ' ' ;
	cout << '\n';
}
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
const int MOD = 998244353;
const int N = 2e5+5;
const int INF = 1000111000111000111LL;
const ld EPS = 1e-12;
const ld PI = 3.141592653589793116;
int dp[3005][3005];
int32_t main()
{
	SYNC
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	dp[0][0] = 1;
	c -= a;
	d -= b;
	rep(j,1,d+1) {
		dp[0][j] = (dp[0][j-1] * a)% MOD;
	}
	rep(i,1,c+1) {
		dp[i][0] = (dp[i-1][0] * b)% MOD;
	}
	rep(i,1,c+1) {
		rep(j,1,d+1) {
			dp[i][j] = dp[i-1][j] * (b+j) + dp[i][j-1] * (a+i)+ MOD - ((a+i-1) * (b+j-1) * dp[i-1][j-1])%MOD;
			dp[i][j] %= MOD;
		}
	}
	// rep(i,0,c+1) {
	// 	rep(j,0,d+1) {
	// 		cout << dp[i][j] << ' ';
	// 	}cout << '\n';
	// }
	cout << dp[c][d];
	return 0;
}

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

int main(){
	
	int a,b,f=0;
	cin>>a>>b;
	
	for(int i=1;i<4;i++){
		if((a*b*i) % 2 ==1){
			f=1;
			break;
		}
	}
	if(f==1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    cout << min(a * n, b) << endl;

    return 0;
}


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

vector<pair<ll,ll> > v;

double dist(ll i, ll j)
{
  double x = (v[i].first-v[j].first);
  double y = (v[i].second-v[j].second);
  return sqrt(x*x + y*y);
}

double fact(ll n)
{
  if(n==1)
  {
    return 1;
  } else {
    return n * fact(n-1);
  }
}

int main()
{
  ll n;
  cin >> n;
  ll x,y;
  rep(n)
  {
    cin >> x >> y;
    v.push_back(make_pair(x,y));
  }
  double sum = 0;

  for (ll i = 0; i < n-1; i++)
  {
    for (ll j = i+1; j < n; j++)
    {
      sum += dist(i,j);
    }
  }

  
  printf("%.10f", sum*2/(double)n);
  

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll n,res=0;
vvi g;

void dfs(int v,int p=-1){
	ll l=v+1,r=n-v;
	if(p>=0&&p<v) l=v-p;
	if(p>v) r=p-v;
	res+=l*r;
	for(auto u:g[v]) if(u!=p) dfs(u,v);
}

int main(){
	cin>>n;
	g=vvi(n);
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		u--,v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(0);
	cout<<res<<endl;
}

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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=605,MOD=1e9+7;
inline int mod(int x){return x<MOD?(x<0?x+MOD:x):x-MOD;}
int n,K,p[MAXN],cnt[MAXN][MAXN],dp[MAXN][MAXN],g[MAXN];
int DP(int l,int r){
	if(dp[l][r]!=-1)return dp[l][r];
	if(l==r)return dp[l][r]=0;
	if(l+1==r)return dp[l][r]=(p[l]==r||(!p[l]&&!p[r]))?1:0;
	
	if(cnt[l][r]==-1||cnt[l][r]&1)return dp[l][r]=0;
	else dp[l][r]=g[cnt[l][r]];
	for(int i=l+1;i<r;++i){
		if(cnt[i+1][r]!=-1)dp[l][r]=mod(dp[l][r]-(ll)DP(l,i)*g[cnt[i+1][r]]%MOD);
	}
	return dp[l][r];
}
int main() {
	n=read()*2;K=read();
	g[0]=1;
	for(int i=2;i<=n;i+=2)g[i]=(ll)g[i-2]*(i-1)%MOD;
	for(int i=1,a,b;i<=K;++i)a=read(),b=read(),p[a]=b,p[b]=a;
	for(int l=1;l<=n;++l){
		for(int r=l;r<=n;++r){
			cnt[l][r]=r-l+1;
			for(int i=l;i<=r;++i){
				if(!p[i])continue;
				if(p[i]<l||p[i]>r){cnt[l][r]=-1;break;}
				cnt[l][r]--;
			}
		}
	}
	memset(dp,-1,sizeof(dp));
	//int l,r;while(cin>>l>>r)cout<<DP(l,r)<<endl;
	int ans=0;
	for(int l=1;l<=n;++l){
		for(int r=l;r<=n;++r){
			int c=n-(r-l+1),ok=1;
			for(int i=1;i<l;++i){
				if(!p[i])continue;
				if(p[i]>=l&&p[i]<=r){ok=0;break;}
				c--;
			}
			if(!ok)continue;
			for(int i=r+1;i<=n;++i){
				if(!p[i])continue;
				if(p[i]>=l&&p[i]<=r){ok=0;break;}
				c--;
			}
			if(!ok)continue;
			ans=mod(ans+(ll)DP(l,r)*g[c]%MOD);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3072