akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

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

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int64_t get_long(void) {
  int64_t num;
  scanf("%lld", &num);
  return num;
}

int get_int2(int64_t *a1, int *a2) {
  scanf("%lld %d", a1, a2);
  return 0;
}

// sort
int asc(const void *a1, const void *a2) {
    int64_t aa1 = *(int64_t*)a1;
    int64_t aa2 = *(int64_t*)a2;
    if(aa1 > aa2) return 1;
    if(aa1 == aa2) return 0;
    return -1;
}

#define NUM_MAX 100000



int main(void) {
    int num = get_int();
    int64_t circle = get_long();
    static int64_t pos[NUM_MAX+1];
    static int64_t value[NUM_MAX+1];

    int i;
    pos[0] = value[0] = 0;
    for(i = 1; i <= num; i++) {
        int64_t p;
        int val;
        get_int2(&p, &val);
        pos[i] = p;
        value[i] = val;
    }
    int64_t ans = 0;

    static int64_t rdp[NUM_MAX+2];
    int64_t prev = 0;
    int64_t profit = 0;
    for(i = num; i >= 0; i--) {
        int64_t cur = circle - pos[i];
        profit = profit -(cur-prev) + value[i];
        rdp[i] = max(rdp[i+1], profit - cur);
        prev = cur;
    }

    // cw
    prev = 0;
    profit = 0;
    static int64_t dp[NUM_MAX+2];
    for(i = 1; i <= num; i++) {
        int64_t cur = pos[i];
        profit = profit - (cur-prev) + value[i];
        dp[i] = max(dp[i-1], profit - cur);
#ifdef DEBUG
        printf("[<-%lld] %lld %lld\n", cur, profit, rdp[i]);
#endif
        ans = max(ans, profit + rdp[i+1]);
        prev = cur;
    }

    prev = 0;
    profit = 0;
    for(i = num; i >= 1; i--) {
        int64_t cur = circle - pos[i];
        profit = profit - (cur-prev)+value[i];
#ifdef DEBUG
        printf("[->%lld] %lld %lld\n", cur, profit, dp[i]);
#endif
        ans = max(ans, profit + dp[i-1]);
        prev = cur;
    }

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

    return 0;
}


Measured memory_bytes: 3328
a = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
b = ''
e = int(input())

for c in list(input()):
  d = a.index(c)
  if d > 25 - e:
    d = d - (26)
    b += a[(d+e)]
  else:
    b += a[(d+e)]

print(b)

Measured memory_bytes: 3060
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
    cout<<fixed;
}

template< typename T >
struct BIT {
  vector< T > data;

