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

int main() {
	int h, m, s, h2, m2, s2;
	int t, t2, u, ans;
	
	for (int i = 0; i < 3; i++) {
		cin >> h >> m >> s;
		cin >> h2 >> m2 >> s2;
		
		t2 = h2 * 3600 + m2 * 60 + s2;
		t = h * 3600 + m * 60 + s;
		u = t2 - t;
		
		cout << u / 3600 << ' ' << (u % 3600) / 60 << ' ' << u % 60 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2988
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        int a[] = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = scn.nextInt();
        }
        for(int i=(n-1); i>=0; i--){
            System.out.print(a[i]);
            if(i==0){
                System.out.println();
            }else{
                System.out.print(" ");
            }
        }


        scn.close();

    }
}



Measured memory_bytes: 26212
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

const int unsolved = numeric_limits<int>::min();
const int mod = 1000 * 1000 * 1000 + 7;

vector<long long> dp;

vector<int> get_index(int mask) {
  vector<int> index;

  while (mask) {
    int i = __builtin_ctz(mask);
    mask &= mask - 1;
    index.push_back(i);
  }

  return index;
}

int get_mask(int mask, const vector<int> &index) {
  int mask_group = 0;

  while (mask) {
    int i = __builtin_ctz(mask);
    mask &= mask - 1;
    mask_group |= 1 << index[i];
  }

  return mask_group;
}

long long solve(int available, const vector<long long> &points, int n) {
  if (available == 0) {
    return 0;
  }

  long long &ret = dp[available];
  if (ret == unsolved) {
    vector<int> index = get_index(available);

    int sz = index.size();
    for (int mask = 1; mask < (1 << sz); ++mask) {
      int mask_group = get_mask(mask, index);
      long long points_group = points[mask_group] + solve(available ^ mask_group, points, n);
      ret = max(ret, points_group);
    }
  }

  return ret;
}

long long get_points(int mask, const vector<vector<int>> &grid) {
  int n = grid.size();
  long long points = 0;

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int pair = (1 << i) | (1 << j);
      if ((mask & pair) == pair) {
        points += grid[i][j];
      }
    }
  }

  return points;
}

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

  vector<vector<int>> grid(n);
  for (auto &row : grid) {
    row.resize(n);
    for (auto &x : row) {
      cin >> x;
    }
  }

  vector<long long> points(1 << n);
  for (int mask = 0; mask < (1 << n); ++mask) {
    points[mask] = get_points(mask, grid);
  }

  dp.resize(1 << n);
  fill(dp.begin(), dp.end(), unsolved);

  long long ans = solve((1 << n) - 1, points, n);
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 1280
import itertools
import math

s = input()
n = []
for i in range(len(s)):
    n.append(s[i])

count = 0
for i in range(1, len(n)):
    if n[i-1] == n[i]:
        count+= 1
        if n[i] == '1':
            n[i] = '0'
        else:
            n[i] = '1'

print(count)

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

typedef long long ll;
typedef long double ld;
using namespace std;
//mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back

//
// dp[i][j] = dp[i-1][j-1] * 25 + dp[i-1][j];

const int maxn = 2000005;
const int mod = 1e9+7;
ll f[maxn],rf[maxn];
ll fpow(ll a,ll b)
{
    ll ret = 1;
    while(b){if(b&1) ret=ret*a%mod;a=a*a%mod;b>>=1;}
    return ret;
}
void init()
{
    f[0] = 1;
    for(int i=1;i<maxn;++i) f[i]=f[i-1]*i%mod;
    rf[maxn-1] = fpow(f[maxn-1],mod-2);
    for(int i=maxn-2;i>=0;--i) rf[i]=rf[i+1]*(i+1)%mod;
}
ll comb(ll n,ll k){if(n<k||k<0)return 0;return f[n]*rf[k]%mod*rf[n-k]%mod;}
int main() {
    init();
    int k;
    cin>>k;
    string s;
    cin>>s;
    int n=s.size();
    ll ans=0;
    for(int i=n;i<=k+n;++i) ans += comb(k+n,i) * fpow(25, k+n-i) % mod;
    ans %= mod;
    cout << ans << endl;
}

Measured memory_bytes: 36552
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
int solve()
{
	int n,k;
	cin>>n>>k;
	int cnt=0;
	while(n>0)
	{
		n/=k;
		cnt++;
	}
	cout<<cnt<<endl;



}
signed main()
{
	fastio;
	clock_t start, end;
//	test
	{
		start=clock();
		solve();
		end=clock();
		double time_taken=double(end-start)/double(CLOCKS_PER_SEC);
//		cout<<time_taken<<endl;
	}
}


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

