akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;
vector<li> perm;
vector<li> raw;
li m, k;
li x[100100];
li a[100100];
li diff[100100];

inline vector<li> calc_perm(const vector<li> &a, const vector<li> &b) {
    vector<li> res(sz(a));
    rep(i, sz(res)) {
        res[i] = b[a[i]];
    }
    return res;
}

inline vector<li> perm_njo(const vector<li> &perm, li k) {
    if (k == 1)return perm;
    if (k == 0)return raw;
    vector<li> perm2 = perm_njo(calc_perm(perm, perm), k / 2);
    if (k % 2 == 0)return perm2;
    return calc_perm(perm2, perm);
}

int main() {
    cin >> n;
    perm.resize(n);
    rin{
        cin >> x[i];
        perm[i] = i;
    }
    raw = perm;
    rep(i, n - 1) {
        diff[i] = x[i + 1] - x[i];
    }
    cin >> m >> k;
    rep(i, m) {
        cin >> a[i];
        a[i]--;
        swap(perm[a[i]], perm[a[i] - 1]);
    }
    vector<li> perm_k = perm_njo(perm, k);

    repp(i, 1, n - 1) {
        x[i] = x[i - 1] + diff[perm_k[i - 1]];
    }
    rin{cout << x[i] << endl;}


    return 0;
}

Measured memory_bytes: 51328
#include<stdio.h>
#define MAX 100000

int main(){
  int H,i,A[MAX+1];
  scanf("%d",&H);
  for(i=1;i<=H;i++)scanf("%d",&A[i]);

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i/2>=1)printf("parent key = %d, ",A[i/2]);
    if(2*i<=H)printf("left key = %d, ",A[2*i]);
    if(2*i+1<=H)printf("right key = %d, ",A[2*i+1]);
  printf("\n");
}
return 0;
}

Measured memory_bytes: 608
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int n, i, j;
	int x[100];
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", x+i);
	}
	long ans=LONG_MAX;
	for(i=1; i<=100; i++){
		long now=0;
		for(j=0; j<n; j++){
			now += ((long)(x[j]-i))*(x[j]-i);
		}
		if(now<ans) ans=now;
	}
	printf("%ld\n", ans);
}


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

// #define int ll
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n) for (int i = 0; i < n; i++)
#define dotc()    int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)     (int)x.size()
#define eb        emplace_back
#define pb        push_back
#define mp        make_pair
#define all(x)    x.begin(), x.end()
#define rall(x)   x.rbegin(), x.rend()
#define fi        first
#define se        second

ll mod(1000000007);
double pi(acos(-1.0));

int n, m, q;
vvi a;
int mx = 0;
void f(int x, int y, ll v) {
  if (x == n) {
    int cur = 0;
    for (auto i : a) {
      if ((v >> (i[1] - 1) * 4 & 0xf) - (v >> (i[0] - 1) * 4 & 0xf) == i[2])
        cur += i[3];
    }
    mx = max(mx, cur);
    return;
  }
  for (int j = y; j <= m; j++) {
    f(x + 1, j, v | (ll)j << x * 4);
  }
}

int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#endif

  cin >> n >> m >> q;
  a.resize(q, vi(4));
  rep(i, q) rep(j, 4) cin >> a[i][j];

  f(0, 1, 0ll);
  cout << mx;

  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii; 
const int N = 1e5+10, mod = 2e9+10;

void solve() {
    string s1, s2; cin >> s1 >> s2;
    string s3 = s1;
    s3 += s2[s2.length() - 1];
    (s3 == s2) ? cout << "Yes\n" : cout << "No\n";
}

int main(void) {
    int t = 1; 
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 3592
A = [0]*5
for i in range(5):
	A[i] = int(input())

mi = 10
sm = 0
min_r = 10
for i in range(5):
	d = A[i] // 10
	r = A[i] % 10
	if r == 0:
		sm += (d)*10
	else:
		sm += (d+1)*10

	if r != 0 and min(mi,r) < mi:
		mi = min(mi,r)
		idx = i
		min_r = r
		min_d = d
	#print(min_r,min_d,i,sm)


print(sm - (10-min_r))

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

int main() {
  
  string S;
  cin >> S;
  
  int hug = 0;
  if (S.size() % 2 == 0) {
    for (int i = 0; i < S.size() / 2; i++) {
      if (S.at(i) != S.at(S.size() - 1 - i)) {
        hug++;
      }
    }
  }
  
  else {
    for (int i = 0; i < (S.size() - 1) / 2; i++) {
      if (S.at(i) != S.at(S.size() -1 - i)) {
        hug++;
      }
    }
  }
  
  cout << hug << endl;
}


Measured memory_bytes: 3612
N = int(input())
n_list = list(map(int,input().split()))
if 0 in n_list :
  print('0')
else:  
  ans = 1
  tho = 10**18
  for i in range (N):
    ans *= n_list[i]
    if ans > tho :
      print('-1')
      break
  if ans <= tho :
    print(ans)

Measured memory_bytes: 21648
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a=n/500;
    ll sum=a*1000;
    n-=a*500;
    ll b=n/5;
    sum+=b*5;
    cout<<sum<<endl;
}


