akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

double MAX;
int t[3005];
int a,b,c,j,d,e,f,k,cnt,x,n,sum,ans,i;
int main()
{
	cin>>a>>b>>c>>d>>e>>f;
	for(i=0;i<=f/a;i++)
	{
		for(j=0;j<=f/b;j++)
		{
			if(j*b*100+i*a*100>f)
				break;
			t[j*b*100+i*a*100]=1;
		}
	}
	MAX=-1;
	for(i=1;i<=f;i++)
	{
		if(t[i]==0)
			continue;
		for(j=0;j<=f/c;j++)
		{
			for(k=0;k<=f/d;k++)
			{
				ans=k*d+j*c;
				if(i+ans>f)
					break;
				if(MAX<=(double)(ans*100)/(ans+i)*1.0&&e*i>=100*ans)
				{
					cnt=ans;
					sum=ans+i;
					MAX=(double)(ans*100)/(ans+i)*1.0;
				}
			}
		}
	}
	cout<<sum<<" "<<cnt<<endl;
}

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

int main() {
  int N,K; cin >>N >>K;
  cout <<((N%K)!=0) << endl;
}


Measured memory_bytes: 256
n, t = map(int, input().split())
ts = list(map(int, input().split()))
ans = 0

for num, s in enumerate(ts):
    try:
        if ts[num] + t <= ts[num+1]:
            ans += t
        else:
            ans += ts[num+1] - ts[num]
    except:
        pass
ans += t
print(ans)


Measured memory_bytes: 25200
# Here your code !
h,w=gets.split.map &:to_i
a=[]
h.times do
a<< gets.chomp.split("")
end
h.times do |i|
w.times do |j|
if a[i][j] == ?.
c=0
3.times do |k|
k-=1
3.times do |l|
l-=1
g=i*w+j+k*w+l
if g>=0 && g<h*w && j+l>=0 && j+l<w && a[i+k][j+l]==?#
c+=1
end
end
end
a[i][j]=c
end
end
end
puts a.map{|e|e.*("")}.*("\n")


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

#define MAX_L 1000

signed main(){
    int n;
    cin >> n;
    int l[n];
    REP(i,n){
        cin >> l[i];
    }
    int mn[MAX_L * 2 + 1] = {}, mx[MAX_L * 2 + 1] = {};
    REP(i,n){
        for(int j = 0; j <= MAX_L * 2; j++){
            if(l[i] < j){
                mn[j]++;
            }
        }
    }
    REP(i,n){
        for(int j = 0; j <= MAX_L * 2; j++){
            if(l[i] > j){
                mx[j]++;
            }
        }
    }
    ll ans = 0;
    REP(a,n){
        for(int b = a + 1; b < n; b++){
            int t = 0;
            if(max(l[a], l[b]) - min(l[a], l[b]) < l[a] && l[a] < l[a] + l[b]){
                t++;
            }
            if(max(l[a], l[b]) - min(l[a], l[b]) < l[b] && l[b] < l[a] + l[b]){
                t++;
            }
            ans += max(0, mx[max(l[a], l[b]) - min(l[a], l[b])] + mn[l[a] + l[b]] - n - t);
        }
    }
    cout << ans / 3 << endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> >vvi;
const ll MOD=1000000007LL;
int main(){
  ll h,w;
  cin>>h>>w;
  if(h==1 || w==1){
    cout<<1<<endl;
    return 0;
  }
  cout<<(h*w+1)/2<<endl;
}
      

Measured memory_bytes: 256
n, t = map(int, input().split())
min_c = 2000
for _ in range(n):
    ci, ti = map(int, input().split())
    if ti <= t:
        min_c = min(min_c, ci)

if min_c == 2000:
    print('TLE')
else:
    print(min_c)

Measured memory_bytes: 2940
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

long P = 10L^^9+7;

long pow(long x, long n) {
    long y = 1;
    while (n) {
        if (n%2 == 1) y = (y * x) % P;
        x = x^^2 % P;
        n /= 2;
    }
    return y;
}

long inv(long x)
{
    return pow(x, P-2);
}

void main()
{
    auto N = readln.chomp.to!int;
    auto cs = readln.split.to!(long[]);
    sort!"a > b"(cs);
    auto inv_2 = inv(2);
    auto xx = 2.pow(N*2) * inv_2 % P;
    long x = xx, r;
    (xx *= inv_2) %= P;
    foreach (c; cs) {
        (r += x * c % P) %= P;
        (x += xx) %= P;
    }
    writeln(r);
}

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

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int dx = x2 - x1, dy = y2 - y1;
  cout << x2 - dy << " " << y2 + dx << " " << x1 - dy << " " << y1 + dx << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

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

struct edge{int to,cost;};

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

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

	int n,m;
	string s,t;
	cin >> n >> m >> s >> t;

	ll a,b;
	if(n >= m){
		a=n;
		b=m;
	}else{
		a=m;
		b=n;
		swap(s,t);
	}
	ull lcm=a*b/gcd(a,b);

	bool found;
	bool once = (gcd(a,b)!=1 || b==1);
	for(int j=0;j<100;j++){
		//cout << lcm << "\n";
		found=true;
		map<ull,char> mp;
		for(int i=0;i<a;i++){
			mp[i*lcm/a] = s[i];
		//	cout << "	" << i*lcm/a+1 << " " << s[i] << "\n";
		}
		for(int i=0;i<b;i++){
			auto itr= mp.find(i*lcm/b);
			if(itr != mp.end()){
				if(itr->second != t[i]){
		//			cout << "stop " << i*lcm/b+1 << " " << t[i] << "\n";
					found=false;
					if(once){
						cout << "-1\n";
						return 0;
					}
					break;
				}
			}
		}
		if(found){
			cout << lcm << "\n";
			return 0;
		}
		lcm*=2;
		if(lcm < 0){
			cout << "-1\n";
			return 0;
		}
	}
	cout << "-1\n";
	return 0;
}