signed main() {
  int A, B;
  cin >> A >> B;

  for (int i = 1; i <= 3; i++) {
    if (i != A && i != B) {
      cout << i << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b,a){
    queue<int>q;
    int s=0;
    for(int i=1;i<=a;i++)q.push(i);
    while(1){
      s++;
      int p=q.front();q.pop();
      if(q.empty()){cout<<p<<endl;break;}
      if(s==b)s=0;
      else q.push(p);
    }
  }
}

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

int main() {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  rep(i, n) {
    rep(j, d) {
      cin >> x.at(i).at(j);
    }
  }
  
  int cnt = 0;
  rep(i, n) {
    for(int j = i+1; j < n; j++) {
      int dist = 0;
      rep(k, d) {
        int diff = abs(x.at(i).at(k) - x.at(j).at(k));
        dist += diff * diff;
      }
      for(int k = 0; k <= dist; k++) {
        if(k * k == dist) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}

        
      

Measured memory_bytes: 3612
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val s = next()

    if (s[0] != 'A') {
        println("WA")
        return
    }

    val ss = s.slice(2..s.length-2)
    if (ss.count { it == 'C' } != 1) {
        println("WA")
        return
    }

    if (s.count { it.isLowerCase() } != s.length-2) {
        println("WA")
    } else {
        println("AC")
    }
}

fun next() = readLine()!!

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 33648
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;

vector<vector<int>>edge;
vector<int> color;
int fec=1, snc=1;
queue<P> q;

int main(){
  int n;
  cin>>n;
  edge=vector<vector<int>> (n);
  color=vector<int>(n, -1);
  int a, b;

  REP(i, n-1){
    cin>>a>>b;
    --a;
    --b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  q.push(make_pair(0, 0));
  q.push(make_pair(n-1, 1));
  color[0]=0;
  color[n-1]=1;
  while(!q.empty()){
      int e=q.front().first;
      int c=q.front().second;
      q.pop();
      for(int i=0; i<edge[e].size(); ++i){
        int to=edge[e][i];
        if(color[to]!=-1) continue;
        q.push(make_pair(to, c));
        color[to]=c;
        if(c==0)++fec;
        else ++snc;
      }
  }
  if(fec>snc) cout<<"Fennec"<<endl;
  else cout<<"Snuke"<<endl;

  return 0;
}


Measured memory_bytes: 6272
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <tuple>
#include <set>

using namespace std;

using TUP = tuple<int, int, int>;
using PII = pair<int, int>;

int main() {
	int n, q, s, t, x, d;
	cin >> n >> q;

	vector<TUP> queries;
	for (int i = 0; i < n; i++) {
		cin >> s >> t >> x;

		queries.emplace_back(make_tuple(x, s, t));
	}
	sort(queries.begin(), queries.end());

	set<PII> ds;
	for (int i = 0; i < q; i++) {
		cin >> d;
		ds.insert(make_pair(d, i));
	}

	vector<int> ans(q, -1);
	for (auto query: queries) {
		tie(x, s, t) = query;
		// printf("query %3d %3d %3d: %3d %3d\n", x, s, t, s - x, t - x);

		auto it = ds.lower_bound(make_pair(s - x, 0));

		while (it != ds.end()) {
			if (it->first >= t - x) {
				break;
			}
			ans[it->second] = x;
			ds.erase(it++);
		}

	}

	for (auto z: ans) {
		cout << z << endl;
	}
	return 0;
}


Measured memory_bytes: 14448
#include<iostream>
using namespace std;
int main(){
  string str;
  cin >> str;
  string str1[3];
  int ii;
  int val = 100;
  int num = 0;
  for(ii=0;ii<3;ii++){
	str1[ii] = str[ii];
	if(str1[ii] == "o"){
	  num++;
	}
  }

  cout << (700 + num*val) << endl;
  return 0;
}


Measured memory_bytes: 384
# 2019/05/21
# AtCoder Grand Contest 027 - A

# For the Answer:
# 1. リストを昇順ソート
# 2. 小さい方から足していく
# 2-1. xと等しくなったら、答え
# 2-2. xを超えたら、最後の1個で満足するのがいるか探索(いなければ-1)
# 2-3. nまで足しても等しくなければ、-1

# Input
n, x = map(int, input().split())
a = list(map(int, input().split()))

# 1.
a.sort()

#2. 
acm = 0
ans = -1
for i in range(n):
    acm += a[i]
    # 2-1.
    if acm == x:
        ans = i + 1
        break
    # 2-2.
    elif acm > x:
        wk_acm = acm - a[i]
        j = i + 1
        while j < n:
            if wk_acm + a[j] == x:
                ans = i + 1
                break
            j += 1
        if j >= n:
            ans = i
        break

# 2-3.
if i == n - 1 and x != acm:
    ans = n - 1

# Output
print(ans)


Measured memory_bytes: 3064
#!python3

LI = lambda: list(map(int, input().split()))

# input
H, W = LI()
A = [input() for _ in range(H)]

MOD = 10 ** 9 + 7


def main():
    dp = [[0] * W for _ in range(H)]
    for i in range(H):
        if A[i][0] == "#":
            break
        dp[i][0] = 1
    for j in range(W):
        if A[0][j] == "#":
            break
        dp[0][j] = 1
    for i in range(1, H):
        for j in range(1, W):
            if A[i - 1][j] == ".":
                dp[i][j] = dp[i - 1][j]
            if A[i][j - 1] == ".":
                dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD
    ans = dp[-1][-1]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 49420
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
const int M=100010;
const int MOD=1000000007;
const int INF=1e16;
using ll=long long;

int main() {
	int n,k,a[200010],cnt=0,ans=0;
	vector<int> v(200010,200010);
	cin>>n>>k;
	rep(i,0,n){
		cin>>a[i];
		if(v[a[i]]==200010)v[a[i]]=0;
		v[a[i]]++;
	}
	sort(ALL(v));
	rep(i,0,200010)if(v[i]!=200010)cnt++;
	if(cnt>k)rep(i,0,cnt-k)ans+=v[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

int main() {
    int n;
    cin >> n;
    int a = n;
    int h = 0;
    while (a > 0) {
        h += a % 10;
        a /= 10;
    }

    if (n % h == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//===

// const ll mod = static_cast<int>(1e9 + 7);


int N, A, B, C;
Vi l;


int dfs(int cur, int a, int b, int c) {
	if (cur == N) {
		int res;
		if (min({ a, b, c }) > 0) {
			res = abs(a - A) + abs(b - B) + abs(c - C) - 30;
		}
		else {
			res = 2002002002;
		}
		return res;
	}

	int res0 = dfs(cur + 1, a, b, c);
	int res1 = dfs(cur + 1, a + l[cur], b, c) + 10;
	int res2 = dfs(cur + 1, a, b + l[cur], c) + 10;
	int res3 = dfs(cur + 1, a, b, c + l[cur]) + 10;

	return min({ res0, res1, res2, res3 });
}


int main() {

	cin >> N >> A >> B >> C;

	l.resize(N);
	for (int i = 0; i < N; ++i) {
		cin >> l[i];
	}

	int ans = dfs(0, 0, 0, 0);

	cout << ans << endl;
 }


Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
  int A, B, pc = 0;
  char S[20];
  scanf("%d %d %s", &A, &B, S);
  for (int i = 0; S[i] != '\0'; i++) {
    (S[i] == '-') ? pc += i + 1 : pc == 0;
  }
  pc == A + 1 ? printf("Yes") : printf("No");
  
  return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout<< "YES"<<endl;
#define No cout<< "No"<<endl;
#define Yes cout<< "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 1000000;

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


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

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

    vector<int> x;
    x.push_back(X);
    for (int i = 0; i < N; ++i) {
        int tmp;
        cin >> tmp;
        x.push_back(tmp);
    }

    sort(x.begin(), x.end());

    int gcd2 = x[1] - x[0];
    for (int i = 1; i < x.size(); ++i) {
        gcd2 = gcd(gcd2, x[i] - x[i - 1]);
    }
    cout << gcd2 << endl;
    return 0;

}


Measured memory_bytes: 892
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0)
    return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1; // 分母
  ll numerator = 1;   // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
private:
  vector<ll> parents;

public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) {
    return root(x) == root(y);
  }

  bool merge(ll x, ll y) {
    if (issame(x, y))
      return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry])
      swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) {
    return -parents[root(x)];
  }

private:
  ll root(ll x) {
    if (parents[x] < 0)
      return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

int main() {
  ll N;
  cin >> N;
  vector<ll> P(N);
  vector<ll> Q(N);
  vector<ll> permutation(N);
  for (ll i = 0; i < N; i++) {
    cin >> P[i];
    permutation[i] = i + 1;
  }

  for (ll i = 0; i < N; i++) {
    cin >> Q[i];
  }

  ll count = 0;
  ll pOrder = 0;
  ll qOrder = 0;
  do {
    bool flagP = true;
    bool flagQ = true;
    for (ll i = 0; i < N; i++) {
      if (permutation[i] != P[i]) {
        flagP = false;
      }

      if (permutation[i] != Q[i]) {
        flagQ = false;
      }
    }

    if (flagQ) {
      qOrder = count;
    }

    if (flagP) {
      pOrder = count;
    }

    count++;
  } while (next_permutation(permutation.begin(), permutation.end()));

  cout << abs(pOrder - qOrder) << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int x[100010];

int gcd(int x, int y) {
	//cout << x << " " << y << endl;
	if (y > x) return gcd(y, x);
	else if (y == 0) return x;
	else return gcd(y, x % y);
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N, X;
	cin >> N >> X;
	rep(i, N) {
		cin >> x[i];
	}
	x[N] = X;
	sort(x, x + N + 1);
	int G = x[1] - x[0];
	rep(i, N - 1) {
		G = gcd(G, x[i + 2] - x[i + 1]);
	}
	cout << G << endl;

    return 0;
}


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

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    if (n % 2 == 0)
    {
        cout << SP(10) << 1 / 2.0 << endl;
    }
    else
    {
        cout << SP(10) << (n-(n / 2)) / (double)n << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <map>
using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	while (1) {
		C -= B;
		if (C <= 0) {
			cout << "Yes" << endl;
			break;
		}
		A -= D;
		if (A <= 0) {
			cout << "No" << endl;
			break;
		}
	}
}


Measured memory_bytes: 3644
using DataStructures
const double = Float64
const int = Int64

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  N = readint()[1]
  A = Vector{int}(undef,N)
  for i in 1:N
    A[i] = readint()[1]
  end
  sp = sortperm(A)
  
  i1 = sp[end]
  m1 = A[sp[end]]
  m2 = A[sp[end-1]]

  for i in 1:N
    if i == i1
      println(m2)
    else
      println(m1)
    end
  end
  return
end



main()

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

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

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

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

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

    int N, A, B;
    cin >> N >> A >> B;
    printf("%lld\n", min(A * N, B));

    return 0;
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int count = 0;
    int ans = 0;
    for (int i = 1; i < s.size() - 1; i++) {
        vector<bool> alpha(26, false);
        count = 0;
        string a, b;
        a = "";
        b = "";
        for (int j = 0; j < i; j++) {
            a += s.at(j);
        }
        for (int j = i; j < s.size(); j++) {
            b += s.at(j);
        }
        for (int j = 0; j < a.size(); j++) {
            for (int k = 0; k < b.size(); k++) {
                if (a.at(j) == b.at(k) && !alpha.at(a.at(j) - 'a')) {
                    count++;
                    alpha.at(a.at(j) - 'a') = true;
                    goto next;
                }
            }
            next:;
        }
        ans = max(ans, count);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;

namespace Product
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string lastchr = str.Substring(str.Length - 1);
            if (lastchr == "2" || lastchr == "4" ||
                lastchr == "5" || lastchr == "7" ||
                lastchr == "9")
            {
                Console.WriteLine("hon");
            } else if
               (lastchr == "0" || lastchr == "1" ||
                lastchr == "6" || lastchr == "8")
            {
                Console.WriteLine("pon");
            } else
            {
                Console.WriteLine("bon");
            }
        }
    }
}


Measured memory_bytes: 25792
import java.util.Scanner;

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

		int K = sc.nextInt();
		String S = sc.next();

		int n=S.length();

		if(n<=K) {
			System.out.println(S);
		}else {
			for(int i=0;i<K;i++) {
				System.out.print(S.charAt(i));
			}
			System.out.println("...");
		}



	}
}


Measured memory_bytes: 35780
#include<iostream>
using namespace std;
int main(){
    int a , b , i;
    for(a = b = 1;a != 0 || b != 0;0){
        cin >> a >> b;
        if(a > b){
            i = a;
            a = b;
            b = i;
        }
        if(a == 0 && b == 0){
            break;

        }
        cout << a << " " << b <<endl;

    }
    return 0;

}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 0x3f3f3f3f;
const ll LINF = 1ll << 55;
const ll MOD = 1e9 + 7;
const ll MAXN = 400 + 5;
const ll MAXK = 1e5 + 10;

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

template<typename T>
ostream& operator<< (ostream& out, vector<T>& vec) {
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        out << *it << " ";
    }
    return out;
}

