akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int M, T, P, R;

struct Team {
    int id, penalty[11], score, ans;
    Team() {
        for (int i = 0; i < 11; ++i)
            penalty[i] = 0;
        score = ans = 0;
    }
};

bool cmp(const Team &a, const Team &b)
{
    return (a.ans > b.ans) || (a.ans == b.ans && (a.score < b.score))
        || ((a.ans == b.ans && a.score == b.score && a.id > b.id));
}

int main()
{
    while (cin >> M >> T >> P >> R) {
        if (M + T + P + R == 0)
            break;

        Team team[T];
        for (int i = 0; i < T; ++i)
            team[i].id = i + 1;

        int m, t, p, j;
        for (int i = 0; i < R; ++i) {
            cin >> m >> t >> p >> j;

            --t;
            if (j == 0) { // 正解
                ++team[t].ans;
                team[t].score += m + 20 * team[t].penalty[p];
            }
            else { // 不正解
                ++team[t].penalty[p];
            }
        }

        sort(team, team + T, cmp);

        cout << team[0].id;
        for (int i = 1; i < T; ++i) {
            if (team[i - 1].ans == team[i].ans &&
                team[i - 1].score == team[i].score)
                cout << "=";
            else
                cout << ",";
            cout << team[i].id;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1164
//BELIEVE IN YOURSELF
//next_permutation

#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 100005
#define se second
#define fi first
#define be begin()
#define en end()
#define sortv(v) sort(v.begin(),v.end());
#define sortr(v) sort(v.rbegin(),v.rend());
#define w() ll _;cin>>_;while(_--)
#define edge pair<ll,ll>
#define pq priority_queue<ll>
#define mod 1000000007
#define Endl "\n"
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;

ll mod_pow(ll a,ll n)
{
	ll res=1;
	
	while(n)
	{
		if(n%2)
		{
			res%=mod;
			a%=mod;
			res=(res*a)%mod;
			n--;
		}
		else
		{
			a%=mod;
			a*=a;
			a%=mod;
			n/=2;
		}
		
	}
	return res%mod;
}

int main()
{
	fast;
	ll i;
	ll n;
	cin>>n;
	if(n<2)
	{
		cout<<0<<endl;
		return 0;
	}
	ll ans=(mod+mod_pow(10,n)%mod+mod_pow(8,n)%mod-(2*mod_pow(9,n))%mod)%mod;
	
	cout<<ans<<Endl;
	
	
	
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  if (s =="SUN") cout << 7 << endl;
  if (s =="MON") cout << 6 << endl;
  if (s =="TUE") cout << 5 << endl;
  if (s =="WED") cout << 4 << endl;
  if (s =="THU") cout << 3 << endl;
  if (s =="FRI") cout << 2 << endl;
  if (s =="SAT") cout << 1 << endl;
}


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

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

const int INF=1e9;
const int MOD=1e9+7;

template<typename T>
struct BIT{
    int n;
    vector<T> f;
    BIT(int n = 500002) : n(n), f(n + 1) {}
 
    T getsum(int p){
        T ret = 0;
        for (++p; p > 0; p -= p & -p){
            ret += f[p];
        }
        return ret;
    }
    
    void add(int p, T x){
        for (++p; p <= n; p += p & -p){
            f[p] += x;
        }
    }
};

int main(){
    int N,Q; cin >> N >> Q;
    int c[N]; 
    for(int i=0;i<N;i++){
        cin >> c[i]; c[i]--;
    }
    pair<int,pair<int,int>> q[Q];
    for(int i=0;i<Q;i++){
        int l,r; cin >> l >> r; l--; r--;
        q[i]={l,{r,i}};
    }
    sort(q,q+Q);
    int cur[N];
    int right[N+1];
    fill(right,right+N,INF);
    fill(cur,cur+N,-INF);
    for(int i=N-1;i>=0;i--){
        if(right[c[i]]==INF) right[c[i]]=i;
        else{
            cur[i]=right[c[i]];
            right[c[i]]=i;
        }
    }
    vector<int> a(N,0);
    BIT<int> bi;
    int ans[Q];
    int l=N-1;
    for(int i=Q-1;i>=0;i--){
        for(int j=l;j>=q[i].first;j--){
            if(cur[j]>=q[i].first){
                bi.add(cur[j],1);
            }
        }
        l=q[i].first-1;
        ans[q[i].second.second]=q[i].second.first-q[i].first+1-bi.getsum(q[i].second.first);
    }
    for(int i=0;i<Q;i++){
        cout << ans[i] << endl;
    }
}

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

int main()
{
   int a,b,c;
   cin>>a>>b;
   while(1){
       c=a%b;
       a=b;
        b=c;
        if(b==0) break;
   }
   cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 3108
# coding: utf-8
group = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
x, y = map(int, input().split())
for i in range(3):
    if x in group[i]:
        x = i
    if y in group[i]:
        y = i
print(['No', 'Yes'][x == y])


Measured memory_bytes: 2940
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))


bsup = 0
asup = 0
for i in range(n):
    if b[i] > a[i]:
        bsup += (b[i]-a[i])//2
    else:
        asup += a[i]-b[i]

if bsup >= asup:
    print("Yes")
else:
    print("No")

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

using namespace std;

using ll=int64_t;

void factorize(ll n,ll p)
{
    ll ans=1,r=p;
    for(ll i=2;i*i<=p;i++)
    {
        if(r%i==0)
        {
            ll power=0;
            while(r%i==0)
            {
                r/=i;
                ++power;
            }
            power/=n;
            if(power)
            {
                for(ll j=1;j<=power;j++)
                {
                    ans*=i;
                }
            }
        }
    }
    if(n==1)
        ans*=r;

    cout<<ans<<endl;
}

int main()
{
    ll n,p;
    cin>>n>>p;
    factorize(n,p);
}


Measured memory_bytes: 256
def dfs(xy, mat)
  mat.delete(xy)
  i, j = xy.split.map(&:to_i)
  direc = [[1,0],[0,1],[-1,0],[0,-1]]
  direc.each{|dx,dy|
    next if i+dx < 0 || j+dy < 0 || i+dx > 11 || j+dy > 11
    key = "#{i+dx} #{j+dy}"
    mat = dfs(key,mat) if mat[key]
  }
  return mat
end

arr = readlines

while arr.size > 0
  mat = Hash.new
  12.times{|i|
    line = arr.shift
    a = line.chomp.split("")
    12.times{|j|
      mat["#{i} #{j}"] = 1 if a[j] == "1"
    }
  }
  count = 0
  while mat.size > 0
    xy = mat.keys[0]
    mat = dfs(xy,mat)
    count += 1
  end
  puts count
  arr.shift if arr.size > 1
end

Measured memory_bytes: 8992
# -*- coding: utf-8 -*-


def higher_search(list, key):
    l = -1
    r = len(list)

    while r - l > 1:
        mid = l + (r - l) // 2
        if list[mid] > key:
            r = mid
        else:
            l = mid

    if r == len(list):
        return -1
    else:
        return r


def lower_search(list, key):
    l = -1
    r = len(list)

    while r - l > 1:
        mid = r - (r - l) // 2
        if list[mid] < key:
            l = mid
        else:
            r = mid

    if l == -1:
        return -1
    else:
        return l


n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

ans = 0
for b in B:
    a_index = lower_search(A, b)
    c_index = higher_search(C, b)
    if c_index == -1:
        c_index = n
    ans += (a_index + 1) * (n - c_index)

print(ans)


Measured memory_bytes: 23328
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <queue>
 
using namespace std;
 
struct Edge {
    int to, cost;
    Edge(int to, int cost) : to(to), cost(cost){}
    Edge(){}
};
 
bool operator < (const Edge &a, const Edge &b)
{
    return (a.cost > b.cost);
}
 
long long int accessable[100000];
bool vis[100000];
vector<Edge> TG[100000];
vector<int> G[100000];
int c[40000], d[40000];
vector<int> topo;
 
void dfs(int v)
{
    vis[v] = true;
     
    for (int i = 0; i < G[v].size(); i++)
        if (!vis[G[v][i]]) dfs(G[v][i]);
    topo.push_back(v);
}
 
int main()
{
    int N, M;
     
    scanf("%d %d", &N, &M);
     
    for (int i = 0; i < M; i++){
        int u, v, w;
        scanf("%d %d %d", &u, &v, &w);
        --u; --v;
        TG[u].push_back(Edge(v, w));
        TG[v].push_back(Edge(u, w));
    }
     
    int a, b, Q;
     
    scanf("%d %d %d", &a, &b, &Q);
     
    --a; --b;
     
    for (int i = 0; i < Q; i++){
        scanf("%d %d", c + i, d + i);
        --c[i]; --d[i];
    }
     
    priority_queue<Edge> pq;
    bool done[100000] = {0};
    int weight[100000];
    fill(weight, weight + N, 1001001001);
     
    for (pq.push(Edge(a, 0)); pq.size(); pq.pop()){
        Edge x = pq.top();
         
        if (done[x.to]) continue;
        done[x.to] = true;
        weight[x.to] = x.cost;
         
        for (int i = 0; i < TG[x.to].size(); i++){
            pq.push(Edge(TG[x.to][i].to, x.cost + TG[x.to][i].cost));
        }
    }
     
    int in[100000] = {0};
    queue<int> q;
    memset(done, 0, sizeof(done));
     
    for (q.push(b); q.size(); q.pop()){
        int x = q.front();
        if (done[x]) continue;
        for (int i = 0; i < TG[x].size(); i++){
            if (weight[x] == weight[TG[x][i].to] + TG[x][i].cost){
                q.push(TG[x][i].to);
                G[TG[x][i].to].push_back(x);
                in[x]++;
            }
        }
        done[x] = true;
    }
     
    for (int i = 0; i < N; i++){
        if (!in[i]) dfs(i);
    }
    reverse(topo.begin(), topo.end());
     
    for (int i = 0; i < (Q + 63) / 64; i++){
        memset(accessable, 0, sizeof(accessable));
        for (int j = i * 64; j < min(Q, (i + 1) * 64); j++){
            accessable[c[j]] |= (1ll << (j % 64));
        }
        for (int j = 0; j < topo.size(); j++){
            for (int k = 0; k < G[topo[j]].size(); k++){
                accessable[G[topo[j]][k]] |= accessable[topo[j]];
            }
        }
        for (int j = i * 64; j < min(Q, (i + 1) * 64); j++){
            if ((accessable[d[j]] >> (j % 64)) & 1) puts("Yes");
            else puts("No");
        }
    }
     
    return (0);
}

Measured memory_bytes: 20864
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007; // 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const ld PI = acos((ld)-1);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template <typename T> V<T> prefix_sum(const V<T>& v) {
  int n = v.size();
  V<T> ret(n + 1);
  rep(i, 0, n) ret[i + 1] = ret[i] + v[i];
  return ret;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
  return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
  os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n;cin>>n;
  V<ll> x(n),y(n);
  rep(i,0,n)cin>>x[i]>>y[i];

  rep(i,0,n){
    ll nx=x[i]+y[i],ny=x[i]-y[i];
    x[i]=nx;
    y[i]=ny;
  }

  sort(all(x));
  sort(all(y));
  
  ll ans=max(x[n-1]-x[0],y[n-1]-y[0]);
  cout<<ans<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 6360
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define de(x) cout<<#x<<" = "<<x<<"\n"
#define dd(x) cout<<#x<<" = "<<x<<" "
#define mes(p) memset(p,0,sizeof(p))
#define per(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(x) x.begin(),x.end()
#define rson mid+1,r,rt<<1|1
#define sz(x) (int)x.size()
#define lson l,mid,rt<<1
#define pb push_back
#define mp make_pair
//#define ls (rt<<1)
#define se second
//#define rs (ls|1)
#define fi first
typedef pair <int ,int > pi;
typedef vector <int > vi;
typedef long long ll;
const int maxn  = 1e5+5;
const int mod = 1e9+7;
char s[maxn];
int dp[maxn][20], a[maxn];
int add(int a,int b){
	if((a+=b)>=mod) a-=mod;
	return a;
}

int main(){	
	ios_base::sync_with_stdio(0);
    cin.tie(0);
	cin >> s;
	int n = strlen(s);
	rep(i,1,n+1) 
	if(s[i-1]!='?')a[i] = s[i-1] - '0';
	else a[i]= -1;
	//if(a[1] == -1) rep(i,0,10) dp[1][i] = 1;
	//else dp[1][a[1]] = 1;
	dp[0][0] = 1;
	rep(i,0,n+1){
		int l=0, r = 9;
		if(a[i]!=-1) r=l=a[i];
		rep(k,0,14){
			rep(j,l,r+1){
				int t =((k*10)+j)%13;
				dp[i+1][t] = add(dp[i+1][t], dp[i][k]);
			}
		}
	}
	cout << dp[n+1][5];
	return 0;
}


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

typedef long long LL;
#define lowbit(x) ((x)&(-x))
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a))
#define	GE() printf(">----------\n")
#define	IN() freopen("in.txt","r",stdin)
#define	OUT() freopen("out.txt","w",stdout)
const int mod=1000000007;
const int inf=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-8;
const int maxn=100005;