Measured memory_bytes: 6528
from math import pi,cos,sqrt
a,b,h,m=map(int,input().split())
th1=(h/6+m/360)*pi
th2=m*pi/30
th=abs(th1-th2)
th=min(th,360-th)
print(sqrt(a**2+b**2-2*a*b*cos(th)))

Measured memory_bytes: 62340
n = int(input())
vlt = input().split()
clt = input().split()

for i in range(0, len(vlt)):
    vlt[i] = int(vlt[i])
for i in range(0, len(clt)):
    clt[i] = int(clt[i])

sum_v = 0
sum_cost = 0
for i in range(0, len(vlt)):
    if vlt[i] > clt[i]:
        sum_v += vlt[i]
        sum_cost += clt[i]

print(sum_v - sum_cost)

Measured memory_bytes: 3064
N = int(input())

count = 0
S = []

while count < N:
    S.append(input())
    count = count + 1


C0 = str(S.count('AC'))
C1 = str(S.count('WA'))
C2 = str(S.count('TLE'))
C3 = str(S.count('RE'))

print('AC x ' + C0)
print('WA x ' + C1)
print('TLE x ' + C2)
print('RE x ' + C3)

Measured memory_bytes: 16292
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
map<string,long>mp;
int main()
{
    long i,j,t,a,b,n,c,temp;
    t=1;
    // cin>>t;
    while(t--)
    {
       cin>>n;
       long arr[n];
       for(i=0;i<n;i++)cin>>arr[i];
       for(i=0;i<n;i++)
       {
           temp=arr[i];
           if(temp<400)
           {
               mp["gray"]++;
           }
          
           else if(temp<800)
           {
               mp["brown"]++;
           }
           else if(temp<1200)
           {
               mp["green"]++;
           }
           else if(temp<1600)
           {
               mp["cyan"]++;
           }
           else if(temp<2000)
           {
               mp["blue"]++;
           }
           else if(temp<2400)
           {
               mp["yellow"]++;
           }
           else if(temp<2800)
           {
               mp["orange"]++;
           }
           else if(temp<3200)
           {
               mp["red"]++;
           }
           else
           {
               mp["ex"]++;
           }
       }
       long cou=0;
       for(auto x:mp)
       {
           if(x.second!=0L && x.first!="ex")
            cou++;
           
       }
       temp=0;
       temp=mp["ex"];
       cout<<max(cou,1L)<<" "<<(cou+temp);
        
    }
}

Measured memory_bytes: 256
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int A[200];
 
signed main() {
    int N, X; cin >> N >> X;
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }
    sort(A, A+N);

    int ans = 0, rest = X;
    for(int i=0; i<N; i++) {
        if(rest >= A[i]) {
            ans++;
            if(i == N-1 && rest > A[i]) ans--;
            rest -= A[i];
        }
    }
    cout << ans << endl;
    return 0;
}

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

const int MAX = 301;
const int MAX2 = 90001;
const int MOD = 998244353;

