akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    string s;
    cin >> s;

    deque<ll> q;
    rep(i, s.size()){
        switch(s[i]){
            case '0':
                q.push_back(0);
                break;
            case '1':
                q.push_back(1);
                break;
            case 'B':
                if(!q.empty()){
                    q.pop_back();
                }
                break;
        }
    }

    while(!q.empty()){
        cout << q.front();
        q.pop_front();
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3600
def nikkei19q_c():
    N = int(input())
    dish = []
    for i in range(N):
        a, b = map(int, input().split())
        dish.append((a, b))

    prior = sorted(dish, key=lambda x: x[0] + x[1], reverse=True)
    pt_tak, pt_aok = 0, 0

    for i, (a, b) in enumerate(prior):
        if i%2 == 0:
            pt_tak += a
        else:
            pt_aok += b

    ans = pt_tak - pt_aok
    print(ans)

nikkei19q_c()

Measured memory_bytes: 22140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
const int INF=1e9+5;
const int N=2e3+5;
const int mod=998244353;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll h,w;
	cin>>h>>w;
	if(h==1||w==1) return cout<<1,0;
	cout<<h*w/2+(h%2&&w%2)<<endl;
	return 0;
}


Measured memory_bytes: 256
#create date: 2020-09-13 21:01

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    a, b, c, d = na()
    print(max(a*c, b*d, a*d, b*c))

if __name__ == "__main__":
    main()

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

vector<vector<int>> T(200000);
vector<int> Count(200000, 0);

void solve(int a) {
	for (int i : T[a]) {
		Count[i] += Count[a];
		solve(i);
	}
	return;
}

int main(){
	int N, Q, a, b, p, x;
	cin >> N >> Q;
	for (int i = 0;i < N - 1;i++) {
		cin >> a >> b;
		a--;b--;
		T[a].push_back(b);
	}
	for (int i = 0;i < Q;i++) {
		cin >> p >> x;
		p--;
		Count[p] += x;
	}
	solve(0);
	for (int i = 0;i < N;i++) {
		cout << Count[i] << " ";
	}
}


Measured memory_bytes: 20352
#include <iostream>
#include<string>
//#include<algorithm>
//#include<vector>
//#include<cmath>

using namespace std;

int main()
{
	long long int N, A, B;
	cin >> N >> A >> B;
	if (N % (A + B) >= A) 
	{
		cout << A + N / (A + B) * A ;
	}
	else
	{
		cout << N % (A + B) + N / (A + B) * A;
	}
	cout << endl;
	return 0;
}

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