template<typename T>
istream& operator>> (istream& in, vector<T>& vec) {
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        in >> *it;
    }
    return in;
}

int main() {
    ll H, W, D;
    cin >> H >> W >> D;
    vll posx(H * W + 10);
    vll posy(H * W + 10);
    ll A;
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            cin >> A;
            posx[A] = i;
            posy[A] = j;
        }
    }
    vll sum(H * W + 10);
    for (int i = 1 + D; i <= H * W; ++i) {
        sum[i] = sum[i - D] + abs(posx[i] - posx[i - D]) + abs(posy[i] - posy[i - D]);
    }
    ll Q;
    ll L, R;
    cin >> Q;
    for (int i = 0; i < Q; ++i) {
        cin >> L >> R;
        cout << sum[R] - sum[L] << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) (V).begin(),(V).end()

int main() {
	int N;
	cin >> N;
	vector<ll> A(N);
	vector<ll> S(N);
	for (int i = 0;i < N;i++) {
		cin >> A[i];
	}
	sort(all(A));
	for (int i = 0;i < N;i++) {
		if (i)
			S[i] = S[i - 1] + A[i];
		else
			S[i] = A[i];
	}
	ll cnt = 1;
	for (int i = N - 1;i > 0;i--) {
		if (S[i - 1] * 2 >= A[i])
			cnt++;
		else
			break;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 1792
N, = map(int, input().split())
X = map(int, input().split())
from collections import defaultdict
d = defaultdict(int)
ccs = []
ccs2 = []
for x in X:
    d[x] += 1
    if d[x] == 2:
        ccs.append(x)
ccs.sort()
if len(ccs) > 1:
    r =ccs[-1]*ccs[-2]
    if d[ccs[-1]] >= 4:
        print(ccs[-1]**2)
    else:
        print(r)
else:
    print(0)


Measured memory_bytes: 66968
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		String result = "Draw";

		if (A == 1) {
			A = A * 100;
		}
		if (B == 1) {
			B = B * 100;
		}

		if (A > B) {
			result = "Alice";
		} else if (B > A) {
			result = "Bob";
		}
		System.out.println(result);
	}
}

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