Measured memory_bytes: 256
H, W = list(map(int, input().split()))
L = []
ansL = [[0 for i in range(W)] for j in range(H)]
ansL[0][0] = 1

for i in range(H):
	L.append(list(input()))

for i in range(W):
	for j in range(H):
		if L[j][i] == ".":
			if i >= 1:
				ansL[j][i] += ansL[j][i - 1]
			if j >= 1:
				ansL[j][i] += ansL[j - 1][i]
			ansL[j][i] = ansL[j][i] % 1000000007

print(ansL[H - 1][W - 1])

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

const int N = 5005;
const int MOD = 1e9 + 7;

int n, m;
string s;
int f[N][N];

void add(int &x,int y) { x = x + y < MOD ? x + y : x + y - MOD; }
int mult(int x,int y) { return 1LL * x * y % MOD; }

int fpow(int x,int y) {
	int ret = 1;
	while (y) {
		if (y & 1) ret = mult(ret, x);
		x = mult(x, x);
		y >>= 1;
	}
	return ret;
}

int main() {
	ios_base::sync_with_stdio(false);
	f[0][0] = 1;
	for (int i = 1; i < N; ++i) {
		f[i][0] = f[i - 1][0]; add(f[i][0], f[i - 1][1]);
		for (int j = 1; j <= i; ++j) {
			f[i][j] = mult(2, f[i - 1][j - 1]);
			add(f[i][j], f[i - 1][j + 1]);
		}
	}
	cin >> n >> s; m = s.size();
	cout << mult(f[n][m], fpow(2, MOD - 1 - m));
}

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

int main(){
  int n,x;
  std::cin >> n>>x;
  std::vector<int> m(n);
  for (int i = 0; i < n; i++) {
    /* code */
    std::cin >> m[i];
  }
  x-=accumulate(m.begin(),m.end(),0);
  sort(m.begin(),m.end());
  std::cout << n+x/m[0]  << std::endl;
  
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long [] in = new long [n];
        long [] ans = new long [n+1];
        for(int i=0;i<n;i++){
                             in[i] = sc.nextLong();
                            }
        ans [0] = 0;
        ans [1] = 2*in[0];
        for(int i=0;i<n-1;i++){ans[i+2] = ans[i]+2*(in[i+1]-in[i]);
                              }
        long a = ans[n]/2;
        for(int i=0;i<n;i++){if(i%2==0){System.out.println(ans[i]+a);}
                             else{System.out.println(ans[i]-a);}
                            }		
	}
}


Measured memory_bytes: 88876
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

long long inv(long long a, long long  m)
{
    long long  x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    long long  b = m;
    while (b != 0)
    {
        long long  q = a / b;
        long long  tmp = a;
        a = b;
        b = tmp % b;
        tmp = x0;
        x0 = x1;
        x1 = tmp - q * x1;
        tmp = y0;
        y0 = y1;
        y1 = tmp - q * y1;
    }
    return (x0 % m + m) % m;
}

