akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cassert>
#include <bitset>
#include <fstream>
#include <cstring>
#include <stack>

using namespace std;

#define fst first
#define snd second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define ld long double

const ld pi = acos(-1);

template<typename T>
T abs(T x) {
    return x > 0 ? x : -x;
}

template<typename T>
T sqr(T x) {
    return x * x;
}

template<typename T>
ostream& operator << (ostream &s, const vector<T> &x) {
    s << "[";
    for (auto it : x) {
        s << it << ", ";
    }
    s << "]";
    return s;
}

template<typename T>
ostream& operator << (ostream &s, const set<T> &x) {
    s << "{";
    for (auto it : x) {
        s << it << ", ";
    }
    s << "}";
    return s;
}


template<typename U, typename V>
ostream& operator << (ostream &s, const pair<U, V> &x) {
    s << "(" << x.fst << ", " << x.snd << ")";
    return s;
}

template<typename T>
bool chmax(T &x, const T &y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T &x, const T &y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}

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


int main() {
    srand(time(NULL));
    retry:
#ifdef LOCAL
    freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#else
    //freopen("sum.in", "r", stdin);
	//freopen("sum.out", "w", stdout);
#endif

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



    if ((a % 2) == 0 || (b % 2) == 0 || (c % 2) == 0) {
        cout << 0 << endl;
    } else {
        cout << min(a * b, min(b * c, a * c)) << endl;
    }



    return 0;
}





Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <vector>
#include <iostream>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main() {
    int n, m;
    cin >> n >> m;
    int x = 1900*m + 100*(n-m);
    int p = 1;
    rep(i, m) p *= 2;

    cout << x * p << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]

sl = [0 for i in range(n+1)]
sr = [0 for i in range(n+1)]
ans = []

for i in range(1, n+1):
  sl[i] = sl[i-1] ^ a[i-1]
  sr[n-i] = sr[n-i+1] ^ a[n-i]

for i in range(n):
  ans.append(str(sl[i] ^ sr[i+1]))
  
print(" ".join(ans))

Measured memory_bytes: 50660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

void printAns(int row, int column)
{
  vector<vector<int>> ans(row);
  int offset = 0;
  int c = 1;
  rep(i, row - 1)
  {
    rep(j, row - 1 - offset)
    {
      ans[offset].push_back(c);
      ans[offset + j + 1].push_back(c);
      c++;
    }
    offset++;
  }

  cout << row << endl;
  rep(i, row)
  {
    cout << ans[i].size() << " ";
    rep(j, ans[i].size())
    {
      cout << ans[i][j];
      if (j != ans[i].size() - 1)
        cout << " ";
    }
    cout << endl;
  }
}

