akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <fstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define sz size()
#define endl "\n"
#define print(X) cout << (X) << "\n"
// // #define input(X) getline(cin,X)
static const ll  INF = 1e9+7;
static const ll INFL = 1e18+7;
ll n,m,l, p;
string s,t;
ll d[200010],e[200010],dp[1001][1001];
char field[202][202];

int main(){
  vp vec;
  int time = 0;
  bool ok = true;
  cin >> n;
  rep(i,0,n){
    cin >> m >> l;
    vec.pb(P{l,m});
  }

  sort(all(vec));
  // puts("");
  rep(i,0,vec.sz){
    time += vec[i].second;
    if(!(time <= vec[i].first))ok = false;

    // printf("now[%d] : time=%lld, task=%lld\n", time, vec[i].first, vec[i].second);
  }
  if(ok)puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 6384
#include <stdio.h>
#include <string.h>

int LCSlength(char X[],char Y[]){
  int i,j,c[1003][1003];
  int m,n;
  
  m = strlen(X);
  n = strlen(Y);
  
  for(i = 0 ; i <= m ; i++){
    c[i][0] = 0;
  }
  for(j = 0 ; j <= n ; j++){
    c[0][j] = 0;
  }
  
  for(i = 1 ; i <= m ; i++){
    
    for(j = 1 ; j <= n ; j++){
      
      if(X[i-1] == Y[j-1]){
	c[i][j] = c[i-1][j-1] + 1;
	
      }
      else {
	if(c[i-1][j] >= c[i][j-1]){
	  c[i][j] = c[i-1][j];
	}
	else {
	  c[i][j] = c[i][j-1];
	}
      }
      
    }
  }
  
  return c[m][n];
}

int main(void){
  int n,Z[1000000],m,l,i,j,lcs[1003];
  char X[1003],Y[1003];
  
  scanf("%d",&n);
  
  for(i = 0 ; i < n ; i++){
    scanf("%s",X);
    
    scanf("%s",Y);
    
    lcs[i] = LCSlength(X,Y);
  }
  
  for(i = 0 ; i < n ; i++){
    printf("%d\n",lcs[i]);
  }
  
  return 0;
}

Measured memory_bytes: 4308
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[4][4];
	for(int i=1;i<=3;i++)
	{
		for(int j=1;j<=3;j++)
		{
			cin>>a[i][j];
		}
	}
	cout<<a[1][1]<<a[2][2]<<a[3][3];
	return 0;
} 

Measured memory_bytes: 764
import java.util.*;
public class Main { 
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		ST:while(true) {
			int n = stdIn.nextInt();
			if(n == 0) break;
			long[] a = new long[n];
			boolean[] b = new boolean[n];
			boolean lastB = false;
			boolean km = true;
			boolean stop = false;
			for(int i = 0; i < n; i++) {
				String k = stdIn.next();
				if(stop) {
					continue;
				}
				if(k.equals("x")) {
					a[i] = 0L;
					b[i] = true;
					if(lastB) {
						System.out.println("none");
						stop = true;
					}
					lastB = true;
					km = false;
				}
				else {
					
					a[i] = Long.parseLong(k);
					if(!lastB) {
						if(i != 0 && (i+1)%2 == 0) {
							if(a[i-1] >= a[i]) {
								System.out.println("none");
								stop = true;
							}
						}
						else if(i != 0 && (i+1)%2 == 1) {
							if(a[i-1] <= a[i]) {
								System.out.println("none");
								stop = true;
							}
						}
					}
					lastB = false;
				}
			}
			if(stop) {
				continue ST;
			}
			if(km) {
				System.out.println("ambiguous");
				continue ST;
			}
			long max = Long.MAX_VALUE;
			long min = Long.MIN_VALUE;
			for(int i = 0; i < n; i++) {
				if(b[i]) {
					if((i+1)%2 == 0) {
						long an = Long.MIN_VALUE;
						long bn = Long.MIN_VALUE;
						if(i != 0 && !b[i-1]) {
							an = a[i-1];
						}
						if(i != n-1 && !b[i+1]) {
							bn = a[i+1];
						}
						if(min < Math.max(an, bn)) {
							min = Math.max(an, bn);
						}
					}
					else {
						long an = Long.MAX_VALUE;
						long bn = Long.MAX_VALUE;
						if(i != 0 && !b[i-1]) {
							an = a[i-1];
						}
						if(i != n-1 && !b[i+1]) {
							bn = a[i+1];
						}
						if(max > Math.min(an, bn)) {
							max = Math.min(an, bn);
						}
					}
				}
			}
			if(max - min == 2) {
				System.out.println(min+1);
			}
			else if(max - min < 2){
				System.out.println("none");
			}
			else {
				System.out.println("ambiguous");
			}
		}
	}
	
}