int main()
{
    const long long  m = 1000000000 + 7;
    long long  S;
    cin >> S;
    long long  ln_max = S / 3;
    long long  sum = 0;
    for (long long  ln = 1; ln <= ln_max; ++ln)
    {
        long long T = S - 3 * ln;
        long long  a = 1;
        long long  b = 1;
        for (long long  i = ln - 1; i >= 1; --i)
        {
            a = (a * (T + i)) % m;
            b = (b * i) % m;
        }
        sum += (a * inv(b, m)) % m;
        sum %= m;
    }
    cout << (sum % m + m) % m;

    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
using namespace std;
int main(){
    string s;
    cin>>s;
    int len=s.length();
    int min_number=753;
    for(int i=0;i<len-2;i++){
	int temp=0;
	temp+=s[i]-'0';
	temp*=10;
	temp+=s[i+1]-'0';
	temp*=10;
	temp+=s[i+2]-'0';
	temp-=753;
	if(temp<0) temp=-temp;
	min_number=min_number>temp? temp:min_number;
	//cout<<temp<<endl;
    }
    cout<<min_number<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
double t[11][2]={
	{-9999999.9999999,48.0},
	{48.0,51.0},
	{51.0,54.0},
	{54.0,57.0},
	{57.0,60.0},
	{60.0,64.0},
	{64.0,69.0},
	{69.0,75.0},
	{75.0,81.0},
	{81.0,91.0},
	{91.0,9999999.9999999},
};
string str[11]={
	"light fly",
	"fly",
	"bantam",
	"feather",
	"light",
	"light welter",
	"welter",
	"light middle",
	"middle",
	"light heavy",
	"heavy"
};
int main(){
	double in;
	while(cin>>in){
		for(int i=0;i<11;i++){
			if(t[i][0]<in&&in<=t[i][1]){
				cout<<str[i]<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1224
N = int(input())
A = [0]*N
for i in range(N):
    A[i] = int(input())
m = max(A)
if A.count(m) > 1:
    for _ in range(N):
        print(m)
else:
    mi = A.index(m)
    for i in range(N):
        if mi == i:
            print(sorted(A)[-2])
        else:
            print(m)

Measured memory_bytes: 15820
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N, X, T;
	cin >> N >> X >> T;

	LL ans = N/X;
	if((N % X) != 0){
		ans++;
	}
	printf("%lld\n", ans*T);
	return 0;

}



Measured memory_bytes: 3768
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 10056
#define mod2 20071027
//#define mod 1000074259
#define base 139
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case %lld:\n", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
const ll N=300010;
ll a;
bool isprime[N];
vector<ll>prime;
void seive()
{
    isprime[0]=1;
    isprime[1]=1;
    for(ll i=4; i<=N-5; i+=2) isprime[i]=1;
    for(ll i=3; i*i<=N-5; i+=2)
    {
        if(isprime[i]==0)
            for(ll j=i*i; j<=N-5; j+=2*i) isprime[j]=1;
    }
    for(ll i=2; i<=N-5; i++)
        if(isprime[i]==0) prime.pb(i);
}
int main()
{
   seive();
   in1(a);
   for(auto p:prime)
   {
       if(p>=a)
       {
           printf("%lld\n", p);
           return 0;
       }
   }
    return 0;
}
/*

*/


Measured memory_bytes: 896
import sys
input = sys.stdin.readline
from heapq import *

N, R, L = map(int, input().split())
score = [0]*N
pq = []

for i in range(N):
    heappush(pq, (-score[i], i))

prev_t = 0
now = 0
time = [0]*N

for _ in range(R):
    di, ti, xi = map(int, input().split())
    time[now] += ti-prev_t
    prev_t = ti
    heappush(pq, (-score[now], now))
    heappush(pq, (-score[di-1]-xi, di-1))
    score[di-1] += xi
    
    while True:
        s, idx = heappop(pq)
        s *= -1
        
        if score[idx]==s:
            break

    now = idx

time[now] += L-prev_t
max_t = 0
ans = -1

for i in range(N):
    if time[i]>max_t:
        max_t = time[i]
        ans = i+1

print(ans)



Measured memory_bytes: 105152
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = (!!1) . words
printer = (++"\n") . show

solver ss = length $ L.group ss

Measured memory_bytes: 2428
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i;
        while(true){
            int n = sc.nextInt();
            if(n == 0) break;
            int data[] = new int[n];
            double ave = 0,dev = 0;
            for (i=0;i<n;i++) {
                data[i] = sc.nextInt();
                ave += data[i];
            }
            ave /= n;
            for (i=0;i<n;i++) {
                dev += (data[i] - ave)*(data[i] - ave);
            }
            dev = Math.sqrt(dev/n);
            System.out.println(dev);
        }
    }
}



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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    int64_t N, ans = 0;
    cin >> N;
    for (int64_t i = 1; i <= N; i++)
    {
        int64_t M = N / i;
        ans += i * M * (M + 1) / 2;
    }
    cout << ans;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int i=1;
	while(1){
		if(i%2){
			c-=b;
		}else{
			a-=d;
		}
		if(c<=0){
			cout<<"Yes";
			return 0;
		}else if(a<=0){
			cout<<"No";
			return 0;
		}
		i++;
	}
}

Measured memory_bytes: 3688
import java.util.Scanner;

/**
 * @author miyaa
 *
 */
class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int money = sc.nextInt();
		int cakePrice = sc.nextInt();
		int donutPrice = sc.nextInt();

		int result = getBuyingSweetsResult(money, cakePrice, donutPrice);
		System.out.println(result);
	}

	public static int getBuyingSweetsResult(int money, int cakePrice, int donutPrice) {
		money -= cakePrice;
		while (money - donutPrice >= 0)
			money -= donutPrice;
		return money;
	}
}


Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,t;
    cin>>n;
    string s;
    map<string,int> m;
    int dp[n]={0};
    for(int i=0;i<n;i++)
    {
        cin>>s>>t;
        m[s]=i;
        dp[i]=dp[max(0,i-1)]+t;
    }
    cin>>s;
    cout<<dp[n-1]-dp[m[s]];
}


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

