akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    int n;
    long long X=0,x=0,ans=1000000000000000000LL;
    cin >> n;
    vector<long long> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        X += a[i];
    }
    for(int i=0;i<n;i++){
        x+=a[i];
        if(i+1<n) ans = min(ans,abs(X-2*x));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
const ll infl=1LL<<60;
int n, m;
template<class V, int NV> struct SegTree { //[l,r) rは含まないよ!
	V comp(V& l, V& r) { return min(l, r); };
 
	vector<V> val; SegTree() { val = vector<V>(NV * 2, infl); }
    //xy間の最小値をとる
	V get(int x, int y, int l = 0, int r = NV, int k = 1) {
		if (r <= x || y <= l)return infl; if (x <= l && r <= y)return val[k];
		auto a = get(x, y, l, (l + r) / 2, k * 2);
		auto b = get(x, y, (l + r) / 2, r, k * 2 + 1);
		return comp(a, b);
	}
	void update(int i, V v) {
		i += NV; val[i] = v;
		while (i > 1) i >>= 1, val[i] = comp(val[i * 2], val[i * 2 + 1]);
	}
	void add(int i, V v) { update(i, val[i + NV] + v); }
	V operator[](int x) { return get(x, x + 1); }
};
vector <p> q[100001];
SegTree<ll, 1<<17> st;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>m;
    for (int i = 0; i < m; i++)
    {
        ll templ ,tempr, tempc;
        cin >> templ>>tempr>>tempc;
        q[tempr].push_back(make_pair(templ,tempc));
    }
    //支点は0
    st.update(1,0);
    for(int i=2;i<=n;i++){
        for(int j=0;j<q[i].size();j++){
            int l=q[i][j].first;
            int cost=q[i][j].second;
            st.update(i,min(st[i],st.get(l,i)+cost));
        }
    }
    if(st[n]!=infl)
    cout << st[n] << "\n";
    else
    cout<<-1<<"\n";
}


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