  BIT(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

int main(){
    init();
    ll N,Q;cin>>N>>Q;
    BIT<ll>bit(N);
    for(int i=0;i<Q;i++){
        ll com,x,y;
        cin>>com>>x>>y;
        if(com==0)bit.add(x-1,y);
        else cout<<bit.sum(y-1)-bit.sum(x-2)<<endl;
    }
}


Measured memory_bytes: 3636
n=int(input())
l=[int(i) for i in input().split()]
s=sum(l)
res=0
while s>0:
  res+=1
  i=0;j=0
  for i in range(n):
    if l[i]>0:
      l[i]-=1
      s-=1
      break
  for j in range(i+1,n):
    if l[j]==0:
      break
    else:
      l[j]-=1
      s-=1
print(res)

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

int main() {
    
    long long A,B,V,W,T;
    
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;
    
    if(A <= B){
        if(B+W*T <= A + V*T)cout << "YES" <<endl;
        else cout << "NO" << endl;
    }else{
        if(A-V*T<=B-W*T)cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    
}


Measured memory_bytes: 3604
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#define ll long long
using namespace std;
struct Edge
{
	int from;
	int to;
	int next;
}e[200005];
int n,m,edgenum,head[100005],ans[100005],d[100005];
bool flag[100005];
queue<int>q;
void add(int u,int v)
{
	e[++edgenum].from=u;
	e[edgenum].to=v;
	e[edgenum].next=head[u];
	head[u]=edgenum;
}
void work(int root)
{
	ans[root]=0;
	q.push(root);
	memset(flag,0,sizeof(flag));
	flag[root]=1;
	while(!q.empty())
	{
		int node=q.front();
		q.pop();
		for(int hd=head[node];hd;hd=e[hd].next)
		{
			int to=e[hd].to;
			if(flag[to])continue;
			d[to]--;
			if(d[to]==0)
			{
				flag[to]=1;
				q.push(to);
				ans[to]=node;
			}
		}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	m+=n-1;
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
	}
	for(int i=1;i<=edgenum;i++)
	{
		int u=e[i].from,v=e[i].to;
		d[v]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(d[i]==0)
		{
			work(i);
			break;
		}
	}
	for(int i=1;i<=n;i++)
	  printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 3328
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)

void print1d(const vector<int>& vec) {for (auto val : vec) {cout << val << " ";} cout << endl;}

void print2d(const vector<vector<int>>& vec) {for (auto row : vec) {for (auto val : row) {cout << val << " ";} cout << endl;}}

signed main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// #endif
// 	crap;

	string str;
	cin >> str;

	deque<char> dq;

	for(auto x: str)
		dq.push_back(x);

	int q;
	cin >> q;

	int cnt = 0;

	while (q--) {
		int t;
		cin >> t;

		if (t == 2) {
			int f;
			char c;
			cin >> f >> c;
			// cout << f << c << endl;

			if (cnt % 2 == 0) {
				if (f == 1)
					dq.push_front(c);
				else
					dq.push_back(c);
			} else {
				if (f == 2)
					dq.push_front(c);
				else
					dq.push_back(c);
			}

		} else {
			cnt++;
		}
	}

	string ans = "";
	for(auto x: dq)
		ans += x;
	if (cnt & 1){
		reverse(ans.begin(), ans.end());
	}

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






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

int main(){
	int H, W;
	cin >> H >> W;
	char C[H+1][W+1];
	rep(i,H)rep(j,W) cin >> C[i+1][j+1];

	for (int i = 1; i <= 2*H; i++) {
		for (int j = 1; j <= W; j++) {
			cout << C[(i+1)/2][j];
			if (j == W) cout << "\n"; 
		}
	}
	return 0;
}


Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(2*10**5)

N = int(input())
u, v, w = (
    zip(*(map(int, input().split()) for _ in range(N - 1))) if (N - 1) else
    ((), (), ())
)

G = [{} for _ in range(N + 1)]
for x, y, c in zip(u, v, w):
    G[x][y] = c
    G[y][x] = c

dp = [-1 for _ in range(N + 1)]
dp[1] = 0


def f(i):
    for j in G[i]:
        if dp[j] == -1:
            if G[i][j] % 2 == 0:
                dp[j] = dp[i]
            else:
                dp[j] = 1 - dp[i]
            f(j)


f(1)
ans = '\n'.join(
    str(dp[i])
    for i in range(1, N + 1)
)
print(ans)


Measured memory_bytes: 88904
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;



int32_t main()
{


    IOS



    int x;
    cin >> x;

    int ans = 8;

    for(int i = 599; i <= 1999; i+= 200)
    {
      if(x <= i)
      {
        cout << ans;
        return 0;
      }
      ans--;
    }






    return 0;
}


Measured memory_bytes: 3636
import java.util.* ;
public class Main {
	public static void main(String[] args) {
		Scanner S = new Scanner( System.in ) ;
		int n = S.nextInt() ;
		int k = S.nextInt() ;
		int[] arr = new int[n] ;
		for( int i=0;i<arr.length;i++ ) arr[i] = S.nextInt() ;
		Arrays.sort(arr) ;
		int result = 0 ;
		for( int i=0;i<k;i++ ) result += arr[i] ;
		System.out.println( result ) ;
	}
}

Measured memory_bytes: 39020
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        for(int i = 1; i <= n; i++){
            String s = String.valueOf(i);
            ans += s.length()%2 != 0 ? 1 : 0;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 28372
x, n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))
    ans = 1e18
    for i in range(102):
        if i not in p:
            ans = min(ans, abs(x-i))
    if x-ans not in p:
        print(x-ans)
    else:print(x+ans)
if n == 0:
    print(x)


Measured memory_bytes: 61840
import java.util.*;
import java.util.Map.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int currentPosition = sc.nextInt();
        
        TreeSet<Integer> numSet = new TreeSet<Integer>();
        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            numSet.add(num);
        }
        
        int p = -1;
        if (numSet.size() > 1) {
            int a = 2000000000;
            int b = 2000000000;
            
            try {
                a = numSet.floor(currentPosition);
            } catch (Exception e) {
            }
            try {
                b = numSet.ceiling(currentPosition);
            } catch (Exception e) {
            }
            
            if (Math.abs(currentPosition - a) < Math.abs(currentPosition - b)) {
                p = a;
            } else {
                p = b;
            }            
        } else {
            for (Integer num : numSet) {
                p = num;
            }
        }
        
        int d = Math.abs(currentPosition - p);
        int answer = 1;
        for (int i = 1; i < d; i++) {
            boolean end = true;
            if (d % i != 0) continue;
            int length = d / i;
            
            for (Integer num : numSet) {
                if ((num - currentPosition) % length != 0) {
                    end = false;
                    break;
                }
            }
            
            if (end) {
                answer = length;
                break;
            }
        }
        
        System.out.println(answer);
    }
}


Measured memory_bytes: 63284
#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 watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	ll a,b; cin>>a>>b;
	if(a<=0 && b>=0){ cout<<"Zero\n"; exit(0); }
	
	if(a>0) {cout<<"Positive\n"; exit(0);}
	
	if((b-a+1)%2==0) cout<<"Positive\n"; 
	else cout<<"Negative\n";
	
	return 0;
}