const int N = 2e5 + 5;
typedef long long ll;

int n;
ll a[N], f[N], sum;

int main() {
	cin>>n;
	for(int i = 1; i <= n; i++) {
		cin>>a[i];
		if(i&1) sum += a[i];
		if(i == 1) continue;
		if(i&1) f[i] = max(f[i - 2] + a[i], f[i - 1]);
		else f[i] = max(f[i - 2] + a[i], sum);
	}
	cout<<f[n]<<endl;
}


Measured memory_bytes: 6748
import java.util.*;

class Main {
    public static void main(String args[]) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        
        int counter = 0;
        
        for(int i = 0; i < n - 2; ++i) {
            if((s.charAt(i) == 'A') && (s.charAt(i+1) == 'B') && (s.charAt(i+2) == 'C')) {
                ++counter;
            }
            else continue;
        }
        
        System.out.println(counter);

    }
}

Measured memory_bytes: 21844
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a >= 10 || b >= 10) {
			System.out.println("-1");
		} else {
			System.out.println(a * b);
		}

		sc.close();
	}
}

Measured memory_bytes: 27100
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define printA(arr) for(int i = 0; i < SZ(arr); i++){cout << arr[i];if (i==SZ(arr)-1){cout<<endl;}else{cout << " ";}}
typedef long long ll;

