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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int T, A; cin >> T >> A;
    int H[10010];
    rep(i, N) cin >> H[i];
    T *= 1000; A *= 1000;
    int idx = 0;
    rep(i, N - 1) {
        int tmp0 = T - H[idx] * 6;
        int tmp1 = T - H[i + 1] * 6;
        int d0 = abs(A - tmp0);
        int d1 = abs(A - tmp1);
        if (d0 > d1) idx = i + 1;
    }
    cout << idx + 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <stack>

using namespace std;

int main(){
  int a[3];
  int count;
  cin >> a[0] >> a[1] >> a[2];
  sort(a,a+3);
  count = a[2]-a[1];
  a[0] += count;

  if((a[2]-a[0])%2==0){
    count += (a[2]-a[0])/2;
  }else{
    count += (a[2]-a[0])/2+2;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	vector<ll> v(5);
	REP(i, 5){
		cin >> v[i];
		if(v[i] == 0)cout << i+1 << endl;
	}


	return 0;
}


Measured memory_bytes: 3640
import sys
sys.setrecursionlimit(1000000)


def input():
    return sys.stdin.readline()


n = int(input())
aa = [int(i) for i in input().split()]
e = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = [int(i) - 1 for i in input().split()]
    e[a].append(b)
    e[b].append(a)

dp = [10 ** 9] * (n + 10)
dp[0] = 0
ans1 = [0] * n
ans2 = [0] * n


def dfs(i=0, r=-1):
    global dp, ans1, ans2
    mi = 0
    ma = n
    while mi != ma:
        mm = (mi + ma) // 2
        if dp[mm] >= aa[i]:
            ma = mm
        else:
            mi = mm + 1

    be = dp[mi]
    dp[mi] = min(dp[mi], aa[i])
    ans1[i] = mi
    ans2[i] = max(ans1[i], ans2[r])

    for j in e[i]:
        if j == r:
            continue
        dfs(j, i)

    dp[mi] = be


dfs()
print("\n".join(map(str, ans2)))


Measured memory_bytes: 272480
#pragma region Include/Defines
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <limits.h>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <memory.h>
#include <string.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <functional>
#include <cassert>
#include <map>
#include <set>
#include <iostream>
#include <queue>
#include <time.h>

using namespace std;
typedef long long lli;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
typedef vector<pii> vpii;
typedef vector <pll> vpll;
typedef long double ld;
#define all(a) std::begin(a), std::end(a)

const int INF = 0x3f3f3f3f;
const lli LINF = 0x3f3f3f3f3f3f3f3f;

template<typename T, typename T2> inline void _max(T &a, T2 b) { a = max((T)a, (T)b); }
template<typename T, typename T2> inline void _min(T &a, T2 b) { a = min((T)a, (T)b); }

#ifdef _DEBUG
#define epr(...) fprintf(stderr,__VA_ARGS__)
#else
#define epr(...) 
#endif
#pragma endregion

const int MAX = 1e5 + 10;
int a[MAX], n;

void clear() {
}

void read() {
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
}

void solve() {
	int t = 1;
	int u[MAX] = { 0 };
	int res = 0;
	while (t != 2) {
		if (u[t]) return void(printf("-1\n"));
		u[t] = 1;
		t = a[t];
		res++;
	}
	printf("%d\n", res);
}

int main() {
#ifdef _LOCAL_VAN
	freopen("in.txt", "r", stdin);
#endif
	while (scanf("%d", &n) == 1) {
		clear();
		read();
		solve();
#ifndef _LOCAL_VAN
		return 0;
#endif
	}
	return 0;
}

Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int D = sc.nextInt();

		int i = 0;
		int count = 0;
		while (i < N) {
			i += 1 + D * 2;
			count++;
		}

		PrintWriter out = new PrintWriter(System.out);
		out.println(count);

		out.flush();
	}

	public static int gcd(int a, int b) {
	    if (b == 0) return Math.abs(a);
	    return gcd(b, a % b);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22612
enqu = []
n = m = 0

def solve():
    score = [ sum(enqu[i][j] for i in range(0, n)) for j in range(0, m)]
    x = [ [j + 1, score[j]] for j in range(0, m)]
    x.sort(key = lambda y: y[1], reverse=True)
    print(" ".join(list(map(lambda y: str(y[0]), x))))
    

while True:
    enqu = []
    line = input()
    n, m = map(int, line.split())
    if n == 0 and m == 0:
        break
    for _ in range(0, n):
        answer = list(map(int, list(input().split())))
        enqu.append(answer)
    solve()


Measured memory_bytes: 6524
// B - Collecting Balls (Easy Version)

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	int ans = 0;
	int x;
	for (int i=0; i<N; i++) {
		cin >> x;
		ans += min(x, K - x) * 2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;
int main()
{
    int n,m;
    while(cin >> n >> m){
        if(n==0&&m==0){
            break;
        }
        int a[n],b[m];
        for(int i=0;i<n;i++){
            cin >> a[i];
        }
        for(int i=0;i<m;i++){
            cin >> b[i];
        }
        int k=0;
        int j=0;
        while(j<n-1){
            j+=b[k]+a[j+b[k]];
            k++;
        }
        cout << k << endl;;
    }

    return 0;
}



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

n = int(input())
uvw = [tuple(int(x) for x in input().split()) for _ in range(n-1)]

c = [-1] * n

r = [[] for _ in range(n)]

for u, v, w in uvw:
    r[u-1].append([v-1, w])
    r[v-1].append([u-1, w])

def f(p):
    count = 0
    for x, w in r[p]:
        if c[x] == -1:
            if w % 2 == 0:
                c[x] = c[p]
                f(x)
            else:
                c[x] = (c[p] + 1) % 2
                f(x)
            count += 1
    #print(count)

c[0] = 0
f(0)

for x in c:
    print(x)

Measured memory_bytes: 98404
#include<bits/stdc++.h>
typedef long long ll ;
using namespace std ;
const int maxn = 2e5 + 5 ;
int n ;
int a[maxn] ;
bool flag = 0 ;
int main()
{
	scanf("%d" , &n) ;
	for(int i = 1 ; i <= n ; i ++)
	{
		scanf("%d" , &a[i]) ;
		if(a[i] == 1)  flag = 1 ;
	}
	if(!flag)
	{
	   printf("-1\n") ;
	   return 0 ;	
	}  
	int now = 1 ; 
	for(int i = 1 ; i <= n ; i ++)
	{
		int j = i ;
		while(j + 1 <= n && a[j] != now)
		  j ++ ;
		if(a[j] == now)
		  now ++ ;
		else 
		  break ;
		i = j ;
	}
	printf("%d\n" , n - now + 1) ;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (a < b) swap(a, b);
    if (a < c) swap(a, c);
    cout << b + c + (1 << k) * a;
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int32_t main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	char c; cin >> c;
	cout << (char) (c+1) << endl;
	
	return 0;
}


Measured memory_bytes: 256
def main():
    a, b, c = map(int, input().split())
    k = int(input())
    while b <= a:
        b *= 2
        k -= 1
        if k < 0:
            print('No')
            exit()
    while c <= b:
        c *= 2
        k -= 1
        if k < 0:
            print('No')
            exit()
    print('Yes')
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 9088
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main() {
  ll mul,a,b,flgy=0;
  cin>>mul>>a>>b;
   ll i;
  if(a%mul==0)
    flgy=1;
 
  else
  {
    for( i=a;i<=b;i++)
    {
      if(i%mul==0)
      { 
        flgy=1; 
        break;
      
      }
    }
  }
  if(flgy==1)
    cout<<"OK";
  else
    cout<<"NG";
  return 0;

}

Measured memory_bytes: 3568
#include <iostream>
using namespace std;
int main(){
    // Your code here!
    long long int n,a[10000],max,min,sum=0;
    min = 100000000;
    max = -100000000;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(max<a[i]){
            max = a[i];
        }if(min>a[i]){
            min = a[i];
        }
        sum += a[i];
    }
    cout << min << " " << max << " " << sum << endl; 
    return 0;
}



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

int main() {
	int n, t[3], a, b, c=0;
	cin >> n;
	for(int m=0; m<n; m++){
	for(int i=0; i<3; i++){
		cin >> t[i];
	}
	for(int j=0; j<3; j++){
		int v = t[j];
		int k = j-1;
		while(t[k]<v && k>=0){
			t[k+1] = t[k];
			k--;
			t[k+1] = v;
		}
	}
	if(t[0]*t[0] == t[1]*t[1]+t[2]*t[2])
		cout << "YES" << endl;
	else cout << "NO" << endl;
	}
	return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  vector<int> d(3);
  vector<P> q;
  cin >> n;
  rep(i, 3) cin >> d[i];
  rep(i, n) {
    string s;
    cin >> s;
    q.emplace_back(s[0]-'A', s[1]-'A');
  }
  q.emplace_back(0, 0);
  string ans;
  auto add = [&] (int a, int b) {
    d[a]++;
    d[b]--;
    ans.push_back('A'+a);
  };
  rep(i, n) {
    int q1 = q[i].first;
    int q2 = q[i].second;
    if (!d[q1] && !d[q2]) {
      cout << "No\n";
      return 0;
    }
    if (!d[q1]) add(q1, q2);
    else if (!d[q2]) add(q2, q1);
    else {
      int nx1 = q[i+1].first;
      int nx2 = q[i+1].second;
      if (q1 == nx1 || q1 == nx2) add(q1, q2);
      else add(q2, q1);
    }
  }
  cout << "Yes\n";
  rep(i, ans.size()) cout << ans[i] << endl;
}

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

#define INF (1<<29)
#define max_n 10000

using namespace std;

struct node_t{
  node_t *pp,*lp,*rp;
  int id,val,mini,minId,lazy;
  bool rev;

  node_t(int id,int v):id(id),val(v),mini(v){
    pp=lp=rp=NULL;
    rev=false; 
    lazy=0; 
    update();
  }
   
  void update(){
    mini=val,minId=id;
    push();
    if(lp)lp->push();
    if(rp)rp->push();
    if(lp && mini>lp->mini)mini=lp->mini,minId=lp->minId;
    if(rp && mini>rp->mini)mini=rp->mini,minId=rp->minId;
  }
   
  void push(){
    if(rev){
      rev=false;
      swap(lp,rp);
      if(lp)lp->rev^=true;
      if(rp)rp->rev^=true;
    }
    if(lp)lp->lazy+=lazy;
    if(rp)rp->lazy+=lazy;

    val+=lazy,mini+=lazy,lazy=0;
  }
 
  bool is_root(){
    return !pp || (pp->lp != this && pp->rp != this);
  }
  
  void rotr(){
    node_t *q=pp,*r=q->pp;
    if((q->lp=rp))rp->pp=q;
    rp=q;q->pp=this;
    if((pp=r)){
      if(r->lp==q)r->lp=this;
      if(r->rp==q)r->rp=this;
    }
    q->update();
  }

  void rotl(){
    node_t *q=pp,*r=q->pp;
    if((q->rp=lp))lp->pp=q;
    lp=q;q->pp=this;
    if((pp=r)){
      if(r->lp==q)r->lp=this;
      if(r->rp==q)r->rp=this;
    }
    q->update();
  }

  void splay(){
    while(!is_root()){
      node_t *q=pp;
      node_t *r=q->pp;
      if(!q->is_root())r->push();
      q->push();
      push();
      if(q->is_root()){
	if(q->lp==this)rotr();
	else rotl();
      } else {
	if(r->lp==q){
	  if(q->lp==this){q->rotr();rotr();}
	  else {rotl();rotr();}
	} else {
	  if(q->rp==this){q->rotl();rotl();}
	  else {rotr();rotl();}
	}
      }
    }
    push();
    update();
  }
};

node_t *expose(node_t *x){
  node_t *rp=NULL;
  for(node_t *p=x;p;p=p->pp){
    p->splay();
    p->rp=rp;
    rp=p;
  }
  x->splay();
  return rp;
}

node_t *find_root(node_t *x){
  expose(x);
  while(x->lp)x=x->lp;
  return x;
}

bool isConnected(node_t *x, node_t *y){
  if(x->id==y->id)return true;
  expose(x);
  //assert(x->pp==NULL);
  expose(y);
  return (x->pp != NULL);
}

//Verified.
void evert(node_t *p){
  expose(p);
  p->rev^=true;
}

void cut(node_t *c){
  expose(c);
  node_t *p=c->lp;
  c->lp=NULL;
  p->pp=NULL;
}

void link(node_t *c,node_t *p){
  if(isConnected(c,p))return;
  evert(c);
  c->pp=p;
}

//Verified.
int minId(node_t *x){expose(x); return x->minId;}
void add(node_t *x,int val){ expose(x); x->lazy=val; }

//Verified. AOJ GRL_5_C
node_t *lca(node_t *x,node_t* y){
  expose(x);
  return expose(y);
}

//Verified.
int min(node_t *from, node_t *to){
  evert(from);
  expose(to);
  return to->mini;
}

//Verified.
void add(node_t *from, node_t *to,int v){
  evert(from);
  expose(to);
  to->lazy+=v;
}


//AOJ GRL_5_C
node_t *node[100001];
int main(void){
  int n;
  cin >> n;
  
  for(int i=0;i<n;i++)node[i]=new node_t(i,0);
  for(int i=0;i<n;i++){
    int k,t;
    cin >> k;
    for(int j=0;j<k;j++){
      cin >> t;
      link(node[t],node[i]);
    }
  }
  int q;
  cin >> q;
  for(int i=0;i<q;i++){
    int u,v;
    cin >> u >> v;
    cout << lca(node[u],node[v])->id << endl;
  }
  
  return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct UnionFindTree{
    vector<int>par,sz;
    UnionFindTree(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        if(sz[x]<sz[y])swap(x,y);
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool areSame(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

int N,M;
int deg[111111];
int A[111111],B[111111];
signed main(){
	cin>>N>>M;
	rep(i,M){
		int a,b;
		cin>>a>>b;
		a--;b--;deg[a]++;deg[b]++;
		A[i]=a;B[i]=b;
	}

	rep(i,N)if(deg[i]%2){
		cout<<"No"<<endl;
		return 0;
	}
	if(*max_element(deg,deg+N)>=6){
		cout<<"Yes"<<endl;
		return 0;
	}

	if(M>N+2){
		cout<<"Yes"<<endl;
	}
	else if(M<=N+1){
		cout<<"No"<<endl;
	}
	else{
		int a=find(deg,deg+N,4)-deg;
		UnionFindTree uf(N);
		rep(i,M)if(A[i]!=a&&B[i]!=a)uf.unite(A[i],B[i]);
		int cnt=0;
		rep(i,N)if(uf.find(i)==i)cnt++;
		if(cnt==2)cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
	return 0;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n,m,r;cin>>n>>m>>r&&n|m|r;){
		vi rs(r);
		rep(i,r) cin>>rs[i],rs[i]--;
		vvi a(n,vi(n,INF));
		rep(_,m){
			int u,v,w; cin>>u>>v>>w; u--,v--;
			a[u][v]=a[v][u]=w;
		}
		rep(k,n) rep(i,n) rep(j,n)
			a[i][j]=min(a[i][j],a[i][k]+a[k][j]);

		vvi dp(r,vi(1<<r,INF));
		rep(i,r) dp[i][1<<i]=0;
		repi(i,1,1<<r){
			rep(j,r) if(i>>j&1)
				rep(k,r) if(!(i>>k&1))
					dp[k][i|1<<k]=min(dp[k][i|1<<k],dp[j][i]+a[rs[j]][rs[k]]);
		}
		int res=INF;
		rep(i,r) res=min(res,dp[i].back());
		cout<<res<<endl;
	}
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    long int n, k;
    cin >> n >> k;
    long int a[n];
    rep(i, n) cin >> a[i];
    long int bit[42];
    rep(i, 42) bit[i] = 0;
    rep(i, n){
        rep(j, 42){
            if (((a[i] >> j) & 1) == 1){
                bit[j]++;
            }
        }
    }
    long int num = 0;
    for (long int i = 41; i >= 0; i--){
        if (bit[i] <= n / 2){
            if (num + ((long int)1 << i) <= k){
                num += ((long int)1 << i);
            }
        }
    }
    long int ans = 0;
    rep(i, n){
        ans += num ^ a[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main() {
	int K, A, B;
	scanf("%d", &K);
	getchar();
	
	scanf("%d %d", &A, &B);
	for(int i = A; i <= B; i++) {
	 if (i % K == 0) {
	 	printf("OK");
	 	return 0;
	 } else {
	 	continue;
	 }
	}
	printf("NG");
	return 0;
}

Measured memory_bytes: 1732
n, m = map(int, input().split())
if n%2 == 1:
    l = 1
    r = n-1
    for i in range(m):
        print(l, r)
        l += 1
        r -= 1
else:
    l = 1
    r = n-1
    flag = False
    for i in range(m):
        if (not flag) and r-l <= n//2:
            r -= 1
            flag = True
        print(l, r)
        l += 1
        r -= 1


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

int fibonacci(int* dp, int i, int n)
{
    // メモ化再帰
    if(n == 1) return 1;
    if(i == 0 || i == 1){
        dp[i] = 1;
        return fibonacci(dp, i+1, n);
    }
    dp[i] = dp[i-1] + dp[i-2];
    if(i >= n) return dp[i];
    return fibonacci(dp, i+1, n);
}

int fibonacci2(int n)
{
    // DP
    int dp[50];
    dp[0] = dp[1] = 1;
    for(int i=2;i<=n; ++i)
    {
        dp[i] = dp[i-1] + dp[i-2];
    }
    return dp[n];
}

int main()
{
    int n;
    int dp[50];
    cin >> n;
    cout << fibonacci2(n) << endl;
}



Measured memory_bytes: 3100
def calc(a, b, op):
    """
    a: int
    b: int
    op: operator
    returns the result of arithmetic operation

    >>> calc(1, 2, '+')
    3
    >>> calc(56, 18, '-')
    38
    >>> calc(13, 2, '*')
    26
    >>> calc(100, 10, '/')
    10
    >>> calc(27, 81, '+')
    108
    """
    def add(a, b):
        return a + b
    def sub(a, b):
        return a - b
    def prod(a, b):
        return a * b
    def div(a, b):
        return a // b

    operators = {
        '+': add,
        '-': sub,
        '*': prod,
        '/': div,
    }

    if op in operators:
        return operators[op](a, b)

    raise Exception('invalid operator')


if __name__ == '__main__':

    while True:
        cmd = input().split(' ')
        (a, op, b) = (int(cmd[0]), cmd[1], int(cmd[2]))
        if op == '?':
            break
        print(calc(a, b, op))

Measured memory_bytes: 7676
#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

ll v[101010];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n,q;
	cin>>n>>q;
	vector<ll> qs;
	qs.push_back(n);
	for (int i=0;i<q;i++){
		ll qq;
		cin>>qq;
		while (qs.size()>0&&qs.back()>=qq) qs.pop_back();
		qs.push_back(qq);
	}
	map<ll, ll> qq;
	qq[qs.back()]=1;
	for (int i=(int)qs.size()-2;i>=0;i--){
		ll t=qs[i];
		//cout<<t<<endl;
		while ((*qq.rbegin()).F>t){
			ll k=(*qq.rbegin()).F;
			ll a=(*qq.rbegin()).S;
			//cout<<k<<" "<<a<<endl;
			qq.erase(k);
			ll wt=k/t;
			qq[t]+=a*wt;
			if (k%t>0){
				qq[k%t]+=a;
			}
		}
	}
	for (auto a:qq){
		v[a.F]+=a.S;
	}
	for (int i=n;i>=0;i--){
		v[i]+=v[i+1];
	}
	for (int i=1;i<=n;i++){
		cout<<v[i]<<"\n";
	}
}

Measured memory_bytes: 9460
from itertools import combinations
import sys

n,m,x = map(int, input().split())

a = [list(map(int, input().split())) for i in range(n)]

result = []
for i in range(1, n+1):
  cmb = [s for s in combinations(a, i)]
  for j in cmb:
    total = [0] * (m+1)
    for s in range(i):
      total = [x+y for (x,y) in zip(j[s], total)]
      result.append(total)
      
result.sort()
for k in result:
  price = k[0]
  del k[0]
  if min(k) >= x:
    print(price)
    sys.exit()

print('-1')

Measured memory_bytes: 24408
import java.util.*;
public class Main {
    public void solve() {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int A = N%1000;
        if(A  == 0)System.out.println(0);
        else System.out.println(1000-A);

    }

    public static void main(String[] args) {
        new Main().solve();
    }
}

Measured memory_bytes: 35756
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long ans = 9e15;
	long long N; cin >> N;
	for (long long i = 1; i <= sqrt(N); i++) {
		if (N % i == 0) {
			if (ans > i + (N / i) - 2) ans = i + (N / i) - 2;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
  int n, a, b; cin >> n >> a >> b;
  string s; cin >> s;
  int e = 0;
  int f = 0;
  for (int i = 0; i < n; i++)
  {
    if (e < a + b)
    {
      if (s[i] == 'a')
      {
        e++; 
        cout << "Yes" << endl;
      }
      else if (s[i] == 'b' && ++f <= b)
      {
        e++;
        cout << "Yes" << endl;
      }
      else
        cout << "No" << endl;
    }
    else
      cout << "No" << endl;
  }
}

Measured memory_bytes: 3776
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, m, p;
int pos;
char str[10000];
map<string, vector<int> > mapto;
map<vector<int>, string> mapfrom;
map<string, string> convert;
vector<int> error;

vector<int> formula();
vector<int> factor() {
  vector<int> lhs;
  if (str[pos] == '(') {
    pos++;
    lhs = formula();
    if (lhs == error) { return error; }
    assert(str[pos] == ')');
    pos++;
  } else {
    assert(isalpha(str[pos]));
    string s;
    while (isalpha(str[pos])) { s += str[pos++]; }
    if (!convert.count(s)) { return error; }
    if (!mapto.count(convert[s])) { return error; }
    lhs = mapto[convert[s]];
  }
  return lhs;
}

vector<int> term() {
  vector<int> lhs = factor();
  if (lhs == error) { return error; }
  while (str[pos] == '*' || str[pos] == '/') {
    int s = str[pos] == '*' ? 1 : -1;
    pos++;
    vector<int> rhs = factor();
    if (rhs == error) { return error; }
    REP(i, n) {
      lhs[i] += s * rhs[i];
    }
  }
  return lhs;
}

vector<int> formula() {
  vector<int> lhs = term();
  if (lhs == error) { return error; }
  while (str[pos] == '+' || str[pos] == '-') {
    pos++;
    vector<int> rhs = term();
    if (rhs == error) { return error; }
    REP(i, n) {
      if (lhs[i] != rhs[i]) { return error; }
    }
  }
  return lhs;
}

int main() {
  error = vector<int>(1, -1000000000);
  while (scanf("%d %d %d", &n, &m, &p), n|m|p) {
    pos = 0;
    mapto.clear();
    mapfrom.clear();
    REP(i, m) {
      string s;
      cin >> s;
      vector<int> vect(n, 0);
      REP(i, n) {
        scanf("%d", &vect[i]);
      }
      mapto[s] = vect;
      mapfrom[vect] = s;
    }
    scanf("%s", str);
    REP(i, p) {
      string from, to;
      cin >> from >> to;
      convert[from] = to;
    }
    vector<int> ans = formula();
    if (ans[0] <= -100000) {
      puts("error");
    } else if (mapfrom.count(ans)) {
      printf("%s\n", mapfrom[ans].c_str());
    } else {
      puts("undefined");
    }
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define INF 1000000000
int i,j,k,p;
int main(){
    int n;cin>>n;
    vector<int> x(n);
    for(i=0;i<n;i++){cin>>x[i];}

    int MIN=INF;
    for(p=1;p<=100;p++){
        int sum=0;
        for(j=0;j<n;j++){
            sum+=(x[j]-p)*(x[j]-p);
        }
        MIN=min(MIN,sum);
    }

    cout<<MIN<<endl;
    return 0;
}

Measured memory_bytes: 256
from heapq import *

xs, ys, xt, yt = [int(_) for _ in input().split()]
N = int(input())
XYR = [[xs, ys, 0]] + [[int(_) for _ in input().split()]
                       for _ in range(N)] + [[xt, yt, 0]]
G = [[0] * (N + 2) for _ in range(N + 2)]
for i in range(N + 1):
    for j in range(i + 1, N + 2):
        G[i][j] = G[j][i] = max(
            ((XYR[i][0] - XYR[j][0])**2 +
             (XYR[i][1] - XYR[j][1])**2)**0.5 - XYR[i][2] - XYR[j][2], 0)


def dijkstra(V, G, start):
    INF = float('inf')
    D = [INF for _ in range(V)]
    D[start] = 0
    H = [(0, start)]
    while H:
        du, u = heappop(H)
        if D[u] < du:
            continue
        for v, d in enumerate(G[u]):
            if D[v] > du + d:
                D[v] = du + d
                heappush(H, (D[v], v))
    return D


D = dijkstra(N + 2, G, 0)
print(D[-1])


Measured memory_bytes: 124252
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];


int main(){
    int K,X;
    cin >> K>>X;
    cout << 6-K-X << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}


int main() {
	int i, j, k;

	int N, M, K;

	ll A, B;
	cin >> A >> B;
	ll ans = abs(A) + abs(B);
	if (A < B) {
		ans = min(abs(-B - A) + 1, B - A);
	}
	else
		ans = min(abs(-B - A) + 1, abs(-B + A) + 2);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int search(int A[],int n,int key)
{
	int i=0;
	A[n]=key;
	while(A[i]!=key)
	{
		i++;
	}
	return i != n;
}

int main()
{
	int A[10000+1],q,key,i,n,count=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&A[i]);
	}
	
	scanf("%d",&q);
	for(i=0;i<q;i++)
	{
		scanf("%d",&key);
		if(search(A,n,key))
		{
			count++;
		}
	}
	
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 2760
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const double PI = acos(-1);
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  while(1){
    c -= b;
    if(c <= 0) break;

    a -= d;
    if(a <= 0) break;
  }
  if(c <= 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main() {

	long long int a, b;
	cin >> a >> b;

	long long int c = b - a;

	long long int aa = 0;

	for (long long int i = 1; i <= c; i++) {
		aa += i;
	}

	cout << aa - b << endl;

	return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll N;
	cin >> N;
	vector <ll> a(N, 0);
	for (ll ii = 0; ii < N; ++ii){
		cin >> a[ii];
	}

	vector <ll> ans(N, 0);
	ll cnt = 0;
	for (ll ii = N; ii > 0; --ii){
		ll tmp = ii * 2;
		ll sum = 0;
		while (tmp <= N) {
			sum += ans[tmp-1];
			tmp += ii;
		}
		if (sum % 2 != a[ii-1]){
			ans[ii-1] = 1;
			cnt++;
		}
	}

	cout << cnt << endl;
	for (int ii = 0; ii < N; ++ii){
		if (ans[ii]){
			cout << ii + 1 << " ";
		}
	}
	cout << endl;
	

	return 0;
}


Measured memory_bytes: 3968
/*▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄█████████████  █▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐*/
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
#pragma GCC optimize("fast-math")
#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
// #define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vector<ll> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<ll, ll, ll> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<ll> > vvi;
typedef vector<char> vc;

const ll INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9 + 7;
// const ll MAXN = 3e5;
const ld eps = 1e-6;
const ld eps2 = 1e-9;
const ll MOD2 = 998244353;
const ll dosz = 5e5;
const ll SZ = (1<<18);
const ld PI = atan2l(0, -1);


void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
        // freopen("a.in", "r",stdin);
#else
       // freopen("tickets.in", "r", stdin);
       // freopen("tickets.out", "w", stdout);
#endif
}

static const int keklol = -300;

int sq5(int a){
    return a*a*a*a*a;
}

void solve(){
    vi kek;
    int n;
    cin >> n;
    for(int i=keklol; i<=-keklol; i++){
        kek.pb(i);
    }
    sort(all(kek));
    for(int i=0; i<kek.size(); i++){
        for(int j=i+1; j<kek.size(); j++){
            if(sq5(kek[j])-sq5(kek[i])==n){
                cout << kek[j] << " " << kek[i] << endl;
                return;
            }
        }
    }
} 

signed main() {
    fast_io();
    ll q = 1;
    // cout << fixed;
    // cin >> q;
    while(q--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
	long long int A, B, C;
	cin >> A >> B >> C;
	if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0)
	{
		cout << 0 ;
	}
	else if(A > B){
		if(A > C){
			cout << B * C;
		}
		else{
			cout << B * A;
		}
	}
	else{
		if(B > C){
			cout << A * C;
		}
		else{
			cout << A * B;
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(std::string S, std::string T){
  std::cout << T << S << std::endl;
}

int main(){
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;
  solve(S, T);
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define fr(i,s,e) for(i=s;i<e;i++)
typedef long long ll;
int main() {
	string s;
	ll i,n;
	cin>>n;
	ll a[n][2],c=0,f=0;
	fr(i,0,n)
	{
		cin>>a[i][0]>>a[i][1];
		if(a[i][0]==a[i][1])
		{
			c++;
		}
		else
		{
			c=0;
		}
		if(c==3)
		{
			f=1;break;
		}
	}
	if(f==1)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3624
s = input()
p = input()
tmp_s = s
flag = False
for i in range(len(s)):
    tmp_s = tmp_s[-1]+tmp_s[0:-1]
    if tmp_s.count(p)>0:
        flag = True
        break
    else:
        pass
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 7504
arr = []
3.times do
  arr << gets.split.map(&:to_i)
end
# binding.pry
pre = Array.new(3)
3.times do |i|
  3.times do |j|
    if pre[j] && pre[j] != arr[(j+1) % 3][i] - arr[j][i]
      puts "No"
      exit
    end
    pre[j] = arr[(j+1) % 3][i] - arr[j][i]
  end
end

pre2 = Array.new(3)
3.times do |i|
  3.times do |j|
    if pre2[j] && pre2[j] != arr[i][(j+1) % 3] - arr[i][j]
      puts "No"
      exit
    end
    pre2[j] = arr[i][(j+1) % 3] - arr[i][j]
  end
end
puts "Yes"

Measured memory_bytes: 1788
//
//  main.cpp
//  usaco
//
//  Created by 김현수 on 2020/08/30.
//  Copyright © 2020 김현수. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
int main()
{
    int a, b, c;
    scanf("%d %d", &a, &b);
    for(int i=1;i<=12;i++)
    {
        if(a==i)
        {
            if(a<=b)
            {
                printf("%d", i);
            }
            else if(a>b)
            {
                printf("%d", i-1);
            }
        }
    }
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define rv(s) reverse(s.begin(),s.end());
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  ll l,r;cin>>l>>r;
  int mod=2019;
  ll ans=2018;
  for(ll i=l;i<r;i++){
    for(ll j=i+1;j<=r;j++){
      int tmp=i*j%mod;
      if(ans>tmp)ans=tmp;
      if(ans==0){
        cout(0);return 0;
      }
    }
  }
  cout(ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

int main(void) {
  int n, y;
  cin >> n >> y;

  for(int i = 0; i <= n; i++) {
    for(int j = 0; j <= n - i; j++) {
      if(y == 10000 * i + 5000 * j + 1000 * (n - i - j)) {
	cout << i << ' ' << j << ' ' << (n - i - j) << endl;
	return 0;
      }
    }
  }

  cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int N,time=0;
    cin>>N;
    char A[N];
    for(int i=0;i<N;i++)
        cin>>A[i];
    for(int i=0;i<N;i++)
    {
    if(A[i]=='A'&&A[i+1]=='B'&&A[i+2]=='C')
        time=time+1;
    }
    cout<<time;
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int flag = 1;
    for(int i = 0; i < s.length(); i++){
        if((i+1) % 2 == 0){
            if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D'){
                //continue;
            }else{
                flag = 0;
                break;
            }
        }
        else{
            if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D'){
                //continue;
            }else{
                flag = 0;
                break;
            }
        }
    }
    if(flag == 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;

    }
}

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

double p[2999], dp[3000][3000] = {};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    for (int i=0; i<n; i++)
        cin >> p[i];

    dp[0][0] = 1;
    for (int i=0; i<n; i++)
        for (int j=0; j<n; j++) {
            dp[i+1][j] += dp[i][j] * (1 - p[i]);
            dp[i+1][j+1] += dp[i][j] * p[i];
        }

    double ret = 0;
    for (int j=0; j<=n; j++)
        if (j > n - j)
            ret += dp[n][j];

    cout << fixed << setprecision(10) << ret << "\n";

    return 0;
}


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

int main()
{
    set<int>l;
    int64_t a,b,k;
    cin>>a>>b>>k;
   if(k>=abs(a-b)) {
    for(int i=a;i<=b;i++)
        cout<<i<<endl;
   }
  else
    {
        for(int i=a;i<a+k;i++)
        l.insert(i);
    for(int i=b;i>b-k;i--)
        l.insert(i);
    set<int> :: iterator it=l.begin();
    for(it=l.begin();it!=l.end();it++)
        cout<<*it<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;
const int maxn = 85;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int a[maxn][maxn],b[maxn][maxn],c[maxn][maxn];
bool dp[2][maxn][maxn*maxn*2];
//vector<int> dp[maxn][maxn];
int main(){
	n=read();m=read();
	for(register int i=1;i<=n;i++)
		for(register int j=1;j<=m;j++)
			a[i][j]=read();
	for(register int i=1;i<=n;i++)
		for(register int j=1;j<=m;j++)
			b[i][j]=read();
	for(register int i=1;i<=n;i++)
		for(register int j=1;j<=m;j++)
			c[i][j]=abs(a[i][j]-b[i][j]);
	int w=6400;
	dp[0][1][w+c[1][1]]=dp[0][1][w-c[1][1]]=1;
	for(register int len=3;len<=n+m;len++){
		int flag=len&1;
		memset(dp[flag],0,sizeof(dp[flag]));
		for(register int i=1;i<=min(len-1,n);i++){
			int j=len-i;
			for(register int k=-6400;k<=6400;k++){
				if(i!=1){
					if(dp[flag^1][i-1][w+k+c[i][j]]){dp[flag][i][w+k]=1;}
					else if(dp[flag^1][i-1][w+k-c[i][j]]){dp[flag][i][w+k]=1;}
				}
				if(j!=1){
					if(dp[flag^1][i][w+k+c[i][j]]){dp[flag][i][w+k]=1;}
					else if(dp[flag^1][i][w+k-c[i][j]]){dp[flag][i][w+k]=1;}
				}
			}
		}
	}
	int flag=(n+m)&1;
	for(register int i=0;i<=6400;i++){
		if(dp[flag][n][w+i] || dp[flag][n][w-i]){printf("%d\n",i);return 0;}
	}
	/*dp[1][1].push_back(c[1][1]);
	dp[1][1].push_back(-c[1][1]);
	for(register int i=1;i<=n;i++){
		for(register int j=1;j<=m;j++){
			sort(dp[i][j].begin(),dp[i][j].end());
			int len=dp[i][j].size();
			for(register int k=0;k<len;k++){
				if(k && dp[i][j][k]==dp[i][j][k-1])continue;
				int x=dp[i][j][k];
				if(j<m)dp[i][j+1].push_back(x-c[i][j+1]);
				if(j<m)dp[i][j+1].push_back(x+c[i][j+1]);
				if(i<n)dp[i+1][j].push_back(x-c[i+1][j]);
				if(i<n)dp[i+1][j].push_back(x+c[i+1][j]);
			}
			if(i==n && j==m)continue;
			dp[i][j].clear();
		}
	}
	int ans=10000,len=dp[n][m].size();
	for(register int i=0;i<len;i++){
		ans=min(ans,abs(dp[n][m][i]));
	}
	printf("%d\n",ans);*/
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<double,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

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;}

struct edge{ll to;double cost;};
struct graph{
	ll V;
	vector<vector<edge>> G; //隣接リスト
	vector<double> d; //最短距離

	graph(ll n){
		init(n);
	}

	void init(ll n){
		V=n+2; //1-origin
		G.resize(V);
		d.resize(V);
		rep1(i,V-1) d[i]=INF;
	}

	void add_edge(ll from,ll to,double cost){
		edge e;
		e.to=to;
		e.cost=cost;
		G[from].pb(e);
	}

	void dijkstra(ll s){//O(E*log|V|)
		rep(i,V) d[i]=INF;
		d[s]=0;
		priority_queue<P,vector<P>,greater<P>> que;

		que.push(P(0.0,s));//P.a:最短距離 P.b:頂点の番号

		while(!que.empty()){
			P p=que.top(); que.pop();
			ll v=p.b;//頂点番号
			if(d[v]<p.a) continue;
			rep(i,sz(G[v])){
				edge e=G[v][i];
				if(d[e.to]>d[v]+e.cost){
					d[e.to]=d[v]+e.cost;
					que.push(P(d[e.to],e.to));
				}
			}
		}
	}
};

int main(){
	//input
	ll xs,ys,xg,yg,N; cin>>xs>>ys>>xg>>yg>>N;
	graph g(N);
	vector<ll> x(N+2);
	vector<ll> y(N+2);
	vector<ll> r(N+2);
	x[0]=xs; y[0]=ys; r[0]=0;
	x[N+1]=xg; y[N+1]=yg; r[N+1]=0;
	rep1(i,N) cin>>x[i]>>y[i]>>r[i];
	rep(i,N+1){
		FOR(j,i+1,N+2){
			g.add_edge(i,j,max(0.0,sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j]));
			g.add_edge(j,i,max(0.0,sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j]));
		}
	}
	g.dijkstra(0);
	printf("%.12f\n",g.d[N+1]);
}

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

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

int main(){
	long long a,b,c;
	cin>>a>>b;
	if(a>b){
		c=gcd(a,b);
		cout<<(a*b)/c<<endl;
	}else{
		c=gcd(b,a);
		cout<<(a*b)/c<<endl;
	}
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  if(k==0){
    cout << n*n << endl;
    return 0;
  }
  for(int b=1; b<=n; b++){
    ll p = n / b;
    ll q = n % b;
    ans += p * max(0LL, b-k);
    ans += max(0LL, q-k+1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
X = 50000
R = 1.08

def main(argv)
  n = gets.chomp.to_i

  ans = nil
  (1..X).each do |x|
    ans = x if (x.to_f * R).floor == n
  end

  if ans == nil then
    puts ':('
  else
    puts ans.to_s
  end
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 3836
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
//#define int long long
using namespace std;
const int N=20;
int n,m,c,p[N],a[N][N],tmp[N],res=1e9;
signed main(){
	cin>>n>>m>>c;
	for(int i=0;i<n;i++){
		cin>>p[i];
		for(int j=1;j<=m;j++)	cin>>a[i][j];
	}
	for(int s=0;s<(1<<n);s++){
		int t=0,ok=1;
		memset(tmp,0,sizeof tmp);
		for(int i=0;i<n;i++)	if(s>>i&1){
			for(int j=1;j<=m;j++)	tmp[j]+=a[i][j];
			t+=p[i];
		}
		for(int i=1;i<=m;i++)	if(tmp[i]<c)	ok=0;
		if(!ok)	continue;
		res=min(res,t);
	}
	if(res==1e9)	res=-1;
	cout<<res;
	return 0;
}


Measured memory_bytes: 3640