Measured memory_bytes: 3616
def addbit(i):
    i += 1
    while i <= N:
        BIT[i] += 1
        i += i & (-i)
def getsum(i):
    ret = 0
    i += 1
    while i != 0:
        ret += BIT[i]
        i -= i&(-i)
    return ret
def bit(L):
    global BIT
    BIT=[0] * (N+1)
    re = 0
    for l in L:
        re += getsum(l)
        addbit(l)
    return N*(N-1)//2 - re
def get_rank(L):
    D = {x:i for i,x in enumerate(sorted(L))}
    return [D[x] for x in L]
def calc(Z):
    Z.sort()
    l, r, lc, rc = -1<<28, 1<<28, N*(N-1)//4+1, N*(N-1)//4+1
    while (r - l) / max(abs(l), 1) > 0.000000001:
        m = (l * rc + r * lc) / (lc + rc)
        A = get_rank([s*m+t for s, t in Z])
        c = bit(A)
        if c > N*(N-1)//4:
            l = m
            lc = ((c - N*(N-1)//4) * 2) ** 0.2
        else:
            r = m
            rc = ((N*(N-1)//4 - c) * 2 + 1) ** 0.2
    return l

N = int(input())
X, Y = [], []
for _ in range(N):
    a, b, c = map(int, input().split())
    X.append((-a/b, c/b))
    Y.append((-b/a, c/a))
print(calc(X), calc(Y))

Measured memory_bytes: 130448
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

class parts{
public:
  int size, abc;
  bool operator<(const parts& another) const{
    if(size == another.size) return abc > another.abc;
    return size < another.size;
  }
};

void solve(){
  int n; cin >> n;
  vector<parts> p(3 * n);
  for(int i = 0; i < 3 * n; i++){
    cin >> p[i].size;
    if(i < n) p[i].abc = 0;
    else if(i < 2 * n) p[i].abc = 1;
    else p[i].abc = 2;
  }

  sort(p.begin(), p.end());
  /*for(int i = 0; i < p.size(); i++){
    cout << p[i].size << " " << p[i].abc << endl;
  }*/
  unsigned long long int an = 0, abn = 0, ans = 0;
  for(int i = 0; i < p.size(); i++){
    if(p[i].abc == 0) an++;
    else if(p[i].abc == 1) abn += an;
    else ans += abn;
  }
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
using namespace std;

int syc(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	int n;
	cin >> n;
	for(int i=n;i<1000;i++){
		int a=i/100;
		int b=(i%100)/10;
		int c=i%10;
		if(a==b&&b==c){
			cout << 100*a+10*b+c << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
const ll INF = (ll)1e18 + 1;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int n;
int a[125252];
int b[125252];

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

    cin >> n;
    rep(i,n+1) cin>>a[i];
    rep(i,n) cin>>b[i];

    ll ans = 0;
    rep(i,n){
        int sb = min(a[i], b[i]);
        a[i] -= sb;
        b[i] -= sb;
        ans += sb;
        sb = min(a[i+1], b[i]);
        a[i+1] -= sb;
        b[i] -= sb;
        ans += sb;
    }
/*      
    rep(i,n){
        if(b[i] + c > a[i]){
            c = b[i] + c - a[i];
            ans += a[i];
        }
        else{
            ans += b[i] + c;
            c = 0;
        }
    }
    if(a[n] > c) ans += c;
    else ans += a[n];
*/
    cout << ans << ln;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;


int main() {
    int n; cin >> n;
    int beft = 0, befx = 0, befy = 0;
    rep(i, n) {
        int t, x, y; cin >> t >> x >> y;
        if (t - beft < abs(x - befx) + abs(y - befy)) break;
        if ((t - beft) % 2 != (abs(x - befx) + abs(y - befy)) % 2) break;
        if (i == n - 1) {cout << "Yes" << endl; return 0;}
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce
from itertools import groupby
from heapq import heapify, heappush, heappop

# sys.setrecursionlimit(5000)

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]
def linc(A, d=1): return map(lambda x: x + d, A)
def ldec(A, d=1): return map(lambda x: x - d, A)

N = n1()
S = sl(N)

C = array1(4)

for s in S:
    if s == "AC": C[0] += 1
    if s == "WA": C[1] += 1
    if s == "TLE": C[2] += 1
    if s == "RE": C[3] += 1

print("AC x {}".format(C[0]))
print("WA x {}".format(C[1]))
print("TLE x {}".format(C[2]))
print("RE x {}".format(C[3]))

Measured memory_bytes: 85372
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'){
            s.erase(s.begin(),s.begin()+i);
            //cout<<s<<endl;
            break;
        }
    }
    for(int j=0;j<s.size();j++){
        if(s[s.size()-1-j]=='Z'){
            s.erase(s.begin()+s.size()-j,s.end());
            //cout<<s<<endl;
            break;
        }
    }
    cout<<s.size()<<endl;
    return 0;
}

Measured memory_bytes: 640
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for y in b:
  i = bisect.bisect_left(a, y)
  j = bisect.bisect_right(c, y)
  if i > 0 and j != len(c):
    ans += i * (n - j)
print(ans)

Measured memory_bytes: 23360
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = 1;i <= n;i++)
#define fi first
#define se second
const int inf = 1e18;
typedef pair<int,int> P;

vector<P> x[200001], y[200001], G[400010];
priority_queue<P, vector<P>, greater<P> > q;
int d[400010];
signed main(){
	int w, h, n;
	fill(d, d+400010, inf);
	scanf("%lld%lld%lld", &w, &h, &n);
	for(int i = 1;i <= n;i++){
		int yy, xx;
		scanf("%lld%lld", &xx, &yy);
		x[xx].push_back(P(yy, i));
		y[yy].push_back(P(xx, i));
	}
	x[1].push_back(P(1, 0));
	x[w].push_back(P(h, n+1));
	y[h].push_back(P(w, n+1));
	n++;
	
	for(int i = 1;i <= w;i++){
		sort(x[i].begin(), x[i].end());
		for(int j = 1;j < x[i].size();j++){
			int from = x[i][j-1].se, to = x[i][j].se;
			int cost = x[i][j].fi-x[i][j-1].fi;
			G[from].push_back(P(to, cost));
			G[to].push_back(P(from, cost));
		}
	}
	for(int i = 1;i <= h;i++){
		sort(y[i].begin(), y[i].end());
		for(int j = 1;j < y[i].size();j++){
			int from = y[i][j-1].se+n, to = y[i][j].se+n;
			int cost = y[i][j].fi-y[i][j-1].fi;
			G[from].push_back(P(to, cost));
			G[to].push_back(P(from, cost));
		}
	}
	for(int i = 1;i <= n-1;i++){
		G[i].push_back(P(i+n, 1));
		G[i+n].push_back(P(i, 1));
	}
	
	d[0] = 0;
	q.push(P(0, 0));
	while(!q.empty()){
		P p = q.top();q.pop();
		if(d[p.se] < p.fi)continue;
		for(int i = 0;i < G[p.se].size();i++){
			int from = p.se, to = G[p.se][i].fi;
			int cost = G[from][i].se;
			if(d[from]+cost < d[to]){
				d[to] = d[from]+cost;
				q.push(P(d[to], to));
			}
		}
	}
	
	int ans = min(d[n], d[2*n]);
	if(ans == inf)printf("-1\n");
	else printf("%lld\n", ans);
	return 0;
} 


Measured memory_bytes: 69632
#include<iostream>
#include<string>
#include<cmath>

using namespace std;

int n,L;
int sum;
int hikaku = 100000000;
int margine;

int main(){
	int apltaste[200];

	cin >> n >> L;


	for (int i = 0; i < n; i++) {
		apltaste[i] = L + i;
		sum += apltaste[i];
	}

	for(int i=0;i<n;i++){
		if (pow(apltaste[i],2.0) < hikaku) {
			margine = apltaste[i];
			hikaku = pow(apltaste[i], 2.0);
		}
	}


	cout << sum - margine << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
using namespace std;

signed main(){
    int a,b;
    cin>>a>>b;
    if(a+b==15)cout<<"+"<<endl;
    else if(a*b==15)cout<<"*"<<endl;
    else cout<<"x"<<endl;
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextLong();
  vector<ll> A(N);
  REP(i, N) A[i] = nextLong();
  sort(ALL(A));
  reverse(ALL(A));

  ll ans = 0;


  priority_queue<int> q;
  ans += A[0];
  q.push(A[1]);
  q.push(A[1]);
  for (int i = 2; i < N; i++) {
    int val = q.top();
    q.pop();
    ans += val;
    q.push(A[i]);
    q.push(A[i]);
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
const int ms = 1e5+9;
int dp[ms];
vector<int> g[ms];


int solve(int u){
  int maxi = dp[u];
  if(maxi)
    return maxi;
  
  for(auto v: g[u]){
    maxi = max(maxi, solve(v));
  }

  return dp[u] = maxi + 1;

}
int main(){
  int n, m, u, v;
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    cin >> u >> v;
    u--;v--;
    g[u].push_back(v);
  }

  int ans = 0;

  for(int i = 0; i < n; i++){
    ans = max(ans, solve(i));
  }

  cout<<(ans - 1)<<endl;


}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define INF 999999999
using namespace std;
int main() {
  ll a,b,c,k;
  ll ans = 0;
  cin>> a >> b >> c >> k;
  if (a >= k) {
    cout<< k <<endl;
  }
  else if(a+b >= k) {
    cout<< a <<endl;
  }
  else{
    cout<< a-(k-a-b) <<endl;
  }
}


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#define MOD 1000000007
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <functional>
#include <algorithm>
#include <iterator>
#include <cstdio>
#include <utility>
#include <unordered_map>
#include <cmath>
#include <chrono>
#include <random>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

typedef pair<ll, ll> P;
struct edge { ll to, cost; };

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n-1,-1)

inline ll madd(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a + b) % MOD;
}
inline ll msub(ll a, ll b) {
	a %= MOD;b %= MOD;
	a += MOD;
	return (a - b) % MOD;
}
inline ll mmul(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a*b) % MOD;
}
inline ll mpow(ll a, ll r) {
	long long res = 1;
	while (r > 0) {
		if (r & 1) res = res * a % MOD;
		a = a * a % MOD;
		r >>= 1;
	}
	return res;
}
inline ll minv(ll a) {
	a %= MOD;
	ll b = MOD, u = 0, v = 1;
	while (a) {
		ll t = b / a;
		b -= t * a; swap(a, b);
		u -= t * v; swap(u, v);
	}
	if (u < 0) u += MOD;
	return u;
}
inline ll mdiv(ll a, ll b) {
	a %= MOD;
	a *= minv(b);
	return a%MOD;
}

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

/*
ll fact[100001], fact_inv[100001];
void calc_fact{
	fact[0]=1;
	REP(i,100000){
		fact[i+1]=mmul(fact[i],i+1);
		fact_inv[i+1]=minv(fact[i+1]);
	}
}
ll combi(int a, int b) {
	return mmul(fact[a], mmul(fact_inv[b], fact_inv[a - b]));
}
*/


ll to[] = { 0,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9 };
int main(void) {
	ll m, d, c;
	cin >> m;
	ll res = 0;
	ll x;
	REP(i, m) {
		cin >> d >> c;
		if (i == 0) {
			x = d;
			c--;
		}
		if (c < 100) {
			REP(ccc, c) {
				x += d;
				if (x > 9) res++;
				x = to[x];
				res++;
			}
		}
		else {
			ll init = x;
			ll numc = 1, numres = 1;
			x += d;
			if (x > 9) numres++;
			x = to[x];
			while (x != init) {
				x += d;
				if (x > 9) numres++;
				x = to[x];
				numc++;
				numres++;
			}
			res += c / numc * numres;
			c %= numc;
			REP(ccc, c) {
				x += d;
				if (x > 9) res++;
				x = to[x];
				res++;
			}
		}
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String[] nyu=sc.nextLine().split(" ");
        int A=Integer.parseInt(nyu[0]);
        int B=Integer.parseInt(nyu[1]);
        
      System.out.println(A*B /2) ;
    }
}

Measured memory_bytes: 21588
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
#define INF 1e+18
using namespace std;

int n;
vector<int> G[100000];
vector<int> path;

bool dfs(int v,int prev){
	if(v == n - 1) {
		path.push_back(v);
		return true;
	}
	for(int i = 0;i < G[v].size();i++){
		int to = G[v][i];
		if(to == prev) continue;
		if(dfs(to,v)) {
			path.push_back(v);
			return true;
		}
	}
	return false;
}

int dfs2(int v,int prev){
	int sum = 1;
	for(int i = 0;i < G[v].size();i++){
		int to = G[v][i];
		if(to == prev) continue;
		sum += dfs2(to,v);
	}
	return sum;
}

signed main(){
	cin >> n;
	for(int i = 0;i < n - 1;i++){
		int a,b;
		cin >> a >> b; a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(0,0);
	int a = (path.size() - 1) / 2;
	reverse(path.begin(),path.end());
	if(dfs2(path[a],path[a + 1]) > dfs2(path[a + 1],path[a])) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
	return 0;
}

Measured memory_bytes: 11512
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main() {
    cin>>N;
    cout<<N*N*N<<endl;
}

Measured memory_bytes: 256
import itertools
import numpy
import math

n = int(input())

seq = []
for _ in range(n):
  i = list(map(int, input().split(" ")))
  seq.append(i)
  
length = len(list(itertools.permutations(seq)))
results = []
paths = list(itertools.combinations(seq, 2))
factorial = math.factorial(n - 1)
for path in paths:
  a, b = path
  a = numpy.array(a)
  b = numpy.array(b)
  u = b - a
  results.append(numpy.linalg.norm(u) * (factorial * 2))
print(sum(results) / length)

Measured memory_bytes: 17004
// C.

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

using namespace std;

typedef long long LL;

LL a, b, c, x, y;

LL cost(LL ab) {
	LL t = ab * 2 * c;
	t += max(0LL, x - ab) * a;
	t += max(0LL, y - ab) * b;
	return t;
}

int main(int argc, char *argv[]) {
	cin >> a >> b >> c >> x >> y;
	LL left = 0, right = max(x, y);
	for (int t = 0; t < 100; ++t) {
		if (cost((left * 2 + right) / 3) < cost((left + right * 2) / 3)) {
			right = (left + right * 2) / 3;
		} else {
			left = (left * 2 + right) / 3;
		}
	}
	LL ans = 1LL << 60;
	for (LL ab = max(0LL, left - 5); ab <= left + 5; ++ab) {
		ans = min(ans, cost(ab));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;

int main() {
int N;
  in(N);
  if(N==1){
    out(1);
  return 0;
  }
 vl s = {1,4,8,16,32,64,128,256,512,9,27,81,243,729,25,125,625,36,216,49,343,100,1000,121,144,169,196,225,289,324,361,400,441,484,529,576,625,676,729,784,841,900,961};
for(int i=N;i>=1;i--){
  bool f = false;
 for(int j=0;j<=42;j++){
  if(i==s[j]) f = true; 
 }
  if(f){
   out(i);
    return 0;
  }
}
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <stack>
#include <queue>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll x,y;
    cin>>x>>y;
    ll i=1;
    if(x%y!=0){
        cout<<x*(y+1)<<endl;
    }else{
        cout<<-1<<endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
int main(){
	char moji;
	int b[26];
	int a,c;
	for(c=0;c<26;c++){
		b[c]=0;
	}
	while(scanf("%c",&moji)!=EOF){
	//	if(moji=='.')break;
		a=moji-'a';
		if(a>=0&&a<26)b[a]++; 
		a=moji-'A';
		if(a>=0&&a<26)b[a]++;
	}

	for(c=0;c<26;c++){
		printf("%c : %d\n",c+'a',b[c]);
	}
//	printf("\n");


//scanf("%d",&a);

 return 0;
} 

Measured memory_bytes: 540
N = int(input())
a_li = list(map(int,input().split()))
b_li = list(map(int,input().split()))

total = 0

for i in range(N):
    if(a_li[i] <= b_li[i]):
        total = total + a_li[i]
        b_li[i] = b_li[i] - a_li[i]
        if(a_li[i+1] <= b_li[i]):
            total = total + a_li[i+1]
            a_li[i+1] = 0
        else:
            total = total + b_li[i]
            a_li[i+1] = a_li[i+1] - b_li[i]
    else:
        total = total + b_li[i]

print(total)



Measured memory_bytes: 18624
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	a %= p;
	return a >= 0 ? a : a + p;
}

int **mul(int N, int **A, int **B){
	int i, j, k;
	int **C = (int **)malloc(sizeof(int *) * N);
	for(i = 0; i < N; i++){
		C[i] = (int *)malloc(sizeof(int) * N);
		for(j = 0; j < N; j++){
			C[i][j] = 0;
			for(k = 0; k < N; k++){
				C[i][j] = MOD(C[i][j] + A[i][k] * B[k][j]);
			}
		}
	}
	return C;
}

int **power(int N, int **A, int K){
//	printf("K = %lld\n", K);
	if(K == 0){
		int i, j;
		int **ans = (int **)malloc(sizeof(int *) * N);
		for(i = 0; i < N; i++){
			ans[i] = (int *)malloc(sizeof(int) * N);
			for(j = 0; j < N; j++){
				ans[i][j] = (i == j);
			}
		}
		return ans;
	}
	else if(K % 2 == 0){
		return power(N, mul(N, A, A), K / 2);
	}
	else{
		return mul(N, A, power(N, A, K - 1));
	}
}

signed main(){
	int N, K, i, j;
	scanf("%lld%lld", &N, &K);
//	printf("(N, K) = (%lld, %lld)\n", N, K);
	int **a = (int **)malloc(sizeof(int *) * N);
	for(i = 0; i < N; i++){
		a[i] = (int *)malloc(sizeof(int) * N);
		for(j = 0; j < N; j++){
			scanf("%lld", &a[i][j]);
//			printf("a[%lld][%lld] = %lld\n", i, j, a[i][j]);
		}
	}
	int **res = power(N, a, K);
	int ans = 0;
	for(i = 0; i < N; i++){
		for(j = 0; j < N; j++){
			ans = MOD(ans + res[i][j]);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2688
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll N) {
  map<int,int> cnt;
  for (int i = 1; i <= N; ++i) {
    int n = i;
    for (int j = 2; j <= i; ++j) {
      while (n % j == 0) {
        cnt[j] += 1;
        n /= j;
      }
    }
  }
  const int mod = 1e9 + 7;
  ll res = 1;
  for (auto p: cnt) {
    res *= p.second + 1;
    res %= mod;
  }
  cout << res << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	solve(N);
	return 0;
}


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

#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

const ll MX=1e18;

int main(){
 int n,i;
 ll ans=1;
 cin>>n;
 bool ng=false;
 rep(i,n){
    ll a;
    cin>>a;
    if (a==0){
        cout<<0<<endl;
        return 0;
    }
    if (ng||(MX+1)/ans<a||ans*a>MX){
        ng=true;
    }
    ans*=a;
 }
 if (ng){
     cout<<-1<<endl;
 }else{
     cout<<ans<<endl;
 }
 return 0;
}

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

int main()
{

    ll n;
    cin >> n;
    vector<ll> v(n+1,0);
    for(ll i = 1; i <= n; i++) cin >> v[i];
    if(n==2)
    {

        cout << abs(v[1]-v[2]);
        return 0;
    }
    for(ll i = 1; i <= n; i++) v[i] = v[i]+v[i-1];
    ll ans = inf;
    for(ll i = 2; i <= n-1; i++)
    {

        ll y = v[i-1];
        ll x = v[n]-v[i-1];
        ll df = abs(x-y);
        ans=  min(ans,df);
    }
    cout << ans;
}


Measured memory_bytes: 1792
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    ans = 0
    stack = []
    for c in input():
        if len(stack) >= 2 and stack[-2:] == ["A", "B"] and c == 'C':
            ans += len(stack) - 1
            stack.pop()
        elif len(stack) >= 1 and stack[-1] == 'A' and c in ('A', 'B'):
            stack.append(c)
        elif c == 'A':
            stack = ['A']
        else:
            stack = []
    print(ans)
resolve()

Measured memory_bytes: 85856
#include <iostream>
#include <vector>
using namespace std;
const long MOD = 10e8 + 7;
const int MAX = 2000;
long dp[MAX+1][MAX+1];
void make(){
    for(int i = 1; i <= MAX; ++i){
        for(int j = 0; j <= MAX; ++j){
            if(i == j || j == 0) dp[i][j] = 1;
            else {
                dp[i][j] = (dp[i-1][j] + dp[i-1][j-1]) % MOD;
            }
        }
    }
}

int main(){
    make();
    int N, K;
    cin >> N >> K;
    for(int i = 1; i <= K; ++i){
        if(K == 1) cout << 1 << endl;
        else {
            long long c = dp[N-K+1][i]*dp[K-1][i-1];
            c %= MOD;
            cout << c << endl;
        }
        
    }
    return 0;
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int sum = 0;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum ^= a[i];
  }
  for (int i = 0; i < n; ++i) {
    cout << (sum ^ a[i]) << " \n"[i == n - 1];
  }
  return 0;
}



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

int main(){
  int N;
  cin >> N;
  int L=(int)((double)N/1.08);
  int R=(int)((double)(N+1)/1.08)+1;
  for(int i=L; i<=R; i++){
    if((int)((double)i*1.08)==N){
      cout << i << endl;
      goto finish;
    }
  }
  cout << ":(" << endl;
finish: N=0;
}

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

int main()
{
	long long int n,k;cin>>n>>k;
	vector<long long int> v,b;
	for(long long int i=0;i<n;i++)
	{
		long long int l,p;cin>>l>>p;
		v.push_back(l);
		b.push_back(p);
	}
	long long int arr[n+1][k+1];
	for(long long int i=0;i<=n;i++)
	{
		for(long long int j=0;j<=k;j++)
		{
			if(i==0 || j==0)
			{
				arr[i][j]=0;
			}
			else if(v[i-1]<=j)
				arr[i][j]=max(b[i-1]+arr[i-1][j-v[i-1]],arr[i-1][j]);
			else
				arr[i][j]=arr[i-1][j];
			//cout<<arr[i][j]<<" ";
		}
		//cout<<endl;
	}
	cout<<arr[n][k];
	return 0;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int P=1e9+7;
const int M=1e5+5;
char str[M];
int cnt[30],n;
int main(){
	scanf("%d%s",&n,str+1);
	for(int i=1;i<=n;i++)cnt[str[i]-'a'+1]++;
	ll s=1;
	for(int i=1;i<=26;i++)(s*=(cnt[i]+1))%=P;
	s--;
	printf("%lld\n",(s+P)%P);
	return 0;
}

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

#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;


int main()
{
    int X,t;
    cin >> X >>t;
    if(X<=t){
        cout<<"0"<<endl;
    }else{
        cout<<X-t<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n)     for (ll i = 0; i < (n); ++i)
#define rep2(i, a, b) for (ll i = (a); i < (b); ++i)
#define repin(a, n)  \
    vector<ll> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repins(a, n)     \
    vector<string> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repind(a, n)     \
    vector<double> a(n); \
    rep(i, n) { cin >> a[i]; }
#define in(a) \
    ll a;     \
    cin >> a;
#define ins(a) \
    string a;  \
    cin >> a;
#define ind(a) \
    double a;  \
    cin >> a;
template <class T>
inline void out(T a) {
    cout << a << endl;
}
inline void out(double a) { printf("%.10f\n", a); }
#define all(x)  (x).begin(), (x).end()    //昇順
#define rall(x) (x).rbegin(), (x).rend()  //降順
#define yes     out("Yes");
#define no      out("No");

#include <atcoder/all>
using namespace atcoder;

int main() {
    in(k);
    rep(i, k) {
        cout << "ACL";
    }
    cout << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
constexpr double eps = 1e-9;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a, b;
    double c;
    cin >> a >> c;
    b = floor(c * 100.0 + eps);
    ll res = a * b;
    res /= 100LL;
    cout << res << newl;
}


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

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define SIZE 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
/*ios_base::sync_with_stdio(false);cin.tie(0);*/

int main(){
    ll n ,k;
    cin >> n>>k;
    int count =0;
    ll cur;
    for (int i = 0; i <n ; ++i) {
        cin>>cur;
        if(cur >=k)count++;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;

void main(){
	auto Q=readln.split.to!(int[]),A=Q[0],B=Q[1];
	if(A+B>=24)writeln((A+B)-24);
	else writeln(A+B);
}

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

int main() {
    long long n, p;
    cin >> n >> p;
    map<long long, int> c;
    for (long long i = 2; i * i <= p; ++i) {
        while (p % i == 0) {
            p /= i;
            c[i]++;
        }
        if (p == 1) break;
    }
    if (p != 1) c[p]++;
    long long ans = 1;
    for (auto it = c.begin(); it != c.end(); ++it) {
        ans *= pow(it->first, (int) it->second/n);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
// Colorful Hats
// * frank_c1
// * 2017 / 10 / 01

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, mx = 0, mi = (int)(1e9), cmx = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		int x; scanf("%d", &x);
		if (x > mx) mx = x, cmx = 1;
		else if (x == mx) ++cmx; 
		if (x < mi) mi = x; 
	} 
	if (mx == mi && mx == n - 1) return printf("Yes\n"), 0;
	if (mx - mi > 1 || !(mx >= n - cmx + 1 && mx <= n - cmx + (cmx >> 1))) return printf("No\n"), 0;
	return printf("Yes\n"), 0;
}

Measured memory_bytes: 256
#include <stdio.h> 

int main(void){
    int a,b;
	scanf("%d %d", &a,&b);
	
	if(-1000<=a,b<=1000){
	    if(a<b){
	     printf("a < b\n");
    	}
    	if(a>b){
	     printf("a > b\n");
    	}
    	if(a==b){
	     printf("a == b\n");
    	}
	}
    return 0;
}


Measured memory_bytes: 2040
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    for(int i=0;i<n;i++){
        if(s[i] == "AC"){
            ac++;
        }else if(s[i] == "WA"){
            wa++;
        }else if(s[i] == "TLE"){
            tle++;
        }else{
            re++;
        }
    }
    cout << "AC x "<< ac << endl;
    cout << "WA x "<< wa << endl;
    cout << "TLE x "<< tle << endl;
    cout << "RE x "<< re << endl;
    return 0;
}

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

int main() {
  	string A,B;
  	cin >> A >> B;
  
  
  	if(A.size() > B.size()) {
    	cout << "GREATER" << endl;
    }else if(A.size() < B.size()) {
    	cout << "LESS" << endl;
    }else {
      	bool equal = true;
    	for(int i = 0; i < A.size(); i++) {
        	if(A.at(i) > B.at(i)) {
            cout << "GREATER" << endl;
            equal = false;
            break;
            }else if(A.at(i) < B.at(i)) {
            cout << "LESS" << endl;
            equal = false;
            break;
            }
        }
      if(equal)
      cout << "EQUAL" << endl;
    }
}

Measured memory_bytes: 256
import sys
from pprint import pprint

def solve(m, d):
    ans = 0
    if d < 22:
        print(ans)
        return

    for m_i in range(1, m+1):
        for d_i in range(22, d+1):
            if d_i % 10 < 2:
                continue
            if m_i == (d_i // 10) * (d_i % 10):
                # print(m_i, d_i)
                ans += 1
    print(ans)

if __name__ == '__main__':
  m, d = map(int, sys.stdin.readline().strip().split(" "))
  solve(m, d)

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

int main()
{
  const long l = 1000000000;
  long s;
  cin >> s;
  cout << 0 << " " << 0 << " " << l << " " << 1 << " ";
  long h = (s - 1) / l + 1;
  long w = h * l - s;
  cout << w << " " << h << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;int main(){int a[100];int b,c;cin>>b>>c;for (int d = 0; d < b; d++) cin>>a[d];for(int k=2;k<=c;k++)for(int g=0;g<b-1;g++)if(a[g]% k>a[g+1] % k)swap(a[g],a[g + 1]);for(int s=0;s<b;s++)cout<<a[s]<<endl;}

Measured memory_bytes: 3092