int main()
{
  int N;
  cin >> N;
  rep(k, 1000)
  {
    if (k * (k + 1) / 2 == N)
    {
      cout << "Yes" << endl;
      printAns(k + 1, N);

      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 2304
package main

import (
    "fmt"
)

func main() {
    var n, m int 
    fmt.Scan(&n, &m) 
    am := make(map[int]bool)
    for i := 0; i < m; i++ {
        var a int 
        fmt.Scan(&a)
        am[a] = true
    }   

    // dp[n] = n本で作れる最大の数字
    dp := make([][]int, n+1)
    for i := 1; i <= n; i++ {
        if i >= 2 { 
            if b, ok := am[1]; ok && b { 
                dp[i] = max(dp[i], dp[i-2], 1, i-2)
            }   
        }   
        if i >= 5 { 
            if b, ok := am[2]; ok && b { 
                dp[i] = max(dp[i], dp[i-5], 2, i-5)
            }   
        }   
        if i >= 5 { 
            if b, ok := am[3]; ok && b { 
                dp[i] = max(dp[i], dp[i-5], 3, i-5)
            }   
        }   
        if i >= 5 { 
            if b, ok := am[5]; ok && b { 
                dp[i] = max(dp[i], dp[i-5], 5, i-5)
            }   
        }   
        if i >= 4 { 
            if b, ok := am[4]; ok && b { 
                dp[i] = max(dp[i], dp[i-4], 4, i-4)
            }   
        }   
        if i >= 6 { 
            if b, ok := am[6]; ok && b { 
                dp[i] = max(dp[i], dp[i-6], 6, i-6)
            }   
        }   
        if i >= 6 { 
            if b, ok := am[9]; ok && b { 
                dp[i] = max(dp[i], dp[i-6], 9, i-6)
            }   
        }   
        if i >= 3 { 
            if b, ok := am[7]; ok && b { 
                dp[i] = max(dp[i], dp[i-3], 7, i-3)
            }   
        }   
        if i >= 7 { 
            if b, ok := am[8]; ok && b { 
                dp[i] = max(dp[i], dp[i-7], 8, i-7)
            }   
        }   
        //fmt.Println(i, dp[i])
    }   
    for i := range dp[n] {
        fmt.Print(dp[n][i])
    }   
    fmt.Println("")
}

func max(dst, src []int, num, bi int) []int {
    if bi != 0 && len(src) == 0 { 
        return dst 
    }   

    if big(dst, src, num) {
        ns := make([]int, len(src)+1)
        for i := range src {
            ns[i] = src[i]
        }   
        ns[len(ns)-1] = num 
        return ns
    } else {
        return dst 
    }   
}

// src+num > dst
func big(dst, src []int, num int) bool {
    //fmt.Println(dst, src, num)
    if len(src)+1 == len(dst) {
        for i := range src {
            if src[i] != dst[i] {
                return src[i] > dst[i]
            }   
        }   
        if num > dst[len(dst)-1] {
            return true
        }   
        return false
    }   
    return len(src)+1 > len(dst)
}

func nume(s []int) int {
    var sum int 
    for i := range s { 
        sum *= 10
        sum += s[i]
    }   
    return sum 
}


Measured memory_bytes: 398704
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		
		HashMap<Character, HashSet<String>> map = new HashMap<Character, HashSet<String>>();
		for(char ch = 'a'; ch <= 'z'; ch++){
			map.put(ch, new HashSet<String>());
		}
		
		for(char first = 'a'; first <= 'z'; first++){
			map.get(first).add(first + "" + 'a');
			
			for(char second = 'a'; second <= 'z'; second++){
				map.get(first).add(first + "" + second + "" + 'a');
			}
		}
		
		//System.out.println(set);
		
		boolean first = true;
		String input  = "";
		String output = "";
		HashSet<String> set = new HashSet<String>();
		LinkedList<String> list = new LinkedList<String>();
		while(true){
			if(first){
				input = "aa";
				map.get('a').remove("aa");
				first = false;
			}else{
				char[] out = output.toCharArray();
				
				char[] prev_in = input.toCharArray();
				
				if(out[0] != prev_in[prev_in.length - 1]){
					System.out.println("!OUT");
					System.out.flush();
					return;
				}else if(set.contains(output)){
					System.out.println("!OUT");
					System.out.flush();
					return;
				}
				set.add(output);
				map.get(out[out.length - 1]).remove(output);
				
				for(String str : map.get(out[out.length - 1])){
					input = str;
					break;
				}
				
				map.get(out[out.length - 1]).remove(input);
			}
			
			list.add(input);
			
			System.out.println("?" + input);
			System.out.flush();
			set.add(input);
			try{
				output = sc.next();
				list.add(output);
			}catch(Exception e){
				System.err.println(list);
				//System.err.println(input + " " + output);
			}
		}
		
	}

}

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

long long dp[5010][5010];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; long long a, b; cin >> n >> a >> b;
    vector<int> p(n, 0), rem(n+1, 1);
    for (int i = 0; i < n; i++) cin >> p[i];
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            dp[i][j] = 1e16;
        }
    }
    dp[0][0] = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            // dp[i][j]
            if (i < n && p[i] == j+1) dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j]);
            else {
                dp[i][j+1] = min(dp[i][j+1], dp[i][j] + b * rem[j+1]);
                dp[i+1][j] = min(dp[i+1][j], dp[i][j] + a * (i < n && p[i] > j));
            }
            //cout << i << " " << j << " -> " << dp[i][j] << "\n";
        }
        rem[p[i]]--;
    }
    long long ans = 1e16;
    for (int i = 0; i <= n; i++) {
        ans = min(ans, dp[i][n]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 196096
import math

def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y)

n, x = map(int,input().split())
li_x = list(map(int,input().split()))

for i in range(len(li_x)):
  if li_x[i] - x < 0:
    li_x[i] =x - li_x[i]
  else:
    li_x[i] = li_x[i] -x

if len(li_x)==1:
  print(li_x[0])

elif len(li_x)==2:
  print(gcd(li_x[0],li_x[1]))

else:
  g =gcd(li_x[0],li_x[1])
  k=2
  while k<len(li_x):
    g=gcd(g,li_x[k])
    k+=1
  print(g)




Measured memory_bytes: 15020
use std::cmp::{max, min};

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_owned()
}

fn reads<T>() -> Vec<T>
where
    T: std::str::FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    read_line()
        .split_whitespace()
        .map(|w| w.parse().unwrap())
        .collect()
}