int n, v, vis[maxn];

int main()
{
    while(~scanf("%d", &n)){
        memset(vis, 0);
        int ans=0, add=0;
        for(int i=0;i<n;i++){
            scanf("%d", &v);
            if(!vis[v/400]&&v<3200)ans++;
            if(v>=3200)add++;
            vis[v/400]++;
        }
        printf("%d %d\n", ans?ans:1, ans+add);
    }
    return 0;
}



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

void call(int n) {
  for (int i{1}; i <= n; ++i) {
    int x = i;
    if (x % 3 == 0) {
      cout << " " << i;
    } else {
      do {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
      } while (x /= 10);
    }
  }
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  call(n);
  return 0;
}



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

int main() {
    int s,t;
    cin >> s;
    vector<int> A(1000000);
    A.at(0) = s;
    bool search = false;

    for (int i = 1; i < 1000000; i++) {
        if (A.at(i - 1) % 2 == 0) {
            A.at(i) = A.at(i - 1) / 2;
        }

        else {
            A.at(i) = 3 * A.at(i - 1) + 1;
        }

        for (int j = 0; j < i; j++) {
            if (A.at(i) == A.at(j)) {
                search = true;
                t = i + 1;
                break;
            }
        }

        if (search) {
            break;
        }
    }

    cout << t << endl;

}