int64_t pow(int64_t a, int b) {
	if (b == 0) return 1;
	if (b == 1) return a;
	if (b == 2) return a * a % MOD;
	return pow(pow(a, b >> 1), 2) * pow(a, b & 1) % MOD;
}
int main() {
	int N, a[MAX2];
	cin >> N;
	for (int i = 0;i < N;++ i) cin >> a[i];
	static int64_t sum = 0, dp[MAX2], dp2[MAX2], ans = 0;
	// dp[i]は3色に塗り分けるとき、紅色がiとなるようなものの個数
	// dp2[i]は2色に塗り分けるとき、紅色がiとなるようなものの個数
	for (int i = 0;i < N;++ i) sum += a[i];
	for (int i = 0;i < MAX2;++ i) dp[i] = dp2[i] = 0;
	dp[0] = dp2[0] = 1;
	for (int i = 0;i < N;++ i) {
		for (int j = sum;j >= a[i];-- j) {
			dp[j] = (dp[j - a[i]] + dp[j] * 2) % MOD;
			dp2[j] = (dp2[j - a[i]] + dp2[j]) % MOD;
		}
		for (int j = 0;j < a[i];++ j) dp[j] = (dp[j] * 2) % MOD;
	}
	
	
	for (int i = sum + 1 >> 1;i <= sum;++ i) (ans += dp[i] * 3) %= MOD;
	
	if (sum % 2 == 0) (ans -= dp2[sum / 2] * 3) %= MOD;
	cout << (pow(3, N) - ans + MOD) % MOD;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

R≧G,Bとしても一般性を失わない

……解説見た、R≧S/2だけ除外すりゃ終わり！なのか……悲しいね
ちなみに今使っているエディタだと[300][90000]のメモリはとれないので、ちょっとメモリ圧縮してるよ
*/

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


int main()
{
   int w,b,c,sum=0,rest=0;
   cin>>w>>b>>c;

   if(c<b && c+w< b)
   {
       cout<<b-(c+w);
   }
   else if(c<b && c+w>=b)
   {
       cout<<0;
   }

   else if(c>b && c>b+w)
   {
       cout<<c-b-w;
   }
   else if(c>b && b+w>=c)
   {
       cout<<0;
   }
   else if(b==c)
   {
       cout<<0;
   }

}


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

int main() {
  int N; string s, t;
  cin >> N >> s >> t;

  int ans = 0;
  rep(i,1,N) {
    string l = s.substr(N-i,i);
    string r = t.substr(0,i);
    if (l.compare(r) == 0) {
      ans = i + (N - i) * 2;
    }
  }

  if (ans == 0) ans = N * 2;
  cout << ans << endl;
  return 0;
}


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

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class CStrangeDance {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      string t; cin >> t;

      // initialize vector size
      vector<vector<vector<int>>> v(3, vector<vector<int>>(n));
      int k = 1;
      rep(i, n) {
        rep(j, 3) {
          v[j][i].resize(k);
        }
        k *= 3;
      }
      int K = k;

      // initialize vector
      rep(i, n) {
        int idx = 0;
        rep(j, 3) {
          for(auto& e: v[j][i]) {
            e = idx;
            idx++;
          }
        }
      }

      for(auto c: t) {
        if (c=='S') {
          // swap vector
          swap(v[1], v[2]);
        } else {
          // swap by point
          int w = 0;
          rep(i, n) {
            auto v0 = v[0][i][w];
            auto v1 = v[1][i][w];
            auto v2 = v[2][i][w];
            v[1][i][w] = v0;
            v[2][i][w] = v1;
            v[0][i][w] = v2;
            w = v2;
          }
        }
      }

      // recover
      vector<int> ans(K);
      k = 1;
      rep(i, n) {
        for(int j=1; j<=2; j++) {
          for(auto e: v[j][i]) {
            for(int idx=e; idx<K; idx+=(k*3)) {
              ans[idx] += j*k;
            }
          }
        }
        k *= 3;
      }

      for(auto e: ans) {
        cout << e << ' ';
      }
    }
};