fn main() {
    let n: usize = reads()[0];
    let a: Vec<i64> = reads();

    let (odd, odd_cnt, even, even_cnt) = {
        let mut odd = 0;
        let mut even = 0;
        let mut odd_cnt = 0;
        let mut even_cnt = 0;
        for i in 0..n {
            if i % 2 == 0 {
                even += max(0, a[i]);
                if a[i] > 0 {
                    even_cnt += 1;
                }
            } else {
                odd += max(0, a[i]);
                if a[i] > 0 {
                    odd_cnt += 1;
                }
            }
        }
        (odd, odd_cnt, even, even_cnt)
    };

    if even_cnt + odd_cnt == 0 {
        let m: i64 = *a.iter().max().unwrap();
        let mi = a.iter().position(|e| *e == m).unwrap();
        println!("{}", m);
        println!("{}", n - 1);
        for _ in 0..mi {
            println!("1");
        }
        for i in mi + 1..n {
            println!("{}", n - i + 1);
        }
        return;
    }

    let best = max(odd, even);
    let mut seq = vec![];

    let mut l = if (odd, odd_cnt) > (even, even_cnt) {
        seq.push(0);
        1
    } else {
        0
    };
    let mut r = n - 1;

    while a[l] < 0 {
        seq.push(0);
        seq.push(0);
        l += 2;
    }

    while l < r && ((r - l) % 2 != 0 || a[r] < 0) {
        seq.push(r - l);
        r -= 1;
    }

    assert!(l <= r);
    assert!((r - l) % 2 == 0);

    while l < r {
        if a[l + 2] >= 0 {
            seq.push(1);
            l += 2;
        } else {
            assert!(r - l >= 4);
            seq.push(2);
            l += 2
        }
    }

    println!("{}", best);
    println!("{}", seq.len());
    for s in seq {
        println!("{}", s + 1);
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(void){
    int i,h1=0,h2=0,h3=0,work,input;
    for(i=1;i<=10;i++){
        scanf("%d",&input);
        if(h3<input){
            h3=input;
        }
        if(h2<h3){
            work=h2;
            h2=h3;
            h3=work;
        }
        if(h1<h2){
            work=h1;
            h1=h2;
            h2=work;
        }

    }
    printf("%d\n%d\n%d\n",h1,h2,h3);

return 0;
}

Measured memory_bytes: 600
# 累積和
# PyPy なら通る
N, M, Q = map(int, input().split())

t = [[0] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
    L, R = map(int, input().split())
    t[L][R] += 1

for i in range(N + 1):
    for j in range(N):
        t[i][j + 1] += t[i][j]

result = []
for _ in range(Q):
    p, q = map(int, input().split())
    result.append(sum(t[i][q] - t[i][i - 1] for i in range(p, q + 1)))
print('\n'.join(str(v) for v in result))
#print(*result, sep='\n')


Measured memory_bytes: 95884
// Problem : D - Teleporter
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 1e18

#define MAX 200005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void solve(lli the)
{
	char ch;
	db aa,bb,cc,dd,xx;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,d,n,m,l,r,x,y,z,low,high,mid,sum=0,ans=0,temp,t;
    cin >> n >> k;
    lli arr[n+1];
    rep(i,1,n+1)	cin >> arr[i];
    a=1;vector<lli>v,vv;v.pb(a);
    set<lli>se;se.insert(a);
    t=min(MAX,n);
    while(t--){
    	v.pb(arr[a]);se.insert(a);
    	a=arr[a];
    	if(se.count(a)==1)	break;
    }
    b=v[v.size()-1];
    for(i=0;i<v.size();i++){
    	if(v[i]==b)	break;
    }
    if(i!=0){
    	if(k<=i){
    		cout<<v[k];return;
    	}
    }
    vv.pb(b);k-=(i);
    for(j=i+1;j<v.size()-1;j++){
    	if(v[j]==b)	break;
    	vv.pb(v[j]);
    }
    //for(i=0;i<vv.size();i++)	cout<<vv[i]<< " ";
    b=vv.size();k%=b;cout<<vv[k];
    
    
}













int main()
{
	long long int t=1,c=1;
	//scanf("%lld",&t);
	while(t--){
		solve(c);
		c++;
	}
	return 0;
}
/* UJJWAL KESHRI */

Measured memory_bytes: 16632
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
	
		Scanner scanner = new Scanner(System.in);

		int a = Integer.parseInt(scanner.next());
		int b = Integer.parseInt(scanner.next());
		int c = Integer.parseInt(scanner.next());

		if ( a < b ){
			int tmp = a;
			a = b;
			b = tmp;
		}else if ( a < c ){
			int tmp = a;
			a = c;
			c = tmp;
		}
		int total = (a * 10) + b + c;
		System.out.println(total);
	}
}

Measured memory_bytes: 23892
from collections import Counter, defaultdict, deque
import bisect
from sys import stdin, stdout
from itertools import repeat
import math
import random

# sys.stdin = open('input')

def inp():
    re = map(int, raw_input().split())
    if len(re) == 1:
        return re[0]
    return re

def inst():
    return raw_input().strip()

def gcd(x, y):
   while(y):
       x, y = y, x % y
   return x

def get(n, da):
    mx = 0
    for i in range(n):
        if i%2==1:
            mx += da[i]
    st = [0 for i in range(n)]
    dp = [0 for i in range(n)]
    st[0]=1
    dp[0]=da[0]
    for i in range(2,n):
        if i%2==0:
            st[i]=1
            dp[i]=dp[i-2]+da[i]
        else:
            st[i]=1
            dp[i] = dp[i-3]+da[i]
            if st[i-2]:
                dp[i] = max(dp[i], dp[i-2]+da[i])
    return max(mx, max(dp[n-1], dp[n-2]))

def my_main():
    n = inp()
    da = inp()
    if n%2==0:
        print get(n, da)
    else:
        nda = [da[i] for i in range(n) if i%2==0]
        mx = sum(nda) - min(nda)
        mx = max(mx, max(get(n-1, da[1:]), get(n-1, da[:-1])))
        st = [[0 for i in range(n)]for i in range(3)]
        dp = [[0 for i in range(n)]for i in range(3)]
        st[0][0]=1
        dp[0][0]=da[0]
        for i in range(2,n):
            if st[0][i-2]:
                st[0][i] = 1
                dp[0][i] = dp[0][i-2] + da[i]
            if i-3 >= 0 and st[0][i-3]:
                st[1][i] = 1
                dp[1][i] = dp[0][i-3] + da[i]
            if st[1][i-2]:
                st[1][i] = 1
                dp[1][i] = max(dp[1][i], dp[1][i-2] + da[i])
            if i-3>=0 and st[1][i-3]:
                st[2][i] = 1
                dp[2][i] = dp[1][i-3] + da[i]
            if st[2][i-2]:
                if st[2][i]:
                    dp[2][i] = max(dp[2][i], dp[2][i-2]+da[i])
                else:
                    st[2][i] = 1
                    dp[2][i] = dp[2][i-2]+da[i]
        print max(mx, dp[2][n-1])







my_main()


Measured memory_bytes: 116208
#include<cstdio>
#include<vector>
#include<set>

using namespace std;


typedef vector<vector<int> > graph_t;


void dfs(int u, int previous, 
      const graph_t& g, int &timer, vector<bool>& visited, 
      vector<int>& parent, vector<int>& prenum, vector<int>& lowest) {
  prenum[u] = lowest[u] = timer;
  timer++;

  visited[u] = true;

  for (size_t i = 0; i < g[u].size(); ++i) {
    int next = g[u][i];
    if (!visited[next]) {
      parent[next] = u;

      dfs(next, u, g, timer, visited, parent, prenum, lowest);

      lowest[u] = min(lowest[u], lowest[next]);
    }
    else if (next != previous) {
      lowest[u] = min(lowest[u], prenum[next]);
    }
  }
}

void solve(int n, int k) {
  graph_t g(n);

  for (int i = 0; i < k; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }

  vector<bool> visited(n, false);
  vector<int> prenum(n, -1), lowest(n, -1), parent(n, -1);
  int timer = 1;
  dfs(0, -1, g, timer, visited, parent, prenum, lowest);

  set<int> ap;
  int np = 0;
  for (int i = 1; i < n; ++i) {
    int p = parent[i];
    if (p == 0) np++;
    else if (prenum[p] <= lowest[i]) ap.insert(p);
  }
  if (np > 1) ap.insert(0);
  for (set<int>::iterator iter = ap.begin(); iter != ap.end(); ++iter)
    printf("%d\n", *iter);
}

int main() {

  int n, k;
  scanf("%d %d", &n, &k);

  solve(n, k);
  return 0;
}



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

using namespace std;
typedef long long ll;

ll N,M,Q;
ll c[600][600];
ll p[100000];
ll q[100000];

int main(){
    cin >> N >> M >> Q;
    for(int i=0;i<=N+1;i++){
        for(int j=0;j<=N+1;j++){
            c[i][j] = 0;
        }
    }
    for(int i=0;i<M;i++){
        ll a,b;
        cin >> a >> b;
        c[a][b]++;
    }
    for(int i=0;i<Q;i++) cin >> p[i] >> q[i];
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            c[i][j] += c[i][j-1] + c[i-1][j] - c[i-1][j-1];
        }
    }
    for(int i=0;i<Q;i++){
        cout << c[q[i]][q[i]] - c[q[i]][p[i]-1] - c[p[i]-1][q[i]] + c[p[i]-1][p[i]-1] << endl;;
    }
    return 0;
}

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

