akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;
const int maxn=10000+5;
const int inf=99999999;
struct node{
    int from,to,dist,cost;
    node(int from,int to,int dist,int cost):from(from),to(to),dist(dist),cost(cost){}
};
struct Edge{
    int v,d,cost;
    bool operator < (const Edge& rhs)const{
        return d>rhs.d;
    }
};
vector<node>edge;
vector<int>G[maxn];
int d[maxn]={},done[maxn]={};
int n,m;
void dijkstra(){
    priority_queue<Edge, vector<Edge> >q;
    memset(done,0,sizeof(done));
    d[1]=0;
    q.push({1,0,0});
    while(!q.empty()){
        int u=q.top().v;q.pop();
        if(done[u]) continue;
        done[u]=1;
        for(int i=0;i<G[u].size();i++){
            node& e=edge[G[u][i]];
            if(d[e.to]>d[u]+e.dist){
                d[e.to]=d[u]+e.dist;
                q.push(Edge{e.to,d[e.to],0});
            }
        }
    }
}
int main()
{
    while(scanf("%d%d",&n,&m)==2 &&(n+m)){
        edge.clear();
        fill(d,d+1+n,inf);
        for(int i=0;i<=n;i++) G[i].clear();
        for(int i=0;i<m;i++){
            int s,t,d,c;
            scanf("%d%d%d%d",&s,&t,&d,&c);
            edge.push_back(node(s,t,d,c));
            G[s].push_back(edge.size()-1);
            edge.push_back(node(t,s,d,c));
            G[t].push_back(edge.size()-1);
        }
        dijkstra();
        int ans=0;
        for(int i=2;i<=n;i++){
            int min_ans=inf;
            for(int j=0;j<G[i].size();j++){
                node& e=edge[G[i][j]];
                if(d[e.to]+e.dist==d[i] && e.cost<min_ans)
                    min_ans=e.cost;
            }
            ans+=min_ans;
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 4708
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
	int N;
	cin >> N;
	vector<int> A(N+1), B(N);
	rep(i, N+1) cin >> A[i];
	rep(i, N) cin >> B[i];

	i64 ans = 0;
	rep(i, N){
		ans += min(A[i], B[i]);
		B[i] -= min(A[i], B[i]);

		ans += min(A[i+1], B[i]);
		A[i+1] -= min(A[i+1], B[i]);
	}

	cout << ans << endl;
}


Measured memory_bytes: 1024
import fractions
n,m=map(int,input().split())
s=list(str(input()))
t=list(str(input()))

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

l=lcm(n, m)
index=fractions.gcd(n,m)
#print(indexn,indexm)
for i in range(index):
    #print(i)
    if s[n//index*i]!=t[m//index*i]:
        print(-1)
        break
else:
    print(l)

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

//#define kk
//#define int long long
#define FOR(i, n) for(int i=1; i<=n; i++)
#define ff first
#define ss second
#define ll int
#define inf 1000000000
#define pb push_back

const long long INF=1e18+5;
 
typedef pair<int, int> pi;

int dp[3001][3001];

void solve(){
	string X, Y;
	cin>>X>>Y;
	
	int n=X.size(), m=Y.size();
	
	for(int i=0; i<=n; i++){
		for(int j=0; j<=m; j++){
			if(i==0 || j==0) dp[i][j]=0;
			else if(X[i-1]==Y[j-1]) dp[i][j]=dp[i-1][j-1]+1;
			else dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
		}
	}
	
	int a=n, b=m;
	string s="";
	while(a>=1 && b>=1){
		if(X[a-1]==Y[b-1]) s.pb(X[a-1]), a--, b--;
		else{
			if(dp[a][b-1]>dp[a-1][b]) b--;
			else a--;
		}
	}
	
	reverse(s.begin(), s.end());
	cout<<s<<endl;
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	#ifdef kk
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	
	int T=1;
	//cin>>T;
	
	while(T--){
		solve();
	}
}


Measured memory_bytes: 38740
#include <bits/stdc++.h>
using namespace std;
int arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};



int main()
{
	int n;
	cin>>n;
	cout<<arr[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int a, b, c, k, ans;
    cin >> a >> b >> c;
    int bi=max(a,b);
    bi=max(bi,c);
    if(bi==a)
        ans=b+c;
    else if(bi==b)
        ans=a+c;
    else
        ans=a+b;
    cin >> k;
    for(int i=0; i<k; i++)
        bi*=2;
    cout << bi+ans << '\n';
}

Measured memory_bytes: 256
H, W = map(int, input().split())
N = int(input())
A = sorted(enumerate(list(map(int, input().split()))), key=lambda x: x[1])
C = [["0" for _ in range(W)] for _ in range(H)]
w = h = 0
direction = 1
for i, a in A:
    for j in range(a):
        C[h][w] = str(i + 1)
        w += direction
        if w == -1:
            w = 0
            h += 1
            direction = 1
            continue
        if w == W:
            w = W - 1
            h += 1
            direction = -1
for c in C:
    print(" ".join(c))


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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int n, k, q;
int a[100010];
int cnt[100010];

int main()
{
    cin >> n >> k >> q;
    for (int i = 1; i <= q; i++)
    {
        cin >> a[i];
        cnt[a[i]]++;
    }

    for (int i = 1; i <= n; i++)
    {
        int point = k - q + cnt[i];
        if (point > 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

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

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

int n;
const int nax = 22;
int a[nax][nax];
int dp[1 << (nax)];
void add(int& a, int b) {
    a += b;
    if(a >= mod) a -= mod;
}

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

    cin >> n;
    rep(i,0,n) rep(j,0,n) cin >> a[i][j];
    memset(dp,0,sizeof(dp));
    
    dp[0] = 1;
    rep(i,0,(1 << n) - 1) { // if a bit is on that means we already used it!
        int x = __builtin_popcount(i); // this is the number of men that have been assigned values
        rep(j,0,n) {
            if(a[x][j] && !(i & (1 << j))) {
                int bm = i ^ (1 << j);
                add(dp[bm], dp[i]); // we are pushing values to the next, it means that to get to state with bm (st. bits are on), we add to it the dp value curr
            }
        }
    }
    cout << dp[(1 << n) - 1] << endl;
    return 0;
}


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

int main() {
    int m1,d1;
    int m2,d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;
    if(m2-m1==1) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;
int p[51];
int main(void){
	int N;
	cin >> N;
	int cnt = 0;
	for(int i=0;i<N;i++)cin >> p[i];
	for(int i=0;i<N;i++){
		if(p[i]!=(i+1))cnt++;
	}
	if(cnt>2)cout <<"NO"<<endl;
	else cout <<"YES"<<endl;
}

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

typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vp;
const int inf = 1e9;
const ll INF = 1e18;
const db eps = 1e-10;

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ep emplace
#define mem(a) memset(a, 0, sizeof(a))
#define copy(a, b) memcpy(a, b, sizeof(b))
#define PA cout << "pass\n"
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define TM cout << db(clock()) / CLOCKS_PER_SEC << '\n'

const int maxn = 5050;
int f[maxn];

int n, mod;
void add(int &x, int y){
    x += y;
    if(x >= mod) x -= mod;
}

int main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> mod;
    f[0] = 1;
    for(int i = 2; i <= n; i++){
        int t = min(i - 1, n + 2 - i);
        for(int j = t; j <= n; j++){
            add(f[j], f[j -  t]);
        }
    }
    int res = 0;
    for(int i = 0; i <= n; i++) add(res, 1ll * f[i] * (n - i) % mod);
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
typedef long long LL;
const int N=100+5;
const int INF=0x3f3f3f3f;
const double eps=1e-6;
char s[200005];

long long cnt[28];
int main()
{
    while(~scanf("%s", s))
    {
        memset(cnt,0,sizeof(cnt));
        long long x = strlen(s);
        long long ans = 0;
        for(int i = 0; i < x; i++)
            cnt[s[i] - 'a']++;
        for(int j = 0; j < 26; j++)
            ans += (x - cnt[j]) * cnt[j];
        printf("%lld\n", ans / 2 + 1);
    }
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<int> vec;

int h, w;
char mp[52][52];
void solve(){
	int a, b, c; cin >> a >> b >> c;
	cout << (a ^ b^c) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(6);
	//init();
	solve();
	stop
		return 0;
}


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

class Data {
public:
  int n, w, d;
  int p[128], s[128];
};

class Piece {
public:
  Piece() {}
  Piece(int w_, int h_, int gen_) : w(w_), h(h_), gen(gen_) {}
  int w, h;
  int gen;
};

bool operator < (const Piece& a, const Piece& b) {
  if( a.gen != b.gen ) {
    return a.gen < b.gen;
  }
  return a.w * a.h < b.w * b.h;
}

std::pair<Piece, Piece> Cut(const Piece& a, int s, int g) {
  if( s % (a.w + a.h) < a.w ) {
    int w1 = s % (a.w + a.h);
    int w2 = a.w - w1;
    return std::pair<Piece, Piece>(Piece(w1, a.h, g), Piece(w2, a.h, g));
  }
  else {
    int h1 = s % (a.w + a.h) - a.w;
    int h2 = a.h - h1;
    return std::pair<Piece, Piece>(Piece(a.w, h1, g), Piece(a.w, h2, g));
  }
}

void Load(Data& data) {
  scanf("%d %d %d", &data.n, &data.w, &data.d);
  for(int i = 0; i < data.n; ++i) {
    scanf("%d %d", &data.p[i], &data.s[i]);
    data.p[i] -= 1;
  }
}

void Solve(Data& d) {
  std::vector<Piece> ps;
  std::vector<Piece> ps2;
  ps.push_back(Piece(d.w, d.d, 0));
  for(int i = 0; i < d.n; ++i) {
    auto pp = Cut(ps[d.p[i]], d.s[i], i);
    ps2.clear();
    for(int j = 0; j < d.p[i]; ++j) {
      ps2.push_back(ps[j]);
    }
    for(int j = d.p[i] + 1; j < (int)ps.size(); ++j) {
      ps2.push_back(ps[j]);
    }
    ps2.push_back(pp.first);
    ps2.push_back(pp.second);
    std::sort(ps2.begin(), ps2.end());
    std::swap(ps, ps2);
  }
  for(int i = 0; i < (int)ps.size(); ++i) {
    ps[i].gen = 0;
  }
  std::sort(ps.begin(), ps.end());
  printf("%d", ps[0].w * ps[0].h);
  for(int i = 1; i < (int)ps.size(); ++i) {
    printf(" %d", ps[i].w * ps[i].h);
  }
  puts("");
}

int main() {
  Data data;
  for(;;) {
    Load(data);
    if( data.n == 0 and data.w == 0 and data.d == 0 ) break;
    Solve(data);
  }
  
  return 0;
}

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

int digitSum(int n){
    int s=0;
    while(n!=0){
        s+=n%10;
        n/=10;
    }

    return s;
}

int main(void){
    int N,A,B; cin >> N >> A >> B;
    int ans=0;

    for(int i=1; i<=N; i++){
        if(A<=digitSum(i) and digitSum(i)<=B) ans+=i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string n;
	cin>>n;
	if(n[0]==n[1] || n[1]==n[2] || n[2]==n[3])
	{
		cout<<"Bad";
	}
	else
	{
		cout<<"Good";
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <map>

using namespace std;

typedef long long ll;

int main(){
    int N;
    cin >> N;
    set<string> s;
    set<string>::iterator ite;
    map<string,int> m;
    ll count = 0;
    for(int i=0;i<N;i++){
        string s1;
        cin >> s1;
        sort(s1.begin(),s1.end());
        if(s.empty()){
            s.insert(s1);
            m[s1] = 0;
        }else{
            ite=s.find(s1);
            if(ite!=s.end()){
                m[s1]++;
                count += m[s1];
            }else{
                s.insert(s1);
                m[s1]=0;
                
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 20608
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long int ll;

ll a, b, c, d, e;
ll N, H, W;
void input()
{
    cin >> a >> b;
}
void solve()
{
}

int main()
{
    input();
    solve();
    cout << (a - 1) * (b - 1) << endl;
}

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

bool isPrime(int number)
{
    int max = std::sqrt(number);
    for (int i = 2; i <= max; i = i + 1) {
        if(number % i == 0) {
            return(false);
        }
    }
    return(true);
}

int main()
{
    int N, number;
    int counter = 0;
    std::cin >> N;
    for (int i = 0; i < N; i++) {
        std::cin >> number;
        if (isPrime(number)) {
            counter++;
        }
    }
    std::cout << counter << std::endl;
}


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


int main(){
	vector<int> v(0),vv(0);
	int n, k, a, count = 0,tmp;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a;
		v.push_back(a);
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < (int)v.size(); i++) {
		if (i == 0) { tmp = v[i]; }
		if (tmp == v[i]) { count++; }
		else { vv.push_back(count); count = 1; tmp = v[i]; }
	}
	vv.push_back(count);
	sort(vv.begin(), vv.end());
	int result = 0;
	for (int i = 0; i < (int)vv.size() - k; i++) {
		result += vv[i];
	}
	cout << result;
	return 0;
}

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

static int heap[2000000+1];
static int heap_size = 0;

static void exchange(int A[], int x, int y) {
    int t = A[x];
    A[x] = A[y];
    A[y] = t;

    return;
}

static void sink(int A[], int size, int i) {
    int l = i * 2;
    int r = i * 2 + 1;
    int larger;
    
    if ( l > size ) {           /* no child */
        return;
    }

    if ( r > size ) {           /* left is only one child */
        larger = l;
    } else {
        if ( A[l] > A[r] ) {
            larger = l;
        } else {
            larger = r;
        }
    }

    if ( A[i] < A[larger] ) {
        exchange(A, i, larger);
        sink(A, size, larger);
    }

    return;
}

static void swimUp(int A[], int size, int i) {
    int parent = i / 2;

    if ( parent < 1 ) {
        return;                 /* no parent */
    }

    if ( A[parent] < A[i] ) {
        exchange(A, parent, i);
        swimUp(A, size, parent);
    }

    return;
}

static void insert(int k) {
    heap_size++;
    heap[heap_size] = k;
    swimUp(heap, heap_size, heap_size);

    return;
}

static int extractMax(void) {
    int max = heap[1];

    exchange(heap, 1, heap_size);
    heap_size--;

    sink(heap, heap_size, 1);

    return max;
}
    
int main(int argc, char* argv[]) {
    char buf[20];
    int num;

    while ( scanf("%s %d\n", buf, &num) != EOF ) {
        if        ( strcmp("end", buf) == 0 ) {
            break;
        } else if ( strcmp("insert", buf) == 0 ) {
            insert(num);
        } else if ( strcmp("extract", buf) == 0 ) {
            int max = extractMax();
            printf("%d\n", max);
        }
    }

    return 0;
}
    



Measured memory_bytes: 5744
function main(input) {
  inputs = input.split('\n')
  values = inputs[0].split(' ')
  values = values.map(v => Number(v))

  if (
    (values[0] === values[1] && values[0] !== values[2]) ||
    (values[1] === values[2] && values[0] !== values[1]) ||
    (values[0] === values[2] && values[0] !== values[1])
  ) {
    console.log('Yes')
  } else {
    console.log('No')
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 9420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    ll N,K;
    cin >> N >> K;
  	ll k=K/2;
  	ll P=N/K;
  	ll p=N/k;
    if(K%2==0)cout << setprecision(16) << pow(P,3)+pow(p-P,3);
    else cout << setprecision(16) << pow(P,3);

}

/*



 */






Measured memory_bytes: 384
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)

def main():
    x = int(input().strip())
    if 400 <= x and x <= 599:
        print(8)
    elif 600 <= x and x <= 799:
        print(7)
    elif 800 <= x and x <= 999:
        print(6)
    elif 1000 <= x and x <= 1199:
        print(5)
    elif 1200 <= x and x <= 1399:
        print(4)
    elif 1400 <= x and x <= 1599:
        print(3)
    elif 1600 <= x and x <= 1799:
        print(2)
    elif 1800 <= x and x <= 1999:
        print(1)

    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 61760
#include <stdio.h>
#include <math.h>

#include <time.h>

static clock_t start_time,end_time;
void clock_start(){
	start_time = clock();
}
void clock_end(char *msg){
	end_time = clock();
	printf("[%s]%ld\n",msg,(end_time-start_time));
}

int main(int argc, char** argv){
	int n,data;
	int count;
	int i,j,data_limit,found;

	// Init Counter
	count = 0;

//	clock_start();

	// Input n
	scanf("%d",&n);
	for(i=0;i<n;i++){
		// Inpu Data
		scanf("%d",&data);
		// Check Prime or Not
		found = 0;
		data_limit = (int)sqrt(data)+1; 
		if( data_limit >= data ){
			data_limit = data - 1;
		}
		for(j=2;j<=data_limit;j++){
			if( data % j == 0 ){
				found = 1;
				break;
			}
		}
		if( !found ){
			count++;
		}
	}

//	clock_end("Check");

	// Output
	printf("%d\n",count);

	return 0;
}

Measured memory_bytes: 596
import java.util.Stack;
import java.util.Scanner;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static long res = 0;
    public static void main(String[] args) throws Exception {
        while (sc.hasNext()) {
            int n = sc.nextInt();
            for (int i = 1; i <= 600/n; i++) {
                res += (long)Math.pow((i-1)*n,2)*n;
            }
            System.out.println(res);
            res = 0;
        }
    }
}

Measured memory_bytes: 25936
#include <stdio.h>
#include <math.h>

int main(void) {
	
	/*
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	*/
	
	/*
	printf("%d ",a/b);
	printf("%d ",a%b);
	printf("%lf\n",(double)a/b);
	*/
	
	/*
	double r;
	scanf("%lf",&r);
	printf("%lf ",r*r* M_PI);
	printf("%lf\n",r*2*M_PI);
	*/
	
	int a,b,x,y;
	char o;
	while (1){
		scanf("%d %c %d",&a,&o,&b);
		if(o=='?') break;
		if(o=='+'){
			x=a+b;
		}
		else if(o=='-'){
			x=a-b;
		}
		else if(o=='*'){
			x=a*b;
		}
		else if(o=='/'){
			x=a/b;
		}
		printf("%d\n",x);
	}
	
	return 0;
}



Measured memory_bytes: 2148
#include <iostream>
#include <vector>

using namespace std;

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

    vector<bool> d(10, false);
    for (int i = 0; i < k; i++) {
        int di;
        cin >> di;
        d[di] = true;
    }

    int res = n;
    for (; ; res++) {
        bool valid = true;
        for (int i = res; i > 0; i /= 10) {
            valid = (valid && !d[i % 10]);
        }

        if (valid) {
            break;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  string s, t;
  cin>>s;
  cin>>t;
  int n = s.size();
  int ans = 0;
  REP(i, n) if(s[i] != t[i]) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3924
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,C;
  cin >> N>>M>>C;
  
  vector<int> B(M);
  for (int i=0;i<M;i++) {
    cin >> B.at(i);
  }
  
  vector<vector<int>> A(N,vector<int>(M));
  for (int i=0;i<N;i++) {
    for (int j=0;j<M;j++) {
      cin >> A.at(i).at(j);
    }
  }
  
  int count=0;
  long long m=0;
  for (int i=0;i<N;i++) {
    for (int j=0;j<M;j++) {
      m += A.at(i).at(j)*B.at(j);
    }
    if (m+C>0) {
      count++;
    }
    m=0;
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
N,x =map(int, input().split())
candy = list(map(int, input().split()))
eat = 0

for i in range(N - 1):
    if(candy[i] + candy[i + 1] > x):
        ex = candy[i] + candy[i + 1] - x
        eat += ex
        if(candy[i + 1] >= ex):
            candy[i + 1] -= ex
        else:
            candy[i] -= ex - candy[i + 1]
            candy[i + 1] = 0
print(eat)

Measured memory_bytes: 14052
// In the name of Allah 
#include <bits/stdc++.h>
using namespace std;

const int mod = 1e9+7, MAX = 2e5+5;

long long n, m, res=1;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);	
	cin >> n >> m;
	if (abs(n-m) > 1)
		return cout << 0 << endl, 0;

	if (n == m) 
		res *= 2;

	for ( int i = 1; i <= n; i++ )
		res *= i, res %= mod;
	
	for ( int i = 1; i <= m; i++ )
		res *= i, res %= mod;

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    #endif 
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) {
        // cout << "Case #" << tt - t << ": "; 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}

void solve() {  
    int l, r, d;
    cin >> l >> r >> d;
    cout << r / d - (l - 1) / d << '\n';   
}       

Measured memory_bytes: 3620
a,b = [int(i) for i in input().split()]
l = [input() for _ in range(a)]
skip_num = []

for i in range(b):
    key_set = set()
    for j in range(a):
        key_set |= set(l[j][i])
    if key_set == set('.'):
        skip_num.append(i)
        

ans = [[] for _ in range(a)]       
for k in range(a):
    if set(l[k]) ==  set('.'):
        pass
    else:
        for i in range(b):
            if i in skip_num :
                pass
            else:
                ans[k].append(l[k][i])
                

for i in ans:
    if i :
        print(''.join(i))
                

Measured memory_bytes: 3188
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] h = new int[n];
    List<Integer>  index = new ArrayList<>();
    int a = 0;
    for(int i = 0;i < n;i++){
      h[i] = sc.nextInt();
      if(i != 0 && h[i] <= h[i-1])
        index.add(i);
    }
    int sum = 0;
    for(int i = 0;i < index.size();i++){
      sum += h[index.get(i) - 1] - h[index.get(i)];
    }
    sum += h[n - 1];
    System.out.println(sum);
  }
}
 

Measured memory_bytes: 22996
from fractions import gcd

N,K = map(int, input().split())
A = sorted(list(map(int, input().split())))

M = max(A)
while len(A)>1:# Aすべてのgcd
    a1 = A.pop()
    a2 = A.pop()
    A.append(gcd(a1, a2))
G = A[0]
if K%G==0 and K<=M:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 16280
//AUTHOR - NAVEEN KUMAR(@naveen19991124)
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#inlcude<boost/multiprecision/cpp_dec_float.hpp>
#define ll long long
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define v vector<ll>
#define mp make_pair
#define fir first
#define sec second
#define _fast_ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
//using boost :: multiprecision :: cpp_int;
//using boost :: multiprecision :: cpp_dec_float_50;
//using boost :: multiprecision :: cpp_dec_float_100;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1;
a *= a; a %= mod;} return p % mod;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int main()
{
	_fast_
	ll t = 1;
	//cin>>t;
	while(t--){
	ll arr[3][3];
	rep(i,0,3)
	{
		rep(j,0,3)
		{
			cin>>arr[i][j];
		}
	}
	ll n;
	cin>>n;
	map<ll,ll>mm;
	ll no;
	f(n){
		cin>>no;
		mm[no]++;
	}
	bool ans = false;
	for(ll i = 0;i<3;i++)
	{
		bool flag = true;
		for(ll j = 0;j<3;j++)
		{
			if(mm[arr[i][j]] == 0)
			{
				flag = false;
				break;
			}
		}
		if(flag)
		{
			ans = true;
		}
	}
	for(ll i = 0;i<3;i++)
	{
		bool flag = true;
		for(ll j = 0;j<3;j++)
		{
			if(mm[arr[j][i]] == 0)
			{
				flag = false;
				break;
			}
		}
		if(flag)
		{
			ans = true;
		}
	}
	bool flag = true;

	for(ll i = 0;i<3;i++)
	{
		// bool flag = true;
		if(mm[arr[i][i]] == 0)
		{
			flag = false;
			break;
		}
		
	}
	if(flag)
		{
			ans= true;
		}
	flag = true;
	rep(i,0,3)
	{
		if(mm[arr[3-i-1][i]] == 0)
		{
			flag = false;
			break;
		}
	}
	if(flag)
		{
			ans = true;
		}
	if(ans)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long num = scanner.nextInt();
		long rate = scanner.nextInt();
		int count = 0;
		while(num != 0) {
			num /= rate;
			count++;
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9+7;
const int mod= 1e9 + 7;

vector<int> V;
string S;

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

	int N, K, ans = 0;

	cin >> N >> K;
	cin >> S;
	char cur = S[0];
	V.push_back(S[0]);
	FOR(i, 1, S.length()) {
		if (cur == S[i])ans++;
		else {
			V.push_back(S[i]);
			cur = S[i];
		}
	}
		ans += min(2 * K, int(V.size()) - 1);

		cout << ans << endl;




	return 0;
}


Measured memory_bytes: 956
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
using namespace std;
#define INFTY 1<<21

int main() {
  long long  a, b, x, ans;

  cin >> a >> b >> x;

  ans = b / x - a / x;

  if (a%x == 0) ans++;

  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String arg[]){
        Scanner scn=new Scanner(System.in);
        int x =scn.nextInt();
        int answer = 0;
        if(x!=1){
            for(int i=2;i<x;i++){
                for(int j=2;;j++){
                    double buf = Math.pow(i,j);
                    if(x<buf) break;
                    if(answer<buf) answer =(int) buf;
                }
            }
    }else{
        answer = 1;
    }
        System.out.println(answer);
    }
}

Measured memory_bytes: 21460
package main

import (
	"fmt"
	"math"
)

func solve(H int, ans int, count int) int {

	if H == 0 {
		return ans
	} else {
		H = int(math.Floor(float64(H) / 2))
		ans += count
		count *= 2
		return solve(H, ans, count)
	}
}

func main() {
	// Code for D - Caracal vs Monster
	var H int
	fmt.Scanf("%d", &H)

	/*
		var count int = 1

		var ans int
		for {
			if H == 0 {
				break
			} else {
				H = int(math.Floor(float64(H) / 2))
				ans += count
				count *= 2
			}
		}

		fmt.Println(ans)
	*/
	fmt.Println(solve(H, 0, 1))
}


Measured memory_bytes: 1836
n = gets.to_i
alist = gets.split(" ").map(&:to_i)

total = 1
max = 10**18
if alist.select{|num| num==0 }.length > 0 then
    puts "0"
else
    for i in 0..n-1 do
        total = total*alist[i]
        if total > max then
            puts "-1"
            break
        end
    end

    if total <= max then
        puts total
    end
end



Measured memory_bytes: 21672
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

vector<ll> lay;
vector<ll> p;
ll n, k;

//level n ,layer x

ll fun(ll n, ll x)
{
	if (n == 0)
		return (x <= 0 ? 0 : 1);
	if (x <= lay[n - 1] + 1)
		return fun(n - 1, x - 1);
	if (x <= lay[n])
		return p[n - 1] + 1 + fun(n - 1, x - 1 - (lay[n - 1] + 1));
	return p[n];
}

int main()
{
	cin >> n >> k;
	lay.push_back(1), p.push_back(1);
	for (int i = 1; i <= n; i++)
	{
		ll l = lay[i - 1] * 2 + 3;
		ll pp = p[i - 1] * 2 + 1;
		lay.push_back(l);
		p.push_back(pp);
	}
	cout << fun(n, k) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s1,s2;
	int ans=0;
	cin>>s1>>s2;
	for(int i=0;i<s1.size();i++)
		if(s1[i]!=s2[i])
			ans++;
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 3856
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;


int main(){
	int ans = 0;
	string s;
	cin >> s;
	for (int i = 0; i < s.length()/2; i++){
		if (s[i] != s[s.length()-i-1]) ans++;
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n;
  string s;
  cin >> n >> s;
  int dp[n+1];
  rep(i,n+1) dp[i]=-MAX;
  dp[0]=0;
  rep(i,n-2) {
    dp[i+1]=max(dp[i+1],dp[i]);
    if(s[i]=='1'&&s[i+1]=='0'&&s[i+2]=='1') {
      int k=i+2,cnt=0;
      while(k<n&&s[k]=='1') {
        k++;
        cnt++;
        dp[k]=max(dp[k],dp[i]+cnt);
      }
    }
    if(i>=2&&s[i-2]=='1'&&s[i-1]=='1') continue;
    if(s[i]=='1') {
      int k=i,cnt=0;
      while(k<n&&s[k]=='1') {
        cnt++;
        k++;
      }
      if(k<n-1&&s[k+1]=='1') dp[k+2]=max(dp[k+2],dp[i]+cnt);
    }
  }
  int ans=0;
  rep(i,n+1) ans=max(ans,dp[i]);
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}

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

int main(void){
		int n;
		scanf("%d", &n);
		int i = 0;
		while(++i <= n){
				int x = i;
				if(x % 3 == 0){
						cout << " " << i;
						continue;
				}
				while(x){
						if(x  % 10 == 3){
								cout << " " << i;
								break;
						}
						x /= 10;
				}
		}
		printf("\n");
		return 0;
}



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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll k,n;cin>>k>>n;
  ll a[n];rep(i,0,n)cin>>a[i];
  ll ma=a[0]+k-a[n-1];
  rep(i,1,n){
    chmax(ma,a[i]-a[i-1]);
  }

  out(k-ma);


  return 0;
}


Measured memory_bytes: 1792
/*
* @Author: _dp95
* @Date:   2020-04-04 10:00:15
*/
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 22 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

int ar[MAX][MAX], dp[1<<MAX] ;
int n ;

int sol( int mask ){
    int ind = bitcount( mask ) ;
    if( ind == n )
        return 1 ;
    if( dp[mask] != -1 )
        return dp[mask] ;
    int &ans = dp[mask] = 0 ;
    for( int i = 0 ; i < n ; i++ ){
        if( (mask&(1<<i)) or!(ar[ind][i] ) )
            continue ;
        ans += sol(mask|(1<<i)); 
        if( ans >= MOD )
            ans %= MOD ;
    }
    return ans ;
}

signed main( ){
  timesaver ;
  cin >> n ;
  for( int i = 0 ; i < n ; i++ )
    for( int j = 0 ; j < n ; j++ )
        cin >> ar[i][j] ;
  mem( dp, -1 ) ;
  cout << sol( 0 ) << nl ;
}

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

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main() {
  int K;
  cin>>K;
  int counter=0,a;
  for (int i = 1; i <= K; i++) {
  for (int j = 1; j <= K; j++) {
      a= gcd(i, j);
    for (int k = 1; k <= K; k++) {
  counter += gcd(a,k);
  }
  }
  }
  cout << counter<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
using namespace std;

int main(){
    int n;
    cin >> n;
    double ans;
    ans = ((n/2) + n%2 )/((double) n);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 200005
#define oo 2000000007
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, a[maxN];
deque<int> ans;

int main () {
    scanf("%d", &n);
    fto(i, 1, n) {
        scanf("%d", &a[i]);
        if (i%2 == 1) ans.push_back(a[i]);
        else ans.push_front(a[i]);
    }
    if (n%2 == 1) reverse(ans.begin(), ans.end());
    fto(i, 0, n-1) printf("%d ", ans[i]);

    return 0;
}


Measured memory_bytes: 3840
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <cfenv>
#include <cinttypes>
#include <cstdint>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <forward_list>
#include <initializer_list>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#if __cplusplus >= 201402L
#include <shared_mutex>
#endif

#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;

const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};

ll gcd(ll x,ll y){
    x = x%y;
    return x == 0 ? y : gcd(y,x);
}
ll lcm(ll x, ll y){
    return x*y/gcd(x,y);
}



int main(){
 
    string n;
    cin >> n;
    ll ans = 0;
    rep(i,n.length()){
        char a = (n[i]);
        ans += a-'0';
    }
    if(ans % 9 == 0 || n == "0") cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> mat;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int a, b, c;

void solve() {
  cin >> a >> b >> c;
  int d=c-a+b;
  if(d>=0) {
  cout << c - a + b << endl;
  }else{
    cout<<0<<endl;
  }
}

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

  // cout << fixed << setprecision(10);

  solve();

  return 0;
}


Measured memory_bytes: 256
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <limits>

using namespace std;

typedef int64_t i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
    i64 from, to, cost;
    edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
    edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

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

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}
//

#pragma endregion

int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };

int main() {
    i64 n, k;
    cin >> n >> k;
    double ans = 0.0;
    for (int i = 1; i <= n; ++i) {
        double tmp = 1.0 / n;
        i64 cnt = i;
        while(cnt < k){
            tmp *= 0.5;
            cnt *= 2;
        }
        ans += tmp;
    }
    cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
al = [int(input()) for i in range(n)]
m1, m2 = 0, 0
for a in al:
    if m1 < a:
        m1=a
    elif m2 < a:
        m2=a
for a in al:
    print(m2) if m1 == a else print(m1)


Measured memory_bytes: 12520
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

struct point{
  int b, c, d;
};

vector<vector<point>> points;
int n, m, q;

int dfs(int k, vi now, int last){
  int ret = 0;
  if(k == n){
    for(int i = 0; i < n; i++){
      for(int j = 0; j < points[i].size(); j++){
        if(now[points[i][j].b] - now[i] == points[i][j].c) ret += points[i][j].d;
      }
    }
    return ret;
  }
  for(int i = last; i <= m; i++){
    vi temp = now;
    temp.push_back(i);
    ret = max(ret, dfs(k+1, temp, i));
  }
  return ret;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  cin >> n >> m >> q;
  points = vector<vector<point>>(n);
  for(int i = 0; i < q; i++){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    points[a-1].push_back({b-1, c, d});
  }
  cout << dfs(0, vi{}, 1) << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 3656
S = input()
former = ""
isInSequence = False
result = len(S)
count = 0
for c in S:
    count += 1
    if isInSequence:
        result -= 1
        former += c
        isInSequence = False
        continue
    if c == former:
        if count == len(S):
            result -= 1
            continue
        isInSequence = True
    former = c
print(result)


Measured memory_bytes: 3500
def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x%y)

def lcd(x,y):
    return x*y//gcd(x,y)

n = int(input())
t = [int(input()) for i in range(n)]

ans = t[0]
for i in range(1,n):
    ans = lcd(ans,t[i])

print(ans)

Measured memory_bytes: 3060
import sys
readline=sys.stdin.readline

N=int(readline())
A=list(map(int,readline().split()))

money = 1000
maxm = 1000
kabu = 0
down = True # 下降しているという前提で始める

for i in range(len(A) - 1):
  if down: # 下がっているとき
    if A[i] < A[i + 1]: # 上がったなら買う
      kabu += money // A[i]
      money -= kabu * A[i]
      down = False
  else: # 上がっているとき
    if A[i] > A[i + 1]: # 下がったなら売る
      money += kabu * A[i]
      kabu = 0
      if money > maxm:
        maxm = money
      down = True
      
if kabu > 0: # 上がり続けているなら最後売れていない
  money += kabu * A[-1]
  
if money > maxm:
  maxm = money
  
print(maxm)


Measured memory_bytes: 9200
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int m,n;
  cin>>n>>m;
  int mx=0;
  for(i=0;i<n;i++){
    int sm=0;
    for(j=0;j<m;j++){
      int p;
      cin>>p;
      sm+=p;
    }
    mx=max(mx,sm);
  }
  cout<<mx<<endl;
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<ll, ll> P;



int main(){
    int n;  cin >> n;
    vector<ll> a(n, 0);
    vector<ll> count(n+1, 0);

    for(int i = 0; i < n; i++){
        cin >> a[i];
        count[a[i]]++;
    }

    ll total = 0;
    for(int i = 0; i <= n; i++){
        ll x = count[i];
        total += x * (x-1) / 2;
    }

    for(int i = 0; i < n; i++){
        ll dec = count[a[i]]-1;
        cout << total - dec << endl;
    }


    return 0;
}


Measured memory_bytes: 5760