signed main() {
  CStrangeDance solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 9396
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <cmath>
#define LL long long
using namespace std;
const int MOD=1e9+7;
const int INF=0x3f3f3f3f;
const int M=200100;
const int N=100100;
inline void read(int &x){
	x=0;int mm=1; char ch=getchar();
	while((ch>'9'||ch<'0')&&ch!='-') ch=getchar();
	if(ch=='-') mm=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	x=x*mm;
}
inline void read(LL &x){
	x=0;LL mm=1; char ch=getchar();
	while((ch>'9'||ch<'0')&&ch!='-') ch=getchar();
	if(ch=='-') mm=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	x=x*mm;
}
struct Edge{
	int nxt;
	int v,w;
}edge[M<<2];
int head[N],tot;
void add(int u,int v,int w){
	edge[++tot].nxt=head[u];
	edge[tot].v=v;
	edge[tot].w=w;
	head[u]=tot;
}
int n,m;
int dist[N];
bool visited[N],inque[N];
queue <int> q;
bool SPFA(int beginn){
	visited[beginn]=true;
	inque[beginn]=true;
	dist[beginn]=0;
	q.push(beginn);
	int maxx=0,minn=0;
	while(!q.empty()){
		int u=q.front();q.pop();
		inque[u]=false;
		for(int i=head[u];i;i=edge[i].nxt){
			Edge &e=edge[i];
			if(dist[e.v]<INF){
				if(dist[e.v]!=e.w+dist[u]){
					return false;
				}
			}else{
				dist[e.v]=e.w+dist[u];
				maxx=max(maxx,dist[e.v]);
				minn=min(minn,dist[e.v]);
				if(maxx-minn>INF) return false;
				visited[e.v]=true;
				if(!inque[e.v]){
					inque[e.v]=true;
					q.push(e.v);
				}
			}
		}
	}
	return true;
}
int main(){
	read(n),read(m);
	memset(head,0,sizeof(head));
	for(int i=1;i<=m;i++){
		int u,v,w;
		read(u),read(v),read(w);
		add(u,v,w);
		add(v,u,-w);
	}
	memset(dist,INF,sizeof(dist));
	for(int i=1;i<=n;i++){
		if(!visited[i])
			if(!SPFA(i)){
				printf("No");
				return 0;
			}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 6908
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace

from queue import PriorityQueue as pq

def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p//common , q//common )
# from itertools import accumulate
# from collections import deque

import random


def main():
    # l = list(map(int, input().split()))
    ll=input().strip()
    l=[0 for i in range(4)]
    for i in range(len(l)):
        l[i]=int(ll[i])
    NUM_CASE=3

    for case in range(2**NUM_CASE):
        # eprint("case : " + str(case))
        sum=l[0]
        
        stack=[]
        S=""
        for index in range(NUM_CASE):
            if (case>>index) & 1 == 1:
                # eprint("l[%d] : %d" % (index+1,l[index+1]) )
                sum+=l[index+1]
                stack.append("+")
            else:
                # eprint("l[%d] : %d" % (index+1,l[index+1]) )
                sum-=l[index+1]
                stack.append("-")
        # eprint("sum : " + str(sum))
        if sum==7:
            for i in range(4):
                S+=str(l[i])
                if i!=3:
                    S+=str(stack[i])
            S+="=7"
            print(S)
            return
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 64748
/* ex 7_3
   Stuartyg */

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

int main(void){
    int height,width,i,j;
    char **array;
    int col[101] = {0};
    int row[101] = {0};

    scanf("%d %d",&height,&width);

    //メモリ確保
    //各行の配列へのポインタ分のメモリ領域を確保
    array = (char**)calloc(height,sizeof(char*));

    if (array == NULL){ //確保失敗
        exit(1);
    }

    for (i= 0;i<height;i++ ){
        //各行の要素分のメモリ領域を確保
        array[i] = (char*)calloc(width,sizeof(char));
        if (array[i] == NULL){ //確保失敗
            exit(1);
        }
    }

    for (i=0;i<height;i++){
        for(j=0;j<width;j++){
            scanf(" %c",&array[i][j]); //array[i][j]の値の受取り

            //白しかない行、列があるかのチェック       
            if (array[i][j] == '#'){ //黒を含む
                row[i] = 1;
                col[j] = 1;
            }
        }
    }

    //出力
    for (i=0;i<height;i++){
        if(row[i] == 1){ //行には黒を含む
            for (j=0;j<width;j++){
                    if (col[j] == 1){ //列にも黒を含む
                        printf("%c", array[i][j]);
                    }
            }
            printf("\n"); //1行出力するごとに改行
        }
    }

    //メモリ領域の開放
    for (i= 0;i<height;i++ ){
        //各行の要素分のメモリ領域を開放
        free(array[i]);
    }

    //各行の配列へのポインタ分のメモリ領域を開放
    free(array);

    return 0;
}



Measured memory_bytes: 1676
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		int K = nextInt();
		int Q = nextInt();
		int[] A = new int[N];


		int AC = Q-K+1;

		for(int i=0;i<Q;i++) {
			A[nextInt()-1]++;
		}

		for(int i=0;i<N;i++) {
			out.println(A[i]>=AC?"Yes":"No");
		}

	}

	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

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

int n;
vector<int> ans;

void dfs(vector<int> A){
        if (A.size() == 3){
                int x = A[0], y = A[1], z = A[2];
                int i = x*x+y*y+z*z+x*y+y*z+z*x;
                if (i > 0 && (i - 1) < n){
                        i -= 1;
                        if(x == y && y == z)ans[i]++;
                        else if(x!=y&&y!=z) ans[i]+=6;
                        else ans[i]+=3;
                }
                return;
        }
        A.push_back(A.back());
        while(A.back()<sqrt(n)){
                dfs(A);
                A.back()++;
        }
}

int main() {
        cin >> n;
        ans = vector<int>(n, 0);
        rep(i,n){
                vector<int> A(1, i+1);
                dfs(A);
        }
        rep(i,n) cout << ans[i] << endl;
        return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int Sum(VEC<int>a, VEC<int>b){
  int sum = 0;
  REP(i,0,a.size()){
    sum+=a[i]*b[i];
  }
  return sum;
}

int main() {
  int N,M,C;
  cin>>N>>M>>C;
  VEC<int>B(M);
  REP(i,0,M)cin>>B[i];
  auto A = MATINIT(int,N,M,0);
  REP(i,0,N){
    REP(j,0,M){
      cin>>A[i][j];
    }
  }
  int cnt = 0;
  REP(i,0,N){
    if(Sum(A[i],B)+C>0)++cnt;
  }
  cout<<cnt<<endl;

  return 0;
}


Measured memory_bytes: 256
while n=gets.chomp.to_i
break if n==0

result=Hash.new{|id,total|total=0}

n.times{
	id,tanka,kosu=gets.chomp.split(" ").map{|i| i.to_i}
	result[id] += tanka*kosu
}

result.select!{|id,total| total >= 1000000}


if result=={}
		puts "NA"
	else
		puts result.keys
	end
end

Measured memory_bytes: 8684
#include <stdio.h>
int main(void) {
	int c[4][13] = {0};
	int m,r,t,i,j;
	char s;
	char u[4] = "SHCD";
	scanf("%d\n",&t);
	for(i=t;i;i--){
		scanf("%c %d\n",&s, &r);
		switch(s){
		case 'S':m=0;break;
		case 'H':m=1;break;
		case 'C':m=2;break;
		case 'D':m=3;break;
		}
		c[m][r-1] = 1;
	}
	for(;i<=3;i++){
		for(j=0;j<=12;j++){
			if(c[i][j]){continue;}
			printf("%c %d\n",u[i],j+1);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcount(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second<b.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
int main()
{
    FAST
    FO
    FI
    double a,b;
    IN a>>b;
    a+=0.0;
    b+=0.0;
    bool flag= false;
    loop(i,1,1010)
    {
        double t1= double(i)*0.08;
        t1= floor(t1);
        double t2= double(i)*0.1;
        t2= floor(t2);
        if(t1==a && t2==b)
        {
            flag=true;
            OUT i<<endl
            break;
        }
    }
    if(!flag)
    {
        OUT -1<<endl
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int i,n,x,y,b,p,c;

	scanf("%d",&n);
	while(n--){
		scanf("%d%d%d%d",&x,&y,&b,&p);
		c=x*b+y*p;
		if(b>=5 && p>=2)c=c*0.8;
		else{
			if(b<5)b=5;
			if(p<2)p=2;
			if(c>((x*b+y*p)*0.8))c=(x*b+y*p)*0.8;
		}
		printf("%d\n",c);
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
const int N=500;
typedef long long ll;
const ll inf=1e15+7;
ll arr[N][N];
ll brr[N][N];
int main(){
    ll n,m,l;
    cin>>n>>m>>l;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++){
            if(i!=j) arr[i][j]=brr[i][j]=inf;
        }
    
    ll x,y,z;
    
    for(int i=1;i<=m;i++){
        scanf("%lld%lld%lld",&x,&y,&z);
        arr[x][y]=z;
        arr[y][x]=z;
    }
    
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                arr[i][j]=min(arr[i][j],arr[i][k]+arr[k][j]);
    }
    
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++){
            if(arr[i][j]<=l&&i!=j) brr[i][j]=1; 
        }
    
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                brr[i][j]=min(brr[i][j],brr[i][k]+brr[k][j]);
    }
    int q;
    cin>>q;
    while(q--){
        int a,b;
        cin>>a>>b;
        if(brr[a][b]>=inf) cout<<-1<<endl;
        else cout<<brr[a][b]-1<<endl;
    }    
    return 0;
}

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

#define MAX 100000

vector<int> G[MAX];
int N;
bool visited[MAX];
int prenum[MAX], parent[MAX], lowest[MAX], timer;

void dfs( int current, int prev ) {
  // ノード current を訪問した直後の処理
  prenum[current] = lowest[current] = timer;
  timer++;

  visited[current] = true;

  int next;

  for ( int i = 0; i < G[current].size(); i++ ) {
    next = G[current][i];
    if ( !visited[next] ) {
      // ノード current からノード next へ訪問する直前の処理
      parent[next] = current;

      dfs( next, current );

      // ノード next の探索が終了した直後の処理
      lowest[current] = min( lowest[current], lowest[next] );
    } else if ( next != prev ) {
      // エッジ current -> next が Back-edge の場合の処理
      lowest[current] = min( lowest[current], prenum[next] );
    }
  }
  // ノード current の探索が終了した直後の処理
}

void art_points() {
  for ( int i = 0; i < N; i++ ) visited[i] = false;
  timer = 1;
  // lowest の計算
  dfs(0, -1);  // 0 == root

  set<int> ap;
  int np = 0;
  for ( int i = 1; i < N; i++ ) {
    int p = parent[i];
    if ( p == 0 ) np++;
    else if ( prenum[p] <= lowest[i] ) ap.insert(p);
  }
  if ( np > 1 ) ap.insert(0);
  for ( set<int>::iterator it = ap.begin(); it != ap.end(); it++ )
    cout << *it << endl;
}

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

  for ( int i = 0; i < m; i++ ) {
    int s, t;
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }
  art_points();

  return 0;
}


Measured memory_bytes: 6788
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(17)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
//ll longinf=1ll<<60;
int inf=1<<29;
ll longinf=(1ll<<60);

string maximum(string s,string t){
      if(s.size()>t.size()) return s;
      else if(t.size()>s.size()) return t;
      else{
            if(s>=t) return s;
            else return t;
      }
}

int main(){
      cin.tie(0);
      ios::sync_with_stdio(false);
      int n,a,b,c;
      cin>>n>>a>>b>>c;
      int l[n];
      rep0(i,n) cin>>l[i];
      int M=1<<(2*n);
      ll ans=longinf;
      rep0(i,M){
            ll aa=0;
            ll bb=0;
            ll cc=0;
            ll pos=0;
            rep0(j,n){
                  if(((i>>(2*j))&3)==3){
                        if(aa!=0) pos+=10;
                        aa+=l[j];
                  }
                  if(((i>>(2*j))&3)==2){
                        if(bb!=0) pos+=10;
                        bb+=l[j];
                  }
                  if(((i>>(2*j))&3)==1){
                        if(cc!=0) pos+=10;
                        cc+=l[j];
                  }
            }
            if(aa==0||bb==0||cc==0) continue;
            pos+=abs(aa-a);
            pos+=abs(bb-b);
            pos+=abs(cc-c);
            ans=min(pos,ans);
      }
      cout<<ans<<endl;
      return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication78
{
    class Program
    {
        static void Main(string[] args)
{
                int a = int.Parse(Console.ReadLine());
                int[] b = new int[a];
                b = Console.ReadLine().Split().Select(int.Parse).ToArray();
                Array.Sort(b);
                Console.WriteLine(b[a - 1] - b[0]);
            }
        }
    
}

Measured memory_bytes: 13396
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static int ans = 0;

        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var str = Console.ReadLine();
            var strs = str.Split(' ');

            var hs = new List<int>();
            foreach (var item in strs)
            {
                hs.Add(int.Parse(item));
            }

            Watering(hs);

            Console.WriteLine(ans);
        }

        static void Watering(List<int> hs)
        {

            for (int i = 0; i < hs.Count; i++)
            {
                if (hs[i] != 0)
                {
                    break;
                }

                if (i == hs.Count - 1)
                {
                    return;
                }
            }

            if (hs.Count == 1)
            {
                ans += hs[0];
                return;
            }

            while (!hs.Contains(0))
            {
                for (int i = 0; i < hs.Count; i++)
                {
                    hs[i]--;
                }
                ans++;
            }

            var borderIndex = hs.IndexOf(0);

            if (borderIndex != 0)
            {
                Watering(hs.Take(borderIndex).ToList());
            }

            if (borderIndex != hs.Count - 1)
            {
                Watering(hs.Skip(borderIndex + 1).Take(hs.Count - borderIndex).ToList());
            }
        }
    }
}


Measured memory_bytes: 13152
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            var L = long.Parse(ss[0]);
            var R = long.Parse(ss[1]);

            if (R - L >= 2019)
            {
                Console.WriteLine(0);
                return;
            }

            var min = long.MaxValue;
            for (long i = L; i < R; i++)
            {
                for (long j = L + 1; j <= R; j++)
                {
                    long m = ((i % 2019) * (j % 2019)) % 2019;
                    if (m < min)
                    {
                        min = m;
                    }
                }
            }

            Console.WriteLine(min);
        }
    }
}

