akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#define int long long
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 1e6 + 100,mod = 1e9 + 7;
int n,m,cnt,top,a[N],b[N];
int f[N],tr[N];
int S[N];
struct node{int x,y; int friend operator == (node a,node b){return a.x == b.x && a.y == b.y;}}p[N];
int lowbit(int x){return x & -x;}
int cmp(node a,node b){if(a.x != b.x) return a.x < b.x; return a.y > b.y;}
int ask(int x){int res = 0; for(;x;x -= lowbit(x)) res = (res + tr[x]) % mod; return res;}
void add(int x,int v){for(;x <= top;x += lowbit(x)) tr[x] = (tr[x] + v) % mod;}
signed main()
{
	n = read(); m = read();
	for(int i = 1;i <= n;i ++) a[i] = read(); 
	for(int i = 1;i <= m;i ++) b[i] = read();
	for(int i = 1;i <= n;i ++)
	{
		if(a[i] <= b[1] || a[i] >= b[m]) continue;
		int t = lower_bound(b + 1,b + 1 + m,a[i]) - b;
		if(b[t] == a[i]) continue;
		p[++ cnt] = node{a[i] - b[t - 1],b[t] - a[i]};
		S[++ top] = b[t] - a[i];
	}
	sort(S + 1,S + 1 + top); top = unique(S + 1,S + 1 + top) - S - 1;
	for(int i = 1;i <= cnt;i ++) p[i].y = lower_bound(S + 1,S + 1 + top,p[i].y) - S;
	sort(p + 1,p + 1 + cnt,cmp); cnt = unique(p + 1,p + 1 + cnt) - p - 1;
	f[0] = 1; 
	for(int i = 1;i <= cnt;i ++)
	{
		f[i] = ask(p[i].y - 1) + 1;
		add(p[i].y,f[i]);
	}
	int ans = 0; for(int i = 0;i <= cnt;i ++) ans = (ans + f[i]) % mod;
	cout << ans << "\n";
}

Measured memory_bytes: 16128
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

S = input()
K = int(input())

dp = [[[0 for _ in range(2)] for _ in range(4)] for _ in range(102)]

def rec(i, k, is_same):
    if dp[i][k][is_same] != 0:
        return dp[i][k][is_same]
    if k == 0:
        return 1
    if i == 0:
        if k >= 2:
            return 0
        if is_same == 1:
            dp[i][k][is_same] = int(S[len(S) - i - 1])
        else:
            dp[i][k][is_same] = 9
        return dp[i][k][is_same]

    res = 0
    a = int(S[len(S) - i - 1])
    if is_same == 1:
        for x in range(a + 1):
            if x == a and x == 0:
                res += rec(i - 1, k, 1)
            elif x == 0:
                res += rec(i - 1, k, 0)
            elif x == a:
                res += rec(i - 1, k - 1, 1)
            else:
                res += rec(i - 1, k - 1, 0)
    else:
        for x in range(10):
            if x == 0:
                res += rec(i - 1, k, 0)
            else:
                res += rec(i - 1, k - 1, 0)

    dp[i][k][is_same] = res
    return res

n = len(S)
res = rec(n - 1, K, 1)
print(res)

Measured memory_bytes: 9604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String str = s.next();
		StringBuilder sb = new StringBuilder(str);
		/*		int N = s.nextInt();
		*/
		int a = -1;
		int b = -1;
		int c = -1;

		if (str.contains("a")) {
			if (str.contains("b")) {
				if (str.contains("c")) {
					System.out.println("Yes");
				}else{
					System.out.println("No");
				}
			}else{
				System.out.println("No");
			}
		}else{
			System.out.println("No");
		}


	}
}

Measured memory_bytes: 21844
#include <algorithm>
#include <climits>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string.h>
#include <utility>
#include <vector>
using namespace std;

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define REPR(i, n) for(int i = n - 1; 0 <= i; i--)
#define FOR(i, s, e) for(int i = s; i <= e; i++)
#define FORR(i, s, e) for(int i = s; e <= i; i--)
#define LLI long long int
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    int a, b, t;
    cin >> a >> b;
    t = b;
    while(0 < t) {
        a *= 10;
        t /= 10;
    }
    a += b;
    for(int i = 1; i * i <= a; i++) {
        if(i * i == a) {
            cout << "Yes";
            return 0;
        }
        if(a < i * i)
            break;
    }
    cout << "No";
    return 0;
}

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 D;
	cin >> D;
	if (D == 25)
		cout << "Christmas" << endl;
	else if (D == 24)
		cout << "Christmas Eve" << endl;
	else if (D == 23)
		cout << "Christmas Eve Eve" << endl;
	else if (D == 22)
		cout << "Christmas Eve Eve Eve" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;