Measured memory_bytes: 46876
import java.util.Scanner;
import java.util.Arrays;

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

        int n = sc.nextInt();
        int k = sc.nextInt();

        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[sc.nextInt()-1] += 1;
        }

        Arrays.sort(a);

        int[] b = new int[a.length];
        for(int i=0; i<a.length; i++) {
            b[i] = a[a.length-1-i];
        }

        //System.out.println(Arrays.toString(b));

        int count = 0;
        int target = 0;
        for(int i=0; i<b.length; i++) {
            if(b[i] > 0) {
                count += 1;
            }
            if(count > k) {
                target += b[i];
            }
        }
        if(count > k) {
            System.out.println(target);
        } else {
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 86656
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)
from heapq import heappush, heappop

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

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

n = int(input())
S = [ input() for _ in range(n)]

left = 0
right = 0

l_ok = [False] * n
r_ok = [False] * n
LMR = [0] * n
MIN_LMR = [0] * n

for i,s in enumerate(S):
    l = 0
    r = 0
    lok = True
    for j,c in enumerate(s):
        if c == "(":
            l += 1
        else:
            r += 1
            if r > l:
                lok = False
        MIN_LMR[i] = min(MIN_LMR[i], l-r)
    LMR[i] = l - r
    l = 0
    r = 0
    rok = True
    for j in range(len(s)-1, -1, -1):
        if s[j] == "(":
            l += 1
            if l > r:
                rok = False
                break
        else:
            r += 1

    left += s.count("(")
    right += s.count(")")

    l_ok[i] = lok
    r_ok[i] = rok

# log(l_ok)
# log(r_ok)

if left != right:
    print("No")
    exit()


positives = [ (MIN_LMR[i], LMR[i]) for i,x in enumerate(LMR) if x > 0 ]
zeros     = [ (MIN_LMR[i], LMR[i]) for i,x in enumerate(LMR) if x == 0 ]
negatives = [ (MIN_LMR[i], LMR[i]) for i,x in enumerate(LMR) if x < 0 and not r_ok[i] ]
tails     = [ (MIN_LMR[i], LMR[i]) for i,x in enumerate(LMR) if x < 0 and r_ok[i]]

positives.sort(reverse=True)
negatives.sort()
tails.sort()

h = 0
for min_lmr, lmr in positives + zeros:
    if h+min_lmr < 0:
        print("No")
        exit()
    h += lmr

for min_lmr, lmr in negatives + tails:
    if h+min_lmr < 0:
        print("No")
        exit()
    h += lmr

print("Yes")

Measured memory_bytes: 211004
local n, a, b = io.read("n", "n", "n")

if n == 1 and a == b then
	print(1)
	os.exit()
elseif n == 1 then
	print(0)
	os.exit()
elseif a > b then
	print(0)
	os.exit()
end

print((n - 2) * (b - a) + 1)


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

int	main()
{
	int	K, S;
	cin >> K >> S;
	int	cnt = 0;
	for (int X = 0; X <= K && X <= S; ++X) {
		for (int Y = 0; Y <= K && X + Y <= S; ++Y) {
			if (S - (X + Y) <= K)
				++cnt;
		}
	}
	cout << cnt << endl;
}



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

using namespace std;
using ll=long long;