template <int mod = (int)(1e9 + 7)>
struct ModInt {
  int x;
  constexpr ModInt() : x(0) {}
  constexpr ModInt(int64_t y)
      : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  constexpr ModInt &operator+=(const ModInt &p) noexcept {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt &p) noexcept {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt &p) noexcept {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  constexpr ModInt &operator/=(const ModInt &p) noexcept {
    *this *= p.inverse();
    return *this;
  }
  constexpr ModInt operator-() const { return ModInt(-x); }
  constexpr ModInt operator+(const ModInt &p) const
      noexcept {
    return ModInt(*this) += p;
  }
  constexpr ModInt operator-(const ModInt &p) const
      noexcept {
    return ModInt(*this) -= p;
  }
  constexpr ModInt operator*(const ModInt &p) const
      noexcept {
    return ModInt(*this) *= p;
  }
  constexpr ModInt operator/(const ModInt &p) const
      noexcept {
    return ModInt(*this) /= p;
  }
  constexpr bool operator==(const ModInt &p) const
      noexcept {
    return x == p.x;
  }
  constexpr bool operator!=(const ModInt &p) const
      noexcept {
    return x != p.x;
  }
  constexpr ModInt inverse() const noexcept {
    int a = x, b = mod, u = 1, v = 0, t = 0;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  constexpr ModInt pow(int64_t n) const {
    ModInt res(1), mul(x);
    while(n) {
      if(n & 1) res *= mul;
      mul *= mul;
      n >>= 1;
    }
    return res;
  }
  friend constexpr ostream &operator<<(
      ostream &os, const ModInt &p) noexcept {
    return os << p.x;
  }
  friend constexpr istream &operator>>(istream &is,
                                       ModInt &a) noexcept {
    int64_t t = 0;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  constexpr int get_mod() { return mod; }
};

vector<ModInt<>> sum(100010);

ll inv(ll x) {
  ll res = 1;
  ll N = (long long)(1e9 + 7);
  ll k = N - 2;
  ll y = x % N;
  while(k) {
    if(k & 1) res = (res * y) % N;
    y = (y % N * y % N) % N;
    k /= 2;
  }
  return res;
}

int main(void) {
  long long n;
  cin >> n;
  vector<long long> x(n + 1);
  ModInt<> ans = 0;
  ModInt<> kaijo = 1;
  for(int i = 1; i <= n - 1; i++) kaijo = kaijo * i;
  for(int i = 0; i < n; i++) cin >> x[i + 1];
  for(int i = 0; i < n; i++)
    sum[i + 1] = (sum[i] + x[i + 1]);

  for(long long p = 1; p <= n - 1; p++) {
    ModInt<> tmp = inv(n - p) * (x[n] - x[p]);
    ans = ans + tmp;
  }
  for(long long p = 1; p <= n - 2; p++) {
    ModInt<> tmp = inv(p * (p + 1));
    ModInt<> tmp1 = sum[n - 1] - sum[p];
    ModInt<> tmp2 = sum[n - 1 - p];
    ModInt<> tmp3 = tmp1 - tmp2;
    ModInt<> tmp4 = tmp * tmp3;
    ans = ans + tmp4;
  }
  ans = ans * kaijo;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
program ABC148C
    integer(16)::A,B
    read*,A,B
    print"(i0)",A*B/gcd(a,b)
    contains
integer(16) recursive function gcd(a, b)result(res)
  integer(16), intent(in)::a, b
  res=merge(b, gcd(b, mod(a, b)),mod(a, b)==0)
end function
end program

Measured memory_bytes: 640
mod = 998244353
n, s = map(int, input().split())
arr = list(map(int, input().split()))
dp = [[0] * (s + 1) for _ in range(n + 1)]
dp[0][0] = 1

for i in range(1, n + 1):
    var = arr[i - 1]
    for j in range(0, s + 1):
        dp[i][j] = 2 * dp[i - 1][j]
        dp[i][j] %= mod
        if j - var >= 0 and dp[i - 1][j - var] != 0:
            dp[i][j] += dp[i - 1][j - var]
            dp[i][j] %= mod
print(int(dp[n][s]))


Measured memory_bytes: 132564
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
using namespace std;
int n,l,A[li];
int main(){
	scanf("%d %d",&n,&l);
	for(int i=1;i<=n;i++) scanf("%d",&A[i]);
	for(int i=2;i<=n;i++){
		if(A[i]+A[i-1]>=l){
			printf("Possible\n");
			for(int j=1;j<i-1;j++) printf("%d\n",j);
			for(int j=n-1;j>i-1;j--) printf("%d\n",j);
			printf("%d\n",i-1);
			return 0;
		}
	}
	printf("Impossible\n");
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main(){
    int k,a=32;
    int b[a];
    b[1]=1;
    b[2]=1;
    b[3]=1;
    b[4]=2;
    b[5]=1;
    b[6]=2;
    b[7]=1;
    b[8]=5;
    b[9]=2;
    b[10]=2;
    b[11]=1;
    b[12]=5;
    b[13]=1;b[14]=2;b[15]=1;b[16]=14;
    b[17]=1;b[18]=5;b[19]=1;b[20]=5;
    b[21]=2;b[22]=2;b[23]=1;b[24]=15;
    b[25]=2;b[26]=2;b[27]=5;b[28]=4;b[29]=1;b[30]=4;b[31]=1;b[32]=51;
    cin>>k;
    cout<<b[k];
    cout<<endl;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	// write your code here
        Scanner scanner=new Scanner(System.in);
        int A=scanner.nextInt();
        int B=scanner.nextInt();
        System.out.println(Math.max(A+B,Math.max(A-B,A*B)));
    }
}

Measured memory_bytes: 22356
//Subhash Suman
//Description :

#include <bits/stdc++.h>
#define ll long long int
#define pll pair<ll, ll>
#define pii pair<int, int>

using namespace std;
const int N = 105, W = 1e5 + 5;
ll n, w, dp[N][W], arr1[N], arr2[N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> w;
    for (int i = 1; i <= n; i++)
    {
        cin >> arr1[i] >> arr2[i];
    }

    for (int i = 1; i <= n; i++)
    {
        for (int wi = 1; wi <= w; wi++)
        {
            if (wi - arr1[i] >= 0)
            {
                dp[i][wi] = max(dp[i][wi], dp[i - 1][wi - arr1[i]] + arr2[i]);
            }
            dp[i][wi] = max(dp[i][wi], dp[i - 1][wi]);
            dp[i][wi] = max(dp[i][wi], dp[i][wi - 1]);
        }
    }
    cout << dp[n][w] << '\n';
    return 0;
}

Measured memory_bytes: 79360
#include <stdio.h>
int main ()
{
        int daigaku[2][10];
        int i,j,k,tmp,max[2][3] = {0}, put[3];
        int result[2];

        for (i = 0; i < 2; i++) {
                for (j = 0; j < 10; j++) {
                        scanf("%d", &daigaku[i][j]);
                }
        }
        for (i = 0; i < 2; i++) {
                for (k = 0; k < 3; k++) {
                        for (j = 0; j < 10; j++) {
                                if (daigaku[i][j] > max[i][k]) {
                                        max[i][k] = daigaku[i][j];
                                        tmp = j;
                                }
                        }
                        put[k] = max[i][k];
                        daigaku[i][tmp] = 0;
                }
                result[i] = put[0]+put[1]+put[2];
        }

        printf("%d %d\n", result[0], result[1]);
        return 0;

}

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

int main(){

    int K,T;
    cin >> K >> T;
    int A[T];
    int mx = 0;
    for(int i = 0;i < T;i++){
        cin >> A[i];
        mx = max(mx,A[i]);
    }
    
    cout << max(0,mx-1-(K-mx))<<endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int k = scanner.nextInt();

        double[] array = new double[n];
        for (int i = 0; i < n; i++) {
            array[i] = (double) (scanner.nextInt() + 1) / 2;
        }
        double sum = 0;
        for (int i = 0; i < k; i++) {
            sum += array[i];
        }
        double max = sum;

        for (int i = 0; i < n - k; i++) {
            sum += array[i + k] - array[i];
            if (max < sum) {
                max = sum;
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 84028
import statistics as sta

N=int(input())
X=list(map(int,input().split()))

sort_X = sorted(X)
a = sta.median_low(sort_X)
b = sta.median_high(sort_X)

for i in range(N):
    if X[i] <= a:
        print(b)
    else:
        print(a)

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

int a[N], parent[N], SIZE[N];

int find_set(int v) {
  if (v == parent[v]) return v;
  return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    if (SIZE[a] < SIZE[b]) swap(a, b);
    parent[b] = a;
    SIZE[a] += SIZE[b];
  }
}

void solve() {
  int n, m; scanf("%d%d", &n, &m);
  for (int p, i = 0; i < n; ++i) {
    scanf("%d", &p);
    a[p-1] = i;
    parent[i] = i;
    SIZE[i] = 1;
  }
  for (int x, y, i = 0; i < m; ++i) {
    scanf("%d %d", &x, &y);
    --x; --y;
    union_sets(x, y);
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (find_set(i) == find_set(a[i])) ++ans;
  }
  printf("%d", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 4888
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	ll n;
	cin>>n;
	ll a[n];
	ll i;
	for(i=0;i<n;i++){
		cin>>a[i];
	}		
	ll j,k;
	ll count=0;
	sort(a,a+n);
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			for(k=j+1;k<n;k++){
				if(a[k]<a[j]+a[i]&&a[k]!=a[j]&&a[k]!=a[i]&&a[i]!=a[j]){
					count++;
				}
			}
		}
	}
	cout<<count;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

    string s;
    cin>>s;
    bool answer=true;
    for(int i=0; i<s.length()-1; i++){
        if(s[i]==s[i+1]) answer=false;
    }
    if(answer) cout<<"Good";
    else cout<<"Bad";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <list>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
#include <unordered_map>
#include <ctime>
using namespace std;

const unsigned long long BASE = (unsigned long long)(1e9 + 7);

#define FROM_0(i, n) for(int i = 0; i < (n); i++)
#define FROM_S(i, s, e) for(int i = (s); i < (e); i++)
#define ITER_BEGIN_END(iter, vec) for(auto iter = vec.begin(); iter != vec.end(); iter++)

int main()
{
    int d, t, s;
    cin >> d >> t >> s;
    cout << (float(d) / float(s) <= float(t) ? "Yes" : "No") << endl;
    return 0;
}


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

int main(){
  int N; cin >> N;
  vector<int> result(N,0);
  
  for(int x=1; x<=100; x++){
    for(int y=1; y<=100; y++){
      for(int z=1; z<=100; z++){
        int c=x*x+y*y+z*z+x*y+y*z+z*x;
        if(c<=N) result[c-1]++;
      }
    }
  }
  for(int i=0; i<N; i++){
    cout << result[i] << endl;
  }
}

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

long long modpow(long long m, long long n, long long mod){
    long long res = 1;
    while (n > 0)
    {
        if(n & 1) res = res * m % mod;
        m = m * m % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    long long m, n;
    cin >> m >> n;
    cout << modpow(m, n, 1000000007) << endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
    bool check = true;
    while(check){
    int a,b;
    char op;
    int ans;
    cin >> a >> op >> b;
    if(op == '+'){
        ans = a+b;
    }
    if(op == '-'){
        ans = a-b;
    }
    if(op == '*'){
        ans = a*b;
    }
    if(op == '/'){
        ans = a/b;
    }
    if(op == '?'){
        check = false;
    }
    if(check) cout << ans << endl;
}
return 0;
}


Measured memory_bytes: 3060
S = input()
T = input()

best = len(S) + 100
for i in range(len(S)):
    if i + len(T) > len(S):
        break
    pair = S[i : i + len(T)]
    diffs = 0
    for a, b in zip(pair, T):
        if a != b:
            diffs += 1
    best = min(best, diffs)
print(best)


Measured memory_bytes: 9104
#include<bits/stdc++.h>
#define int long long int
using namespace std;
#define pb push_back
#define MAX 1000005
int spf[MAX];
void SPF()
{
	int i,j;
	spf[0]=1;
	for(i=1;i<MAX;i++)	spf[i]=i;
	for(i=2;i<MAX;i++){
		if(spf[i]==i){
			for(j=i*i;j<MAX;j+=i){
				spf[j]=min(i,spf[j]);
			}
		}
	}
}
int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int n;
	scanf("%lld",&n);
	int a[n];
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	SPF();
	map<int,int>ma;
	for(int i=0;i<n;i++){
		int x=a[i];
		map<int,int>temp;
		while(x!=1){
			temp[spf[x]]++;
			x/=spf[x];
		}
		for(auto it=temp.begin();it!=temp.end();it++){
			ma[it->first]++;
		}
	}
	bool ok=true;
	for(auto it=ma.begin();it!=ma.end();it++){
		if(ma[it->first]>1){
			ok=false;
		}
	}
	if(ok){
		cout << "pairwise coprime";
		return 0;
	}
	int g=0;
	for(int i=0;i<n;i++){
		g=__gcd(g,a[i]);
	}
	if(g==1){
		cout << "setwise coprime";
	}
	else{
		cout << "not coprime";
	}



	return 0;
}


Measured memory_bytes: 24068
#include<stdio.h>
#include<ctype.h>
#include<string.h>
int main(void){
	int i,co=0,len;
	char string[100],word[100];
	scanf("%s",&word);
	len=strlen(word);
	while(1){
		scanf("%s",&string);
		if(strcmp(string,"END_OF_TEXT")==0)break;
		for(i=0;string[i]!='\0';i++){
			string[i]=tolower(string[i]);
		}
		if(strcmp(word,string)==0){
			co++;
		}
	}
	printf("%d\n",co);
	return 0;
}


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

int a[110],s[110];
int n;
double m;

int main(){
    cin>>n>>m;
    int ans=0;
    
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    s[1]=a[1];
    
    for(int i=2;i<=n;i++){
        s[i]=a[i]+s[i-1];
    }
    
    double sum=s[n];
    
    double r=sum*(0.25/m);
    
    for(int i=1;i<=n;i++){
        if(a[i]>=r)
            ans++;
    }
    
    if(ans>=m)
        cout<<"Yes\n";
    else
        cout<<"No\n";
        
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
int main(){

  int min,temp,i,j,count=0,x[N],n;

  scanf("%d",&n);

  for(i=0;i<n;i++) scanf("%d",&x[i]);

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

    for(j=i;j<n;j++){
      if( x[j] < x[min] ) min = j;
    }

    if( x[i] != x[min] ){
      temp = x[i];
      x[i] = x[min];
      x[min] = temp;
      count++;
    }
  }

  for(i=0;i<n-1;i++) printf("%d ",x[i]);
  printf("%d\n",x[n-1]);
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 600
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])

arr=[int(arr_data[x][0]) for x in range(1,1+n)]

lamp=arr[0]

cnt=1
chkflg=False
for i in range(n):
    
    if lamp!=2:
        
        lamp=arr[lamp-1]
        cnt+=1
        
    else:
        
        chkflg=True
        break
        
print(cnt if chkflg else -1)


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

int N;
vector<int> G[1000005];
vector<int> indegree(1000005, 0);

int node(int i, int j)
{
    return (min(i, j) * N + max(i, j));
}

int main() {
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        int prev;
        cin >> prev;
        for(int j = 1; j < N - 1; j++)
        {
            int current;
            cin >> current;
            int first = node(i + 1, prev);
            int second = node(i + 1, current);
            G[first].push_back(second);
            indegree[second]++;
            prev = current;
        }
    }
    vector<int> toProcess;
    for(int i = 1; i < N; i++)
    {
        for(int j = i + 1; j <= N; j++)
        {
            if(indegree[node(i, j)] == 0)
                toProcess.push_back(node(i, j));
        }
    }
    int day = 0, count = 0;
    while(!toProcess.empty())
    {
        day++;
        vector<int> nextToProcess;
        count += toProcess.size();
        for(int i = 0; i < toProcess.size(); i++)
        {
            int now = toProcess[i];
            for(int j = 0; j < G[now].size(); j++)
            {
                --indegree[G[now][j]];
                if(indegree[G[now][j]] == 0)
                    nextToProcess.push_back(G[now][j]);
            }
        }
        toProcess = nextToProcess;
    }
    if(count == (N * (N - 1))/2) cout << day << "\n";
    else cout << "-1\n";
}

Measured memory_bytes: 43136
N = int(input())
A = list(map(int, input().split()))
A = sorted([A[i] - (i+1) for i in range(N)])

if N % 2 == 1:
    median = A[N//2]
    sad = sum([abs(A[i] - median) for i in range(N)])
else:
    hoge, fuga = (A[N//2-1]+A[N//2])//2, (A[N//2-1]+A[N//2])//2+1
    sad = min(sum([abs(A[i] - hoge) for i in range(N)]), sum([abs(A[i] - fuga) for i in range(N)]))
print(sad)

Measured memory_bytes: 25744
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){

  int C[VMAX+1];
  int n, i, j;
  int *A, *B;
  
  scanf("%d", &n);

  A = malloc(sizeof(int)*n+1);
  B = malloc(sizeof(int)*n+1);

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

  for (i=1;i<=VMAX;i++){
    C[i]=C[i]+C[i-1];
  }
  
  for (j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for (i=1;i<=n;i++){
    if (i>1) printf(" ");
    printf("%d", B[i]);
  }

  printf("\n");

  return 0;
}

Measured memory_bytes: 16272
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

int dp[100][100];

int main(void){
    int n;
    bool judge = false;
    
    cin >> n;
    
    if(n % 4 == 0)              judge = true;
    else if(n % 7 == 0)         judge = true;
    else{
        if(n < 7){
            if(n == 4)          judge = true;
        }
        else{
            while(1){
                n -= 4;
                if(n % 7 == 0){
                    judge = true;
                    break;
                }
                if(n < 0)       break;
            }
        }
    }
    
    if(judge)       cout << "Yes" << endl;
    else            cout << "No"  << endl;
    
    cin >> n;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	char S[5];
	int ans = 0;

	scanf("%s", S);

	for (int i = 0;i < 4;i++) {
		if (S[i] == '+')ans++;
		if (S[i] == '-')ans--;

	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define ff first
#define ss second
#define hell 1000000007

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009

ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
        
	ll n,k;cin>>n>>k;
	ll a[n+2];
	rep(i,1,n+1)
	cin>>a[i];
	set<ll>s;
	vi v;

	ll curr=1;
	while(1)
	{
		ll val=a[curr];
		if(s.find(val)!=s.end())
			break;
		s.insert(val);
		//test1(val);
		v.pb(val);
		curr=val;
	}
	//k--;
	if(k<=v.size())
	{
		cout<<v[k-1]<<endl;
		return 0;
	}

	k-=v.size();
	v.clear();
	s.clear();

	//curr;
	while(1)
	{
		ll val=a[curr];
		if(s.find(val)!=s.end())
			break;
		s.insert(val);
		//test1(val);
		v.pb(val);
		curr=val;
	}
	k--;
	k%=s.size();
	cout<<v[k]<<endl;

}


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

using namespace std;

vector<int> divisor(int n)
{
    vector<int> v;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0) 
        {
            if(n/i==i) v.push_back(i);
            else
            {
                v.push_back(i);
                v.push_back(n/i);
            }
        }
    }
    return v;
}

int main()
{
    int a,b,i,j,n,t;
    cin>>n;
    vector<int> v;
    int count=0;
    v=divisor(n);
    for(i=1;i<=n;i++) 
    {
        count+=n/i;
    }
    count-=v.size();
    cout<<count-2;
}

Measured memory_bytes: 3720
import Foundation

class City {
    
    private let delay: Int
    private let initial: Int
    private let output: Int
    private let prev: City?
    
    init(delay: Int, initial: Int, output: Int, prev: City?) {
        self.delay = delay
        self.initial = initial
        self.output = output
        self.prev = prev
    }
    
    func total() -> Int {
        return prev?.total() ?? initial
    }
    
    func outputPerMin() -> Int {
        if let prev = prev {
            return min(prev.outputPerMin(), output)
        } else {
            return output
        }
    }
    
    func outputTimes() -> Int {
        return Int(ceil(Double(total()) / Double(outputPerMin())))
    }
    
    func totalTime() -> Int {
        return delay + outputTimes()
    }
}

let N = Int(readLine()!)!

var cities: [City] = []
var prev: City?
for i in 0 ..< 5 {
    let output = Int(readLine()!)!
    let city = City(
        delay: i,
        initial: i == 0 ? N : 0,
        output: output,
        prev: prev)
    cities.append(city)
    prev = city
}

let answer = cities.last!.totalTime()

print(answer)


Measured memory_bytes: 13120
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
 int a,b;
  cin>>a>>b;
  if(a*b%2!=0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3588
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inclass in = new inclass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AChristmasEveEveEve solver = new AChristmasEveEveEve();
        solver.solve(1, in, out);
        out.close();
    }

    static class AChristmasEveEveEve {
        public void solve(int testNumber, inclass in, PrintWriter out) {
            int d = in.nextInt();
            if (d == 25) {
                out.println("Christmas");
            } else if (d == 24) {
                out.println("Christmas Eve");
            } else if (d == 23) {
                out.println("Christmas Eve Eve");
            } else {
                out.println("Christmas Eve Eve Eve");
            }
        }

    }

    static class inclass {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private inclass.SpaceCharFilter filter;

        public inclass(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 20436
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
#define PI 3.1415926535897932384626433
typedef long long ll;
using namespace std;

double deg2rad(double degree)
{
    return degree * PI / 180.0000000000;
}
int main()
{
	ll A,B,C,ANS1,ANS2;
	cin>>A>>B>>C;
	if(A!=0){
		ANS1=(A-1)/C;
		ANS2=B/C;
		cout<<ANS2-ANS1<<endl;
	}
	else{
		ANS2=(B/C)+1;
		cout<<ANS2<<endl;
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const ll LINF = (int)1e18;
const double EPS = 1e-9;

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

  int r;
  cin >> r;
  cout << (r >= 2800 ? "AGC" : (r >= 1200 ? "ARC" : "ABC")) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    while(1){
        int a,b,i,j;
        cin >> a >> b;
        if(a==0 && b==0){
            break;
        }
        else{
            for(j=0; j<a; j++){
                if(j==0 || j==a-1){
                    for(i=0; i<b; i++){
                        if(i==(b-1)){
                            cout << "#" << endl;
                        }
                        else{
                            cout << "#";
                        }
                    }
                }

                else{
                    for(i=0; i<b; i++){
                        if(i==(b-1)){
                            cout << "#" << endl;
                        }
                        else if(i==0){
                            cout << "#";
                        }
                        else{
                            cout << ".";
                        }
                    }
                }
            }
            cout << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3100
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()

l = 0
ans = []
for i in a:
    if l == i:
        ans.append(i)
        l = 0
    else:
        l = i
    if len(ans) == 2:
        print(ans[0] * ans[1])
        exit()
print(0)
      

Measured memory_bytes: 14224
#include <iostream>
#include <queue>

using namespace std;

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

	priority_queue<int> q;
	for (int i = 0; i < N; ++i) {
		int A;
		cin >> A;
		q.push(A);
	}

	for (int j = 0; j < M; ++j) {
		int x = q.top();
		q.pop();
		q.push(x / 2);
	}

	long long ans = 0;
	while (!q.empty()) {
		ans += q.top();
		q.pop();
	}
	cout << ans << endl;
}


Measured memory_bytes: 892
#include<stdio.h>
int main()
{
    char a[1200];
    int b;
    
    for(b=0; a[b-1]!='\n'; b++){
        scanf("%c", &a[b]);
        
        if (65<=a[b] && 90>=a[b]) {
            a[b]+=32;
        }else {
            if(97<=b[a] && 122>=a[b]) {
                a[b]-=32;
            }
        }
    }
    
    a[b-1]=0;
    
    printf("%s\n",a);
    return 0;
}



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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vdbl;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int(i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, b) for (int(i) = a; (i) < (int)b; i++)
#define IREP(i, v) for (auto i = v.begin(); i != v.end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes()
{
    cout << "Yes" << endl;
}
void no()
{
    cout << "No" << endl;
}
//----------------------------------------

int N ;
vector<string> vec ;
vector<string> dc = { "3", "5", "7" } ;

void dfs_list(int d,string s){
    vec.push_back(s) ;
    if(d==N){
        return ;
    }
    for(int i=0;i<dc.size();i++){
        dfs_list(d+1,s+dc[i]) ;
    }
}

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    N = 9 ;
    int n ;
    cin >> n ;
    

    dfs_list(0,"") ;

    vll vv ;
    REP(i,SZ(vec)){
        int cnt3 = 0;
        int cnt5 = 0 ;
        int cnt7 = 0 ;
        REP(j,SZ(vec[i])){
            if(vec[i][j]=='3'){
                cnt3++ ;
            }
            else if(vec[i][j]=='5'){
                cnt5++ ;
            }
            else{
                cnt7++ ;
            }
        }
        if(cnt7!=0 && cnt3!=0 && cnt5!=0){
            vv.PB(stol(vec[i])) ;
        }
    }


    sort(ALL(vv)) ;

    auto itr = UB(ALL(vv),n) ;
    int ans = distance(vv.begin(),itr) ;

    cout << ans <<endl ;

    

    return 0;
}


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

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 999999999

using namespace std;

#define int long long

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

	int ans=2*n;
	for(int i=n-1; i>=0; i--){
		int cnt=2*n;
		if(a[i]==b[0]){
			int k=1;
			cnt--;
			for(int j=i+1; j<n; j++){
				if(a[j]==b[k]){
					k++;
					cnt--;
				}
				else{
					cnt+=INF;
					break;
				}
			}
			ans = min(ans, cnt);
		}
	}
		
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
  int car;
  stack<int> st;
  vector<int> result;

  while (cin >> car) {
    if (car == 0) {
      result.push_back(st.top());
      st.pop();
    } else {
      st.push(car);
    }
  }

  for (int i = 0; i < result.size(); i++)
    cout << result[i] << endl;
  for (int i = 0; i < st.size(); i++) {
    cout << st.top() << endl;
    st.pop();
  }
  return 0;
}

Measured memory_bytes: 1220
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <algorithm>
#include <functional>
using namespace std;



int main(){
	

	int i, j;
	long double A,B,H,M;

	
	string S;

	cin >> A;
	cin >> B;
	cin >> H;
	cin >> M;
	
	long double Ax, Ay,Bx, By,D;

	Ax = B * cosl((H / 12 + M /(60*12) ) * 360 * (M_PI / 180));
	Ay = B* sinl((H / 12 + M / (60*12)) * 360 * (M_PI / 180));
	Bx = A* cosl((M / 60) * 360 * (M_PI / 180));
	By = A * sinl((M / 60) * 360 * (M_PI / 180));
	cout.precision(20); cout << sqrtl((Ax - Bx)*(Ax - Bx) + (Ay - By)*(Ay - By));

	return 0;
}

Measured memory_bytes: 4168
// AOJ 323 ruins
// 2018.2.25 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define LIM		30
#define MAX		1000002
#define EPS		1e-8
 
typedef struct { int x, r; long long r2; } T;
T tbl[100002];
int n;

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int check(double d)
{
	int i;
	double xmin, xmax, xx, d2;

	d2 = d*d;
	xmin = -MAX, xmax = MAX;
	for (i = 0; i < n; i++) {
		if (tbl[i].r < d) return 0;
		xx = sqrt(tbl[i].r2 - d2);
		if (tbl[i].x - xx > xmin) xmin = tbl[i].x - xx;
		if (tbl[i].x + xx < xmax) xmax = tbl[i].x + xx;
		if (xmin > xmax) return 0;
	}
	return 1;
}

int cmp(T *a, T *b) { if (a->r - b->r) return a->r - b->r; return a->x - b->x; }

int main()
{
	int i;
	double hi, lo, mi;

	n = in();
	for (i = 0; i < n; i++) {
		tbl[i].x = in(), tbl[i].r = in();
		tbl[i].r2 = (long long)tbl[i].r * tbl[i].r;
	}
	if (i == 1) { printf("%.6lf\n", (double)tbl[0].r); return 0; }

	qsort(tbl, n, sizeof(T), cmp);
	lo = 0, hi = MAX;
	for (i = 0; i < LIM; i++) {
		mi = 0.5*(lo + hi);
		if (check(mi)) lo = mi; else hi = mi;
	}
	printf("%.6lf\n", lo);
	return 0;
}


Measured memory_bytes: 4456
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long N = scan.nextLong();
		if(N % 2 == 0) {
			System.out.println(N);
		}else {
			System.out.println(N * 2);
		}
		scan.close();
	}
}

Measured memory_bytes: 23892
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

#define max(a,b) ((a > b) ? a : b)
#define min(a,b) ((a < b) ? a : b)

using namespace std;

long int N, A, B;

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

	long int num = N / (A + B);
	long int rest = N % (A + B);

	cout << A*num + min(A,rest) << endl;

	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  map<pair<string,int> ,int> s;
  REP(i,N){
    string S;
    int P;
    cin>>S>>P;
    s[make_pair(S,-P)]=i+1;
  }
  for(auto e:s){
    cout<<e.second<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
ll n,k;
#define N 100010
vector<ll> v[N];
int main(){
    cin>>n;
    for(k=2;k<=n;k++){
	if(k*(k-1)/2==n)break;
    }
    if(k*(k-1)/2!=n){
	cout<<"No"<<endl;
	return 0;
    }
    cout<<"Yes"<<endl;
    ll cnt=1;
    lol(i,k){
	for(int j=i+1;j<k;j++){
	    v[i].push_back(cnt);
	    v[j].push_back(cnt);
	    cnt++;
	}
    }
    cout<<k<<endl;
    lol(i,k){
	cout<<v[i].size();
	for(ll j=0;j<v[i].size();j++){
	    cout<<" "<<v[i][j];
	}
	cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 5504
#include <iostream>
#include <cmath>

using namespace std;

int const NMAX = 1e5;
int const INF = 2e9;

int nStones;
int jumpBound;
int dp[1+NMAX];
int h[1+NMAX]; //this is an indication that your array is starting from index 1

int costOfHop(int from, int to) {
  return abs(h[from]-h[to]);
}

int main() {
  cin >> nStones >> jumpBound;
  for(int i=1; i<=nStones; i++) {
    cin >> h[i];  //stones are 1..nStones
  }

  /*
    dp[i] = minimum cost of getting to ith stone
  */
  for(int i=0; i<=nStones; i++) {
    dp[i] = INF;
  }

  //Bottom-up: we start from a subproblem that we know is optimal.
  dp[1] = 0; //the initial case is an abstract case
  for(int i=1; i<=nStones; i++) {  //you start from a SOLVED problem in bottom-up
    int startingOptimalCost = dp[i];
    for(int j=1; j<=jumpBound; j++) {
      if(i+j <= nStones) {
        dp[i+j] = min(dp[i+j], startingOptimalCost + costOfHop(i, i+j));
      }
    }
  }
  cout << dp[nStones];
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<string>
#include<unordered_map>
#include<math.h>
using namespace std;
using ll = long long;
int main(){
    int X;
    cin >> X;
    int f = X;
    int fx = 0;
    while(f >= 1){
        fx += f % 10;
        f /= 10;
    }
    if(X % fx == 0)cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i< (n);i++)
using namespace std;
//abc102
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int x = c-a,y = d-b;
    printf("%d %d %d %d",c-y, d+x, a-y,b+x);
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int k;
  cin>>k;
  while(k!=0){
    if(a>=b){
      b*=2;
    }
    else{
      c*=2;
    }
    k--;
    if(a<b&&b<c){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}
 


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

int main() {
	int N; cin >> N;
	vector<int> H(N); for(int i = 0; i < N; ++i) cin >> H[i];

	int min_n = 0;
	bool flag = false;
	for(int i = N - 2; i >= 0; --i) {
		if(H[i] > H[i + 1] + 1) {
			flag = true;
			break;
		} else if(H[i] == H[i + 1] + 1) {
			H[i] = H[i] - 1;
		}
	}

	if(flag == false) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a , b;
  	cin >> a >> b;
  	if(1 <= a && a <= 9 && b >= 1 && b <= 9)
      cout << a * b << endl;
  	else
      cout << -1 << endl;
 	return 0; 
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	var ans int
	cij := make([][]int, 10)
	for i := 0; i < 10; i++ {
		cij[i] = make([]int, 10)
	}
	for i := 1; i <= n; i++ {
		istr := strconv.Itoa(i)
		a, _ := strconv.Atoi(string(istr[0]))
		b, _ := strconv.Atoi(string(istr[len(istr)-1]))
		cij[a][b] = cij[a][b] + 1
	}
	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			ans += cij[i][j] * cij[j][i]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 3840
/*  CREATED BY
    Stream_Cipher
    13-sep-2020
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define debug1(a) cout<<#a<<"="<<(a)<<"\n"
#define debug2(a,b) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<"\n"
#define debug3(a,b,c) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<","<<#c<<"="<<(c)<<"\n"
#define fix_precision(n) cout<<fixed<<setprecision(n)
#define all(a) a.begin(),a.end()
const double pi=acos(-1.0);
int inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int mx=5*1000000;//5*64M bit ->5*8M byte ->40MB size for long long int (64 bit)
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
        string a;
        cin>>a;
        int one=0;
        for(auto i:a)
        	if(i=='R')
        		one=1;
        if((a[0]==a[1]&&a[1]=='R')||(a[1]==a[2]&&a[1]=='R'))
        	one=2;
        if(a=="RRR")
        	one=3;
        cout<<one<<endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
    static const double pi = 3.141592653589793;
 typedef pair<int,int> P;
 

int main() {
int a,b,c;
  cin>>a;
  cin>>b;
  cin>>c;
  int d=max(a,b);
  int t=0;
  int i=0;
  while(t<c)
  {
  i++;
    t=t+d;
  
  }
  cout<<i;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<pair<int,int>> ans(N);
    for(int i=0; i<N; i++){
        cin >> A.at(i);
        ans.at(i)=make_pair(A.at(i),i);
    }
    sort(ans.begin(),ans.end());
    for(int i=0; i<N; i++){
        if(i==N-1){
            cout << ans.at(i).second+1 << endl;
        }
        else{
            cout << ans.at(i).second+1 << " ";
        }
    }
}

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

int N,X[1<<18],Y[1<<18];
char D[1<<18];

void Rotate(){
	for(int i=1;i<=N;i++){
		int cx=Y[i],cy=200000-X[i],cz;

		if(D[i]=='U') 
			cz='R';
		if(D[i]=='R') 
			cz='D';
		if(D[i]=='D') 
			cz='L';
		if(D[i]=='L') 
			cz='U';

		X[i]=cx;Y[i]=cy;D[i]=cz;
	}
}

vector<pair<int,char> > V1[1<<19];
vector<pair<int,char> > V2[1<<19];

int solve_01(){
	int Answer=(1<<24);

	for(int i=0;i<=500000;i++) 
		V1[i].clear();

	for(int i=1;i<=N;i++){
		if(!(D[i]=='R' || D[i]=='U')) 
			continue;

		V1[X[i]+Y[i]].push_back(make_pair(X[i],D[i]));
	}

	for(int i=0;i<=500000;i++){
		sort(V1[i].begin(),V1[i].end());

		for(int j=0;j<(int)V1[i].size()-1;j++){
			if(!(V1[i][j].second=='R' && V1[i][j+1].second=='U')) 
				continue;

			Answer=min(Answer,V1[i][j+1].first-V1[i][j].first);
		}
	}

	return Answer*10;
}

int solve_02(){
	int Answer=(1<<24);

	for(int i=0;i<=500000;i++) 
		V2[i].clear();

	for(int i=1;i<=N;i++){
		if(!(D[i]=='L' || D[i]=='R')) 
			continue;

		V2[Y[i]].push_back(make_pair(X[i],D[i]));
	}

	for(int i=0;i<=500000;i++){
		sort(V2[i].begin(),V2[i].end());

		for(int j=0;j<(int)V2[i].size()-1;j++){
			if(!(V2[i][j].second=='R' && V2[i][j+1].second=='L')) 
				continue;

			Answer=min(Answer,V2[i][j+1].first-V2[i][j].first);
		}
	}

	return Answer*5;
}

int main(){
	cin>>N;

	for(int i=1;i<=N;i++) 
		cin>>X[i]>>Y[i]>>D[i];

	int FinalAns=(1<<24);

	for(int t=1;t<=4;t++){
		int val1=solve_01(); 
		FinalAns=min(FinalAns,val1);

		int val2=solve_02(); 
		FinalAns=min(FinalAns,val2);

		Rotate();
	}

	if(FinalAns==(1<<24)) 
		cout<<"SAFE\n";
	else 
		cout<<FinalAns<<"\n";

	return 0;
}

Measured memory_bytes: 42628
#include<iostream>
#include<string>
using namespace std;
int main(void) {
    string S;
    cin >> S;
    if (S[2] == S[3]) {
        if (S[4] == S[5]) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    else {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256