Measured memory_bytes: 11092
import math
Q=int(input())
N=10**5+1

L = []
R = []
for i in range(Q):
    ll,rr=[int(i) for i in input().split()]
    L.append(ll)
    R.append(rr)

def is_prime_list(N):
    is_prime_list = [True for i in range(N)]
    is_prime_list[0], is_prime_list[1] = False, False
    for i in range(2, N):
        if is_prime_list[i]:
            j = 2 * i
            while j < N:
                is_prime_list[j] = False
                j += i
    return is_prime_list

is_prime = is_prime_list(N)
nita = [0]*N
for i in range(N):
    if is_prime[i] == True and is_prime[(i+1)//2] == True:
        nita[i] = nita[i-1] + 1
    else:
        nita[i] = nita[i-1]
#print(nita)
for i in range(Q):
    a = nita[R[i]] - nita[L[i]-1]
    print(a)



Measured memory_bytes: 13372
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }

  bool merge(int x, int y){
    int root_x = find(x);
    int root_y = find(y);
    if(root_x != root_y){
      if(data[root_y] < data[root_x]){
	swap(root_x, root_y);
      }
      data[root_x] += data[root_y];
      data[root_y] = root_x;
    }
    
    return root_x != root_y;
  }
  
  int find(int x){
    if(data[x] < 0){
      return x;
    }else{
      return find(data[x]);
    }
  }

  bool is_same(int x, int y){
    return find(x) == find(y);
  }
  
  int size(int x){
    return -find(x);
  }
};