int main(void)
{
	int N, M;
	cin >> N >> M;
	int *a = new int[N], *b = new int[N];
	for (int i = 0; i < N; ++i) {
		cin >> a[i] >> b[i];
	}
	int *c = new int[M], *d = new int[M];
	for (int i = 0; i < M; ++i) {
		cin >> c[i] >> d[i];
	}

	for (int i = 0; i < N; ++i) {
		int pos = 0;
		int min = 999999999;
		for (int j = 0; j < M; ++j) {
			if (abs(a[i] - c[j]) + abs(b[i] - d[j]) < min) {
				min = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				pos = j;
			}
		}
		cout << pos + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
int n;
ll b[maxn], l[maxn], r[maxn];
void calc(int i)
{
	l[i] = (l[i + 1] + b[i] - 1) / b[i] * b[i];
	r[i] = r[i + 1] / b[i] * b[i];
	if(l[i] > r[i])
	{
		puts("-1");
		exit(0);
	}
	r[i] += b[i] - 1;
}
int main()
{
	cin >> n;
	for(int i = 1; i <= n; ++i) cin >> b[i];
	l[n + 1] = r[n + 1] = 2;
	for(int i = n; i; --i) 
		calc(i);
	cout << l[1] << ' ' << r[1] << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }


ll w[110];
ll v[110];

ll dp[110][100010];

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

  rep(i, N) cin >> w[i] >> v[i];

  for(int i = 0; i < N+1;i++){
    for(int j = 0; j <= W; j++){
      dp[i][j] = 0;
    }
  }

  for(int i = 0; i<N; i++){
    for(int sum_w = 0; sum_w <= W; sum_w++){
      if(sum_w - w[i] >= 0){
        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w-w[i]] + v[i]);
      }
      dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w]);
    }
  }

  cout << dp[N][W] << endl;

  return 0;
}



Measured memory_bytes: 80128
#include<bits/stdc++.h>
 
using namespace std;
 
const int vy[] = {-1, 0, 1, 0};
const int vx[] = {0, -1, 0, 1};
const string vv = "DLUR";
 
const int INF = 1 << 30;
 
int dp1[2002][2002] = {{}}, dp2[2002][2002] = {{}};
int dp3[2001][2002] = {{}}, dp4[2001][2002] = {{}};
 
int main()
{
  string S;
  int K;
 
  cin >> S;
  cin >> K;
 
 
  string A, B;
  for(int i = 0; i < S.size(); i++) {
    if(vy[vv.find(S[i])] != 0) A += S[i];
    else B += S[i];
  }
 
 
  int latte[2002] = {}, malta[2002] = {};
  for(int i = 0; i < A.size(); i++) {
    int mv = A[i] == 'U' ? 1 : -1;
    latte[i] = mv;
  }
  for(int i = 0; i < B.size(); i++) {
    int mv = B[i] == 'L' ? 1 : -1;
    malta[i] = mv;
  }
 
 
  if(!A.empty()) {
    fill_n(*dp1, 2002 * 2002, -INF);
    fill_n(*dp2, 2002 * 2002, INF);
    dp1[0][0] = latte[0];
    dp1[0][1] = -latte[0];
    dp2[0][0] = latte[0];
    dp2[0][1] = -latte[0];
    for(int i = 1; i < A.size(); i++) {
      for(int j = 2000; j >= 0; j--) {
        dp1[i][j + 1] = max(dp1[i][j + 1], dp1[i - 1][j] + (j % 2 == 0 ? -latte[i] : latte[i]));
        dp1[i][j] = max(dp1[i][j], dp1[i - 1][j] + (j % 2 == 1 ? -latte[i] : latte[i]));
        dp2[i][j + 1] = min(dp2[i][j + 1], dp2[i - 1][j] + (j % 2 == 0 ? -latte[i] : latte[i]));
        dp2[i][j] = min(dp2[i][j], dp2[i - 1][j] + (j % 2 == 1 ? -latte[i] : latte[i]));
      }
    }
 
    for(int i = 1; i <= 2000; i++) {
      dp1[A.size() - 1][i] = max(dp1[A.size() - 1][i], dp1[A.size() - 1][i - 1]);
      dp2[A.size() - 1][i] = min(dp2[A.size() - 1][i], dp2[A.size() - 1][i - 1]);
    }
  }
 
 
  if(!B.empty()) {
    fill_n(*dp3, 2001 * 2002, -INF);
    fill_n(*dp4, 2001 * 2002, INF);
    dp3[0][0] = malta[0];
    dp3[0][1] = -malta[0];
    dp4[0][0] = malta[0];
    dp4[0][1] = -malta[0];
    for(int i = 1; i < B.size(); i++) {
      for(int j = 2000; j >= 0; j--) {
        dp3[i][j + 1] = max(dp3[i][j + 1], dp3[i - 1][j] + (j % 2 == 0 ? -malta[i] : malta[i]));
        dp3[i][j] = max(dp3[i][j], dp3[i - 1][j] + (j % 2 == 1 ? -malta[i] : malta[i]));
        dp4[i][j + 1] = min(dp4[i][j + 1], dp4[i - 1][j] + (j % 2 == 0 ? -malta[i] : malta[i]));
        dp4[i][j] = min(dp4[i][j], dp4[i - 1][j] + (j % 2 == 1 ? -malta[i] : malta[i]));
      }
    }
    for(int i = 1; i <= 2000; i++) {
      dp3[B.size() - 1][i] = max(dp3[B.size() - 1][i], dp3[B.size() - 1][i - 1]);
      dp4[B.size() - 1][i] = min(dp4[B.size() - 1][i], dp4[B.size() - 1][i - 1]);
    }
  }
 
  int ret = 0;
 
  for(int i = 0; i <= K; i++) {
    int aa = dp1[max(0, (int) A.size() - 1)][i];
    int bb = dp2[max(0, (int) A.size() - 1)][i];
    int cc = dp3[max(0, (int) B.size() - 1)][K - i];
    int dd = dp4[max(0, (int) B.size() - 1)][K - i];
 
    ret = max(ret, max(aa, -bb) + max(cc, -dd));
  }
 
  cout << ret << endl;
}