int main()
{
  vector<int> a;

  REP(i,3){
    int num;
    cin >> num;
    a.push_back(num);
  }
  int d;
  cin >> d;

  if ( (abs(a[2]-a[1])<=d && abs(a[1]-a[0]) <=d )|| abs(a[2] - a[0]) <= d){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


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

using namespace std;

#define INF 1e9
#define MAXN 200005
#define MAXM 100005
#define MOD 2019
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans = 0;
int N, cur;
string S;
vi Rems, tmp;
int remCnt[2019] = {};

int calcCombi(int n){
    return n*(n-1)/2;
}

int calcRem(int k){
    if(k == 0) return tmp[0];
    else{
        tmp[k] = 10*tmp[k-1]%MOD;
        return tmp[k];
    }

}

void solve(){
    Rems[0] = 0;

    rep(i, N){
        cur = S[i] - '0';
        // cout << cur << endl;
        Rems[i+1] = (Rems[i]+cur*calcRem(i))%MOD;
    }

    rep(i, N+1){
        remCnt[Rems[i]]++;
    }

    rep(i, 2019){
        if(remCnt[i] >= 2) ans += calcCombi(remCnt[i]);
    }

    cout << ans << endl;
}

int main(){
    cin >> S;
    N = S.size();

    Rems.resize(N+1);
    tmp.resize(N);
    tmp[0] = 1;

    reverse(S.begin(), S.end());

    solve();
}


Measured memory_bytes: 5172
n,c,k=map(int,input().split())
t=[int(input()) for _ in [0]*n]
t.sort()
b=1
h=0
d=t[0]
for i in range(n):
  if(h<c and t[i]-d<=k):
    h+=1
  else:
    b+=1
    h=1
    d=t[i]
print(b)

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

void selectionSort(int A[], int N) {
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        int minj = i;
        for (int j = i; j < N; j++) {
            if (A[j] < A[minj]) minj = j; //未ソート部分の最小値を探している
        }
        swap(A[i], A[minj]);
        if (i != minj) cnt++; //swap しないなら、インクリメントしない
    }
    rep(i,N) {
        cout << A[i];
        if (i != N-1) cout << " ";
    }
    printf("\n");
    cout << cnt << endl;
}

int main() {
    int n;
    cin >> n;
    int A[n];
    rep(i,n) cin >> A[i];

    selectionSort(A, n);

    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n;
	cin >> n;
	if(n / 10 == 9 || n % 10 == 9) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(x, n)              for (int x = 0; x < n; x++)
#define forr(x, n)              for (int x = n; x >= 0; x--)
#define fore(x, a, b, c)        for (int x = a; x <= b; x += c)
#define forre(x, a, b, c)       for (int x = a; x >= b; x -= c)
#define clr                     cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define all(container)          (container).begin(), (container).end()
#define rall(container)         (container).rbegin(), (container).rend()
#define FILL(x, val)            memset(x, val, sizeof(x))
#define pb                      push_back
#define eb                      emplace_back
#define fi                      first
#define se                      second
#define mod                     (int)1000000007
#define INF                     (int)0x3f3f3f3f

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

typedef long long i64; 
typedef vector< int > vi;
typedef vector< i64 > vi64;
typedef pair< int, int > pi;
typedef vector< pair< int, int > > vpi;

void crypt() {
	int n; cin >> n;
	i64 a, b, a_val = 0, b_val = 0;
	forn(i, n) {
		cin >> a >> b;
		if (!i) {a_val = a; b_val = b;}
		else {
			i64 x = a_val / a + (a_val % a ? 1 : 0);
			i64 y = b_val / b + (b_val % b ? 1 : 0);
			a_val = a * max(x, y);
			b_val = b * max(x, y);
		}
		trace(a_val, b_val);
	}
	cout << a_val + b_val << "\n";
}

int main(void) {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cout << setprecision(10);
	cout << fixed;
	int t = 1; 
//	cin >> t;
	while (t--) crypt();
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
ans_lsit = []

for i in range(-100, 101):
    tmp = 0
    for j in range(N):
        tmp += (i-a[j])**2
    ans_lsit.append(tmp)

ans = min(ans_lsit)
print(ans)

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

int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int main()
{
    int n,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                sum+=gcd(i,gcd(j,k));
            }
        }
    }

    cout<<sum;

}