Measured memory_bytes: 4096
import math
from decimal import Decimal

n, k = [int(i) for i in input().split()]

win_p = []

for n0 in range(1, n+1):
    if k <= n0:
        win_p.append(1)
        continue
    x = math.ceil(math.log2(Decimal(str(k)) / Decimal(str(n0))))
    win_p.append(Decimal(0.5)**x)

print('{:.9f}'.format(sum(win_p) / n))


Measured memory_bytes: 6464
// Shift-JIS（シフトジス）

#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 v = 0;
    int h = 0;
    for (int i = 0; i < N; i++) {
        if (h <= H[i]) {
            v++;
            h = H[i];
        }
    }
    cout << v << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <set>
using namespace std;

const int INF = INT_MAX;
struct Elem {
    int l, r, val;
    Elem(int a, int b, int x) : l(a), r(b), val(x) {}
    bool operator<(const Elem &e) const {
        return l < e.l;
    }
};

int main() {
    while(1) {
        int N; scanf("%d", &N);
        if(!N) break;

        set<Elem> S;
        S.insert(Elem(INF, INF, -1));
        while(N--) {
            char c; scanf(" %c", &c);
            if(c == 'W') {
                int val, width; scanf(" %d%d", &val, &width);
                int prev = 0;
                for(auto it=S.begin(); it!=S.end(); it++) {
                    Elem e = *it;
                    int diff = e.l - prev;
                    if(diff == 0) {
                        prev = e.r;
                    }
                    else {
                        int nwid = min(diff, width);
                        int nl = prev, nr = prev + nwid;
                        S.insert(Elem(nl, nr, val));
                        width -= nwid;
                        if(width == 0) break;
                        prev = e.r;
                    }
                }
            }
            if(c == 'D') {
                int id; scanf(" %d", &id);
                for(auto it=S.begin(); it!=S.end(); it++) {
                    Elem e = *it;
                    if(e.val == id) S.erase(it);
                }
            }
            if(c == 'R') {
                int idx; scanf(" %d", &idx);
                bool found_val = false;
                for(auto it=S.begin(); it!=S.end(); it++) {
                    Elem e = *it;
                    if(e.l <= idx && idx < e.r) {
                        printf("%d\n", e.val);
                        found_val = true;
                    }
                }
                if(!found_val) printf("-1\n");
            }

            /*
            printf("operate end\n");
            for(auto it=S.begin(); it!=S.end(); it++) {
                Elem e = *it;
                printf("l = %d, r = %d, val = %d\n", e.l, e.r, e.val);
            }
            */
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2932
import java.util.Scanner;

public class Main {
    private static final int YUKICHI = (int) 1e4;
    private static final int HIGUCHI = (int) (5 * 1e3);
    private static final int NOGUCHI = (int) 1e3;

    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int y = scanner.nextInt();

        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n - i; j++) {
                if (YUKICHI * i + HIGUCHI * j + NOGUCHI * (n - i - j) == y) {
                    System.out.println(i + " " + j + " " + (n - i - j));
                    return;
                }
            }
        }

        System.out.println("-1 -1 -1");
    }
}


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

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    string s;
    cin >> s;
    int n = s.length();
    sort(s.begin(), s.end());
    if (s[0] == 'a' && s[1] == 'b' && s[2] == 'c') cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<queue>