int main()
{
    char a,b;
    cin>>a>>b;
    if(a>b){
        cout<<">"<<endl;
    }else if(a==b){
        cout<<"="<<endl;
    }else{
        cout<<"<"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  vector<int> C(3);
  for(int i=0;i<3;i++){
    cin >> C.at(i);
  } 
  if((C.at(2)-C.at(0) >= 0)&&(C.at(2)-C.at(0) <= C.at(1))){
    cout << "YES" <<endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int K;
	int i,j;
	int count=0;
	
	scanf("%d",&K);
	
	for(i=1;i<=K;i++){
		for(j=1;j<=K;j++){
			if(i%2 == 1){
				if(j%2 == 0){
					count+=1;
				}
			}
		}
	}
	
	printf("%d",count);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h, w;
    cin >> h >> w;
    char a[110][110];
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cin >> a[i][j];
        }
    }
    bool tate[110], yoko[110];
    for(int i=1; i<=h; i++){
        yoko[i] = false;
    }
    for(int i=1; i<=w; i++){
        tate[i] = false;
    }
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            if(a[i][j] == '#'){
                yoko[i] = true;
                tate[j] = true;
            }
        }
    }
    for(int i=1; i<=h; i++){
        if(yoko[i]){
            for(int j=1; j<=w; j++){
                if(tate[j]){
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str;
  cin >> str;
  
  int x = str.find_first_of('A');
  int y = str.find_last_of('Z');
  
  int ans = y - x + 1;
  
  cout << ans << endl;

}
             
 

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  i32 n, r;
  cin >> n >> r;
  if (n >= 10) {
    cout << r;
  } else {
    cout << r + 100 * (10 - n);
  }

  return 0;
}


Measured memory_bytes: 3564
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int                     integer;
#define int                     long long
typedef pair<int, int>          pii;
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define rep(i, a, b)            for(int i = a; i < (b); i++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<(x)<<endl
#define p2(x,y)                 out<<(x)<<' '<<(y)<<endl
#define p3(x,y,z)               out<<(x)<<' '<<(y)<<' '<<(z)<<endl
#define p4(x,y,z,w)             out<<(x)<<' '<<(y)<<' '<<(z)<<' '<<(w)<<endl
#define p1d(a,n)                for(int ix=0;ix<n-1;ix++) out<<a[ix]<<' '; out<<a[n-1]<<'\n';
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define pl(x)                   out<<(x)
#define pll(x)                  out<<(x)<<' '
#define range(v)                v.begin(),v.end()
#define all(x)                  begin(x), end(x)
#define sz(x)                   (int)(x).size()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

#define EACH(x, a) for (auto& x: a)
template<class T> void read_v(T& x, std::istream& in) {
    in >> (x);
}
template<class A> void read_vec(vector<A>& x, std::istream& in) {
    EACH(a, x)
        read_v(a, in);
}

ll iceildiv(const ll a, const ll b){ if(a==0){return 0;} return (1 + ((a - 1)/b));}
bool sortpairbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
template <typename T>
T factmod(T a, T modulus){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=modulus;} return res; }
template <typename T>
int powmod(T a, T b, const int m){ int ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
int power(T a, T b){ int ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}


void ssolve(std::istream& in, std::ostream& out){
    int n; s(n);
    int cnt = 0;
    bool ans = false;
    rep(i, 0, n){
        int a, b; s2(a, b);
        if(a == b){
            cnt++;
        }else{
            cnt = 0;
        }
        if(cnt >= 3){
            ans = true;
        }
    }
    p(ans?"Yes":"No");
    return;
}

class BGoToJail {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(nullptr);out.tie(nullptr);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    BGoToJail solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

Measured memory_bytes: 3560
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define mem0(a) memset(a,0,sizeof(a))
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
const int mod=1e9+7;
const int N=1e5+5;
int  a[N];
int main()
{
	int n;
	cin>>n;
	rep(i,0,n)
	cin>>a[i];
	int flag=0;
	int i,j,k;
for( i=0;i<n-1;i++)
	{  k=i;
		for( j=i+1;j<n;j++)
		{
			if(a[k]>a[j])k=j;
		}
		if(k!=i)
		{swap(a[i],a[k]);
		flag++;
		}
	}
if(flag>=2)
printf("NO\n");
else
printf("YES\n");
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

const ll N_MAX = 300005;

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];
void make(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll) i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

ll Combination(ll C, ll D){
    if(C<D) return 0;
    return fac[C]*(finv[D]*finv[C-D]%mod)%mod;
}

ll powLL(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res *= a;
            res %= mod;
        }
        a = a*a;
        a %= mod;
        n >>= 1;
    }
    return res;
}

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

    ll N, A, B, C;
    cin >> N >> A >> B >> C;
    ll a = A * inv[A+B] % mod;
    ll b = B * inv[A+B] % mod;
    ll c = 100 * inv[100-C] % mod;

    ll res = 0;
    for(int M=N;M<2*N;M++){
    	ll tmp1 = powLL(a, N);
    	tmp1 *= powLL(b, M-N);
    	tmp1 %= mod;
    	tmp1 *= Combination(M-1, N-1);
    	tmp1 %= mod;
    	res += (tmp1 * M % mod);
    	res %= mod;

    	ll tmp2 = powLL(a, M-N);
    	tmp2 *= powLL(b, N);
    	tmp2 %= mod;
    	tmp2 *= Combination(M-1, N-1);
    	tmp2 %= mod;
    	res += (tmp2 * M % mod);
    	res %= mod;
    }
    res *= c;
    res %= mod;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 7296
fun main(args: Array<String>) = println(run {
    val s = (1..3).map { readLine()!! }
    val i = intArrayOf(0,0,0)

    var t = 0
    while (true) {
        if(s[t].lastIndex < i[t]) return@run 'A'+t
        t = s[t][i[t]++]-'a'
    }

})

Measured memory_bytes: 33816
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define D(a) (double)(a)
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define vb vct<bool>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<' '; cout<<endl;
#define PI acos(-1.0)
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
#define rt return true
#define rf return false
///................function.....................///
#define siz(s) (int)(s.size())
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mod 1000000007
const int N=5005;
vll p(N),c(N);
int main()
{
    FIO;
    ll n,k,i,j;
    cin>>n>>k;
    for(i=1; i<=n; i++)
        cin>>p[i];
    for(i=1; i<=n; i++)
        cin>>c[i];
    ll res=LLONG_MIN;
    for(i=1; i<=n; i++)
    {
        ll tot=0LL;
        ll x=i;
        vll v1={0LL};
        do
        {
            x = p[x];
            tot+=c[x];
            v1.pb(c[x]);
            ///cout<<x<<" "<<p[i]<<" "<<c[x]<<endl;

        }while(x!=i);
        ll t1=0LL;
        for(j=1; j<siz(v1)&&j<=k; j++)
        {
            t1+=v1[j];
            ll now = t1;
            if(tot>0)
            {
                ll baki = (k-j)/(siz(v1)-1);
                now+=baki*tot;
            }
            res = max(res,now);
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3840
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

	public static void main(String[] args) {
		while (true) {
			int N = nextInt();
			if (N == 0) {
				break;
			}

			int M = nextInt();
			ArrayList<Edge> list = new ArrayList<Edge>();
			for (int i = 0; i < N; i++) {
				int D = nextInt();
				int P = nextInt();
				list.add(new Edge(D, P));
			}

			Collections.sort(list);

			int deathP = 0;
			for (Edge e : list) {
				if (M >= e.D) {
					M -= e.D;
				} else {
					deathP += (e.D - M) * e.P;
					M = 0;
				}
			}
			System.out.println(deathP);
		}

	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

}

class Edge implements Comparable<Edge> {
	int D, P;

	Edge(int d, int p) {
		this.D = d;
		this.P = p;
	}

	@Override
	public int compareTo(Edge arg0) {
		return arg0.P - this.P;
	}
}

Measured memory_bytes: 37340
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int q,h,s,d,n;
  cin>>q>>h>>s>>d>>n;
  q*=4;
  h*=2;
  s=min(s,min(h,q));
  if(s*2 < d){
    cout<<s*n<<endl;
  }else{
    cout<<(n/2)*d+(n%2)*s<<endl;
  }
  
  

  return 0;
}


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

int main() {
	int W, H, N, x, y, a, count = 0;
	cin >> W >> H >> N;
	bool M[100][100] = { false };
	for (int i = 0; i < N; i++) {
		cin >> x >> y >> a;
		if (a == 1) {
			for (int X = 0; X < x; X++) {
				for (int Y = 0; Y < H; Y++) {
					M[X][Y] = true;
				}
			}
		}
		if (a == 2) {
			for (int X = x; X < W; X++) {
				for (int Y = 0; Y < H; Y++) {
					M[X][Y] = true;
				}
			}
		}
		if (a == 3) {
			for (int X = 0; X < W; X++) {
				for (int Y = 0; Y < y; Y++) {
					M[X][Y] = true;
				}
			}
		}
		if (a == 4) {
			for (int X = 0; X < W; X++) {
				for (int Y = y; Y < H; Y++) {
					M[X][Y] = true;
				}
			}
		}
	}
	for (int X = 0; X < W; X++) {
		for (int Y = 0; Y < H; Y++) {
			if (M[X][Y]) count++;
		}
	}
	cout << W * H - count << endl;
}

Measured memory_bytes: 256
class UnionFind:
    # 初期化
    def __init__(self, n):
        # 根なら-size, 子なら親の頂点
        self.par = [-1] * n
        # 木の高さ
        self.rank = [0] * n

    # 検索
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        # 異なる集合に属する場合のみ併合
        if x != y:
            # 高い方をxとする。
            if self.rank[x] < self.rank[y]:
                x,y = y,x
            # 同じ高さの時は高さ+1
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            # yの親をxとし、xのサイズにyのサイズを加える
            self.par[x] += self.par[y]
            self.par[y] = x

    # 同集合判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # 集合の大きさ
    def size(self, x):
        return -self.par[self.find(x)]


n,m = map(int, input().split())

ab = []
for i in range(m):
    a,b = map(int, input().split())
    a-=1
    b-=1
    ab.append([a,b])

u = UnionFind(n)

f = sum(i for i in range(n))
ans = [f]

for i in range(m):
    a = ab[-1-i][0]
    b = ab[-1-i][1]
    if not u.same(a,b):
        ans.append(ans[-1]-u.size(a)*u.size(b))
        u.unite(a, b)
    else:
        ans.append(ans[-1])

for i in range(m):
    print(ans[-2-i])




Measured memory_bytes: 115032
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=2020000000;

int A,B,C,D;
int min(int a,int b){
	if(a<b) return a;
	else return b;
}

int main() {
	cin>>A>>B>>C>>D;
	cout<<min(A,B)+min(C,D)<<endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mx 1005
#define fr first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

char s1[mx][mx];
ll dp[mx][mx];
int r,c;

bool okay(int i, int j)
{
    if(i>=0 && i<r && j>=0 && j<c && s1[i][j] == '.') return 1;
    return 0;
}

ll func(int i, int j)
{
    if(i == r-1 && j == c-1) return 1;
    ll &ret=dp[i][j];
    if(ret!=-1) return ret;
    ll ans1=0,ans2=0;
    if(okay(i,j+1)){
        ans1 = (ans1%mod+func(i,j+1)%mod)%mod;
    }
    if(okay(i+1,j)){
        ans2 += (ans2%mod+func(i+1,j)%mod)%mod;
    }
    ll cc = (ans1%mod+ans2%mod)%mod;
    return ret = cc;

}
int main()
{
   fast;
   cin >> r >> c;
   memset(dp,-1,sizeof dp);
   for(int i=0; i<r; i++) cin >> s1[i];
   cout << func(0,0) << "\n";
   return 0;
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<int,ll>Pil;
typedef pair<P1,ll> P2;
typedef list<int> li;
typedef list<li> lli;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x;
	ll cost;
};

int main(){

	string s;
	cin>>s;
	ll t=0;
	rep(i,s.size()){
		int x=s[i];
		t+=x-48;
	}
	if(t%9==0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 3708
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    string a, b;
    ll c = 1;
    for (ll i = 0; i < s.size(); i++)
    {
        a.push_back(i % 2 + '0');
        b.push_back(c % 2 + '0');
        c++;
    }
    ll aa = 0, bb = 0;
    for (ll i = 0; i < s.size(); i++)
    {
        if (a[i] != s[i])
        {
            aa++;
        }
        if (b[i] != s[i])
        {
            bb++;
        }
    }
    cout << min(aa, bb) << endl;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		String SArray[] = S.split("");
		int count = 0;

		for(int i = 0; i < S.length(); i++) {
			if (SArray[i].equals("o")){
					count++;
			}
		}

		System.out.println(700 + (100 * count));
	}

}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		double pi = Math.PI;
		double area = r*r*pi;
		double length = 2*pi*r;
		System.out.printf("%f %f", area, length);
		sc.close();
	}
}


Measured memory_bytes: 28284
N=int(input())
p = list(map(int,input().split()))


# print(p)
sp = sorted(p)
# print(sp)

diff = 0
for i in range(N):
    if p[i] != sp[i]:
        diff+=1

if diff==2 or diff==0:
    print("YES")
else:
    print("NO")


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

int main() {
  
  int N, A, B;
  cin >> N >> A >> B;
  
  int sum_result = 0;
  
  for (int n = 1; n <= N; n++) {
    
    int num_10000 = n / 10000;
    int num_1000  = (n % 10000) / 1000;
    int num_100   = ((n % 10000) % 1000) / 100;
    int num_10    = (((n % 10000) % 1000) % 100) / 10;
    int num_1     = (((n % 10000) % 1000) % 100) % 10;
    int sum = num_10000 + num_1000 + num_100 + num_10 + num_1;
    
    if (sum >= A && sum <= B) sum_result += n;
    
  }
  
  cout << sum_result << endl;
  
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  
  sort(A.begin(), A.end());

  

  int ans=1;
 
  for(int i=0; i<N-1; i++){
    if(A.at(i)!=A.at(i+1)){
      ans++;
    }
  }
  
  cout<<ans<<endl;
  

  

}






Measured memory_bytes: 256
/* _________________________________________________________________________________________________
  |                                                                                                 |
  |                             Author      : Aditya Ahuja                                          |
  |                             Date        : Thu, 20th Jun 2019                                    |
  |_________________________________________________________________________________________________|
*/
 
#include<bits/stdc++.h>
using namespace std;

// #define int long long

#define pb          push_back
#define F           first
#define S           second
#define rep(i,a,b)  for(int i=a; i<b; i++)
#define all(a)      (a).begin(),(a).end()
#define ret(x)      {cout << (x) << endl; return;}
#define sz(x)       (int)x.size()
#define type(x)     typeid(x).name()

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

#define wa(x)       cout << (#x) << " -------- " << (x) << endl
#define pvi(v)      {for(auto it:v) cout << it << " "; cout << endl;}
#define line1	    printf("---------------------------\n")

// #define wa //
// #define line1 //
// #define pvi //
// #define printf //

void solve();
signed main() {
	//ios_base::sync_with_stdio(false); cin.tie(NULL);
	////cout << fixed << setprecision(10);

	int t=1; 
	//cin>>t;
	while(t--) solve();
	return 0;
}

//___________________________________________________________________________________________________

void solve() {

	int n,k;
	cin>>n>>k;

	vi a(n);
	rep(i,0,n) cin>>a[i];

	vi dp(n, 1e9+5);
	dp[0] = 0;

	rep(i,0,n){
		rep(j,i+1,k+i+1){
			if(j < n){
				dp[j] = min(dp[j], dp[i] + abs(a[j]-a[i]));
			}
		}
	}

	ret(dp[n-1]);
}


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

void solve()
{
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i<s.length(); i++)
    {
        if(s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
}


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll t;
    solve();
    return 0;
}


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

int main(){
	int a, b ,c;
	cin >> a >> b >> c;
	int sum = a+b+c;
	if(sum >= 22) cout << "bust" << endl;
	else{
		cout << "win" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#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 ll long long
#define ld long double
#define fo(i,v,e) for(v=i;v<e;v++)
#define rfo(i,v,e) for(v=i;v>e;v--)
#define pb(x) push_back(x)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fi first 
#define se second
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vl vector<ll>
#define sz(x) (int)x.size()
#define ull unsigned long long
#define vvi vector<vi>
#define vvl vector<vl>
#define vpi vector<pii>
#define vpl vector<pll>
ll mod = 1000000007;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define openfile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x);
#define fastio
#else
#define openfile
#define deb(x...)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#endif
void init()
{
    
}
void solve()
{
    ll n,m,i,j,k,l,tot = 0,ans = 0;cin>>n>>m>>k;
    char c;
    vvl mat(n,vl(m));
    fo(0,i,n)
    {
        fo(0,j,m)
        {
            cin>>c;
            mat[i][j] = (c=='#');
        }
    }
    fo(0,i,(1ll<<(n+m)))
    {
        ll temp = 0;
        fo(0,j,n)
        {
            fo(0,l,m)
            {
                if(((i>>j) & 1)==0 and ((i>>n+l) & 1)==0)
                {
                    temp+=mat[j][l];
                }
            }
        }
        if(temp==k)ans++;
    }
    cout<<ans<<endl;
}
int main()
{
    init();
    // openfile;fastio;
    int T = 1;
    // cin>>T;
    while(T--)
    {
        solve();
    }
}

Measured memory_bytes: 3604
N,M=map(int, input().split())

cum=[0]*(N+1)
div_to_cnt={}
for i, n in enumerate(map(int, input().split()), start=1):
    cum[i] = cum[i-1] + n
    div = cum[i] % M
    if not div in div_to_cnt: div_to_cnt[div] = 0
    div_to_cnt[div] += 1

res = 0
for k,v in div_to_cnt.items():
    if k == 0: res += v
    res += v*(v-1) // 2
print(res)


Measured memory_bytes: 17376
INF = 10000000000
count = 0

def merge(A, left, mid, right):
    global count 
    L = A[left:mid] + [INF]
    R = A[mid:right] + [INF]
      
    i, j = 0, 0
    for k in range(left, right):
        count = count + 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i = i + 1
        else:
            A[k] = R[j]
            j = j + 1
    return count
  
def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        countL = mergeSort(A, left, mid)
        countR = mergeSort(A, mid, right)
        return merge(A, left, mid, right)
         
    return 0
          
  
n = int(input())
A = [int(i) for i in input().split()]
#A = list(np.round(np.random.rand(n)*10,0))
count = mergeSort(A, 0, n)
print(*A)
print(count)


Measured memory_bytes: 61656
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;
const int INF = 1001001001;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

int n;
ll k;
vector<ll> a;
vector<ll> negative, positive, zero;
int sz_p, sz_n, sz_z, sz_h;
ll negative_cnt;
ll zero_cnt;

bool C2(ll x){
    ll res = 0;
    for(int i = 0; i < sz_n - 1; ++i){
        res += upper_bound(negative.begin() + i + 1, negative.end(), x / negative[i]) - (negative.begin() + i + 1);
    }
    for(int i = 0; i < sz_p - 1; ++i){
        res += upper_bound(positive.begin() + i + 1, positive.end(), x / positive[i]) - (positive.begin() + i + 1);
    }
    return res >= k - negative_cnt - zero_cnt;
}

bool C1(ll x){
    ll res = 0;
    for(int i = 0; i < sz_n; ++i){
        res += upper_bound(positive.begin(), positive.end(), x / negative[i]) - positive.begin();
    }
    return res <= negative_cnt - k;
}

int main(){
    cin >> n >> k;
    a.resize(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        if(a[i] == 0)   zero.push_back(a[i]);
        else if(a[i] > 0)   positive.push_back(a[i]);
        else    negative.push_back(-a[i]);
    }
    sz_p = positive.size();
    sz_n = negative.size();
    sz_z = zero.size();

    negative_cnt = (ll)sz_p * sz_n;
    zero_cnt = (ll)sz_z * (n - sz_z) + (ll)sz_z * (sz_z - 1) / 2;
    if(k > negative_cnt && k <= negative_cnt + zero_cnt){
        cout << 0 << endl;
        return 0;
    }
    sort(negative.begin(), negative.end());
    sort(positive.begin(), positive.end());
    if(k <= negative_cnt){
        ll lb = 0, ub = 1e+18;
        while(ub - lb > 1){
            ll mid = (lb + ub) / 2;
            if(C1(mid)) lb = mid;
            else    ub = mid;
        }
        cout << -ub << endl;
        return 0;
    }
    
    ll lb = 0, ub = 1e+18;
    while(ub - lb > 1){
        ll mid = (lb + ub) / 2;
        if(C2(mid))  ub = mid;
        else    lb = mid;
    }
    cout << ub << endl;
}

Measured memory_bytes: 4084
n = int(input())
cumsum_w = [0]
for w in map(int, input().split()):
  cumsum_w.append(cumsum_w[-1] + w)
minimum = 100
for s in cumsum_w[1:-1]:
  minimum = min(minimum, abs(cumsum_w[-1] - 2 * s))
print(minimum)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 2000000000
#define MOD 1000000007
#define N 505
#define M 1000005
#define LOG 19
#define KOK 32000
#define EPS 0.000000001
using namespace std;
#define fill fewfwe

int n,x,fill[N*N];
vector<ii> v;

void fail() {

	printf("No");

	exit(0);

}

int main() {

//	freopen("input.txt","r",stdin);

	scanf("%d",&n);

	for(int i=1;i<=n;i++) {

		scanf("%d",&x);

		if(fill[x]) fail();

		fill[x]=i;

		v.pb({x,i});

	}

	sort(all(v));

	for(int i=0;i<n;i++) {

		int tot=v[i].nd-1;

		for(int j=1;tot && j<=v[i].st-1;j++) {

			if(!fill[j]) {

				fill[j]=v[i].nd;

				tot--;

			}

		}

		if(tot) fail();

	}

	for(int i=n-1;i>=0;i--) {

		int tot=n-v[i].nd;

		for(int j=v[i].st+1;tot && j<=n*n;j++) {

			if(!fill[j]) {

				fill[j]=v[i].nd;

				tot--;

			}

		}

		if(tot) fail();

	}

	printf("Yes\n");

	for(int i=1;i<=n*n;i++) {

		if(!fill[i]) assert(0);

		printf("%d ",fill[i]);

	}


}



Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

char agct_convert(char b);

char agct_convert(char b){
	char b2;
	if (b == 'A') {
		b2 = 'T';
	} else {
		if (b == 'C') {
			b2 = 'G';
		} else {
			if (b == 'G') {
				b2 = 'C';
			} else {
				if (b == 'T') {
					b2 = 'A';
				} else {
					b2 = b;
				}
			}
		}
	}
	return(b2);
}


int main() {
	string b;
	char b_i;
	int b_n;
	cin >> b;
	b_n = b.length();
	int n, cand = 0;
	for (int i = 0; i < b_n; ++i)
	{	
		if (b[i] == agct_convert(b[i])) {
			if (n < cand) {
				n = cand;
			}
			cand = 0;
		} else {
			cand += 1;
		}
	}
	if (n < cand) {
		n = cand;
	}
	cout << n << endl;	
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
    function Main(inputString) {
    	// 1行目がinput[0], 2行目がinput[1], …に入る
        inputString = inputString.trim();
    	let a = parseInt( inputString.substr(0,1));
    	let b = parseInt( inputString.substr(1,1));
    	let c = parseInt( inputString.substr(2,1));
        let isContain = '';
        if( (a==7) || (b==7) || (c==7) ){
            isContain = 'Yes';
        }else {
            isContain = 'No';
        }
    	//出力
    	console.log(isContain);
    }
    //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));
    //Main('711');

Measured memory_bytes: 29628
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 100000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
int vis[N];
int main() {
    int n;
    scanf("%d",&n);
    deque<pair<int,int> > Q;
    Q.push_front(make_pair(1,1));
    while(!Q.empty()){
        pair<int,int> temp=Q.front();
        Q.pop_front();
        if(!vis[temp.first]){
            vis[temp.first]=true;
            if(temp.first==0){
                printf("%d\n",temp.second);
                break;
            }
            Q.push_front(make_pair((temp.first*10)%n,temp.second));
            Q.push_back(make_pair((temp.first+1)%n,temp.second+1));
        }
    }
    return 0;
}

Measured memory_bytes: 1408
#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;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> opset;
#define SZ(X) ((int)X.size())
#define ALL(I) I.begin(), I.end()
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define eps 1e-12
#define INF 1000000007
#define MXN 200005
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
const LL mod = INF;

inline LL add(LL x, LL y){
	return x + y >= mod ? x + y - mod : x + y;
}

int n, a[MXN];
LL dp[MXN], ans;

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++){
		scanf("%d", &a[i]);
		if(a[i] == a[i - 1]){
			i --;
			n --;
		}
	}
	dp[a[1]] = 1;
	for(int i = 1; i <= n; i ++){
		ans = dp[a[i]];
		dp[a[i + 1]] = add(dp[a[i + 1]], dp[a[i]]);
	}
	printf("%lld\n", ans);
}




Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  int H, W, h, w; cin >> H >> W >> h >> w;
  int ans = H*W-h*W-(H-h)*w;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] p = new int[n];
		for(int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}
		Arrays.sort(p);
		int sum = 0;
		for(int i = 0; i < k; i++) {
			sum += p[i];
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 38872
#include <iostream>
#include <queue>
using namespace std;
const int N = 20000+10;
int prime[N], cnt = 0;
bool vis[N]; 
int phi[N], mius[N];

bool isprime(int x) {
    if(x==2) return 1;
    for(int i=2;i*i<=x;i++)
        if(x%i==0) return 0;
    return 1;
}
void getPrime() {
    phi[1] = 1, mius[1] = 1;
    for (int i = 2; i < N; i ++) {
        if (vis[i] == 0) {
            prime[++ cnt] = i;
            phi[i] = i - 1;
            mius[i] = -1;
        }
        for (int j = 1; j <= cnt && prime[j] * i < N; j ++) {
            vis[prime[j] * i] = 1;
            if (i % prime[j] == 0) {           
                mius[prime[j] * i] = 0;
                phi[prime[j] * i] = phi[i] * prime[j];
                break;
            } else {
                mius[prime[j] * i] = mius[i] * -1;
                phi[prime[j] * i] = phi[i] * (prime[j] - 1);
            }
        }
    }
}

int main() {


    getPrime();
    int n; cin >> n;
    int cnt=0;
    for(int i=1;;i++) {

        if(prime[i]%5==1) {
            cnt++;
            printf("%d ", prime[i]);
        }
        if(cnt==n) return 0;
    }
}

Measured memory_bytes: 384
N = int(input())
xs, ys = [], []
for _ in range(N):
    x, y = map(int, input().split())
    xs.append(x)
    ys.append(y)
A = [x + y for x, y in zip(xs, ys)]
B = [x - y for x, y in zip(xs, ys)]
ans = max([max(A) - min(A), max(B) - min(B)])
print(ans)

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

int main(void){
    int n, m;
    cin >> n >> m;
    int in, out;

    int max = 0, c = 0;
    for(int i = 1; i <= n; i++){
        cin >> in >> out;
        int K = m + in - out;
        if(K >= 0){
            if(K > max) max = K;
        }
        else c++;
        m = K;
    }
    if(c == 0) cout << max << endl;
    else cout << "0" << endl;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main(){
	int a,b,c,b1,c1;
	cin>>a>>b>>c;
	b1=b+a;
	c1=c+a;
	if(c<=b1&&c>=b)
	{
		cout<<0;
		return 0;
	}
	if(c1>=b&&c1<=b1)
	{
		cout<<0;
		return 0;
	}
	if(c>b1) 
	{
		cout<<c-b1;
		return 0;
	}
	cout<<b-c1;
	return 0;
}


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

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; }
const long long INF = 1LL << 60;

int main(){
    int N,K;
    int h[110000];
    cin >> N >> K;
    for(int i=0;i<N;++i) cin >> h[i];
    long long dp[110000];
    fill(dp,dp+N,INF);
    dp[0] = 0;
    
    for(int i=0;i<N;++i){
        for(int k=1;k<=K;++k){
            chmin(dp[i+k],dp[i]+abs(h[i]-h[i+k]));
        }
    }

    cout << dp[N-1] << endl;
    
    return 0;

}

Measured memory_bytes: 1408
#include<stdio.h>

int main() {
	int a, b, calc;
	char op;
	while (1) {
		scanf("%d %c %d", &a, &op, &b);
		switch (op)
		{
		case '?':
			return 0;
			break;
		case '+':
			calc = a + b;
			break;
		case '-':
			calc = a - b;
			break;
		case '*':
			calc = a*b;
			break;
		case '/':
			calc = a / b;
			break;
		default:
			break;
		}
		printf("%d\n", calc);
	}
	return 0;
}

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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int main(){
  int a,b,c;
  cin >> a >> b;
  int ans;
  if((a+b)%2 == 0){
    cout << (a+b)/2 <<endl;
  }else{
    cout << "IMPOSSIBLE" <<endl;
  }
}

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

#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define endl        '\n'
#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

namespace InOp{
template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
}
using namespace InOp;

namespace ModOp{
template<class x,class y,class z> z add(x a,y b,z m){return (a+b)%m;}
template<class x,class y,class z> z sub(x a,y b,z m){return (a-b+m)%m;}
template<class x,class y,class z> z mul(x a,y b,z m){return ((ll)a*b)%m;}
template<class y,class z> z expo(ll b,y e,z m){ll a=1;b%=m;while(e!=0){if((e&1)==1){a=a*b;a=a%m;}b=b*b;b%=m;e>>=1;}return a%m;}
template<class x,class z> z inv(x b,z m){return expo(b,m-2,m);}
template<class x,class y> x invGeneral(x a,y b){if(a==0)return b==1?0:-1;x m=invGeneral(b%a,a);return m==-1?-1:((1-(ll)b*m)/a+b)%b;}
template<class x,class y,class z> z div(x a,y b,z m){ll c=inv(b,m);return mul(a,c,m);}
}
using namespace ModOp;

namespace Debug{
template<class x> void deb(x a){cerr<<"a"<<": "<<a<<endl;}
template<class x,class y> void deb(x a,y b){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<endl;}
template<class x,class y,class z> void deb(x a,y b,z c){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<endl;}
template<class x,class y,class z,class xy> void deb(x a,y b,z c,xy d){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<" | "<<"d"<<": "<<d<<endl;}
}
using namespace Debug;

#define N  1000005

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,r,x,y,m,n;
        cin>>n;
        x=n%10;
        if(x==3)
        {
            cout<<"bon";
            return 0;
        }
        if(x==0||x==1||x==6||x==8)
        {
            cout<<"pon";
            return 0;
        }
        cout<<"hon";return 0;
    }
    return 0;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
using namespace std;

int main(){
    int n,d,x[10][10],sum,r,sa,ans=0;
    scanf("%d %d",&n,&d);
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            scanf("%d",&x[i][j]);
        }
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            sum=0;
            for(int k=0;k<d;k++){
                sa=x[i][k]-x[j][k];
                sum+=sa*sa;
            }
            r=sqrt(sum);
            if(r*r==sum){
                ans++;
            }
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 128
n = input()
for i in range(n):
    c,a,n = map(int, raw_input().strip().split(" "))
    can = min(c,a,n)
    c -= can; a -= can; n -= can;
    cca = min(c/2, a)
    c -= 2 * cca; a -= cca;
    ccc =  c/3
    print can + cca + ccc

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

typedef long long ll;

using namespace std;

#define all(x) x.begin(), x.end()

const ll INF = 1e9;

string s;
ll cnt[160];
ll ps[160];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    fill(ps, ps + 160, INF);
    for (int i = 0; i < s.size(); i++)
        cnt[s[i]]++;
    for (int i = 0; i < s.size(); i++)
    {
        if (ps[s[i]] == INF)
            ps[s[i]] = i;
    }
    if (s[0] == s[s.size() - 1])
    {
        for (char c = s[0]; c <= s[0]; c++)
    {
        for (char d = 'a'; d <= 'z'; d++)
        {
            if (c == d)
                continue;
            if (cnt[c] == 0 || cnt[d] == 0)
                continue;
            if (ps[c] > ps[d])
                continue;
            int x = 1;
            int cnt = 0;
            for (int i = 0; i < s.size(); i++)
            {
                if (s[i] == c && x == 1)
                {
                    x = 2;
                    cnt++;
                }
                if (s[i] == d && x == 2)
                {
                    x = 1;
                    cnt++;
                }
            }
            if ((s.size() - cnt) % 2 == 0)
            {
                //cout << c << " " << d << endl;
                cout << "Second";
                return 0;
            }
        }
    }
    cout << "First";
        return 0;
    }
    for (char c = s[0]; c <= s[0]; c++)
    {
        for (char d = s[s.size() - 1]; d <= s[s.size() - 1]; d++)
        {
            if (c == d)
                continue;
            if (cnt[c] == 0 || cnt[d] == 0)
                continue;
            if (ps[c] > ps[d])
                continue;
            int x = 1;
            int cnt = 0;
            for (int i = 0; i < s.size(); i++)
            {
                if (s[i] == c && x == 1)
                {
                    x = 2;
                    cnt++;
                }
                if (s[i] == d && x == 2)
                {
                    x = 1;
                    cnt++;
                }
            }
            if ((s.size() - cnt) % 2 == 0)
            {
                //cout << c << " " << d << endl;
                cout << "Second";
                return 0;
            }
        }
    }
    cout << "First";
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int r, g;
    cin >> r >> g;
    int x = g * 2 - r;
    cout << x << endl; 
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (){
	char input1,input2;
	scanf ("%c %c",&input1,&input2);getchar();
	if(input1=='D'&&input2=='H'){
		printf ("D\n");
	}else if (input1=='H'&&input2=='D'){
		printf ("D\n");
	}else printf ("H\n");
}

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

void swapValue(int *a, int *b)
{
	int temp;
	
	temp = *a;
	*a = *b;
	*b = temp;


}

int main(void)
{
	int a1, a2, a3;
	
	cin >> a1 >> a2 >> a3;
	

	if(a1 > a2)
	{
		swapValue(&a1, &a2);
	}


	if(a2 > a3)
	{
		swapValue(&a2, &a3);
	}

	if(a1 > a2)
	{
		swapValue(&a1, &a2);
	}

	cout << a1 << " " << a2 << " " << a3 << endl;


	return 0;

}

Measured memory_bytes: 1164