Measured memory_bytes: 3636
#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 gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long int
#define s(x)	cin>>x
#define p(x)	cout<<x<<"\n"
#define goog(x, y)  cout<<"Case #"<<x<<": "<<y<<"\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 100000000000
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpi;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
typedef long double ld;

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);
int gcd(int a, int b) ;

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve() {
    int n;cin>>n;
    vl vals1,vals2;
    fo(i,n)
    {   ll a,b;cin>>a>>b;
        vals1.pb(a+b);
        vals2.pb(a-b);
    }
    ll maxv=0;
    sortall(vals1);
    sortall(vals2);
    
    
    maxv=max(maxv,vals1[n-1]-vals1[0]);
    maxv=max(maxv,vals2[n-1]-vals2[0]);
    p(maxv);
    
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

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

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    //u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

Measured memory_bytes: 13772
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define ind(a) scanf("%d", &a)
#define inlld(a) scanf("%lld", &a)
#define ind2(a, b) scanf("%d%d", &a, &b)
#define inlld2(a, b) scanf("%lld%lld", &a, &b)
#define ind3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define inlld3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

using namespace std;

const int N=1e5+5;
const int MOD=1e9+7;

typedef long long ll;
typedef long double ld;

ll n, dp[N], arr[N];

int main() 
{
    inlld(n);
    for(ll a=1; a<=n; a++)
        inlld(arr[a]);
    dp[1]=0;
    dp[2]=abs(arr[2]-arr[1]);
    for(ll a=3; a<=n; a++)
        dp[a]=min(dp[a-1]+abs(arr[a-1]-arr[a]), dp[a-2]+abs(arr[a-2]-arr[a]));
    printf("%lld\n", dp[n]);
    return 0;
}



Measured memory_bytes: 1792
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

bool is_prime(long long N) {
    if (N == 1)
        return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0)
            return false;
    }
    return true;
}

int main() {
    ll X;
    cin >> X;
    while (true) {
        if (is_prime(X)) {
            cout << X << endl;
            return 0;
        }
        X++;
    }
}

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