Measured memory_bytes: 65832
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long int
#define pair <ll, ll> pi
#define vector <ll> vi
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define SQ(a) (a) * (a)
#define ordered_set tree<ll, null_type, greater_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> //greater_equal<ll> or less<ll>
// find_by_key()   order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen('input.txt', 'r', stdin);
    //freopen('output.txt', 'w', stdout);
    ll i, j, k, n, m, b, d, t, ans = 0,a,x,y,cnt=0;
    cin>>n;
    string s="";
    ll ch[26];
    ch[1]='a';
    ch[0]='z';
    for(i=2;i<26;i++){
        ch[i]=ch[i-1]+1;
    }
    ll temp;
    while(n>0){
        temp=n%26;
        s+=ch[temp];
        if(temp==0){
            n-=26;
        }
        else{
            n-=temp;
        }
        n=n/26;
    }
    for(i=s.size()-1;i>=0;i--){
        cout<<s[i];
    }
    
    
    

    return 0;
}

Measured memory_bytes: 3620
N, M, X = map(int, input().split(' '))
C = []
A = []

for n in range(N):
    l = list(map(int, input().split(' ')))

    C.append(l[0])
    A.append(l[1:])


# print('NMX', N, M, X)
# print('C', C)
# print('A', A)


def buy_nth_book(x, n):
    if (x >> n) & 1:
        return True
    return False


ans_C = []
ans_A = []

# bit全探索でans_Cに合計代金, ans_Aに獲得能力を入れる
for i in range(2 ** N):
    ans_C.append(0)
    ans_A.append([0 for m in range(M)])
    for n in range(N):
        if buy_nth_book(i, n):
            ans_C[i] += C[n]

            for m in range(M):
                ans_A[i][m] += A[n][m]

res_C = []
# Xの条件を満たすCをリストに入れる
for c, a in zip(ans_C, ans_A):
    if all([aa >= X for aa in a]):
        res_C.append(c)
# ans_A_idx = [ aa for aa in ans_A if [ a >= X for a in aa]]

if res_C:
    print(min(res_C))
else:
    print('-1')


Measured memory_bytes: 11524
n = int(input())

fact = [1]
for i in range(1, n):
  fact.append(fact[-1] * i)
  
check = [True] * (n+1)
check[0] = False

a = 1
for i, p in enumerate(map(int, input().split())):
  check[p] = False
  a += sum(check[:p]) * fact[n-i-1]
  
check = [True] * (n+1)
check[0] = False

b = 1
for i, p in enumerate(map(int, input().split())):
  check[p] = False
  b += sum(check[:p]) * fact[n-i-1]
  
print(abs(a-b))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
ll INF = 9999999999999999;

int N;
ll h[100010];
ll dp[100010];

ll rec(int i){
    
    if(dp[i] < INF) return dp[i];
    
    if(i == 0) return 0;
    
    ll res = INF;
    res = min(res, rec(i-1) + abs(h[i] - h[i-1]));
    if (i > 1) res = min(res, rec(i-2) + abs(h[i] - h[i-2]));
    
    return dp[i] = res;
}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll max(ll a, ll b){
    if(a > b) return a;
    else return b;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}
 