typedef pair<long long int, pair<long long int, long long int> > Edge;

inline Edge make_edge(int a, int b, int c){
  return make_pair(c, make_pair(a, b));
}

int main(int argc, char* argv[]){

  while( true ) {

    long long int n, m;
    cin >> n >> m;
    if ( n == 0 ) break;

    priority_queue< Edge, vector< Edge >, greater< Edge > > q;

    for ( long long int i = 0; i < m; i++ ) {

      long long int a, b, c;
      cin >> a >> b >> c;
      q.push(make_edge(a, b, c));
    }

    
    UnionFind uf(n);
    long long int costs = 0;
    while(!q.empty()){
      Edge edge = q.top(); q.pop();
      const int from = edge.second.first;
      const int to = edge.second.second;

      if(!uf.is_same(from, to)){
	uf.merge(from, to);
	//	cout << edge.first << endl;
	costs += edge.first;
      }
    }
 
    cout << costs << endl;
  }

  return 0;
  
}

Measured memory_bytes: 1208
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>
#include <set>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;


const long long MAX_N = 1 << 17;

long long dat[2 * MAX_N - 1];

ll ecd(ll a, ll b) {
	if (a < b) swap(a, b);
	if (b == 0) return a;
	else {
		return ecd(b, a % b);
	}
}