void solve() {
    int n; cin >> n;
    ll sum = 0;
    ll m = 0;
    for (int _ = 0; _ < n; _++) {
        int d; ll c;
        cin >> d >> c;
        sum += d * c;
        m += c;
    }
    ll res = (sum-1)/9 + (m-1);
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

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

using namespace std;

int main() {
  int n;
  std::cin >> n;
  std::vector<int> s(n);
  rep(i, n) std::cin >> s[i];

  int ans = 0;
  rep(i, n) { ans += s[i]; }
  sort(s.begin(), s.end());

  if (ans % 10 != 0) {
    std::cout << ans << std::endl;
    return 0;
  }

  for (int i = 0; i < n; ++i) {
    if (s[i] % 10) {
      std::cout << ans - s[i] << std::endl;
      return 0;
    }
  }

  std::cout << 0 << std::endl;
  return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int N, A;
    cin >> N >> A;

    int ans = N - (N / 500) * 500;
    ans -= A;
    if (ans <= 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
'use strict'
function main(input) {
  input = input.trim().split(' ').map(v => Number(v))
  let ans = input[0] - input[1]
  if (input[1] === 1) ans = 0
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 22964
#include <stdio.h>
#define GRAY  2 
#define WHITE 1
#define BLACK 3 
#define INF -1
int n,color[110],d[110],Q[110],adj[110][110];
int head=0,tail=0;
int judge(){
  if(tail==head) return 1;

  return 0;
}

void enQ(int s){
  Q[tail]=s;
  if(tail==110)tail=0;
  else tail++;
}
int deQ(){
  int a;
  a=Q[head];
  if(head==100)head==0;
  else head++;

  return a;
}

void bfs(int s){
  int i,j,u;
  for(i=2;i<=n;i++){
    color[i]=WHITE;
    d[i]=INF;
  }

  color[s]=GRAY;
  d[s]=0;
 
  enQ(s);

  while(judge() != 1){
 
    u = deQ();
 
    for( j = 1; j <= n; j++ ){
      if(color[j]==WHITE&&adj[u][j]==1){
 
	color[j] = GRAY;
 
	d[j] = d[u] + 1;
 
	enQ(j);
      }
    }
    color[u]=BLACK;
  }

}


int main(){

  int u,k,v,i,j;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      adj[u][v]=1;
    }
  } 
  bfs(1);

  for(i=1;i<=n;i++){
    printf("%d %d\n",i,d[i]);
  }
  return 0;



}

Measured memory_bytes: 1072
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int a, b, c, d; cin >> a >> b >> c >> d;
    vector<vector<ll>> dp(c-a+1,vector<ll>(d-b+1));
    dp[0][0] = 1;
    int x = c-a+1;
    int y = d-b+1;
    repp(i,y,1) dp[0][i] = (dp[0][i-1] * a) % MOD;
    repp(i,x,1) dp[i][0] = (dp[i-1][0] * b) % MOD;
    repp(i,x,1){
        repp(j,y,1){
            ll ans = dp[i][j-1] + dp[i-1][j];
            ans %= MOD;
            ll p = dp[i][j-1] * (i+a-1) % MOD;
            ll q = dp[i-1][j] * (j+b-1) % MOD;
            ll r = dp[i-1][j-1] * (i+a-1) * (j+b-1) % MOD;
            ans += p + q - r;
            ans += MOD;
            ans %= MOD;
            dp[i][j] = ans;
        }
    }
    cout << dp[x-1][y-1] << endl;
}

Measured memory_bytes: 73564
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
LL dp[101][100001];
LL *val,*wgt;
LL knapsack(LL n, LL w) {
    if(n==0 || w==0) return 0;
    if(dp[n][w] == -1) {
        if(wgt[n-1]>w) {
            dp[n][w] = knapsack(n-1,w);
        } else {
            dp[n][w] = max(val[n-1]+knapsack(n-1,w-wgt[n-1]),
                           knapsack(n-1,w));
        }
    }
    return dp[n][w];
}
int main() {
    ios_base::sync_with_stdio(false);
    LL n,w;
    cin >> n >> w;
    val = new LL[n];
    wgt = new LL[n];
    for(int i=0; i<n; i++) cin >> wgt[i] >> val[i];
    memset(dp,-1,sizeof(dp));
    cout << knapsack(n,w) << "\n";
}


Measured memory_bytes: 79232
#include<iostream>
#include<stdio.h>
using namespace std;
int ans=0x7fffffff;
void work(int a,int b)
{
	int aa=0,bb=0;
	while(a>0)
	{
		aa+=a%10;
		a/=10;
	}
	while(b>0)
	{
		bb+=b%10;
		b/=10; 
	}
	if(ans>aa+bb)ans=aa+bb;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n/2;i++)
	{
		work(i,n-i);
	}
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort_by{|e| -e}

b = [a.shift / 2]
(m-1).times do
    if a.empty?
        a = b
        b = [a.shift / 2]
    elsif a[0] > b[0]
        b << a.shift / 2
    else
        b << b.shift / 2
    end
end

puts (a + b).inject(:+)

Measured memory_bytes: 11648
#include<bits/stdc++.h>
using namespace std;
 
int n, m, k, p;
int s[6], t[6];
 
struct edge{
  int to, cost;
};
typedef vector< vector< edge > > Graph;
typedef long long int64;
int64 min_cost[1005][1 << 6][1 << 6];
int flag[1005], tour[1005];
const int64 INF = 1LL << 55;
 
int64 Dijkstra(Graph& info, int s, int g) { //s??????g???????????????
  typedef pair< int64, int64 > Pi;
  typedef pair< Pi, Pi > Piii;
  priority_queue< Piii, vector< Piii >, greater< Piii > > que;
  fill_n( **min_cost, (1 << 6) * (1 << 6) * 1005, INF);
  que.push( Piii(Pi(0, s), Pi(0, 0)));
  min_cost[s][0][0] = 0;
  while(!que.empty()){
    Piii p = que.top(); que.pop();
    if(p.second == Pi((1LL << k) - 1, (1LL << k) - 1)) return p.first.first;
    if(p.first.first > min_cost[p.first.second][p.second.first][p.second.second]) continue;
    for(int i = 0; i < info[p.first.second].size(); i++){
      edge& e = info[p.first.second][i];
      int nextf = p.second.first, nexts = p.second.second;
      if(flag[e.to] >= 0) nextf |= 1LL << flag[e.to];
      else if(tour[e.to] >= 0) nexts |= (((p.second.first >> tour[e.to]) & 1) << tour[e.to]);
      if(p.first.first + e.cost < min_cost[e.to][nextf][nexts]) {
        min_cost[e.to][nextf][nexts] = p.first.first + e.cost;
        que.push( Piii(Pi( min_cost[e.to][nextf][nexts], e.to), Pi(nextf, nexts)));
      }
    }
  }
  return -1;
}
 
int main() {
  cin >> n >> m >> k >> p;
  --p;
  fill_n( flag, 1005, -1);
  fill_n( tour, 1005, -1);
 
  Graph graph(n);
  for(int i = 0; i < m; i++) {
    int x, y, A;
    cin >> x >> y >> A;
    --x, --y;
    graph[x].push_back((edge){y, A});
    graph[y].push_back((edge){x, A});
  }
  for(int i = 0; i < k; i++) {
    cin >> s[i] >> t[i];
    --s[i], --t[i];
    assert(flag[s[i]] < 0);
    assert(tour[t[i]] < 0);
    flag[s[i]] = i;
    tour[t[i]] = i;
  }
  int64 ret = Dijkstra(graph, p, -1);
  if(ret >= 0LL) cout << ret << endl;
  else cout << "Cannot deliver" << endl;
}

Measured memory_bytes: 39508
#define _CRT_SECURE_NO_WARNINGS 1

#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <string>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define rep(i,a,b) for(int i = (a) ; i <= (b) ; i++)
#define per(i,a,b) for(int i = (a) ; i >= (b) ; i--)
#define mem(a) memset(a,0,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const LL INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int maxn = 2e5 + 7;

int head[maxn << 1];
struct Edge {
    int to,next;
} edge[maxn << 1];
int tot;

void init() {
    memset(head,-1,sizeof(head));
    tot = 0;
}

void addedge(int u,int v) {
    edge[tot].to = v;
    edge[tot].next = head[u];
    head[u] = tot++;
}

int vis[maxn];
int res;

void dfs(int u) {
    vis[u] = true;
    res++;
    for(int i = head[u] ; i != -1 ; i = edge[i].next) {
        int v = edge[i].to;
        if(!vis[v]) {
            dfs(v);
        }
    }
}

int main() {
    int n,m;
    sd(n),sd(m);
    init();
    rep(i,1,m) {
        int u,v;
        sd(u),sd(v);
        addedge(u,v), addedge(v,u);
    }
    int ans = 0;
    rep(i,1,n) {
        if(!vis[i]) {
            res = 0;
            dfs(i);
            ans = max(ans,res);
        }
    }
    pd(ans);
    return 0;
}

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

int main(){
    int N; cin >> N;
    vector <int> A(N);
    rep(i,N) cin >> A[i];
    sort(A.begin(),A.end());
    int ans=0;
    rep(i,N-1){
        if(A[i]!=A[i+1]) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
use std::vec::Vec;
 use std::cmp::max;
 
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let (h, w) = {
    let v: Vec<usize> = read_vec();
    (v[0], v[1])
  };

  let mut grid: Vec<Vec<char>> = Vec::new();
  for _ in 0..h {
    let s: Vec<char> = read::<String>().chars().collect();
    grid.push(s);
    }
  let mut m = vec![vec![0; w]; h];

  for i in 0..h {
    let mut tmp = 0;
    for j in 0..w {
      if grid[i][j] == '.' {
        tmp += 1;
      }
      else {
        tmp = 0;
      }
      m[i][j] += tmp;
    }

    tmp = 0;
    for j in (0..w).rev() {
      if grid[i][j] == '.' {
        tmp += 1;
      }
      else {
        tmp = 0;
      }
      m[i][j] += tmp - 1;
    }
  }

  for j in 0..w {
    let mut tmp = 0;
    for i in 0..h {
      if grid[i][j] == '.' {
        tmp += 1;
      }
      else {
        tmp = 0;
      }
      m[i][j] += tmp;
    }

    tmp = 0;
    for i in (0..h).rev() {
      if grid[i][j] == '.' {
        tmp += 1;
      }
      else {
        tmp = 0;
      }
      m[i][j] += tmp - 2;
    }
  }

  let mut res = 0;

  for i in 0..h {
    for j in 0..w {
      res = max(res, m[i][j]);
    }
  }
  println!("{}", res);
}


Measured memory_bytes: 37116
#include<stdio.h>
int main(void){
	int a,b,c,x,y,z;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a>b){
		x=a;
		a=b;
		b=x;
	}
	if(b>c){
		y=b;
		b=c;
		c=y;
	}
	if(a>b){
		z=a;
		a=b;
		b=z;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

		

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

int main()

{
    int a,b,c,temp,d,e;

    scanf("%d%d%d",&a,&b,&c);
    
    d=a-b;

    if(d<c){

        e=c-d;

        printf("%d",e);

    }

    else{

        printf("0");
    }

    return 0;

    }

Measured memory_bytes: 256
#include <iostream>
using namespace std;
char map[23][23], dp[20][20][4][16];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int w,h;

int search(int x,int y, int d, int m){
	while(1){
		x=(x+w)%w;y=(y+h)%h;
		char c = map[y][x];
		if(dp[x][y][d][m]) return 0;
		dp[x][y][d][m] = 1;
		if(c == '<') d = 2;
		if(c == '>') d = 0;
		if(c == '^') d = 3;
		if(c == 'v') d = 1;
		if(c == '_') d = (m)?2:0;
		if(c == '|') d = (m)?3:1;
		if(c == '@') return 1;
		if(c == '+') m=(m+1)%16;
		if(c == '-') m=(m+15)%16;
		if(c >= '0' && c <= '9') m=c-'0';
		if(c == '?'){
			for(d=0;d<4;d++) if(search(x+dx[d],y+dy[d],d,m)) return 1;
			return 0;
		}
		x += dx[d];y += dy[d];
	}
}
main(){
	int i,j;
	char *p,*q;
	cin>>h>>w;
	for(i=0;i<h;i++) cin>>map[i];
	cout << ((search(0, 0, 0, 0))?"YES":"NO") << endl;
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,p,ans=1;
    cin >> n >> p;
    vector<ll> e(1e6+1);
    ll sp=p;
    for(ll i = 2;i <= 1e6;i ++){
        while(p%i==0){
            e[i] ++;
            p /= i;
        }
    }
    for(ll i = 2;i <= 1e6;i ++){
        if(e[i]>=n) ans *= pow(i,e[i]/n);
    }
    if(n==1&&ans!=sp) ans = sp;
    cout << ans << endl;
    return 0;
}

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

int bubbleSort(int A[], int N) {
    int sw = 0;
    bool flag = 1;
    for ( int i=0; flag; i++ ) {
        flag = 0;
        for( int j = N -1; j >= i+1; j--) {
            if (A[j] < A[j-1]) {
                //隣接要素の交換
                swap(A[j], A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main() {
    int A[100], N, sw;
    cin >> N;
    for(int i=0; i<N; i++) cin>>A[i];
    
    sw = bubbleSort(A,N);
    
    for(int i=0; i<N; i++) {
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;
    
    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<string>

using namespace std;
int main()
{
    string s;
    cin >> s;

    if(s[1] == 'R')
    {
        s[1] = 'B';
    }
    else if(s[1] == 'B')
    {
        s[1] = 'R';
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int a;
	int n2 = 0, n4 = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a % 4 == 0) {
			n4++;
		}
		else if (a % 2 == 0) {
			n2++;
		}
	}

	if (n4 >= n / 2 || n4 * 2 + n2 >= n) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int X, t;
    cin >> X >> t;
    cout << max(0, X - t) << endl;
    return 0;
}

Measured memory_bytes: 256
s = int(input())
a = []
a.append(s)
b = float('inf')

for i in range(1000010):
    if a[i] % 2 == 0:
        b = a[i]//2
        if b in a:
            ans = i
            break
        else:
            a.append(b)
    else:
        b = 3*a[i]+1
        if b in a:
            ans = i
            break
        else:
            a.append(b)

print(ans+2)

Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
from collections import Counter

n, k = map(int, input().split())
a = [int(item) for item in input().split()]

for itr in range(k):
    diff = [0] * (n + 1)
    for i, val in enumerate(a):
        start = max(0, i - val)
        end = min(i + val + 1, n)
        diff[start] += 1
        diff[end] -= 1
    na = [0]
    for item in diff:
        na.append(na[-1] + item)
    a = na[1:-1]
    cnt = Counter(a)
    if cnt[n] == n:
        print(" ".join([str(n) for _ in range(n)]))
        exit()
print(" ".join([str(item) for item in a]))

Measured memory_bytes: 183256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < N; i++)
#define rep2(i, x, n) for (int i = x; i < N; i++)
using ll = long long int;
int main() {
    int N=0;
    cin >> N;
    int P = N / 1000 + 1;
    if (N % 1000 != 0) cout << 1000 * P - N << endl;
    else cout << "0" << endl;
    return 0;
}

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

int main()
{
    int x,y,a,b,c;
    cin>>x>>y;
    a=x-y;
    b=x+y;
    c=x*y;
    if(a>=b&&a>=c) cout<<a<<endl;
    else if(b>=a&&b>=c) cout<<b<<endl;
    else cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def main():
    N = int(input())
    ans = 0
    for a in range(1, N):
        ans += (N-1) // a
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62796
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

const int MOD = 1000000007;
typedef long long ll;

bool f(ll cnt, ll A, ll B, vector<ll> h, ll N) {
  vector<ll> tmp(N);
  for(int i=0;i<N;i++){
    tmp[i] = h[i]-cnt*B;
  }
  ll sum=0LL;
  for(int i=0;i<N;i++){
    if(tmp[i]>0)sum+=(tmp[i]+(A-B-1))/(A-B);
  }
  if(sum<=cnt){
    return true;
  }else{
    return false;
  }
}


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,A,B;
  cin>>N>>A>>B;
  vector<ll> h(N);
  for(int i=0;i<N;i++){
    cin>>h[i];
  }

  ll sum=accumulate(h.begin(),h.end(),0ll);
  
  ll ok=2000000001ll;
  ll ng=-1ll;
  
  while (ok - ng > 1) {
    ll mid = (ok + ng) / 2;
    (f(mid,A,B,h, N) ? ok : ng) = mid;
  }

  cout << ok << endl;
}


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

using namespace std;

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

using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
    s << '[';
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len-1) s << ", ";
	}
    s << ']';
	return s;
}

int d[30][30];
int num[3][30] = {0};

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

	int n, C;
	cin >> n >> C;

	rep(i, C){
	    rep(j, C){
	        cin >> d[i][j];
	    }
	}
	rep(i, n){
	    rep(j, n){
	        int c; cin >> c;
			++num[(i+j)%3][c-1];
	    }
	}

	ll ans = LINF;
	rep(i, C){
		rep(j, C){
			if(i == j) continue;
		    rep(k, C){
		        if(k == i or k == j) continue;
				ll tmp = 0ll;
				rep(l, C){
				    tmp += d[l][i] * num[0][l];
					tmp += d[l][j] * num[1][l];
				    tmp += d[l][k] * num[2][l];
				}
				ans = min(ans, tmp);
			}
		}
	}


	ppp(ans);

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fod(i,a,b) for(int i=a;i>=b;--i)
#define min(q,w) ((q)>(w)?(w):(q))
#define max(q,w) ((q)<(w)?(w):(q))
using namespace std;
const int N=350,M=1e7;
int read(int &n)
{
	char ch=' ';int q=0,w=1;
	for(;(ch!='-')&&((ch<'0')||(ch>'9'));ch=getchar());
	if(ch=='-')w=-1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())q=q*10+ch-48;n=q*w;return n;
}
int m,n,ans;
bool az[M+10],prz[M+10];
bool B[N][N];
int pr[M/5];
int a[N],b[N],zx[N];
int z[N],TI;
void Pre()
{
	fo(i,2,M)
	{
		if(!prz[i])pr[++pr[0]]=i;
		fo(j,1,pr[0])
		{
			int t=i*pr[j];
			if(t>M)break;
			prz[t]=1;
			if(!t%pr[j])break;
		}
	}
	prz[1]=prz[2]=1;
}
bool OK(int q)
{
	if(z[q]==TI)return 0;
	z[q]=TI;
	fo(i,1,b[0])if(B[q][i]&&(!zx[i]||OK(zx[i])))return zx[i]=q,1;
	return 0;
}
int main()
{
	int q;
	Pre();
	read(n);
	fo(i,1,n)az[read(q)]=1;
	fo(i,1,M+1)if(az[i]!=az[i-1])
	{
		if(i&1)a[++a[0]]=i;
		else b[++b[0]]=i;
	}
	fo(i,1,a[0])fo(j,1,b[0])if(!prz[abs(a[i]-b[j])])B[i][j]=1;
	q=0;
	fo(i,1,a[0])
	{
		++TI;if(OK(i))++q;
	}
	ans=q+2*((a[0]-q)/2+(b[0]-q)/2);
	if((a[0]-q)&1)ans+=3;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 24832
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define REP(i, n) for(int i = 0; i < (n); i++)
using namespace std;

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

int main()
{
	// 入力

	int h, w, a, b;
	cin >> h >> w >> a >> b;
	

	//

	// 処理
	
	
	REP(i, h)
	{
		REP(j, w)
		{
			if (i < b == j < a)
			{
				cout << 1;
			}
			else
			{
				cout << 0;
			}
		}
		cout << endl;
	}


	//

	// 出力

	//cout << "No";

	//

	return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int n,i;
	string s;
	cin>>s>>n;
	rep(i,s.length())if(i%n==0)cout<<s[i];
	cout<<endl;
	
	
	
	
	
//////////////////////////////////////////////////////
return 0;}











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

int N,Q;
string S;


// 左に落ちないならtrueを返す関数
bool CL(int x, vector<char> t, vector<char> d){
    for(int i=0; i<Q; i++){
        if(S[x-1] == t[i]){
            if(d[i] == 'L'){
                x--;
            }else{
                x++;
            }
        }
        if(x < 1){
            return false;
        }
        if(x > N){
            return true;
        }
    }
    return true;
}

// 右に落ちないならtrueを返す関数
bool CR(int x, vector<char> t, vector<char> d){
    for(int i=0; i<Q; i++){
        if(S[x-1] == t[i]){
            if(d[i] == 'L'){
                x--;
            }else{
                x++;
            }
        }
        if(x < 1){
            return true;
        }
        if(x > N){
            return false;
        }
    }
    return true;
}


int main(){
    cin >> N >> Q >> S;
    vector<char>t(Q);
    vector<char>d(Q);
    for(int i=0; i<Q; i++){
        cin >> t[i] >> d[i];
    }

    // 左に落ちない最小値ubL
    // ubL == N+1の時は全部落ちる
    int lbL=0, ubL = N + 1;
    while( ubL-lbL > 1 ){
        int mid = (lbL+ubL)/2;
        if(CL(mid, t, d)){
            ubL = mid;
        }else{
            lbL = mid;
        }
    }

    // 右に落ちない最大値lbR
    // lbL == 0の時は全部落ちる
    int lbR=0, ubR = N + 1;
    while( ubR-lbR > 1 ){
        int mid = (lbR + ubR) / 2;
        if (CR(mid, t, d)) {
            lbR = mid;
        } else {
            ubR = mid;
        }
    }

    // 出力
    int ans;
    if(lbR == 0 || ubL == N + 1){
        cout << 0;
    }else{
        ans = lbR - ubL + 1;
        cout << ans;
    }
    return 0;
}

Measured memory_bytes: 1328
def main():
    n = int(input())
    a = tuple([int(t)for t in input().split()])

    ans = 1000
    stock = 0
    if a[0]<=a[1]:
        buy = ans//a[0]
        ans -= buy*a[0]
        stock += buy
    for i in range(1,n-1):
        if a[i-1]<=a[i]:
            ans+=stock*a[i]
            stock = 0
        if a[i]<=a[i+1]:
            buy = ans//a[i]
            ans -= buy*a[i]
            stock += buy

    ans+=stock*a[-1]
    stock = 0
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 9216
#include <iostream>

using namespace std;

int bexp(int a, int x, int p) {
    if (x == 0) {
        return 1;
    }
    if (x % 2 == 1) {
        return a * bexp(a, x - 1, p) % p;
    }
    int t = bexp(a, x / 2, p);
    return t * t % p;
}

int inv(int a, int p) {
    return bexp(a, p - 2, p);
}

int main() {
    int p;
    cin >> p;
    int a[p];
    for (int i = 0; i < p; i++) {
        cin >> a[i];
    }

    int c[p][p];
    for (int i = 0; i < p; i++) {
        c[i][0] = c[i][i] = 1;
        for (int j = 1; j < i; j++) {
            c[i][j] = (c[i-1][j-1] + c[i-1][j]) % p;
        }
    }

    int e[p][p];
    for (int i = 0; i < p; i++) {
        for (int j = 0; j < p; j++) {
            e[i][j] = j == 0 ? 1 : e[i][j-1] * i % p;
        }
    }

    int fac[p];
    for (int i = 0; i < p; i++) {
        fac[i] = i == 0 ? 1 : fac[i-1] * i % p;
    }

    int b[p];
    for (int i = p - 1; i >= 0; i--) {
        int x = 0, y = 0;
        int neg = 1;
        for (int j = i; j >= 0; j--) {
            y = ((y + a[j] * c[i][j] * neg) % p + p) % p;
            neg = -neg;
        }
        b[i] = y * inv(fac[i], p) % p;

        for (int j = 0; j < p; j++) {
            a[j] = ((a[j] - b[i] * e[j][i]) % p + p) % p;
        }
    }

    for (int i = 0; i < p; i++) {
        cout << b[i] << (i == p - 1 ? '\n' : ' ');
    }

    return 0;
}


Measured memory_bytes: 70528
/* 
 * Project: AtCoder Beginners Contest 176 B - Multiple of 9
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/08/22
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstdint>
#include <cstring>
using namespace std;

char n[200000];

void solve() {

    uint32_t length = strlen(n);
    uint32_t sum = 0;
    for (int i=0;i<length;i++) {
        sum += n[i]&0x0f;
    }
    if (sum % 9 == 0)
        printf("Yes\n");
    else
        printf("No\n");
}

int main() {

    scanf("%s", n);

    solve();

}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   int N, Z, W;
   cin >> N >> Z >> W;
   vec<ll> v(N);
   rep (i, N) {
      cin >> v[i];
   }

   if (N >= 2) {
      cout << max(abs(v.back()-W), abs(v[N-2]-v.back())) << endl;
   } else {
      cout << abs(v[0] - W) << endl;
   }


   return 0;
}

Measured memory_bytes: 256
def main():
    input()
    array = [int(x) for x in input().split()]
    stocks = 0
    money = 1000

    for day, current_price in enumerate(array):
        lower = False
        higher = False
        for future_day, future_price in enumerate(array[day:]):
            if future_price > current_price:
                higher = True
                # いつか値上がりすることが分かれば今はそれでいい。
                break
            if future_price < current_price:
                lower = True
        if lower:
            # 高くなる前に下がる。短いスパンで見れば分かるが，
            # いま売って下がったときに買えば，枚数を増やしておける。
            money += current_price * stocks
            stocks = 0
        elif higher:  # and not lower
            # 次に高くなるまでに谷がない: 谷があるならそこで買うべき。
            adding, mod = divmod(money, current_price)
            money = mod
            stocks += adding
    money += current_price * stocks
    print(money)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9112
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean[] used=new boolean[8];
        int free=0;
        int n=sc.nextInt();
        int tmp;
        for(int i=0;i<n;i++){
            tmp=sc.nextInt();
            if(tmp>=3200){
                free++;
            }else{
                used[tmp/400]=true;
            }
        }
        int useds=0;
        for(boolean a:used){
            useds+=a?1:0;
        }
        System.out.print(Math.max(useds, 1)+" ");
        System.out.println(useds+free);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <algorithm> // for std::find
#include <iterator> // for std::begin, std::end

using namespace std;
 
int main() {
    int X,N,tempX,temp;
    cin >> X >> N;

    vector<int> p;

    for (int i=0; i<N; i++) {
      cin >> temp;
      p.push_back(temp);
    }

    for (int i=0; i<101; i++){
      tempX = X - i;
      if (std::find(p.begin(), p.end(), tempX) == p.end()) {
        cout << tempX << endl;
        break;
      }

      tempX = X + i;
      if (find(p.begin(), p.end(), tempX) == p.end()) {
        cout << tempX << endl;
        break;
      }
    }
    

  
  	return 0;
}


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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

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

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int N = input(), M = input();

    int l = (N + 1) / 2 / 2, r = l + 1;
    range(i, 0, (M + 1) / 2) {
        cout << l << " " << r << endl;
        r++; l--;
    }

    l = N - (N / 2) / 2 - 1, r = l + 2;
    range(i, 0, M / 2) {
        cout << l << " " << r << endl;
        r++; l--;
    }
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3664
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  ll N,K;
  cin >> N >> K;
  if((N-1)*(N-2)/2<K){
    cout << -1 << endl;
    return 0;
  }
  ll T=0;
  cout << (N)*(N-1)/2-K << endl;
  Rep(i,1,N){
    Rep(j,i+1,N+1){
      if(i==1){
        cout << i << " " << j << endl;
      }
      else{
        if(T>=K){
          cout << i << " " << j << endl;
        }
        T++;
      }
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

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


int main(){
  int N;
  int T;
  scanf("%d%d",&N,&T);
  int k=0;
  int c[N];
  int t[N];
  int i;
  int flag=0;
  for(i=0;i<N;i++){
    scanf("%d%d",&c[i],&t[i]);
  }
  int cc[N];
  for(i=0;i<N;i++){
    if(t[i]<=T){
      cc[k]=c[i];
      k++;
      flag=1;
    }
  }
  if(flag==0){
    printf("TLE");
    return 0;
  }
  qsort(cc, k ,sizeof(int), compare_int);
  printf("%d",cc[0]);
  return 0;
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	A := sc.nextIntSlice(N)
	var dp [3010][3010][2]int
	var flag [3010][3010][2]bool
	var rec func(l, r, order int) int
	rec = func(l, r, order int) int {
		if flag[l][r][order] {
			return dp[l][r][order]
		}
		res := 0
		if l < r {
			if order == 0 {
				res = max(rec(l+1, r, 1)+A[l], rec(l, r-1, 1)+A[r])
			} else {
				res = min(rec(l+1, r, 0)-A[l], rec(l, r-1, 0)-A[r])
			}
		}
		if l == r {
			if order == 0 {
				res = A[l]
			} else {
				res = -A[l]
			}
		}

		flag[l][r][order] = true
		dp[l][r][order] = res
		//fmt.Fprintf(wtr, "l: %d, r: %d, order: %d, res: %d\n", l, r, order, res)
		return res
	}

	fmt.Fprintln(wtr, rec(0, N-1, 0))
	wtr.Flush()
}


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

using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	
	long double a, b;
	cin >> a >> b;

	cout << (ll)(a * b + 0.0001) << endl;

	return 0;
}


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

const long long INF=100000000;

int main(){
    //input
    long long N,M,R;
    cin >> N >> M >> R;
    long long r[R];
    long long i,j,k;
    for(i=0; i<R; i++){
        cin >> r[i];
    }
    long long a[N+1][N+1];
    for(i=0; i<=N; i++){
        for(j=0; j<=N; j++){
            a[i][j]=INF;
        }
    }
    for(i=1; i<=N; i++){
        a[i][i]=0;
    }
    long long A,B,C;
    for(i=1; i<=M; i++){
        cin >> A >> B >> C;
        a[A][B]=a[B][A]=C;
    }

    //calc

    for(i=1; i<=N; i++){
        for(j=1; j<=N; j++){
            for(k=1; k<=N; k++){
                a[j][k]=min(a[j][k],a[j][i]+a[i][k]);
            }
        }
    }
    long long ans=INF, val;
    sort(r,r+R);
    do{
        val=0;
        for(i=0; i<R-1; i++){
            val+=a[r[i]][r[i+1]];
        }
        ans=min(ans,val);
    }while(next_permutation(r,r+R));

    //output
    cout << ans << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 3948