int main(void){
    int N; cin >> N;
    vector<int> six(10, 0), nine(10, 0);
    for(int i = 0; i < 10; i++){
        int num_six = pow(6, i+1);
        int num_nine = pow(9, i+1);
        if(num_six <= N) six[i] = num_six;
        if(num_nine <= N) nine[i] = num_nine;
    }
    
    vector<int> dp(N+1000000, INF);
    dp[0] = 0;
    for(int i = 0; i < N + 100; i++){
        dp[i+1] = min(dp[i+1], dp[i] + 1);
        int j = 0;
        while(six[j] != 0){
            dp[i + six[j]] = min(dp[i + six[j]], dp[i] + 1);
            j++;
        }
        j = 0;
        while(nine[j] != 0){
            dp[i + nine[j]] = min(dp[i + nine[j]], dp[i] + 1);
            j++;
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 4480
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
string s;
  cin>>s;
  s[3]='8';
  cout<<s;
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll n;
	cin >> n;
	string a;
	cin >> a;
	vector <ll> white;
	vector <ll> black;
	ll temp = 0;
	for (int z=0;z<a.size();z++){
		if (a[z] == '#'){
			if (z == 0)break;
			a.erase (a.begin(),a.begin()+z); 
			break;
		}
	}
	for (int z=a.size()-1;z>-1;z--){
		if (a[z] == '.'){
			if (z==a.size()-1)break;
			a.erase (a.begin()+z+1,a.end()); 
			break;
		}
	}
	for (int z=0;z<a.size();z++){
		if (a[z] == '#'){
			if (temp != 0)
			white.push_back(temp);
			temp=0;
		} else {
			temp++;
		}
	}
	if (temp != 0){
		white.push_back(temp);
	}
	temp = 0;
	for (int z=0;z<a.size();z++){
		if (a[z] == '.'){
			if (temp != 0)
			black.push_back(temp);
			temp=0;
		} else {
			temp++;
		}
	}
	if (temp != 0){
		black.push_back(temp);
	}
	if (black.size() < white.size()){
		black.push_back(0);
	}
	if (white.size() < black.size()){
		white.push_back(0);
	}
	ll answer = 0;
	for (int z=0;z<black.size();z++){
		answer += black[z];
	}
	temp = answer;
	for (int z=black.size()-1;z>-1;z--){
		temp += white[z];
		temp -= black[z];
		answer = min(answer,temp);
	}
	cout << answer << endl;
	cin >> n;
}

Measured memory_bytes: 2828
#include<bits/stdc++.h>
using namespace std;
int main()
{

     long long int n,i,j=1,c=0,f=0000000000,l,k,x,y,z,m,b,a;
     string s="",s1;
     char o;
     set <int, greater <int> > st;
     stack<char>sta;
     //int a[5];
    //long long  int arr[n+2][n+2];
     vector<char>ch(27);
     vector<string>str;
     vector<int>vect,vect3;
     map<int,int>mp;
     cin>>n>>k>>l;
      y=ceil(double(n)/double(k));
      cout<<y*l<<endl;
}



Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] x = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }
        sc.close();

        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < n - k + 1; i++) {
            int left = x[i];
            int right = x[i + (k - 1)];
            int candidate1 = Math.abs(left) + Math.abs(right - left);
            int candidate2 = Math.abs(right) + Math.abs(right - left);
            int candidate = Math.min(candidate1, candidate2);
            if (candidate < ans) {
                ans = candidate;
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 50488
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll n ; cin >> n;
    vector<ll> sm(0),df(0);
    rep(i,n){
        ll x,y; cin >> x >> y;
        sm.emplace_back(x+y);
        df.emplace_back(x-y);        
    }
    sort(sm.begin(),sm.end());
    sort(df.begin(),df.end());
    cout << max(sm.at(n-1)-sm.at(0) , df.at(n-1)-df.at(0)) << endl;
    return 0;
}

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

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

  vector<string> s(n);
  map<string, int> map;
  for(int i=0; i<n; ++i){
    cin >> s[i];
    map[s[i]]++;
  }
  int cnt =0;
  for(int i=0; i<map.size(); ++i){
    if(map[s[i]] > 0) cnt++;
  }

  cout <<  cnt;
  

  return 0;
}


Measured memory_bytes: 25176
#include<bits/stdc++.h>
#define ms(x,y) memset(x,y,sizeof(x))
#define ll long long
using namespace std;
const int N=55;
const double inf =1e18;

vector<int> e[N];
int n,m,a,b,c;
bool rea[N];
int vis[105][N];
bool q[2][N];
int cnt[2];

bool bfs() {
//	printf("BFS!");
	bool flag=false;
	cnt[0]=0;
	ms(vis,0);
	ms(q,0);
	for(int i=1;i<=n;i++)
		if(rea[i])q[0][i]=true;
	for(int i=1;i<=c;i++)
	{
		int ju=i&1;
		ms(q[ju],0);
		for(int j=1;j<=n;j++)
			if(q[ju^1][j])
				for(vector<int>::iterator it=e[j].begin();it!=e[j].end();it++){
					q[ju][*it]=true;
					if(i==a || i==b || i==c)
						vis[i][*it]=true;
			}
	}
//	for(int i=1;i<=n;i++)
//		printf("i=%d %d%d%d ",i,vis[a][i],vis[b][i],vis[c][i]);
//	printf("\n");
	for(int i=1;i<=n;i++)
		if(vis[a][i] && vis[b][i] && vis[c][i]){
			if(i==1){
				rea[i]=true;
				return false;
			}
			if(!rea[i]){
				rea[i]=true;
				flag=true;
			}
		}
	return flag; 
}
int main(){
	int ta[3];
	scanf("%d%d%d%d%d",&n,&m,&ta[0],&ta[1],&ta[2]);
	sort(ta,ta+3);
	a=ta[0];b=ta[1];c=ta[2];
	int u,v;
	for(int i=1;i<=m;i++) {
		scanf("%d%d",&u,&v);
		e[v].push_back(u);
	}
	ms(rea,0);
	rea[n]=true;
	int ans=0;
	while(bfs()) ans++;
	if(rea[1])printf("%d\n",ans+1);
	else printf("IMPOSSIBLE\n");
	return 0;
}

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