ll pow(ll a, ll b) {
	vector<ll> d = vector<ll>((ll)(log(b)) + 2);
	d[0] = a;
	rep(i, 1, d.size()) d[i] = d[i - 1] * d[i - 1];
	ll ret = 1;
	rep(i, 0, log(b) + 1) {
		if (b & 1 << i) ret *= d[i];
	}
	return ret;
}

//G
vector<ll> dp;
vector<vector<ll>> graph;

ll dfs(ll v) {
	if (dp[v] > -1) return dp[v];
	if (graph[v].size() == 0) return 0;

	for (const auto& neighbor : graph[v]) {
		dp[v] = max(dp[v], dfs(neighbor) + 1);
	}

	return dp[v];
}

int main(void) {
	ll n, m;
	cin >> n >> m;
	graph = vector<vector<ll>>(n, vector<ll>());
	rep(i, 0, m) {
		ll a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
	}
	dp = vector<ll>(n, -1);

	ll ans = 0;
	rep(i, 0, n) {
		ans = max(ans, dfs(i));
	}
	cout << ans << endl;
}


Measured memory_bytes: 8576
def main():
    N, A, B = (int(i) for i in input().split())
    H = [int(input()) for i in range(N)]

    def is_ok(x):
        y = 0  # 中心爆破必要回数
        for i, h in enumerate(H):
            if h - x*B <= 0:
                continue
            le = 0
            ri = 10**9 + 1
            while ri - le > 1:
                mid = le + ((ri - le) // 2)
                if h - B*(max(x - mid, 0)) - A*mid <= 0:
                    ri = mid
                else:
                    le = mid
            y += ri
        if y <= x:  # 魔物を消し去るのが可能
            return True
        else:
            return False

    def binary_search_meguru():
        left = -1
        right = 10**9 + 1
        while right - left > 1:
            mid = left + ((right - left) // 2)
            if is_ok(mid):
                right = mid
            else:
                left = mid
        return right

    print(binary_search_meguru())


if __name__ == '__main__':
    main()


Measured memory_bytes: 53172
class UnionFind
  attr_accessor(:table)

  def initialize(n)
    @table = Array.new(n, -1)
  end

  def root(x)
    st = []
    tb = @table
    while tb[x] >= 0
      st.push(x)
      x = tb[x]
    end
    
    st.each do |y|
      @table[y] = x
    end
    
    return x
  end
  
  def find(x, y)
    return root(x) == root(y)
  end

  def unite(x, y)
    r1 = root(x)
    r2 = root(y)
    return if r1 == r2
    
    d1 = @table[r1]
    d2 = @table[r2]
    if d1 <= d2
      @table[r2] = r1
      @table[r1] += d2
    else
      @table[r1] = r2
      @table[r2] += d1
    end
  end
end

n, m = $stdin.readline.chomp.split.map(&:to_i)
uf = UnionFind.new(n)
m.times do
  a, b = $stdin.readline.chomp.split.map(&:to_i)
  uf.unite(a - 1, b - 1)
end
puts uf.table.count {|x| x < 0 } - 1

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

using namespace std;

int main() {
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());

    int ans = 300;
    do {
        ans = min(ans, abs(a[0] - a[1]) + abs(a[1] - a[2]));
    } while (next_permutation(a.begin(), a.end()));

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
//#include<bits/stdc++.h>
#include<cmath>
#include<string>
#include<cstdio>
#include<cstring>
#include<queue>
#define pq priority_queue
#define Pi acos(-1.0)
using namespace std;
#define MOD 1000000007
char s1[55][55],s2[55][55];
int n,m;
bool ok(int x,int y)
{
    for(int i=0;i<m;i++)
        for(int j=0;j<m;j++)
        {
            if(s1[i+x][j+y]!=s2[i][j])
                return 0;
        }
    return 1;
}
int main()
{
    bool flag=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        scanf("%s",s1[i]+1);
    for(int i=0;i<m;i++)
        scanf("%s",s2[i]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        {
            if(i+m-1<=n && j+m-1<=n && ok(i,j))
                flag=1;
        }
    if(flag)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


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

using namespace std;
typedef long long ll;
#define pi M_PI
#define gcd(a,b) __gcd(a,b)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fr first
#define sc second
#define pb push_back
#define in insert
#define mp make_pair
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define inmas(i,a,b,c)cin>>b;forr(i,a,b)cin>>c[i]
#define mod 1000000007
ll n,m,ans=0,k,s=0;
int main()
{string x;
cin>>x;
forr(i,0,x.length())
{if(x[i]=='9')cout<<"1";
else if(x[i]=='1')cout<<"9";
else cout<<x[i];


}




return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}
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 (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	REP(i, SZ(S)) {
		if (i % 2 == 0 && S[i] == 'L') {
			cout << "No" << endl;
			return 0;
		}
		else if (i % 2 == 1 && S[i] == 'R') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    public class Prog
    {
        const int MOD = 1000000007;
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Prog().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var x = cin.ReadInt;
            var a = cin.ReadInt;
            var b = cin.ReadInt;

            var ans = (x - a) % b;

            Console.WriteLine(ans);
        }
    }
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; } }
    }
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

struct UnionFind {
    int n;
    vector<int> dat;
    UnionFind(int size): n(size), dat(size, -1) { }
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (dat[y] < dat[x]) swap(x, y);
            dat[x] += dat[y];
            dat[y] = x;
        }
        return x != y;
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    int root(int x){
        return dat[x] < 0 ? x : dat[x] = root(dat[x]);
    }
    int size(int x){
        return -dat[root(x)];
    }
};

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    map<int, ll> mp;
    rep(i,n){
        int a; cin >> a;
        if(mp.count(a)) mp[a] += 1;
        else mp[a] = 1;
    }

    ll cur = 0ll;
    for(auto p : mp){
        cur += p.fi * p.se;
    }
    int q; cin >> q;
    rep(_,q){
        int b,c; cin >> b >> c;
        if(!mp.count(b)){
            cout << cur << endl;
            continue;
        }
        cur = cur + mp[b] * (c - b);
        cout << cur << endl;

        if(mp.count(c)) mp[c] += mp[b];
        else mp[c] = mp[b];
        mp.erase(b);
    }
    return 0;
}