typedef long long ll;


int main() {
int N, M;   cin >> N >> M;
vector<pair<ll, ll>> drinks(N);
for (int i = 0; i < N; i++) {
    cin >> drinks[i].first >> drinks[i].second;
}

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

ll to_buy = M, cost = 0, buy;
int i = 0;
while (to_buy > 0) {
    buy = min(drinks[i].second, to_buy);
    to_buy -= buy;
    cost += drinks[i].first * buy;
    i++;
}

cout << cost << endl;

}

Measured memory_bytes: 1792
import sys
n=int(input())+1
e=list(map(lambda x:x.split(),sys.stdin))
p=[int(e[0][0])]+list(int(x[1])for x in e)
m=[[0]*n for _ in[0]*n]
for l in range(2,n):
 for i in range(1,n-l+1):
  j=i+l-1;m[i][j]=1e6
  for k in range(i,j):m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j])
print(m[1][n-1])


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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(int i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const ll powll = 1LL<<1;

int main(void){
    int n,t; cin >> n >> t;
    int ans = MOD;
    rep(i,0,n){
        int c,tt; cin >> c >> tt;
        if(tt <= t){
            ans = min(ans,c);
        }
    }
    if(ans == MOD) cout << "TLE\n";
    else cout << ans << "\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define MAX_LEN 300000

int data[MAX_LEN];
int ndata;

long long solve()
{
  long long result = 0;
  int last = 0;
  int sum = 0;
  for(int first = 0; first < ndata; first++) {
    for(; last < ndata; last++) {
      if((sum ^ data[last]) != sum + data[last]) {
        break;
      }
      sum += data[last];
      result += last-first+1;
    }
    sum -= data[first];
  }
  return result;
}

int main()
{
  scanf("%d", &ndata);
  for(int i = 0; i < ndata; i++) {
    scanf("%d", &data[i]);
  }
  printf("%lld\n", solve());
  return 0;
}


Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}

int vector_finder(std::vector<int> vec, int number) {//https://qiita.com/wonder_zone/items/51fb5c3a773b98aa130c
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
int main(){//
    
    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    for(int i=0; i<N; i++) cin >> p[i];
    sort(p.begin(), p.end());

    //int ans = 0;
    // auto iter = lower_bound(p.begin(), p.end(), X);
    // auto index = iter - p.begin();

    // for(int i=)

    int i=0;
    while(true){
        bool a = vector_finder(p, X-i);
        bool b = vector_finder(p, X+i);

        if( a == 0){
            cout << X-i << endl;
            return 0;
        }
        if( b == 0){
            cout << X+i << endl;
            return 0;
        }
        i++;
    }

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	ll a,b,k;
	cin>>a>>b>>k;
	ll d=min(a,k);
	a-=d;
	k-=d;
	b-=min(k,b);
	cout<<a<<" "<<b<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define MAX_R 50
#define MAX_N 50

using namespace std;
void solve();

int c[MAX_R],p[MAX_R],n,r;

int main()
{
    while (1) {
        cin>>n>>r;
        if (n==0&&r==0) break;
        for (int i=0; i<r; i++) cin>>p[i]>>c[i];
        solve();
    }
}

void solve()
{
    int card[MAX_N];
    for (int i=n-1; i>=0; i--) card[i]=n-i;
    for (int i=0; i<r; i++) {
        int cut[MAX_N];
        for (int j=0; j<c[i]; j++) cut[j]=card[p[i]+j-1];
        for (int j=p[i]-2; j>=0; j--) card[j+c[i]]=card[j];
        for (int j=0; j<c[i]; j++) card[j]=cut[j];
    }
    cout<<card[0]<<endl;
}

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

int main(){
  string n;
  cin>>n;
  if(n[0]=='7'||n[1]=='7'||n[2]=='7') cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3612
//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)

using namespace std;

const ll sz=1e5+5;
const ll szz=1e6+6;
const ll mod=1e9+7;

int main()
{
	Ryuga;

	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("op.txt","w",stdout);
	#endif

	clock_t startTime=clock();

	ll a,b,n;
	cin>>a>>b>>n;
	ll val1=(a*(b-1))/b;
	ll val2=(a*n)/b;
	cout<<min(val1,val2);

	cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;

}//Goodbye...

Measured memory_bytes: 3796
N, X = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
x.append(X)
D = abs(X-x[0])
x.sort()
for ni in range(N):
    dif = x[ni+1] - x[ni]
    if dif >= D:
        a = dif
        b = D
        r = 1
        while r != 0:
            r = a % b
            a = b
            b = r
        D = a
    else:
        a = D
        b = dif
        r = 1
        while r != 0:
            r = a % b
            a = b
            b = r
        D = a
print(D)

Measured memory_bytes: 14224
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long unsigned int ll;

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

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


int main() {

  int x, a;
  cin >> x >> a;
  int ans =  x < a ? 0 : 10;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int a[4][4];
    for(int i=1;i<=3;i++)
        for(int j=1;j<=3;j++)
            cin>>a[i][j];
    int mm[105]={0};
    int x;
    int n;
    cin>>n;

    for(int i=0;i<n;i++){
        cin>>x;
        mm[x]=1;
    }
    for(int i=1;i<=3;i++)
    {
        x=0;
        for(int j=1;j<=3;j++)
        {
            x+=mm[a[i][j]];
        }
        if(x==3)
        {
            cout<<"Yes";
            return 0;
        }
    }
    for(int i=1;i<=3;i++)
    {
        x=0;
        for(int j=1;j<=3;j++)
        {
            x+=mm[a[j][i]];
        }
        if(x==3)
        {
            cout<<"Yes";
            return 0;
        }
    }
    x=0;
    x=mm[a[1][1]]+mm[a[2][2]]+mm[a[3][3]];
    if(x==3)
    {
        cout<<"Yes";
        return 0;
    }
    x=0;
    x=mm[a[1][3]]+mm[a[2][2]]+mm[a[3][1]];
    if(x==3)
    {
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
    

} 



Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			
			if(h == 0 && w == 0) {
				break;
			}else {
				for(int i1 = 0; i1 < h; i1++) {
					for(int i2 = 0; i2 < w; i2++) {
						if((i1+i2) % 2 == 0) {
							System.out.print("#");
						}else {
							System.out.print(".");
						}
					}
					System.out.println();
				}
				
				System.out.println();
			}
		}
	}
}



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

namespace AtCoder._20190209みんプロ
{
    class C
    {
        List<int> Convert(IEnumerable<string> str)
        {
            var res = new List<int>();
            foreach (var i in str)
            {
                var data = int.Parse(i);
                res.Add(data);
            }
            return res;
        }

        public void solve()
        {
            string input;
            while ((input = Console.ReadLine()) != null)
            {
                var data = Convert(input.Split(' '));
                var result = ANS(data[0], data[1], data[2]);
                Console.WriteLine(result);
            }
        }


        public long ANS(long k, long a, long b)
        {
            long res = 1;
            long diff = b - a;
            if (diff < 2)
            {
                res += k;
                return res;
            }

            for (int i = 0; i < k; i++)
            {
                if (res < a)
                {
                    res++;
                }
                else if (i == k - 1)
                {
                    res++;
                }
                else
                {
                    res += diff;
                    i++;
                }
            }

            return res;

        }


        static void Main(string[] args)
        {
            new C().solve();
        }
    }
}


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

#define ll long long int
#define mod 1000000007

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;


int main()
{  
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n;
    cin>>n;
    vector<pair<ll,ll>> v(n);
    for(int i=0;i<n;i++){
		cin>>v[i].first;
		v[i].second=i;
	}
	sort(v.begin(),v.end());
	vector<vector<ll>> dp(n,vector<ll>(n));
	
	for(int i=n-1;i>=0;i--){
		for(int j=i;j<n;j++){
			ll pos=j-i;
			if(i==j){
				dp[i][j]=v[pos].first * abs(i - v[pos].second);
				continue;
			}
			dp[i][j]=max(v[pos].first * abs(i - v[pos].second) + dp[i+1][j] ,
			              v[pos].first * abs(j - v[pos].second) + dp[i][j-1] );
		}
	}
    cout<<dp[0][n-1]<<"\n";
}



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

int main() {
  long long N, A, B;
  cin >> N >> A >> B;
  if ((max(A, B) - min(A, B)) % 2 == 0) {
    cout << (max(A, B) - min(A, B)) / 2;
  }
  else {
    long long a, b;
    a = (max(A, B) + min(A, B) - 1) / 2;
    b = (N - max(A, B) + 1 - min(A, B) + N) / 2;
    cout << (a > b ? b: a);
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

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

void solve(istream& cin, ostream& cout) {
  int x;
  cin >> x;
  int min_num = INF;
  if (x <= 3) {
    cout << 1 << endl;
    return;
  }
  FOR(b, 2, int(sqrt(x))) {
    FOR(p, 2, 9) {
      int now = pow(b, p);
      if (now > x) break;
      if (x - now < min_num) min_num = x - now;
    }
  }
  cout << x - min_num << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3916
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val n = sc.nextInt()
    val k = sc.nextInt()
    val p = Array(n) { sc.nextInt() }
    val s = Array(n + 1) { 0 }
    for (i in 0 until n) s[i + 1] = s[i] + (p[i] + 1)

    var best = 0
    for (i in 0..n - k){
        val ans = s[i+k] - s[i]
        if(best < ans) best = ans
    }

    println(best.toDouble() / 2)
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


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

int main(){
  int N,M; cin>>N>>M;
  int a[50],b[50],c[50];
  for(int i=1;i<=M;i++){
    cin>>a[i]>>b[i];
  }
  for(int i=1;i<=N;i++){
    int sum=0;
    for(int j=1;j<=M;j++){
      if(a[j]==i){
        sum++;
      }
      if(b[j]==i){
        sum++;
      }
      c[i]=sum;
    }
  }
  for(int i=1;i<=N;i++)
    cout<<c[i]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

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

    int r;
    cin >> r;
    if(r < 1200){
        cout << "ABC" << endl;
    }else if(r < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int flag,temp,sumn,summ,i,j,n,m,ren,rem,nc[101],mc[101];
  while(1){
    sumn=0;
    summ=0;
    ren=100;
    rem=100;
    flag=0;
    scanf("%d%d",&n,&m);
    if(n==0&&m==0) break;

    for(i=1;i<=n;i++){
      scanf("%d",&nc[i]);
      sumn+=nc[i];
    }
    for(i=1;i<=m;i++){
      scanf("%d",&mc[i]);
      summ+=mc[i];
    }
    
    for(i=1;i<=n;i++){
      for(j=1;j<=m;j++){
	if(sumn-nc[i]+mc[j]==summ-mc[j]+nc[i]&&nc[i]+mc[j]<ren+rem){    
          ren=nc[i];
          rem=mc[j];
	  temp=nc[i];
	  nc[i]=mc[j];
	  mc[j]=temp;
	  flag=1;
	}
      }
    }

    if(flag==1) printf("%d %d\n",ren,rem);
    else printf("-1\n");

  }

  return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);
const int MAXN = 107;
const int MAXW = 1e5 + 7;

using namespace std;

vector<int> W(MAXN), V(MAXN);
int n, w;

vector<vector<long long>> dp(MAXW, vector<long long>(MAXN + 1, 0));
long long top_down(int cw, int i) {
    if (i == n) return 0;
    long long &cdp = dp[cw][i];
    if (cdp != 0) return cdp;
    long long ans1 = 0, ans2 = 0;
    if (i < n && W[i] <= cw) ans1 = V[i] + top_down(cw-W[i], i + 1);
    ans2 = top_down(cw, i + 1);
    cdp = max(ans1, ans2);
    return cdp;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> w;
    W.resize(n); V.resize(n);
    for (int i = 0; i < n; ++i) cin >> W[i] >> V[i];
    cout << top_down(w, 0) << '\n';
    return 0;
}



Measured memory_bytes: 91504
#include<iostream>
#include<cmath>
using namespace std;
double x,y,dx,dy,L;
double ansx[1001];
double ansy[1001];
int n;
int main(){
  ansx[1]=1.0;
  ansy[1]=0.0;
  
  for(int i=2;i<1001;i++){
    x=ansx[i-1];
    y=ansy[i-1];

    dx=x*cos(M_PI/2)-y*sin(M_PI/2);
    dy=x*sin(M_PI/2)+y*cos(M_PI/2);
    
    L=sqrt(dx*dx+dy*dy);
    
    ansx[i]=dx/L+ansx[i-1];
    ansy[i]=dy/L+ansy[i-1];
  }
  while(cin>>n){
    if(n==-1)break;
    cout<<ansx[n]<<endl<<ansy[n]<<endl;
    
  }
  return 0;
}

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

int main(){
	int n;
	cin>>n;
	int a[n];
	bool flg[9];
	int ans1=0,ans2=0,cnt=0;
	for(int i=0;i<9;i++) flg[i]=false;
	for(int i=0;i<n;i++){
	    cin>>a[i];
	    if(a[i]<=399) flg[0]=true;
	    else if(a[i]<=799) flg[1]=true;
	    else if(a[i]<=1199) flg[2]=true;
	    else if(a[i]<=1599) flg[3]=true;
	    else if(a[i]<=1999) flg[4]=true;
	    else if(a[i]<=2399) flg[5]=true;
	    else if(a[i]<=2799) flg[6]=true;
	    else if(a[i]<=3199) flg[7]=true;
	    else{
	        flg[8]=true;
	        cnt++;
	    }
	}
	for(int i=0;i<=7;i++){
	    if(flg[i]){
	        ans1++;
	        ans2++;
	    }
	}
	if(flg[8]){
	    if(ans1==0) ans1++;
	    ans2+=cnt;
	}
	cout<<ans1<<" "<<ans2<<endl;
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
 
using namespace std;
 
#define endl "\n"
typedef long long int ll;
#define f first
#define s second
 
#define SEND_HELP ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
inline void setPrecision(int n){cout.precision(n);}
 
//DEBUG
#define BR cerr<<endl
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
 
ll INF = 1e10;
int MOD = 1e9+7;

#define lcm(x, y) ((x * y)/ __gcd(x, y))

int main(){
	#ifndef ONLINE_JUDGE
        freopen("inputf.in", "r", stdin);
    #endif
    SEND_HELP

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

    ll cnt = 0;

    //till a
    -- a;
    cnt += (a / c);
    cnt += (a / d);
    cnt -= (a / lcm(c,d));

    ll tots = 0;
    //till b
    tots += (b / c);
    tots += (b / d);
    tots -= (b / lcm(c,d));

    // dbg(tots);
    // dbg(cnt);

    cout << (b - a) - (tots - cnt);

    return 0;
}

/*

*/

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define pb  push_back
#define rep(var,n)  for(int var=0;var<(n);++var)
#define ALL(c)  (c).begin(),(c).end()
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll solve(int N, int K, vi& t, vi& d) {
    map<int,vi> stat;
    rep(i,N){
        stat[t[i]].pb(d[i]);
    }
    vi head, tail;
    for (auto p: stat) {
        sort(ALL(p.second));
        head.pb(p.second.back());
        p.second.pop_back();
        tail.insert(tail.end(), ALL(p.second));
    }
    sort(ALL(head), greater<int>());
    sort(ALL(tail), greater<int>());
    int H = head.size(), T = tail.size();
    vll head_acc(H+1), tail_acc(T+1);
    head_acc[0] = tail_acc[0] = 0;
    rep(i,H) head_acc[i+1] = head_acc[i] + head[i];
    rep(i,T) tail_acc[i+1] = tail_acc[i] + tail[i];

    ll best = 0;
    for (int kinds=1; kinds<=H; ++kinds) {
        if (IN(K-kinds, 0, T)) {
            ll score = (head_acc[kinds] + tail_acc[K-kinds]) + (ll)kinds*kinds;
            best = max(best, score);
        }
    }
    return best;
}

int main() {
    int N, K; scanf("%d%d", &N,&K);
    vi t(N), d(N);
    rep(i,N) scanf("%d%d", &t[i],&d[i]);
    cout << solve(N,K,t,d) << endl;
    return 0;
}


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

int main(){
    int n,y;
    cin>>n>>y;
    vector<int> a(3,-1);
    for(int i=0;i<=n;++i){
        for(int j=0;i+j<=n;++j){
            if(i*1000+j*5000+(n-j-i)*10000==y){
                a.at(0)=i;
                a.at(1)=j;
                a.at(2)=n-i-j;
            }
        }
    }
    cout<<a.at(2)<<" "<<a.at(1)<<" "<<a.at(0)<<endl;
    return 0;
}

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

#define ADD 100

int map[200][200];
int dx[]={0,1,-1,1,-1,0};
int dy[]={1,1,0,0,-1,-1};

int main()
{
  int t,n;
  for(;cin>>t>>n,t;)
    {
      memset(map,0,sizeof(map));
      for(int i=0;i<n;i++)
	{
	  int x,y;
	  cin>>x>>y;
	  map[x+ADD][y+ADD]=-1;
	}
      int x,y;
      cin>>x>>y;
      queue<pair<pair<int,int>,int> >qu;
      qu.push(make_pair(make_pair(x+ADD,y+ADD),t));
      while(!qu.empty())
	{
	  pair<int,int>pos=qu.front().first;
	  int tt=qu.front().second;
	  qu.pop();
	  if(map[pos.first][pos.second]!=0)
	    continue;
	  map[pos.first][pos.second]=1;
	  if(tt<=0)
	    continue;
	  for(int i=0;i<6;i++)
	    {
	      if(map[pos.first+dx[i]][pos.second+dy[i]]==0)
		qu.push(make_pair(make_pair(pos.first+dx[i],pos.second+dy[i]),tt-1));
	    }
	}
      int ans=0;
      for(int i=0;i<200;i++)
	for(int j=0;j<200;j++)
	  if(map[i][j]==1)
	    {
	      ans++;
	    }
      cout<<ans<<endl;
    }
}

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

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

    string A, B;
    for (int i = 0; i < b; i++)
    {
        A += to_string(a);
    }
    for (int i = 0; i < a; i++)
    {
        B += to_string(b);
    }

    if (A < B) {
        cout << A << endl;
    }
    else {
        cout << B << endl;
    }
}

Measured memory_bytes: 256
n,k=map(int,input().split())
l=list(map(int,input().split()))
ans=l[k-1]-l[0]+min(abs(l[k-1]),abs(l[0]))
for i in range(1,n-k+1):
    ans=min(ans,l[i+k-1]-l[i]+min(abs(l[i+k-1]),abs(l[i])))
print(ans)

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

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    if (K == 0) {
        cout << (ll)N * N << endl;
        return 0;
    }

    ll ans = 0;
    for (int b = K + 1; b <= N; ++ b) {
        ans += (b - K) * (N / b);
        ans += max(0, N % b - (K - 1));
    }

    cout << ans << endl;
}

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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int n, l;

signed main()
{
    cin >> n >> l;

    vector<int> a(n);

    int sum = 0;

    int min = 100000000;
    int ans = 0;

    rep(i, n)
    {
        a[i] = l + i + 1 - 1;
        sum += a[i];
        if (min > abs(a[i]))
        {
            min = abs(a[i]);
            ans = i;
        }
    }

    cout << sum - a[ans] << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    
    public static void main(String[] args) {
    
        var sc = new Scanner(System.in);
    
        int n = Integer.parseInt(sc.next());
        var a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        
        boolean b = true;
        int[] spf = smallestPrimeFactor(1000000);
        var set = new HashSet<Integer>();
        label:for(int i = 0; i < n; i++){
            Set<Integer> set2 = primeFactorization(a[i], spf);
            for(Integer x : set2){
                if(!set.add(x)){
                    b = false;
                    break label;
                }
            }
        }
        
        if(b){
            System.out.println("pairwise coprime");
        }else{
            long gcd = gcd(a[0], a[1]);
            for(int i = 2; i < n; i++){
                gcd = gcd(gcd, a[i]);
            }
            if(gcd == 1){
                System.out.println("setwise coprime");
            }else{
                System.out.println("not coprime");
            }
        }
    }
    
    static Set<Integer> primeFactorization(int n, int[] spf){
        
        var set = new HashSet<Integer>();
        while(n != 1){
            set.add(spf[n]);
            n /= spf[n];
        }
        return set;
    }
    
    static int[] smallestPrimeFactor(int maxN){
        
        var spf = new int[maxN+1];
        for(int i = 1; i <= maxN; i++){
            spf[i] = i;
        }
        for(int i = 2; i*i <= maxN; i++){
            if(spf[i] < i) continue;
            for(int j = i*i; j <= maxN; j += i){
                if(spf[j] == j) spf[j] = i;
            }
        }
        return spf;
    }
    
    static long gcd(long a, long b){
        return b == 0 ? a : gcd(b, a%b);
    }
}

Measured memory_bytes: 67128
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define nl '\n'
typedef long long ll;
//////////////////////////////////////////////////////////////////////

const int N = 100100;
int n,a[N],p[N];

int main(){
  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    p[i]=0;
    for(int temp=a[i];temp%2==0;temp>>=1)
      p[i]++;
  }
  sort(p+1,p+1+n);
  int zc = 0 , oc = 0;
  if(p[1]>0)zc=0;
  else for(int i=1;i<=n and p[i]==0;i++,zc++);

  if(p[zc+1]>1)oc = 0;
  else for(int j=zc+1;j<=n and p[j]==1;j++,oc++);

  int rc = n - zc - oc;

  if(oc==0) cout<< (rc < zc-1 ? "No" : "Yes" ) << nl;
  else cout << (rc < zc?"No":"Yes") << nl;
  
  return 0;
}


Measured memory_bytes: 1024
#include<cstdio>

int main(){
	int H, W;

	while (1){
		scanf("%d %d", &H, &W);

		if (H == 0 && W == 0) break;
		else if (H < 3 || W < 3) printf("ばなな\n");

		else for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				if (i == 0 || i == H - 1 || j == 0 || j == W - 1) printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}



Measured memory_bytes: 2528