int main() {
  int DIV = 1e+9 + 7;
  int N; cin >> N;
  int A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  long sum = 0, sq_sum = 0;
  for (int i = 0; i < N; i++) {
    sum = (sum+A[i]) % DIV;
    sq_sum = (sq_sum + (long)A[i]*A[i]%DIV) % DIV;
  }
  int resx2 = (sum*sum-sq_sum)%DIV;
  if (resx2 % 2 == 0) cout << resx2/2 << endl;
  else cout << (resx2+DIV)/2 << endl;
}

Measured memory_bytes: 4388
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	int n, m, p, tac = 0, twa = 0;
	string s;
	cin >> n >> m;
	vector<int> ac(n + 1), wa(n + 1);
	for (int i = 0; i < m; ++i) {
		cin >> p >> s;
		if (s == "AC") {
			if (!ac[p]) {
				ac[p] = 1;
				++tac;
				twa += wa[p];
			}
		} else {
			if (!ac[p]) {
				wa[p] += 1;
			}
		}
	}
	cout << tac << " " << twa << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

typedef pair<string,int> P;
unordered_map<string, int> m;
const int d[] = {-4, 1, 4, -1};

void f() {
  queue<P> Q;
  Q.push(P(string("01234567"), 0));
  while (!Q.empty()) {
    P p = Q.front(); Q.pop();
    int cost = p.second;
    if (m.count(p.first)) continue;
    m.insert(P(p.first, cost));
    int zidx;
    for (int i = 0; i < 8; ++i)
      if (p.first[i] == '0')
        zidx = i;
    for (int i = 0; i < 4; ++i) {
      if (zidx == 3 && i == 1) continue;
      if (zidx == 4 && i == 3) continue;
      int tidx = zidx + d[i];
      if (tidx < 0 || 8 <= tidx) continue;
      string copy = p.first;
      swap(copy[zidx], copy[tidx]);
      Q.push(P(copy, cost+1));
    }
  }
}


int main() {
  f();
  int t;
  while (cin >> t) {
    string s = "";
    s += '0'+t;
    for (int i = 1; i <= 7; ++i) {
      cin >> t;
      s += '0'+t;
    }
    cout << m[s] << endl;
  }
  return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b)
{
    return b ? gcd(b, a % b) : a;
}
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void func(long long N, long long A, long long B)
{
    if (A == 0)
    {
        cout << 0 << endl;
        return;
    }
    if (N <= A)
    {
        cout << N << endl;
        return;
    }
    if (N > A && N <= B)
    {
        cout << A << endl;
        return;
    }

    ll a = (N / (A + B)) * A;
    ll b = (N % (A + B));
    if (b >= A)
    {
        b = A;
    }
    cout << a + b << endl;
}

int main()
{
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld", &N);
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    func(N, A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;
int n, m, a[200001];
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t; cin >> t;
    if(t < 1200)cout << "ABC" << endl;
    else if(t < 2800)cout << "ARC" << endl;
    else cout << "AGC" << endl;
    return 0;
}


Measured memory_bytes: 3588
S = input().rstrip()
T = input().rstrip()
flg = False
for i in range(len(S)):
    cnt = 0
    for j, s in enumerate(S):
        if s==T[j-i]: cnt += 1
    if cnt==len(S):
        flg = True
if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 67176
#include<iostream>
using namespace std;
int main(){
	int x;
	int y;
	int z;
	int a;
	cin >> x >> y>>z;
	if (x>y){
		a = x;
		x = y;
		y = a;
	}
	if (y > z){
		a = y;
		y = z;
		z = a;
	}
	if (x>y){
		a = x;
		x = y;
		y = a;
	}
	cout << x <<" "<<y<<" "<< z<<"\n";
	return 0;
}

Measured memory_bytes: 3088
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const int MOD = 998244353;
const int INF = 1000000007;
const LL LINF = 1LL * INF * INF; 
const int MAXN = 100007;
const LD EPS = 1e-12;

int A[MAXN];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n, k = 0, x = 0;
	cin >> n;
	REP(i, n)
		cin >> A[i];
	sort(A, A + n);
	reverse(A, A + n);
	while (A[k + 1] > k + 1)
		++k;
	FOR(i, k, n)
		x += (A[i] > k);
	cout << ((A[k] - k) & x & 1 ? "Second" : "First");
	//cout << endl; system("pause");
	return 0;
}

Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define int long long
using vi=vector<int>;
using vvi=vector<vi>;
void solve(int T, int P, int R) {
	vi tid(R), pid(R), time(R);
	vector<string>msg(R);
	rep(i, 0, R) {
		cin >> tid[i] >> pid[i] >> time[i] >> msg[i];
		tid[i]--, pid[i]--;
	}
	vvi ac(T, vi(P)), wa(ac);
	vi pena(T),solved(T);

	rep(i, 0, R) {
		if (ac[tid[i]][pid[i]])continue;
		if (msg[i] == "CORRECT") {
			solved[tid[i]]++;
			ac[tid[i]][pid[i]] = 1;
			pena[tid[i]] += wa[tid[i]][pid[i]] * 1200 + time[i];
		}
		else {
			wa[tid[i]][pid[i]]++;
		}
	}
	vi team(T);
	rep(i, 0, T) {
		team[i] = i;
	}
	sort(team.begin(), team.end(), [&](int x, int y) {
		if (solved[x] == solved[y]) {
			if (pena[x] == pena[y]) {
				return x < y;
			}
			else {
				return pena[x] < pena[y];
			}
		}
		else {
			return solved[x] > solved[y];
		}
	});

	rep(i, 0, T) {
		cout << team[i]+1 << " " << solved[team[i]] << " " << pena[team[i]] << endl;
	}
}