int main()
{
  int n, m;
  int k;
  while (cin >> n >> m)
  {
    if (n<m) swap(n,m);
    while (m>0)
    {
      k=n; n=m; m=k % m;
    }
    cout << n << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
/**
 *    +--+--+--++--++--In the name of ALLAH--++--++--+--+--+
 *
 *    author:  skmonir
 *    created: 31-May-2020 18:07:13
**/

#include <bits/stdc++.h>

using namespace std;

#define endl                '\n'
#define TN                  typename
#define mod                 1000000007LL
#define len(x)              (int) x.size()
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define mem(x, y)           memset(x, y, sizeof x)
#define FOR(x, l, r)        for (int x = l; x <= r; ++x)
#define ROF(x, l, r)        for (int x = l; x >= r; --x)

template <TN T> inline void Int(T &n) {
    n = 0; int f = 1; int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> inline void umin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void umax(T &a, T b) {a = a > b ? a : b;}
template <TN T, TN W> inline void Int(T &x, W &y) {Int(x), Int(y);}
template <TN T, TN W, TN Q> inline void Int(T &x, W &y, Q &z) {Int(x, y), Int(z);}

const int N = 1e5 + 7;
const int inf = 1e9 + 7;


int solve() {
    long long A;
    double b;
    cin >> A >> b;

    b *= 1000.0;

    long long B = (long long) b;
    B /= 10;

    long long c = A * B;

    cout << c / 100 << endl;

    return 0;
}

int main() {
    int tests = 1, CaseNo = 0;
    // Int(tests);
    while (tests--) {
        //printf("Case %d: ", ++CaseNo);
        solve();
    }
    return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define mp(a, b) make_pair(a, b)
typedef pair<int, int> pii; 
const int maxn = 1000 + 10;
int n, m;
const int dx[] = {0, -1, 0, 1};
const int dy[] = {-1, 0, 1, 0};
queue<pii> Q;
char s[maxn][maxn];
int vis[maxn][maxn], ans;
int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++i)
		scanf("%s", s[i] + 1);
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
		{
			vis[i][j] = -1;
			if(s[i][j] == '#')
			{ 
				vis[i][j] = 0; 
				Q.push(mp(i, j));
			}
		}
	while(!Q.empty())
	{
		pii x = Q.front(); Q.pop();
		ans = max(ans, vis[x.first][x.second]);
		for(int i = 0; i < 4; ++i)
			if(vis[x.first + dx[i]][x.second + dy[i]] == -1)
			{
				vis[x.first + dx[i]][x.second + dy[i]] = ans + 1;
				Q.push(mp(x.first + dx[i], x.second + dy[i]));
			}
	}
	printf("%d\n", ans);
	return 0;
}
	

Measured memory_bytes: 13456
#include <stdio.h>
#include <stdlib.h>

typedef struct {
    long long int a;
    long long int b;
} drink;

int cmp( const void *p, const void *q ) {
	int n= ((drink*)p)->a - ((drink*)q)->a;
	if(n==0)
		n= ((drink*)q)->b - ((drink*)p)->b;
	return n;
}


int main(void)
{
 	long long int i,n,m,j=0;
 	long long int sum=0;
 	scanf("%lld%lld",&n,&m);
 	drink ab[n];
 	
 	for(i=0;i<n;i++)
	 	scanf("%lld%lld",&ab[i].a,&ab[i].b);

    qsort( ab, sizeof ab / sizeof(drink), sizeof(drink), cmp );
    
    while(m>0){
    	if(ab[j].b>=m){
    		sum+=ab[j].a*m;
    		printf("%lld",sum);
    		return 0;
    	}
    	else{
    		m=m-ab[j].b;
    		sum+=ab[j].a*ab[j].b;
    	}
    	j++;
    }
    return 0;
}

Measured memory_bytes: 3324
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
typedef pair<ll, ll> p;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const long long mod = 1e9 + 7;
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);

int main() {

    ll sx, sy, tx, ty;

    cin >> sx >> sy >> tx >> ty;

    string ans = "";

    if (sx != tx && sy != ty) {
        rep(i, ty - sy) ans += 'U';
        rep(i, tx - sx) ans += 'R';
        rep(i, ty - sy) ans += 'D';
        rep(i, tx - sx) ans += 'L';
        ans += 'L';
        rep(i, ty - sy + 1) ans += 'U';
        rep(i, tx - sx + 1) ans += 'R';
        ans += "DR";
        rep(i, ty - sy + 1) ans += 'D';
        rep(i, tx - sx + 1) ans += 'L';
        ans += 'U';
    }
    else if (sx == tx) {
        rep(i, ty - sy) ans += 'U';
        ans += 'R';
        rep(i, ty - sy) ans += 'D';
        ans += 'LL';
        rep(i, ty - sy) ans += 'U';
        ans += "RURR";
        rep(i, ty - sy + 1) ans += 'D';
        ans += 'LLU';
    }
    else if (sy == ty) {
        rep(i, tx - sx) ans += 'R';
        ans += 'D';
        rep(i, tx - sx) ans += 'L';
        ans += 'UU';
        rep(i, tx - sx) ans += 'R';
        ans += "DRDD";
        rep(i, tx - sx + 1) ans += 'L';
        ans += 'UUR';
    }

    cout << ans;

    return 0;
}



ll gcd(ll a, ll b) {
    if (a % b == 0)return(b);
    else return(gcd(b, a % b));
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <math.h>
#include <string.h>

long int func(long int n, long int N);

//Nが七五三数ならば1，そうでなければ0を返す関数
int judge(long int N);

int main(void){
  long int N;
  scanf("%ld", &N);

  printf("%ld\n", func(0, N));
  return 0;
}


int judge(long int N){
  int buf;//一時的にデータを蓄える
  int l = 1;//Nの桁数
  int i, j, k;//カウンタ
  int state = 1;//Nが準七五三数ならば1，そうでなければ0
  int state_3 = 0;//Nに3が含まれれば1，そうでなければ0
  int state_5 = 0;//Nに5が含まれれば1，そうでなければ0
  int state_7 = 0;//Nに7が含まれれば1，そうでなければ0
  long int a[10];//a[i] = 10^i

  a[0] = 1;
  for(i = 1; i < 10; i++){
    a[i] = a[i-1]*10;
  }

  //Nの桁数lを求める
  for(i = 0; i < 9; i++){
    if(N >= a[i] && N < a[i+1]){
      l = i+1;
      break;
    }
  }

  //Nが準七五三数かどうかを確かめる
  for(i = 0; i < l; i++){
    buf = (N/a[i])%10;
    if(buf != 3 && buf != 5 && buf != 7){
      state = 0;
    }
  }
  //ここで state == 1 ならば，Nは準七五三数

  if(state == 1){
    //Nが七五三数かどうかを確かめる
    for(i = 0; i < l; i++){
      buf = (N/a[i])%10;
      if(buf == 3){
        state_3 = 1;
      }
      if(buf == 5){
        state_5 = 1;
      }
      if(buf == 7){
        state_7 = 1;
      }
    }
    //ここで state_3 == 1 && state_5 == 1 && state_7 == 1 ならば，Nは七五三数
  }

  if(state == 1 && state_3 == 1 && state_5 == 1 && state_7 == 1){
    return 1;
  }
  else{
    return 0;
  }
}

//d(n):nの桁数
//func(n,N):1以上N以下の整数のうち，上d(n)桁がnであるような七五三数の数
//とくに，d(0)は1以上N以下の七五三数すべての個数
long int func(long int n, long int N){
  if(n > N){
    return 0;
  }
  else if(judge(n) == 1){
    return 1 + func(n*10 + 3, N) + func(n*10 + 5, N) + func(n*10 + 7, N);
  }else{
    return func(n*10 + 3, N) + func(n*10 + 5, N) + func(n*10 + 7, N);
  }
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)++)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define input(x) x; cin >> x;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

using pii = pair<int, int>;

int main(){
	while(true){
		int N;
		cin >> N;
		if(N == 1){
			cout << 1 << " " << 1 << endl;
		}else{

		int n,d,c;
		if (N == 0){
			break;
		}
		int field[500][500] = {0};
		pair<int, int> arr[200];
		arr[0] = make_pair(200,200);
		field[200][200] = 1;
		for (int i = 1; i < N; ++i){
			cin >> n >> d;
			if (d == 0){
				arr[i] = make_pair(arr[n].first-1, arr[n].second);
			}else if (d == 1){
				arr[i] = make_pair(arr[n].first, arr[n].second+1);
			}else if (d == 2){
				arr[i] = make_pair(arr[n].first+1, arr[n].second);
			}else{
				arr[i] = make_pair(arr[n].first, arr[n].second-1);
			}
			// cout << arr[i].first << " " << arr[i].second << endl;
			field[arr[i].first][arr[i].second] = 1;
		}
		// rep(i, 500){
		// 	rep(j, 500){
		// 		cout << field[i][j] << " ";
		// 	}
		// 	cout << endl;
		// }

		vector<int> r0;
		vector<int> r1;
		rep(i, 500){
			rep(j, 500){
				if(field[i][j]){
					r0.push_back(i);
					r1.push_back(j);
				}
			}
		}
		int minv = 1000;
		int maxv = 0;
		for(int i: r0){
			if(minv > i){
				minv = i;
			}
			if(maxv < i){
				maxv = i;
			}
		}
		int minva = 1000;
		int maxva = 0;
		for(int i: r1){
			if(minva > i){
				minva = i;
			}
			if(maxva < i){
				maxva = i;
			}
		}
		// p("%d %d %d %d", minv, maxv, maxva, minva);

		p("%d %d", maxv - minv + 1, maxva - minva + 1);
	}
	}
}

Measured memory_bytes: 4240
#include <iostream>

using namespace std;

int main()
{
    int a, b, k;

    cin >> k;
    cin >> a >> b;

    bool flg = false;

    for (int i = a; i <= b; i++)
    {
        if (i % k == 0)
        {
            flg = true;
            break;
        }
    }

    if (flg)
    {
        cout << "OK" << endl;
    }
    else
    {
        cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
const int SIZE=55;

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

char a[SIZE][SIZE];
int h,w;

bool check(int x,int y){
	for(int i=0;i<4;i++){
		int ux=x+dx[i];
		int uy=y+dy[i];
		if(ux<0 && ux>=h && uy<0 && uy>=w) continue;
		if(a[ux][uy]=='#') return true;
	}
	return false;
}

int main(){
	cin>>h>>w;
	for(int i=0;i<h;i++) cin>>a[i];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(a[i][j]=='#' && !check(i,j)){
				cout<<"No\n";
				return 0;
			}
		}
	}
	cout<<"Yes\n";
	return 0;
}




Measured memory_bytes: 256