Measured memory_bytes: 7572
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(): return "".join(list(map(str, ans)))

op = "+ -".split()
a,o,b = list(input().split())
ans = int(a) + int(b) if(o == op[0]) else int(a) - int(b)
print(ans)

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


int main(void){
  int64_t N,M=0,m=0,a=0;
  cin >> N;
  vector<int64_t> A(N+1),ans(N+1,0);
  for(int64_t i=0;i<=N;i++){
    cin >> A.at(i);
    M+=A.at(i);
  }
  M--;
  if(A.at(0)>0&&N!=0){
    cout << -1 << endl;
    return 0;
  }else if(N==0){
    if(A.at(0)==1){
      cout << 1 << endl;
      return 0;
    }else{
      cout << -1 << endl;
      return 0;
    }
  }
  ans.at(0)=1;
  for(int64_t i=1;i<=N;i++){
    ans.at(i)=ans.at(i-1)-A.at(i-1)+min(ans.at(i-1)-A.at(i-1),M-m);
    m+=min(ans.at(i-1)-A.at(i-1),M-m);
    if(ans.at(i)<A.at(i)){
      cout << -1 << endl;
      return 0;
    }else if(ans.at(i)==A.at(i)&&i!=N){
      cout << -1 << endl;
      return 0;
    }
  }
  for(int64_t i=0;i<=N;i++){
    a+=ans.at(i);
  }
  cout << a << endl;
}

Measured memory_bytes: 4836