signed main() {
	
	int T, P, R;
	while (cin >> T >> P >> R, T or P or R) {
		solve(T, P, R);
	}

	return 0;
}


Measured memory_bytes: 3220
L,R=map(int,input().split())
ans=10**9
if R-L>2019:
  print(0)
else:
  L=L%(2019**2)
  R=R%(2019**2)
  for i in range(L,R):
    for j in range(i+1,R+1):
      ans=min(ans,(i*j)%2019)
  print(ans)


Measured memory_bytes: 2940
import sys

c = [list(map(int, input().split())) for _ in range(3)]

for a_1 in range(min(c[0]), max(c[0])+1):
    for a_2 in range(min(c[1]), max(c[1])+1):
        for a_3 in range(min(c[2]), max(c[2])+1):
            b_1, b_2, b_3 = map(lambda x: x - a_1, c[0])
            if all([a_2 + b_1 == c[1][0],
                    a_2 + b_2 == c[1][1],
                    a_2 + b_3 == c[1][2],
                    a_3 + b_1 == c[2][0],
                    a_3 + b_2 == c[2][1],
                    a_3 + b_3 == c[2][2]]):
                print('Yes')
                sys.exit(0)
print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    vector<string> v(3);
    for (auto &&i : v) cin >> i;
    vector<int> A[3][3];
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            if(i == j) continue;
            for (int k = 0; k < v[i].size(); ++k) {
                int ok = 1;
                for (int l = 0; l + k < v[i].size() && l < v[j].size(); ++l) {
                    if(v[j][l] == '?' || v[i][l + k] == '?' || v[j][l] == v[i][l + k]) continue;
                    ok = 0;
                    break;
                }
                if(ok) A[i][j].emplace_back(k);
            }
            for (int m = v[i].size(); m <= 4000; ++m) A[i][j].emplace_back(m);
        }
    }
    vector<int> perm(3);
    iota(perm.begin(),perm.end(), 0);
    vector<int> sz(3);
    for (int i = 0; i < 3; ++i) sz[i] = v[i].size();
    int ans = sz[0]+sz[1]+sz[2];
    for (int a = 0; a < 3; ++a) {
        for (int b = 0; b < 3; ++b) {
            if(a == b) continue;
            for (int c = 0; c < 3; ++c) {
                if(a == c || b == c) continue;
                for (auto &&i : A[a][b]) {
                    for (auto &&j : A[b][c]) {
                        if(i+j >= sz[a]) ans = min(ans, max({sz[a], i+sz[b], i+j+sz[c]}));
                        else {
                            auto x = *lower_bound(A[a][c].begin(),A[a][c].end(), i+j);
                            if(x == i+j){
                                ans = min(ans, max({sz[a], i+sz[b], i+j+sz[c]}));
                            }
                        }
                    }
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int w,h;
int mp[20][20],memo[20][20];
void saiki(int x,int y){
  if(y >= h-1) memo[y][x]++;
  else 
    for(int i=-1;i<=1;i++) {
      int nx = x+i, ny = y+1;
      if(nx==x && mp[ny][nx] == 2)while(mp[ny][nx] == 2) ny+=2;
      if(nx <0|| nx >= w ||mp[ny][nx] != 0) continue;
      if(memo[ny][nx]==0) saiki(nx,ny);
      memo[y][x] += memo[ny][nx];
    }
  if(memo[y][x] == 0) mp[y][x] = 1;
}
int main() {
  while(1) {
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    for(int i=0;i<=19;i++)
      for(int j=0;j<=19;j++)memo[i][j] = mp[i][j] = 0;
     
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)cin >> mp[i][j];
  
    for(int i=0;i<w;i++)
      if(mp[0][i] !=1) saiki(i,0);
     
    int cnt = 0;
    for(int i=0;i<w;i++)cnt+=memo[0][i];
    cout <<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int main(int argc,char** argv){
	double d,x;
	cin>>d;
	x=d/3.00000;
	cout<<fixed<<setprecision(10)<<x*x*x;
	return 0;
}

Measured memory_bytes: 256