#include<limits>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
using namespace std;

void prob138() {
	int N; cin >> N;
	priority_queue<double,vector<double>,greater<double>> pq;
	for (int i = 0; i < N; i++) {
		double x;
		cin >> x;
		pq.push(x);
	}

	for (int i = 0; i < N - 1; i++) {
		double x = pq.top(); pq.pop();
		double y = pq.top(); pq.pop();
		double z = (x + y) / 2;
		pq.push(z);
	}

	printf("%.10lf\n", pq.top());
}

void prob136() {
	int N; cin >> N;
	int max = 0, min = int_INF;
	bool flag = false;
	rep(i, N) {
		int x; cin >> x;
		if (x > max) {
			max = x; min = int_INF;
		}
		x <= min ? min = x : 1;
		if (max - min > 1) {
			flag = true;
			break;
		}
	}

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

void prob140() {
	int N; cin >> N;
	vector<int> B(N + 1);
	B[0] = int_INF; B[N] = int_INF;
	for (int i = 1; i < N; i++) {
		cin >> B[i];
	}
	ll ans = 0;
	for (int j = 0; j < N; j++) {
		ans += min(B[j], B[j + 1]);
	}

	cout << ans << endl;
}

void prob141() {
	int N, K, Q; cin >> N >> K >> Q;
	vi Contestants(N);
	rep(i, Q) {
		int x;
		cin >> x;
		Contestants[--x]++;
	}

	rep(i, N) {
		if (Contestants[i] + K - Q > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}
int main() {
	prob141();
}

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

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vec;
typedef std::vector<ld> vecld;
typedef std::vector< std::vector<ll> > vecvec;
typedef std::pair<ll, ll> pr;
typedef std::vector< pr > vpr;

#define tin ll t;cin>>t;while(t--)
#define fio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define sz(a) (ll)((a).size())
#define pb push_back
#define trvect(c,i) for(vector<ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define trset(c,i) for(set<ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define trmap(c,i) for(map<ll,ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repp(i,a,b) for(ll i=a;i<=b;i++)
#define present(c,x) ((c).find(x) != (c).end())
#define ff first
#define ss second
#define mp make_pair
#define sq(a) (a)*(a)
#define cube(a) (a)*(a)*(a)
#define cnti(x) (__builtin_popcount(x)) //number of set bits in x
#define mod 1000000007
#define N 100005

ll qpow (ll n, ll m) {
	ll ret = 1;
	while (m) {
		if (m & 1) ret = ret * n % mod;
		n = n * n % mod;
		m >>= 1;
	}
	return ret;
}
ll inv (ll a) {
	return qpow(a, mod - 2);
}

// -------------------------------------------------------------------------------- //

ll gcdd(ll a,ll b){
	if(b==0)
		return a;
	return gcdd(b,a%b);
}

ll gcd(ll a,ll b, ll c){
	return gcdd(a,gcdd(b,c));
}

int main(){
    
    // double r;
    // cin>>r;
    // double c = 2*M_PI*r;
    // cout<<fixed;
    // // cout<<M_PI;
    // cout<<setprecision(10)<<c<<"\n";
    // ll n;
    // cin>>n;
    // ll arr[n],freq[n+1]={0};
    // rep(i,0,n-1) cin>>arr[i],freq[arr[i]]++;

    // repp(i,1,n)
    // 	cout<<freq[i]<<"\n";
    ll k;
    cin>>k;
    ll sum=0;
    repp(i,1,k)
    	repp(j,1,k)
    		repp(l,1,k)
    			sum+=gcd(i,j,l);

    cout<<sum;
}


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

ll dp[100001];

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    for (int i = 1; i < n; ++i) {
        int step1 = dp[i-1] + abs(h[i]-h[i-1]);
        int step2 = 100100101;
        if (i > 1) step2 = dp[i-2] + abs(h[i]-h[i-2]);
        dp[i] = min(step1, step2);
    }
    ll ans = dp[n-1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
	    List<Integer> list = new ArrayList<>();
	    list.add(a);
	    list.add(b);
	    list.add(c);
	    
	    if(list.contains(5)) {
	    	list.remove(list.indexOf(5));
	    	if(list.contains(5)) {
	    		list.remove(list.indexOf(5));
	    		if(list.contains(7)) {
	    			list.remove(list.indexOf(7));
	    			System.out.println("YES");
	    		} else {
	    			System.out.println("NO");
	    		}
	    	}else {
	    		System.out.println("NO");
	    	}
	    } else {
	    	System.out.println("NO");
	    }
		
	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits.h>

using namespace std;

int main()
{
	int A, B, C;
	int X, Y;

	cin >> A >> B >> C >> X >> Y;

	long long ans = LLONG_MAX;

	for (int i = 0; i < X + Y; i++) {
		long long sum = i * 2 * C;
		
		if (X - i > 0)
		{
			sum += A * (X - i);
		}

		if (Y - i > 0)
		{
			sum += B * (Y - i);
		}

		if (ans > sum)
		{
			ans = sum;
		}
	}

	cout << ans << endl;

	return 0;
}


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

#define datatype int

typedef struct edge_sub {
	int v;
	struct edge_sub *next;
}edge;

typedef struct {
	int num;
	int parent;
	int grundy;
	edge *e;
}vertex;

typedef enum{
	false,
	true
}Boolean;

typedef struct node_sub{
	datatype data;
	struct node_sub *next;
}node;

typedef struct {
	node *fst;
	node *last;
	int num;
}queue;

queue *make_queue(){
	queue *q = (queue *)malloc(sizeof(queue));
	q->fst = NULL;
	q->last = NULL;
	q->num = 0;
	return q;
}

Boolean is_empty_q(queue *q){
	if(q->num == 0){
		return true;
	}
	else{
		return false;
	}
}

void add_data_q(datatype val, queue *q){
	node *last = (node *)malloc(sizeof(node));
	last->data = val;
	last->next = NULL;
	if(is_empty_q(q) == true){
		q->fst = last;
	}
	else{
		q->last->next = last;
	}
	q->last = last;
	q->num++;
}

datatype take_data_q(queue *q){
	if(q->num == 0){
		printf("no data in the queue\n");
	}
	datatype ans = q->fst->data;
	node *fst = q->fst;
	if(q->num == 1){
		q->fst = NULL;
		q->last = NULL;
	}
	else{
		q->fst = fst->next;
	}
	free(fst);
	q->num--;
	return ans;
}

void add_edge(int x, int y, vertex *V){
	edge *new;
	new = (edge *)malloc(sizeof(edge));
	new->v = y;
	new->next = V[x].e;
	V[x].e = new;
	new = (edge *)malloc(sizeof(edge));
	new->v = x;
	new->next = V[y].e;
	V[y].e = new;
}

typedef struct {
	node *fst;
	int num;
}stack;

stack *make_stack(){
	stack *s = (stack *)malloc(sizeof(stack));
	s->fst = NULL;
	s->num = 0;
	return s;
}

Boolean is_empty_s(stack *s){
	if(s->num == 0){
		return true;
	}
	else{
		return false;
	}
}

void add_data_s(datatype val, stack *s){
	node *fst = (node *)malloc(sizeof(node));
	fst->data = val;
	fst->next = s->fst;
	s->fst = fst;
	s->num++;
}

datatype take_data_s(stack *s){
	if(s->num == 0){
		printf("no data in the stack\n");
	}
	datatype ans = s->fst->data;
	node *fst = s->fst;
	s->fst = fst->next;
	free(fst);
	s->num--;
	return ans;
}

int main(){
	int N, x, y, i;
	vertex v;
	edge *e;
	scanf("%d", &N);
	vertex *V = (vertex *)malloc(sizeof(vertex) * N);
	for(i = 0; i < N; i++){
		V[i].num = i;
		V[i].parent = -1;
		V[i].grundy = 0;
		V[i].e = NULL;
	}
	for(i = 1; i < N; i++){
		scanf("%d%d", &x, &y);
		add_edge(x - 1, y - 1, V);
	}
	queue *q = make_queue();
	stack *s = make_stack();
	add_data_q(0, q);
	add_data_s(0, s);
	while(is_empty_q(q) == false){
		v = V[take_data_q(q)];
		//printf("v.num = %d\n", v.num);
		//printf("v.parent = %d\n", v.parent);
		e = v.e;
		while(e != NULL){
			if(e->v != v.parent){
				//printf("e->v = %d\n", e->v);
				V[e->v].parent = v.num;
				add_data_q(e->v, q);
				add_data_s(e->v, s);
			}
			e = e->next;
		}
	}
	while(1){
		v = V[take_data_s(s)];
		//printf("v.num = %d\n", v.num);
		//printf("v.grundy = %d\n", v.grundy);
		if(v.parent == -1){
			break;
		}
		V[v.parent].grundy ^= (v.grundy + 1);
	}
	if(V[0].grundy == 0){
		printf("Bob\n");
	}
	else{
		printf("Alice\n");
	}
	return 0;
}

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

int main() {
  int a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f;
  a *= 100; b *= 100;
  double maxThickness = -1;
  int ans[2] = {};
  for (int i = 0; i <= f/a; i++) {
    for (int j = 0; j <= (f-a*i)/b; j++) {
      int water = a * i + b * j;
      int maxSugar = min(f - water, water / 100 * e);
      for (int k = 0; k <= maxSugar/c; k++) {
        for (int l = 0; l <= (maxSugar-c*k)/d; l++) {
          int sugar = c * k + d * l;
          int sugarWater = water + sugar;
          if (sugarWater == 0) continue;
          double thickness = 100.0 * sugar / sugarWater;
          if (maxThickness < thickness) {
            maxThickness = thickness;
            ans[0] = sugarWater;
            ans[1] = sugar;
          }
        }
      }
    }
  }
  cout << ans[0] << " " << ans[1] << endl;
}

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

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

	vector<int> L(N);

	for (int i = 0; i < N; i++) {
		cin >> L.at(i);
	}

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

	int sum=0;
	for (int i = 0; i < N-1; i++) {
		sum += L.at(i);
	}

	if (sum > L.at(N - 1)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
input1 = input().split()
N = int(input1[0])
M = int(input1[1])
zahyo = list(map(int,input().split()))

if M == 1 or N >= M:
    print(0)
else:
    zahyo.sort()

    sa = [0]*(M-1)
    for i in range(M-1):
        sa[i] = zahyo[i+1] - zahyo[i]

    sa.sort()
    print(sum(sa[:M-N]))

Measured memory_bytes: 13968
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    string s,t;
    cin>>s>>t;
    ll ans=0;
    for (int i = 0; i < s.length(); ++i)
    {
        if(s[i]!=t[i]){
            ans++;
        }
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int n,m;
    cin >> n >> m;
    int a[n];
    vector<pair<int,int>> b(n);
    cin >> a[0];
    b[0]=make_pair(a[0],0);
    int k=0;
    int w=0;
    int ans=0;
    for(int i=1;i<n;i++){
        cin >>a[i];
        
        b[i]=make_pair(a[i],i);
        
        if(a[i-1]>a[i]){
            w++;
            k+= m-a[i-1]-1;
            ans+=m+a[i]-a[i-1];

        }else{
            ans+=a[i]-a[i-1];
        }

    }
    sort(b.begin(),b.end());
    int t;
    int gmax =0;
    int g=0;
    for(int i=0;i<n;i++){
        g=k+w*b[i].first;
        if(i==0||((b[i-1].first!=b[i].first)&&(gmax<g)))gmax=g;
        switch(b[i].second){
            case 0:
                k+=-a[0]-1;
                w++;
                break;
           
            default:
                if(b[i].second==n-1){
                    t=a[n-2]-a[n-1];
                    if(t>0)t-=m;
                    k+=t+a[n-1]+1;
                    w--;
                }else{
                    t=a[b[i].second -1]-b[i].first;
                    if(t>0)t-=m;
                    k+=t;
                }
                
                break;
        }
    }
    cout <<ans-gmax;
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define PB(a,n) FOR(i,0,n){ll buf; scanf("%lld",&buf); a.pb(buf); }
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define INF 111111111111111111
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[8] = { 1,-1,0,0,1,1,-1,-1 }, ddy[8] = { 0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 111111


ll dp[2][410][410];
int main(void) {
  ll mb;
  vll a, b, c;
  cin >> n >> ma >> mb;
  FOR(i, 0, n) {
	cin >> tmp;
	a.pb(tmp);
	cin >> tmp;
	b.pb(tmp);
	cin >> tmp;
	c.pb(tmp);
  }
  FOR(i, 0, 2) FOR(j, 0, 401) FOR(k, 0, 401) dp[i][j][k] = INF;

  dp[1][0][0] = 0;
  FOR(i, 0, n) {
	FOR(j, 0, 401) FOR(k, 0, 401) dp[i % 2][j][k] = dp[(i + 1) % 2][j][k];
	FOR(j, 0, 401 - a[i]) {
	  FOR(k, 0, 401 - b[i]) {
		if (dp[(i + 1) % 2][j][k] != INF)
		  dp[i % 2][j + a[i]][k + b[i]] = min(dp[i % 2][j + a[i]][k + b[i]], dp[(i + 1) % 2][j][k] + c[i]);
	  }
	}
	cnt++;
  }

  ans = INF;
  FOR(i, 1, 401) {
	FOR(j, 1, 401) {
	  if (dp[(cnt + 1) % 2][i][j] != INF && (ld)i / ma == (ld)j / mb) ans = min(ans, dp[(cnt + 1) % 2][i][j]);
	}
  }
  
  if (ans == INF) {
	cout << "-1" << endl;
  }
  else {
	cout << ans << endl;
  }

  return 0;
}

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

vector<int> to[200005];
vector<int> ans;
ll gcd(ll a, ll b);

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

	vector<int> a(n + 1);
	rep(i, n) cin >> a[i + 1];
	
	vector<int> b(n + 1);
	
	ll sum = 0;

	for (int i = n; i > 0; i--) {
		ll j = n / i, tot = 0;
		while (j != 1) {
			tot += b[j * i];
			j--;
		}
		if (tot % 2 != a[i]) {
			b[i] = 1;
			sum++;
		}
	}

	if (sum == 0) cout << 0;
	else {
		cout << sum << endl;
		repl(i, 1, n + 1) {
			if (b[i] == 1) cout << i << " ";
		}
	}
	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: 9608
#include<bits/stdc++.h>
using namespace std;
int t1,t2;
char c;
bool k(int t){
	if(t>0&&t<13){
		return 1;
	}
	return 0;
}
int main(){
	cin>>c;
	t1+=c-'0';
	cin>>c;
	t1*=10;
	t1+=c-'0';
	cin>>c;
	t2+=c-'0';
	cin>>c;
	t2*=10;
	t2+=c-'0';
	if(k(t1)){
		if(k(t2)){
			cout<<"AMBIGUOUS";
		}else{
			cout<<"MMYY";
		}
		return 0;
	}
	if(k(t2)){
		cout<<"YYMM";
	}else{
		cout<<"NA";
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL


struct node {
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
};

typedef struct node * Node;


Node root = NIL;

Node treeSearch(Node root, int k) {

  if (root == NIL) return NIL;
  if (root->key == k) return root;
  if (root->key > k) {

    if (root->l != NIL) return treeSearch(root->l, k);
    else return NIL;
  }
  else {
    if (root->r != NIL) return treeSearch(root->r, k);
    else return NIL;
  }
}

int find(Node root, int k) {
  if (root->key == k) return 1;

  if (root->key < k) {
    if (root->l != NIL) return find(root->l, k);
    else return 0;
  }
  else {
    if (root->r != NIL) return find(root->r, k);
    else return 0;
    
  }
}

void insert(int k) {
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

  while (x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->l;
    }
    else {
      x = x->r;
    }
  }
	
  z->p = y;
	
  if (y == NIL) {
    root = z;
  }
  else if (z->key < y->key) {
    y->l = z;
  }
  else {
    y->r = z;
  }
}

void inorder(Node u) {
  if (u == NIL) return;

  inorder(u->l);
  printf(" %d", u->key);
  inorder(u->r);
  return;
}

void preorder(Node u) {
  if (u == NIL) return;
  printf(" %d", u->key);
  preorder(u->l);
  preorder(u->r);
  return;
}

void treeDelete(Node z) {
  Node y;
  Node x;
  return;
}

int main(void) {
  int n, i, x;
  char com[20];
  Node t;
  scanf("%d", &n);

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

    scanf("%s", com);

    if ( com[0] == 'f' ) {
      scanf("%d", &x);
      t = treeSearch(root, x);

      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if ( com[0] == 'i') {

      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p') {

      inorder(root);
      printf("\n");

      preorder(root);
      printf("\n");
    }
    else if ( com[0] == 'd') {

      scanf("%d", &x);

      treeDelete(treeSearch(root, x));
    } 
  }
	
  return 0;
}




  

 



Measured memory_bytes: 20444
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
typedef std::pair<std::string,double> P;

int N, K; 
string s;
int arr[11];
void solve(){
    for(int i=0; i<K; ++i){
        int a; cin >> a;
        arr[a]++;
    }
    int ans=N-1;
    int tmp1=N;
    while(1){
        int tmp2=tmp1;
        bool ok = true;
        
        while(tmp2){
            if(arr[tmp2%10]) ok = false;
            tmp2/=10;
        }
        if(ok) ans = tmp1;
        if(ans >= N) break;
        tmp1++;
    }
    cout << ans << endl;
}
int main() {
    cin >> N >> K;
    solve();
	return 0;
}

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

using namespace std;
int main() {
  long n, a, b;
  cin >> n >> a >> b;
  
  long ans_a = a * (n / (a + b));
  
  long mod = n % (a + b);
  
  if(mod >= a)
  {
    ans_a += a;
  }
  else
  {
    ans_a += mod;
  }
  
  cout << ans_a << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public Main(){
		Scanner sc = new Scanner(System.in);
		int c = 0, f;
		while(sc.hasNext()){
			String str = sc.next();
			f = 0;
			for(int i = 0, j = str.length()-1; i < j; i++, j--){
				if(!str.substring(i, i+1).equals(str.substring(j, j+1))){
					f = 1;
					break;
				}
			}
			
			if(f == 0){
				c++;
			}
		}
		
		System.out.println(c);
	}
	
	public static void main(String[] args){
		new Main();
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			int N = sc.nextInt();
			if (N == 0) break;
			boolean[][] dir = new boolean[H][W];
			sc.nextLine();
			for (int i = 0; i < H; ++i) {
				String line = sc.nextLine();
				for (int j = 0; j < W; ++j) {
					dir[i][j] = line.charAt(j * 2) == '1';
				}
			}
			int[][] count = new int[H + 1][W + 1];
			count[0][0] = N - 1;
			for (int i = 0; i < H; ++i) {
				for (int j = 0; j < W; ++j) {
					count[i + 1][j] += count[i][j] / 2;
					count[i][j + 1] += count[i][j] / 2;
					if (count[i][j] % 2 == 1) {
						if (dir[i][j]) {
							count[i][j + 1] += 1;
						} else {
							count[i + 1][j] += 1;
						}
						dir[i][j] = !dir[i][j];
					}
				}
			}
			int r = 0;
			int c = 0;
			while (r < H && c < W) {
				if (dir[r][c]) {
					++c;
				} else {
					++r;
				}
			}
			System.out.println((r + 1) + " " + (c + 1));
		}
	}
}

Measured memory_bytes: 17000
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int a,b;
int main(){
	cin>>a>>b;
	cout<<a*b-(a+b)+1;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define re_ return
#define in_ inline
#define op_ operator
#define inc(l, i, r) for(i=l; i<r; ++i)
typedef long long ll;
typedef double db;

struct wat
{
    db t; int v;
    wat(): t(0), v(0){}
    wat(db a, int b): t(a), v(b){}
    in_ wat op_+ (wat a)
    {re_ v+a.v? wat((t*v+a.t*a.v)/(v+a.v), v+a.v): wat();}
    in_ wat& op_+= (wat a)
    {re_ *this=*this+a;}
    in_ wat op_- (wat a)
    {re_ v^a.v? wat((t*v-a.t*a.v)/(v-a.v), v-a.v): wat();}
    in_ wat& op_-= (wat a)
    {re_ *this=*this-a;}
    in_ void wr(char* a)
    {printf("(%.6lf, %d)%s", t, v, a);}
};

const int mxn=1<<19;

int n, v0; wat q[mxn];

int main()
{
    int s, t; wat a, b;
//    a.wr("\n");
    scanf("%d%d", &n, &v0);
    for(s=t=0; n--;)
    {
        scanf("%lf%d", &a.t, &a.v);
        for(b+=a; b.v>v0;)
            if(q[s].v<=b.v-v0) b-=q[s++];
            else q[s].v-=b.v-v0, b-=wat(q[s].t, b.v-v0);
        printf("%lf\n", b.t);
        for(;s<t && q[t-1].t>=a.t; a+=q[--t]);
        q[t++]=a;
    }
    re_ 0;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int N; cin>> N;
VI a(N); rep(i, 0, N) cin >> a[i];

int mini = INF;
rep(i, *min_element(ALL(a)), *max_element(ALL(a))+1){
    int cost = 0;
    rep(j, 0, N){
        cost += pow(abs(a[j] - i) , 2);
    }
    mini = min(mini, cost);
}
cout << mini << endl;
}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#define print(n) std::cout << n << std::endl
#define print_no_indention(n) std::cout << n
using namespace std;


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

    print((a + b) % 24);
}

Measured memory_bytes: 256
//
//  Competitive Programming
//  Don't Copy Be Original - Ehsaan Rahman
//  Copyright © 2020 Ehsaan Rahman. All rights reserved.
//
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<map>
#include<bitset>
#include<cstring>
#include<stack>
#include<queue>
#include<set>
#include<chrono>
#include<list>
#include<climits>
#include<iomanip>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #define PBDS tree<long long int,null_type,less<long long int>, rb_tree_tag,tree_order_statistics_node_update>
// using namespace __gnu_pbds;
#define arrsize 100001
#define dpsize 1001
#define vpp vector<PP>
#define vll vector<ll>
#define vcc vector<char>
#define vbb vector<bool>
#define w(t) while(t--)
#define PP pair<ll,ll>
#define szs(x) x.length()
#define szv(x) x.size()
#define INF 1999999996000000010
#define ll long long int
#define takeINP(arr,n) for(long long int i=0;i<n;i++) cin>>arr[i];
#define f(i,s,e) for(long long int i=s;i<e;i++)
#define cf(i,s,e) for(long long int i=s;i<=e;i++)
#define rf(i,e,s) for(long long int i=e-1;i>=s;i--)
#define mem(arr) memset(arr,0,sizeof(arr));
#define MOD 1000000007
#define pp(a,b) make_pair(a,b)
#define pb push_back
#define print(arr,s,e) f(i,s,e) cout<<arr[i]<<" "; cout<<endl;
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define vll vector<ll>
#define triplet pair<ll,pair<ll,ll> >
#define MITR(a,b) map<a,b>::reverse_iterator 
using namespace std;
using namespace chrono;

///Author - Ehsaan Rahman - Don't Copy Be Original
///---------------Functions---------------------///
ll advceil(ll num,ll den){return (num%den==0?num/den:num/den+1);}
ll lstbt(ll val){ ll msk = val&(val-1); return log2(val^msk);}
ll expo(ll a,ll b){	ll res=1;	while(b>0){		if(b&1) res = (res%MOD*a%MOD)%MOD;		a = (a%MOD*a%MOD);		b/=2;	}	return res;}
ll gcd(ll a,ll b){ return a==0?b:gcd(b%a,a); }

///---------x------------x----------x-----------///

void solve(){
	ll n,x,t; cin>>n>>x>>t;
	cout<<advceil(n,x)*t<<endl;
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r" ,stdin);
		freopen("output.txt", "w" ,stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    auto start1 = high_resolution_clock::now();
    solve();
    auto stop1 = high_resolution_clock::now();
	auto duration = duration_cast<microseconds>(stop1 - start1);
    #ifndef ONLINE_JUDGE
		cerr << "Time: " << duration.count() / 1000.0 << endl;
	    cout<<duration.count()/1000.0<<endl;
    #endif
}

Measured memory_bytes: 3668
import sys
input = sys.stdin.readline

def solve():
    def makeBIT(numEle):
        numPow2 = 2 ** (numEle-1).bit_length()
        data = [0] * (numPow2+1)
        return data, numPow2
    def addValue(iA, A):
        iB = iA + 1
        while iB > 0:
            data[iB] += A
            iB -= iB & -iB
    def getValue(iA):
        iB = iA + 1
        ans = 0
        while iB <= numPow2:
            ans += data[iB]
            iB += iB & -iB
        return ans
    def addRangeValue(iFr, iTo, A):
        addValue(iTo, A)
        if iFr > 0:
            addValue(iFr-1, -A)

    N, M = map(int, input().split())
    LRss = [[] for _ in range(M+1)]
    for _ in range(N):
        L, R = map(int, input().split())
        LRss[R-L+1].append((L, R))

    data, numPow2 = makeBIT(M+1)

    anss = []
    numOK = N
    for d in range(1, M+1):
        ans = numOK
        for i in range(d, M+1, d):
            ans += getValue(i)
        anss.append(ans)
        numOK -= len(LRss[d])
        for L, R in LRss[d]:
            addRangeValue(L, R, 1)

    print('\n'.join(map(str, anss)))


solve()


Measured memory_bytes: 96816