int main() {
    char ch;
    int a[26] = {};
    while(scanf("%c", &ch) != EOF){
        if (isalpha(ch)) {
            if (isupper(ch)) {
                ch = tolower(ch);
            }
            a[(int)(ch - 'a')] += 1;
        }
    }
    for (int i=0; i < 26; i++) {
        cout << char(i+97) << " : " << a[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3236
function A(){
   var max=0;
   var ary=[];
   for(var i=1;i<=8;i++){
      for(var j=1;j<=8;j++){
         if(yx[i][j]!=".")continue;
         var cnt=seach(i,j,"x","o");
         if(cnt>max){ary=[i,j];max=cnt;}
      }
   }
   return ary;
}
function B(){
   var max=0;
   var ary=[];
   for(var i=8;i>=1;i--){
      for(var j=8;j>=1;j--){
         if(yx[i][j]!=".")continue;
         var cnt=seach(i,j,"o","x");
         if(cnt>max){ary=[i,j];max=cnt;}
      }
   }
   return ary;
}
function seach(y,x,a,b){
   var dy=[-1,-1,-1,0,0,1,1,1];
   var dx=[-1,0,1,-1,1,-1,0,1];
   var sum=0;
   for(var i=0;i<8;i++){
      var DY=dy[i];
      var DX=dx[i];
      var cnt=0;
      var k=1; 
      while(true){
         if(yx[y+DY*k][x+DX*k]=="f" || yx[y+DY*k][x+DX*k]==".")break;
         else if(yx[y+DY*k][x+DX*k]==a)cnt++;
         else if(yx[y+DY*k][x+DX*k]==b){sum+=cnt;break;}
         k++;
      }
   }
   return sum;
}
function change(y,x,a,b){
   yx[y][x]=b;
   var dy=[-1,-1,-1,0,0,1,1,1];
   var dx=[-1,0,1,-1,1,-1,0,1];
   var cnt=0;
   for(var i=0;i<8;i++){
      var DY=dy[i];
      var DX=dx[i];
      var cnt=0;
      var k=1;
      var flag=false;
      while(true){
         if(yx[y+DY*k][x+DX*k]=="f" || yx[y+DY*k][x+DX*k]==".")break;
         else if(yx[y+DY*k][x+DX*k]==a)flag=true;
         else if(yx[y+DY*k][x+DX*k]==b){
            if(flag){
               while(k--)yx[y+DY*k][x+DX*k]=b;
            }
            break;
         }
         k++;
      }
   }
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var yx=[];
yx.push("ffffffffff".split(""));
arr.forEach(function(v){
   v="f"+v+"f";
   yx.push(v.split(""));
});
yx.push("ffffffffff".split(""));
var pass=0;
while(true){
   var ansA=A();
   if(ansA.length==0)pass++;
   else {pass=0;change(ansA[0],ansA[1],"x","o");}
   var ansB=B();
   if(ansB.length==0)pass++;
   else {pass=0;change(ansB[0],ansB[1],"o","x");}
   if(pass>=2)break;
}
yx.shift();
yx.pop();
console.log(yx.join("\n").replace(/\,|f/g,""));

Measured memory_bytes: 15896
#include <bits/stdc++.h>
	using namespace std;
	#define IOS ios::sync_with_stdio(false), cin.tie(0)
	#define REP(i, n) for (int i = 0; i < n; i++)
	#define FOR(i, a, b) for (int i = a; i < b; i++)
	#define ALL(x) (x).begin(), (x).end()
	#define dump(x) cout << (x) << endl
	#define LMAX 9223372036854775807LL
	#define LMIN -9223372036854775807LL

	using ll = long long;
	template<typename T>
	using vec = vector<T>;
	using P = pair<ll, ll>;

	template <typename A, size_t N, typename T>
	void Fill(A (&array)[N], const T &val){
		fill((T *)array, (T *)(array + N), val);
	}
	
	const ll INF = 1e18;
	const ll mod = 1e9 + 7;

	//int dx[4] = {1,0,-1,0};
	//int dy[4] = {0,1,0,-1};
	//ll pas[51][52];
	ll n;
	vec<ll> g[114514];
	ll d[2][114514];
	ll used[2][114514] = {};
	void dfs(int d1,int d2,int sum){
		used[d1][d2] = true;
		for(int i = 0;i <g[d2].size();i++){
			if(!used[d1][g[d2][i]]){
				d[d1][g[d2][i]] = sum + 1;
				dfs(d1,g[d2][i],sum + 1);
			}
		}
	}

	signed main(){
		IOS;
		cin >> n;
		REP(i,n - 1){
			int a, b;
			cin >> a >> b;
			g[a].push_back(b);
			g[b].push_back(a);
		}
		dfs(0,1,0);
		dfs(1,n,0);
		int fe = 0,su = 0;
		for(int i = 2;i < n;i++){
			if(d[0][i] <= d[1][i])fe++;
			else su++;
		}
		if(fe > su)dump("Fennec");
		else dump("Snuke");
	}

Measured memory_bytes: 17280
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i = 0; i < n; ++i)
#define all(a) (a).begin(),(a).end()
#define fst first
#define snd second
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
typedef pair<pii,ll> piii; // 正答数、時間、チーム

#define int ll
main(){
  int t,p,r;
  while(cin >> t >> p >> r,t){
    vector<vi> wanum(t,vi(p));
    vector<piii> result(t);
    rep(i,t) result[i].snd = i;
    int tid,pid,time;
    string m;
    rep(i,r){
      cin >> tid >> pid >> time >> m; tid--; pid--;
      if(m == "WRONG"){
	wanum[tid][pid]++;
      }else if(m == "CORRECT"){
	result[tid].fst.fst--;
	result[tid].fst.snd += wanum[tid][pid] * 1200 + time;
      }
    }
    sort(all(result));
rep(i,t) cout << result[i].snd+1 << " " << -result[i].fst.fst << " " << result[i].fst.snd << endl;
  }
}



Measured memory_bytes: 3172
from collections import defaultdict
from heapq import heappush, heappop, heapify
from sys import stdin
def sp(G,R,V):
    d = {}
    q = [(0, R)]
    heapify(q)
    #seen = set()
    while q:
        (cost, v) = heappop(q)
        if v not in d:
            #seen.add(v)
            d[v] = cost
            for (next, c) in G[v].items():
                heappush(q, (cost + c, next))
    return d

V, E, R = [int(x) for x in stdin.readline().split()]
G = defaultdict(dict)
for case in range(E):
    s, t, w = [int(x) for x in stdin
    .readline().split()]
    G[s][t] = w
d = sp(G, R, V)
for k in range(V):
    if k not in d:
        print("INF")
    else:
        print(d[k])

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

int main() {
    double a, b;
    cin >> a >> b;
    double ave = ((a + b) / 2); //少数第一位を一の位に
    
    int avex = ave * 10;
    int v = avex % 10;
    
  if (v >= 5)
    {
        avex = avex + (10 - v);
        cout << avex / 10;
    }
    else {
        avex = avex - v;
        cout << avex / 10;
    }
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if(9<a||9<b) cout << -1 << endl;
  else cout << a*b << endl;
}

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

int main()
{
  ll i,j,k,l,n;
  string s;
  cin >> s;
  cin >> n;
  for(i=0;i<s.length();i+=n)
    cout << s[i];
  cout << endl;

}


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

#define sen 1000
#define gosen 5000
#define man 10000

int main() {
	long long n,y;
	
	cin >> n >> y;
	
	for (long long i=0;i<=n;i++){
		for (long long j=0;j<=n-i;j++){
			long long k = n-i-j;
			long long sum = i*sen + j*gosen + man*k;
			if (sum == y) {
				cout << k << " " << j << " " << i << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

ll uymax=-1e8, uymin=1e8, symax=-1e8, symin=1e8, dymax=-1e8, dymin=1e8;
ll lxmax=-1e8, lxmin=1e8, sxmax=-1e8, sxmin=1e8, rxmax=-1e8, rxmin=1e8;

double solve(double t) {
  t = fabs(t);
  double xmax = max(sxmax*1.0, max(rxmax*1.0+t, lxmax*1.0-t));
  double xmin = min(sxmin*1.0, min(rxmin*1.0+t, lxmin*1.0-t));
  double ymax = max(symax*1.0, max(uymax*1.0+t, dymax*1.0-t));
  double ymin = min(symin*1.0, min(uymin*1.0+t, dymin*1.0-t));
  return (xmax-xmin)*(ymax-ymin);
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  for (int i=0; i<n; ++i) {
    ll x, y;
    string d;
    cin >> x >> y >> d;
    if (d=="R") {
      symax=max(symax, y);
      symin=min(symin, y);
      rxmax=max(rxmax, x);
      rxmin=min(rxmin, x);
    }
    if (d=="L") {
      symax=max(symax, y);
      symin=min(symin, y);
      lxmax=max(lxmax, x);
      lxmin=min(lxmin, x);
    }
    if (d=="U") {
      uymax=max(uymax, y);
      uymin=min(uymin, y);
      sxmax=max(sxmax, x);
      sxmin=min(sxmin, x);
    }
    if (d=="D") {
      dymax=max(dymax, y);
      dymin=min(dymin, y);
      sxmax=max(sxmax, x);
      sxmin=min(sxmin, x);
    }
  }
  double ans = solve(0.0);
  /*
  ll uymax=-1e8, uymin=1e8, symax=-1e8, symin=1e8, dymax=-1e8, dymin=1e8;
  ll lxmax=-1e8, lxmin=1e8, sxmax=-1e8, sxmin=1e8, rxmax=-1e8, rxmin=1e8;
  */
  ans = min(ans, solve((symax-uymax)*1.0));
  ans = min(ans, solve((dymax-symax)*1.0));
  ans = min(ans, solve((dymax-uymax)*0.5));
  ans = min(ans, solve((symin-uymin)*1.0));
  ans = min(ans, solve((dymin-symin)*1.0));
  ans = min(ans, solve((dymin-uymin)*0.5));
  ans = min(ans, solve((sxmax-rxmax)*1.0));
  ans = min(ans, solve((lxmax-sxmax)*1.0));
  ans = min(ans, solve((lxmax-rxmax)*0.5));
  ans = min(ans, solve((sxmin-rxmin)*1.0));
  ans = min(ans, solve((lxmin-sxmin)*1.0));
  ans = min(ans, solve((lxmin-rxmin)*0.5));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

int main(){
	int n ; 
	cin >> n ;
	vector<int> v(n+1) ; 
	for(int i=1;i<=n;i++){
		cin >> v[i] ; 
	}
	int cnt = 0 ; 
	int ans = 0 ; 
	for(int i=1;i<=n;i++){
		if ( i == v[i] ){
			cnt++ ; 
			while(i+1<=n && v[i+1] == i+1 ){
				cnt++ ; 
				i++ ; 
			}
		}
		else{
			ans += (cnt+1)/2 ; 
			cnt = 0 ; 
		}
		debug() << imie(cnt) ; 
	}
	if ( cnt ){
		ans += (cnt+1)/2 ; 
	}
	cout << ans << endl;

    return 0 ;
}


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

int main(){

  string s;
  string ans[1000];
  int n = -1;
  int r,k = 0;

  getline(cin,s);

  for(int i=0;i<s.size();i++){

    if(s[i] == ' ' || s[i] == ',' || s[i] == '.'){
      if(i-1-n > 2 && i-1-n < 7){

	for(int j=n+1;j<i;j++) ans[k] += s[j];

	k++;
	n = i;
      }

      else n = i;

    }
  }

  cout << ans[0];
  for(int i=1;i<k;i++) cout << " " << ans[i];
  cout << endl;

}

Measured memory_bytes: 1176
#include <stdio.h>
#include <cmath>

using namespace std;

const long long MAXM = 40;
const int MAXN = 1000;

long long n, v[MAXN][2], ps[MAXM + 1], sum[MAXM + 1];
char sol[MAXN][MAXM];

bool wk(long long x, long long y, long long r) {
	if(abs(x) + abs(y) <= r) {
		return true;
	} else {
		return false;
	}
}

int main ()
{	

	int m = MAXM;
	scanf("%lld", &n);

	int rest = -1;
	for(int i = 0; i < n; i++) {
		scanf("%lld %lld", &v[i][0], &v[i][1]);
		int mod = (v[i][0] + v[i][1]) & 1;
		if(rest == -1) {
			rest = mod;
		} else {
			if(rest != mod) {
				printf("-1\n");
				return 0;
			}
		}
	}

	if(rest == 1) {
		for(int i = 0; i < m; i++) {
			ps[i] = (1LL << (m - i - 1));
		}
	} else {
		for(int i = 1; i < m; i++) {
			ps[i - 1] = (1LL << (m - i - 1));
		}
		ps[m - 1] = 1;
	}

	sum[m] = 0;
	ps[m] = 0;
	for(int i = m - 1; i >= 0; i--) {
		sum[i] = ps[i] + sum[i + 1];
	}
	
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			char afis;
			if(wk(v[i][0] - ps[j], v[i][1], sum[j + 1])) {
				afis = 'R';
				v[i][0] -= ps[j];
			} else {
				if(wk(v[i][0] + ps[j], v[i][1], sum[j + 1])) {
					afis = 'L';
					v[i][0] += ps[j];
				} else {
					if(wk(v[i][0], v[i][1] - ps[j], sum[j + 1])) {
						afis = 'U';
						v[i][1] -= ps[j];
					} else {
						if(wk(v[i][0], v[i][1] + ps[j], sum[j + 1])) {
							afis = 'D';
							v[i][1] += ps[j];
						}
					}
				}
			}
			sol[i][j] = afis;
		}
		if(v[i][0] != 0 || v[i][1] != 0) {
			printf("-1\n");
			return 0;
		}
	}

	printf("%d\n", m);
	for(int i = 0; i < m; i++) {
		printf("%lld ", ps[i]);
	}
	printf("\n");

	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			printf("%c", sol[i][j]);
		}
		printf("\n");
	}


	return 0;
}

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

int roads[100000][2];

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  for(int i = 0; i < n; i++) cin >> h[i];
  for(int i = 0; i < m; i++){
    cin >> roads[i][0];
    cin >> roads[i][1];
  }
  
  int peaks[n];
  for(int i = 0; i < n; i++) peaks[i] = 0; //0が良い展望台
  
  for(int i = 0; i < m; i++){
    if(h[roads[i][0]-1] > h[roads[i][1]-1]){
      peaks[roads[i][1]-1] = 1;
    }else if(h[roads[i][0]-1] < h[roads[i][1]-1]){
      peaks[roads[i][0]-1] = 1;
    }else{
      peaks[roads[i][0]-1] = 1;
      peaks[roads[i][1]-1] = 1;
    }
  }
  
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(peaks[i] == 0) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 4840
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)


int main(){
    int n,num = 0;
    cin >> n;
    int A[n];
    rep(i,n){
        cin >> A[i];
        while(A[i] % 2 == 0){
            A[i] /= 2;
            num++;
        }
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<N;i++)
#define INF 1e9
typedef long long LL;
const LL MOD = 1e9+7;

int main() {
  LL N;
  cin >> N;
  vector<LL> a(N);
  rep(i,N) cin >> a[i];
  
  vector<LL> box(N);
  LL count = 0;
  for (int i = N-1; i >= 0; i--) {
    LL sum = 0;
    for (int j = i; j < N; j+=i+1) {
      sum += box[j];
    }
    sum %= 2;
    
    if (sum != a[i]) {
      box[i]++;
      count++;
    }
  }
  
  cout << count << endl;
  rep(i,N) {
    if (box[i] == 1) cout << i + 1 << ' ';
  }
  return 0;
}

Measured memory_bytes: 3968
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define MAX 100

int judge(char []);
void slide(char []);

const char TERM[3][5] = {"the", "this", "that"};

int main(void) {
    char str[MAX];
    for(; fgets(str, sizeof(str), stdin); printf("%s", str)) {
        for(; judge(str); slide(str));
    }
    return 0;
}

int judge(char str[]) {
    int i;
    for(i = 0; i < 3; i++) {
        if(strstr(str, TERM[i])) {
            break;
        }
    }
    return i == 3;
}

void slide(char str[]) {
    int i;
    for(i = 0; i < strlen(str); i++) {
        if(isalpha(str[i])) {
            str[i] = (str[i] - '`') % 26 + 'a';
        }
    }
}

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

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

	if (a > b) {
		t = b; b = a; a = t;
	}
	if (b > c) {
		t = c; c = b; b = t;
	}
	if (a > b) {
		t = b; b = a; a = t;
	}

	cout << a << " " << b << " " << c << endl;

	return 0;
}

Measured memory_bytes: 1164
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Text;

namespace ConsoleApp
{
    class Program
    {

        static void Main(string[] args)
        {
            var s = ReadLine();
            var q = long.Parse(ReadLine());

            bool isRev = false;
            StringBuilder l = new StringBuilder();
            StringBuilder r = new StringBuilder();

            for (int i = 0; i < q;i++)
            {
                var input = ReadLine().Split();
                if(input[0] == "1"){
                    isRev = !isRev;
                } 
                else{
                    var f = input[1];
                    var c = input[2];

                   
                    if(f == "1"){
                        if(!isRev){
                            l.Append(c);
                        }
                        else{
                            r.Append(c);
                        }
                    }
                    else
                    {
                        if(!isRev){
                            r.Append(c);
                        }
                        else{
                            l.Append(c);
                        }
                    }

                }

            }

            string res =  new string(l.ToString().Reverse().ToArray() )+ s + r.ToString();
            if(isRev){
                var t = res.Reverse();
                res = string.Join("",t);
            }
            
            WriteLine(res);
        }



    }

}


Measured memory_bytes: 21812
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

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


int main() {
	int N;
	vector<int> V;
	int tmp;
	cin >> N;

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

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

	double res = V[0];
	for (int i = 1; i < N; i++) {
		res = (res + V[i]) / 2;
	}
	cout << res;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, x;

void solve() {
    if (x == 1 || x == 2 * n -1) {
        cout << "No" << endl;
        return;
    }

    int a[2*n-1];
    a[n-1] = x;
    int l = 1, r = 2*n-1;
    int j = 1;
    while (l < r) {        
        a[n-1-j] = l;
        a[n-1+j] = r;
        if (j % 2) swap(a[n-1-j], a[n-1+j]);
        l++; r--;
        if (l == x) l++;
        if (r == x) r--;
        j++;
    }
    cout << "Yes" << endl;
    for (int i = 0; i < 2*n-1; i++)
        cout << a[i] << endl;
}

void input() {
    cin >> n >> x;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    solve();
}

Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int n;
    int l,lm=0,lsum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>l;
        lm=max(lm,l);
        lsum+=l;
    }
    lsum-=lm;
    if(lsum>lm){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

vvi to;

int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  to = vvi(n);
  rep(i,m) {
    int a,b;
    scanf("%d%d",&a,&b);
    --a; --b;
    to[a].pb(b);
    to[b].pb(a);
  }
  vi vq, dq, cq;
  int q;
  scanf("%d",&q);
  rep(i,q) {
    vq.pb(in()-1);
    dq.pb(in());
    cq.pb(in());
  }
  vi ans(n), w(n,-1);
  drep(qi,q) {
    int v = vq[qi];
    int d = dq[qi];
    int c = cq[qi];
    queue<P> q;
    if (w[v] >= d) continue;
    maxs(w[v],d);
    if (!ans[v]) ans[v] = c;
    q.push(P(d,v));
    while (sz(q)) {
      v = q.front().se;
      d = q.front().fi-1;
      q.pop();
      for (int u : to[v]) {
        if (w[u] >= d) continue;
        w[u] = d;
        if (!ans[u]) ans[u] = c;
        q.push(P(d,u));
      }
    }
  }
  rep(i,n) {
    printf("%d\n",ans[i]);
  }
  return 0;
}






















Measured memory_bytes: 8912
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void solve(long long N, long long M)
{
    for (ll i = M; i >= 1; i--) {
        if ((M % 2 == 1 && i % 2 == 1) || (M % 2 == 0 && i % 2 == 0)) {
            cout << 1 + ((M - i + 1) / 2) << " " << M + 1 - ((M - i + 1) / 2) << endl;
        } else {
            cout << 1 + ((M - i + 1) / 2) + M << " " << M + 1 - ((M - i + 1) / 2) + M + 1 << endl;
        }
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=("; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

int main()
{

	vec l(3);
	cin >> l[0] >> l[1] >> l[2];

	SORT(l);

	cout << l[0]*l[1] / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n;
  int a;
  bool f=true;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a%2==0){
      if(a%3!=0&&a%5!=0){
        cout<<"DENIED\n";
        return 0;
      }
    }
  }
  cout<<"APPROVED\n";
}

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

using namespace std;

#define ll long long
#define pb push_back
#define F first
#define S second
#define rf(i,a,b) for(int (i) = (a); (i) <= (b); (i)++)
#define rb(i,b,a) for(int (i) = (b); (i) >= (a); (i)--)
#define watch(x) cout << (#x) << " = " << (x) << endl
#define test(t) int(testCnt) = 0; int(t); cin >> (t); while(t -- && ++testCnt)

const int INF = 2e9 + 7;
const int MAXA = 3e3 + 10;
const ll MOD = (ll) 1e9 + 7;
const ll INFLL = 9e18 + 7;

typedef pair<int, int> ii;
typedef pair<ii, int> II;
typedef vector<int> vi;
typedef vector<ii> vii;

ll a[MAXA], f[MAXA][MAXA][3];
int n;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen("in.in", "r", stdin);
    #endif

    cin >> n;

    rf(i, 0, n) {
        rf(j, 0, n) {
            f[i][j][1] = INFLL;
        }
    }
    rf(i, 1, n) {
        cin >> a[i];
        f[i][1][1] = -a[i];
        f[i][1][0] = a[i];
    }
    rf(i, 2, n) {
        rf(j, 1, n) {
            if(j + i - 1 > n) break;
            f[j][i][0] = max(a[j] + f[j + 1][i - 1][1], a[j + i - 1] + f[j][i - 1][1]);
            f[j][i][1] = min(-a[j] + f[j + 1][i - 1][0], -a[i + j - 1] + f[j][i - 1][0]);
        }
    }
    cout << f[1][n][0];
    return 0;
}


Measured memory_bytes: 211968
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;

#define ll long long

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

ll lcm(ll a, ll b){
	return a / gcd(a, b) * b;
}


int main(){
    ll ans = 1;
    ll N;
    cin >> N;
    vector<ll> T(N);
    for(int i = 0; i < N; i++) cin >> T[i];
    for(int i = 0; i < N; i++){
        ans = lcm(ans, T[i]);
    }
    cout<< ans << endl;
}


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

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

using namespace std;

int main()
{
	double a[10],n;
	while(cin >> n)
	{
		double ans = 0;
		a[0] = n;
		REP(i,1,10)
		{
			if((i+1)%2 == 0)
			{
				a[i] = a[i-1]*2;
			}
			else
			{
				a[i] = (a[i-1]/3);
			}
		}
		rep(i,10)
		{
			ans += a[i];
		}

		
		cout << setprecision(10)<< ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

int main() {
  int n;
  cin >> n;
  if(n<=3 || n==5 || n==6 || n==9 || n==10 || n==13 || n==17){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}

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

int n,a,sum=0;
bitset<2000007>jojo;
//C++的 bitset在bitset头文件中它是一种类似数组的结构它的每一个元素只能是０或１每个元素仅用１bit空间

int main(){
    scanf("%d",&n);
    jojo[0]=1;
    for(int i=1;i<=n;i++){
        scanf("%d",&a);
        jojo|=jojo<<a;
        sum+=a;
    }
    for(int i=(sum+1)/2;i<=sum;i++){
        if(jojo[i]){
		printf("%d\n",i);
		break;
		}
    }
    return 0;
}

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

int ans = 0;

void solve(long long X, long long Y){
    long long tmp = X;
    for(int i=0;tmp <= Y;i++){
        tmp = tmp * 2;
        ans ++;
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    
    int n,result = 100;
    cin >> n;
    
    for(int i = 0; i < n; i++){
        int a,t = 0;
        cin >> a;
        while(a%2 == 0){
            a /= 2;
            t++;
        }
        result = min(result,t);
    }
    
    cout << result << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(ll i = a - 1; i >= b; i--)
#define rrep(i, a) rFOR(i, a, 0)
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};

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

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

class SegmentTree_max{//maximum
    long long n;
    vector<long long> seg;
public:
    void seg_init(int n_){
        n=1;
        while(n<n_){
            n*=2;
        }
        seg.assign(2*n-1,0);
    }
    void update(int k,long long a){
        k+=n-1;
        seg[k]=a;
        while(k>0){
            k=(k-1)/2;
            seg[k]=max(seg[2*k+1],seg[2*k+2]);
        }
    }
    long long get_max(int a,int b,int k=0,int l=0,int r=-1){//[a,b)
        if(r<0){
            return get_max(a,b,k,0,n);
        }
        if(r<=a||b<=l){
            return -INF;
        }
        if(a<=l&&r<=b){
            return seg[k];
        }
        else{
            long long maxl=get_max(a,b,2*k+1,l,(l+r)/2);
            long long maxr=get_max(a,b,2*k+2,(l+r)/2,r);
            return max(maxl,maxr);
        }
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,K;
    cin >> N >> K;
    vl A(N);
    SegmentTree_max st;
    st.seg_init(300001);
    rep(i,N){
        cin >> A[i];
    }
    rep(i,N){
        int x=st.get_max(max(0LL,A[i]-K),min(A[i]+K,300001LL)+1);
        x++;
        //cout << x << ' ';
        if(st.get_max(A[i],A[i]+1)<x){
            st.update(A[i],x);
        }
    }
    cout << st.get_max(0LL,300002LL);
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 13696
def main():
    n = int(input())
    d = [list(map(int, input().split())) for _ in range(n)]

    ans = 0
    for i in range(n):
        for j in range(n):
            if i == j:
                continue
            flag = True
            for k in range(n):
                if k == i or k == j:
                    continue
                if d[i][j] > d[i][k]+d[k][j]:
                    print(-1)
                    exit()
                elif d[i][j] == d[i][k]+d[k][j]:
                    flag = False
                else:
                    pass
            if flag:
                ans += d[i][j]
    #print(ans)
    print(ans//2)

if __name__ == '__main__':
    main()


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

int main(){
    int d,t,s;
    cin>>d>>t>>s;
    float x=float(d)/float(s),y=float(t);
    if(x>y){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main(){
    int N;
    cin >> N ;
    vector<pair<pair<string,int>,int> > data(N);
    for(int i = 0;i<N;i++){
        cin >> data[i].first.first >> data[i].first.second;
        data[i].first.second = -data[i].first.second;
        data[i].second = i+1;
    }
    sort(data.begin(),data.end());
    for(int i = 0;i<N;i++){
        cout << data[i].second <<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;
using P = pair<int,int>;

int main(){

  int N, M;
  cin >> N >> M;

  vector<P> student(N);
  vector<P> check(M);
  vector<int> ans(N);

  for (int i = 0; i < N; i++) {
    cin >> student[i].first >> student[i].second;
  }

  for (int i = 0; i < M; i++) {
    cin >> check[i].first >> check[i].second;
  }

  for (int i = 0; i < N; i++) {
    int p = 51;
    int num = 1e9;
    for (int j = 0; j < M; j++) {
      int dst = abs(student[i].first - check[j].first) + abs(student[i].second - check[j].second);

      // cout << "dst:" << dst << " num:" << num << " P:" << p << endl;

      if(dst < num){
        num = dst;
        p = j+1;
      }
      // cout << "dst:" << dst << " num:" << num << " P:" << p << endl;
      // cout << endl;

    }
    ans.at(i) = p;
  }

  for (int i = 0; i < N; i++) {
    cout << ans.at(i) << endl;
  }

  return 0;
}

Measured memory_bytes: 3608
N, W = map(int, input().split())

weight = [0] * N
value = [0] * N
for i in range(N):
    w, v = map(int, input().split())
    weight[i], value[i] = w, v

dp = [[0]*(W+1) for _ in range(N)]
for i in range(weight[0], W+1):
    dp[0][i] = value[0]

for i in range(1, N):
    for ws in range(W+1):
        if ws - weight[i] >= 0:
            dp[i][ws] = dp[i-1][ws - weight[i]] + value[i]
        dp[i][ws] = max(dp[i][ws], dp[i-1][ws])

print(dp[N-1][W])

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while (true) {
    int t, p, r;
    cin >> t >> p >> r;
    if (t + p + r == 0) return 0;
    
    vector<vector<int>> x(t, vector<int>(p));
    vector<vector<int>> ans(t, vector<int>(3)); // -AC数, ペナルティ数, チーム番号
    for (int i = 0; i < t; i++) ans.at(i).at(2) = i + 1;
    for (int i = 0; i < r; i++)  {
      int tid, pid, time;
      string message;
      cin >> tid >> pid >> time >> message;
      tid--;
      pid--;
      if (message == "CORRECT") {
        ans.at(tid).at(0)--;
        ans.at(tid).at(1) += time + x.at(tid).at(pid) * 1200;
      }
      else {
        x.at(tid).at(pid)++;
      }
    }
    
    sort(ans.begin(), ans.end());
    
    for (int i = 0; i < t; i++) {
      cout << ans.at(i).at(2) << " " << -ans.at(i).at(0) << " " << ans.at(i).at(1) << '\n';
    }
  }
}


Measured memory_bytes: 3192
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(|s| s.parse().ok().unwrap())
        .collect()
}

const MODULO: i64 = 1_000_000_000 + 7;
fn mod_pow(a: i64, n: i64, p: i64) -> i64 {
    if n == 0 {
        1
    } else if n % 2 == 0 {
        let x = mod_pow(a, n / 2, p);
        x * x % p
    } else {
        let x = mod_pow(a, n / 2, p);
        a * ((x * x) % p) % p
    }
}

fn combination(n: i64, r: i64, p: i64) -> i64 {
    let mut x = 1;
     for i in 0..r {
         x = x * (n - i) % p;
    }
    let mut y = 1;
    for i in 1..r+1 {
        y = y * i % p;
    }
    x * mod_pow(y, p - 2, p) % p
}

fn main() {
    let input = read_vec::<i64>();
    let n = input[0];
    let a = input[1];
    let b = input[2];

    let all = mod_pow(2, n, MODULO) - 1;

    let ans = ((all - combination(n, a, MODULO) + MODULO) % MODULO - combination(n, b, MODULO) + MODULO) % MODULO;


    println!("{}", ans);
}

Measured memory_bytes: 4476
from itertools import accumulate
N = int(input())
a = tuple(map(int,input().split()))
s = list(accumulate(a))
b = [0]*(N+1)
if N == 0 and a[0] > 1:
    print(-1)
    exit()
if a[0] == 0:
    b[0] = 1
ans = 1
flag = 0
for d in range(1,N+1):
    b[d] = b[d-1]-a[d]
    tmp = min(s[-1]-s[d],2*b[d-1]-a[d])
    if b[d] > tmp or tmp < 0:
        flag = 1
        break
    else:
        b[d] = tmp
if flag:
    print(-1)
else:
    print(s[-1]+sum(b))

Measured memory_bytes: 22264
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

/*
解説PDF見た.

消費税が 8% のとき A 円、消費税が 10% のとき B 円となる金額を直接求めなくても、
1 ≤ A ≤ B ≤ 100 の条件から、
最大でも考える必要のある金額は 1009 円であるため、
小さい方から計算していけばよいです。
*/

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

  int aTax, bTax;

  for (int i = 0; i < 1010; i++){
    aTax = i*0.08;
    bTax = i*0.10;
    if(aTax==a && bTax==b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>
#include<random>
#include<set>
 
#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
#define Sort(X) sort(X.begin(), X.end())
#define RSort(X, T) sort(X.begin(), X.end(), greater<T>())
//#define MOD 998244353
#define MAX 100000
 
typedef long long int ll;
typedef unsigned long long int ull;
 
using namespace std;
 
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll H, W, K;
	cin >> H >> W >> K;

	vector<vector<char>> S(H, vector<char>(W));
	rep(i, H) {
		rep(k, W) {
			cin >> S[i][k];
		}
	}

	vvl O(H, vl(W));

	ll bef = 0;
	ll cnt = 1;
	ll cntfin = 0;
	bool flgE = false;
	rrep(y, H) {
		rep(x, W) {
			if (S[y][x] == '#') {
				flgE = true;
				break;
			}
		}
		if (flgE) break;
		cntfin++;
	}

	rep(y, H-cntfin) {
		flgE = false;
		rep(x, W) {
			O[y][x] = cnt;
			if (S[y][x] == '#') {
				if (flgE) cnt++;
				flgE = true;
				O[y][x] = cnt;
			}
			rep(i, bef) {
				O[y - i - 1][x] = cnt;
			}
		}
		if (flgE) {
			bef = 0;
			cnt++;
		}
		else bef++;
	}

	rep(x, W) {
		rep(i, cntfin) {
			O[H - i - 1][x] = O[H-cntfin-1][x];
		}
	}


	rep(y, H) {
		rep(x, W) {
			cout << O[y][x] << " ";
		}
		cout << endl;
	}
	return 0;

}

Measured memory_bytes: 1536
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		int[][] field = new int[h][w];
		int hIdx = 0;
		int wIdx = 0;
		for (int i = 0; i < n; i++) {
			while (arr[i] > 0) {
				field[hIdx][wIdx] = i + 1;
				if (hIdx % 2 == 0) {
					if (wIdx == w - 1) {
						hIdx++;
					} else {
						wIdx++;
					}
				} else {
					if (wIdx == 0) {
						hIdx++;
					} else {
						wIdx--;
					}
				}
				arr[i]--;
			}
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (j != 0) {
					sb.append(" ");
				}
				sb.append(field[i][j]);
			}
			sb.append("\n");
		}
		System.out.print(sb);
	}
}


Measured memory_bytes: 31376
#include <iostream>

using namespace std;

int main(){
	int X = 0;
    cin >> X;
  	int coin500 = X / 500;
  	X %= 500;
  	int coin5 = X /5;
  	cout << coin500*1000 + coin5*5 << endl;
      
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<utility>
#include<climits>
#define MAX 1000000
#define pb push_back
#define f first
#define s second

using namespace std;

typedef pair<int, int> pii;
typedef map<int, int> mapint;

int32_t main(){
	string s;
	cin>>s;
	int ans = 0;
	for(int i=1; i<s.length(); i++){
		if(s[i]==s[i-1]){
			if(s[i]=='0') s[i]='1', ++ans;
			else s[i] = '0', ++ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 512