akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
print(S[:-8])


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

int main() {
 int N;
 cin >> N;
 
  for (int i =0; i < N; i++){
   string S;
   cin >> S;
   
    if( S != "Y" ){
     if( i<N-1 ){
     continue;
     }
     cout << "Three" << endl;
    }
   
    else if( S == "Y"){
     cout << "Four" << endl;
     break;
    }   
  } 
}

Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
// #include <boost/algorithm/string/replace.hpp>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define FOR(i, j, n) for (int i = j; i < n; i++)
#define OUT(s) cout << s << endl;
#define IN(a) cin >> a;
#define PACK(a, n)                                                             \
  for (int i = 0; i < n; i++)                                                  \
    cin >> a[i];
#define LIST(a, n)                                                             \
  for (int i = 0; i < n; i++)                                                  \
    cout << i << ": " << a[i] << endl;
#define PP(label, obj) cout << "[" << label << "] " << obj << endl;

int main() {
  int A, B;
  IN(A >> B);

  OUT(max(max(A + B, A - B), A * B));
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;//ハッシュテーブル用
using System.Linq;

class Program
{
    //Hashtable ht = new Hashtable();
    static List<int> s = new List<int>();
    static List<int>[] sl;
    static decimal result;
    static int N,K;
    //StringBuilder strresult= new StringBuilder("");//Append(str ○○)関数で文字を追加していく



    static void Main()
    {
        //Modular mo = new Modular(0);//素数で割った余りを出せで使う。()内が初期値。★使い方：Modular型で宣言すると、その時点でのその素数で割った余りを保持する変数になる（powべき乗、Fac累乗、nCr組み合わせも関数として存在）
        //Node<> no = new Node<>();//UnionFind★Find関数で根っこの値を返す（根っこの値が一緒なら同グループ）、Unite関数で二つの木をくっつける
        //Permutation<> pe = new Permutation<>();//配列＆リストを並べ替えた場合の全ケースを出力★All関数でリスト形式で返す。
        //Treap<> tr = new Treap<>();//平衡二分木★Insert()関数で挿入、FindIndex()関数で該当する大きさの物が入るべき配列番号を返す。
        //PriorityQueue<int,int> pr = new PriorityQueue<int,int>();//優先度付キュー★Add(key,value)で格納、Dequeue()で取りだし。keyが小さいものから取り出す。
 string tmp = Console.ReadLine();
for(int i=0;i<tmp.Length;i++){if(i%2==0){if(tmp[i]=='R' || tmp[i]=='U' || tmp[i]=='D'){}else{Console.WriteLine("No");return;}}else{if(tmp[i]=='L' || tmp[i]=='U' || tmp[i]=='D'){}else{Console.WriteLine("No");return;}}}
Console.WriteLine("Yes");return;
      //Console.WriteLine(result.ToString());
    }


    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }

    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
        N = int.Parse(tmp[0]);
        K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {
        sl = new List<int>[N];
        for (int i = 0; i < N; i++) {
            sl[i] = new List<int>();
            string[] tmp = Console.ReadLine().Split(' ');
            for (int j = 0; j < K; j++) {
                sl[i].Add(int.Parse(tmp[j]));
            }
        }

    }
}

Measured memory_bytes: 11092
#include<cstdio>
#include<vector>
#include<deque>
#include<utility>

using namespace std;


typedef vector<pair<int,int> > edge_t;
typedef unsigned int ui;


class vertex_t
{
	public:
	int m_id, m_is_passed;
	edge_t m_edge;
};


int main(void)
{
	vector<vertex_t> vertex;
	deque<int> result;
	int n, m, a, b;
	int c=1;

	while(scanf("%d%d", &n, &m)==2)
	{
		result.clear();
		vertex.clear();
		vertex.resize(n+1);
		for(int i=1;i<=n;i++)
		{
			vertex[i].m_id=i;
			vertex[i].m_is_passed=0;
		}
		for(int i=0;i<m;i++)
		{
			scanf("%d%d", &a, &b);
			vertex[a].m_edge.push_back(pair<int,int>(a, b));
			vertex[b].m_edge.push_back(pair<int,int>(b, a));
		}
		for(int i=1;i<=n;i++)
		{
			edge_t& edge=vertex[i].m_edge;
			if(edge.size()>=1)
			{
				c=i;
				break;
			}
		}

		for(int i=c;;)
		{
			ui j;
			edge_t& edge=vertex[i].m_edge;
			vertex[i].m_is_passed=1;
			result.push_front(i);
			for(j=0;j<edge.size();j++)
			{
				if(vertex[edge[j].second].m_is_passed==0)
				{
					i=edge[j].second;
					break;
				}
			}
			if(j>=edge.size()) break;
		}

		result.pop_back();
		for(int i=c;;)
		{
			ui j;
			edge_t& edge=vertex[i].m_edge;
			vertex[i].m_is_passed=1;
			result.push_back(i);
			for(j=0;j<edge.size();j++)
			{
				if(vertex[edge[j].second].m_is_passed==0)
				{
					i=edge[j].second;
					break;
				}
			}
			if(j>=edge.size()) break;
		}

		printf("%lu\n%d", result.size(), result[0]);
		for(ui i=1;i<result.size();i++)
		{
			printf(" %d", result[i]);
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 7424
// Tenshi ni Fureta yo!

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return *(cur == ed ? ed = buffer + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur = buffer : cur)++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

// END tpl.

const int MAXN = (int) 1e5;

int n, m;

vector<pii> adj[MAXN + 5];
int deg[MAXN + 5];

inline void input()
{
	n = read<int>(), m = read<int>();
	for(int i = 1; i <= m; ++i)
	{
		int u = read<int>(), v = read<int>();
		adj[u].emplace_back(v, i), ++deg[u];
		adj[v].emplace_back(u, i), ++deg[v];
	}
}

int vis[MAXN + 5], cut[MAXN + 5];

inline int dfs(int u, int id, int p)
{
	vis[u] = 1;
	for(auto it : adj[u]) if(it.snd != id)
	{
		int v = it.fst;
		if(v == p) return 1;
		if(!cut[v] && !vis[v] && dfs(v, it.snd, p)) return 1;
	}
	return 0;
}

inline void solve()
{
	for(int i = 1; i <= n; ++i) if(deg[i] % 2 == 1) { puts("No"); return; }

	int mx = *max_element(deg + 1, deg + n + 1);
	if(mx >= 6) puts("Yes");
	else if(mx <= 2) puts("No");
	else
	{
		static vector<int> nds;

		for(int i = 1; i <= n; ++i) if(deg[i] == 4) nds.push_back(i);

		if(SZ(nds) > 2) { puts("Yes"); return; }
		else if(SZ(nds) == 1) { puts("No"); return; }
		{
			cut[nds[1]] = 1;
			puts(dfs(nds[0], 0, nds[0]) ? "Yes" : "No");
		}
	}
}

int main()
{
#ifdef K_ON
	freopen("C.in", "r", stdin);
	freopen("C.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}




Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
const ll MOD=1000000007;

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if (a%2==0||b%2==0||c%2==0){
        cout << 0 << endl;
    }
    else {
        ll ans =min(min(a*b,b*c),c*a);
        cout << ans << endl;
    }
}

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

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
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 INF = 1LL << 60;
typedef pair<int, int> P;

int a, b, c;
int main() {
    cin >> a >> b >> c;
    if (a - b >= c) {
        cout << 0 << "\n";
    } else {
        cout << c - (a - b) << "\n";
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int a,b;

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

	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else if(a==b){
		printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<float.h>
using namespace std;

double pos[4][2];
int solve(){
    double a, b, c, d;
    a = (pos[0][1] - pos[2][1])*(pos[1][0] - pos[0][0]);
    a -= (pos[0][0] - pos[2][0])*(pos[1][1] - pos[0][1]);
    b = (pos[0][1] - pos[2][1])*(pos[3][0] - pos[0][0]);
    b -= (pos[0][0] - pos[2][0])*(pos[3][1] - pos[0][1]);
    c = (pos[1][1] - pos[3][1])*(pos[0][0] - pos[1][0]);
    c -= (pos[1][0] - pos[3][0])*(pos[0][1] - pos[1][1]);
    d = (pos[1][1] - pos[3][1])*(pos[2][0] - pos[1][0]);
    d -= (pos[1][0] - pos[3][0])*(pos[2][1] - pos[1][1]);
    if(a*b<=0 && c*d<=0){
        return true;
    }else{
        return false;
    }
}
int main(){
    int i, j;
    char comma;
    while(cin >> pos[0][0]){
        cin >> comma >> pos[0][1];
        for(i=1;i<4;i++){
            for(j=0;j<2;j++){
                cin >> comma >> pos[i][j];
            }
        }
        if(solve()){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
}

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

int main(){
    int X, Y;
    cin >> X >> Y;

    if(Y%2==1){
        cout << "No" << endl;
        return 0;
    }

    if(X*2 <= Y && Y <= X*4){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
const int N = 3e3 + 5;
const long long INF = 1e18;
const int mod = 1e9 + 7;//786433;//998244353;
const double Pi = acos(-1);
const int p = 510200;
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, w;
long long dp[100005];

signed main()
{
	Fastio();
	cin >> n >> w;
	for(int i = 1; i <= 100000; i++)
	{
		dp[i] = INF;
	}
	dp[0] = 0;
	for(int i = 1; i <= n; i++)
	{
		int v;
		long long ww;
		cin >> ww >> v;
		for(int j = 1000 * i; j >= v; j--)
		{
			dp[j] = min(dp[j], dp[j - v] + ww);
		}
	}
	int t = 0;
	for(int j = 0; j <= 100000; j++)
	{
		if(dp[j] <= w)
		{
			t = j;
		}
	}
	cout << t;
}

Measured memory_bytes: 1024
import sys
from collections import deque,Counter
from decimal import Decimal
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    t,x = SL()
    t = Decimal(t)
    x = Decimal(x)
    ans = t/x
    print(ans)
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 27136
#include<stdio.h>
int primecheck(int n)
{
  if(n==2) return 1;
  for(int i=2;i*i<=n;i++){
    if(n%i==0) return 0;
  }
  return 1;
}
int main(void)
{
  int x;
  scanf("%d",&x);
  while(primecheck(x)==0){
    x++;
  }
  printf("%d",x);
  return 0;
}

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

int main(){
	char ango[24*26][26],ss[300],sso[300];
	int i,j,k,n,a,b;
	i=0;
	for(a=1;a<26;a++){
		if(a%2==0 || a%13==0)continue;
		for(b=0;b<26;b++){
			for(j=0;j<26;j++){
				ango[i][(a*j+b)%26]=j;
			}
			++i;
		}
	}
	scanf(" %d ",&n);
	
	for(i=0;i<n;i++){
		memset(ss,0,sizeof(ss));
		fgets(ss,sizeof(ss),stdin);
		
		for(j=0;;j++){
			for(k=0;k<300;k++){
				if(ss[k]=='\0')break;
				if(ss[k]=='\n')ss[k]='\0';
				if('a'<=ss[k] && ss[k]<='z'){
					sso[k]='a'+ango[j][ss[k]-'a'];
					continue;
				}
				sso[k]=ss[k];
			}
			if(strstr(sso,"this")!=NULL || strstr(sso,"that")!=NULL)break;
		}
		
		printf("%s\n",sso);
	}
	return 0;
}

Measured memory_bytes: 0
solve (s_) 
    | f1 && f2 = "AMBIGUOUS"
    | f1 = "MMYY"
    | f2 = "YYMM"
    | otherwise = "NA"
    where
        s = take 4 s_ 
        check i_ = 0 < i && i < 13 where i = read i_
        f1 = check $ take 2 s
        f2 = check $ drop 2 s

main = interact solve


Measured memory_bytes: 508
#include"bits/stdc++.h"

using namespace std;

typedef long long ll;

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

	ll N;
	cin >> N;
	vector<ll>A(N);
	ll cnt = 0;

	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		if (A[i] < 0) {
			cnt++;
		}
	}

	vector<ll>B(N);
	ll ans = 0;
	ll mn = 1000000000;

	if (cnt % 2 == 1) {
		for (int i = 0; i < N; i++) {
			ll tmp = abs(A[i]);
			mn = min(mn, tmp);
		}
	}
	else {
		mn = 0;
	}

	for (int i = 0; i < N; i++)
	{
		ans += abs(A[i]);
	}

	cout << ans - (mn * 2)<< endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main() {
    int h,w;
    while(1){ cin >> h  >> w;
        if (h == 0 && w == 0) {break;}
        for(int i=0; i<h;i++ ){
            for(int j=0; j<w;j++){
                cout <<"#";
            }
            cout << endl;
            
        }
        cout << endl;
    }
}


Measured memory_bytes: 3092
n= int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

candy=[a,b]
n_i=0
n_j=0

score=0
for i in range(n):
    tmp_a = a[:i+1]
    tmp_b = b[i:]
    tmp_score = sum(tmp_a) + sum(tmp_b)

    score = max(score,tmp_score)


print(score)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define Mod 998244353
using namespace std;
using lint = long long;
using vi = vector<lint>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

// cout << fixed << setprecision(12)

int main(){
  lint N;
  cin >> N;
  
  vi A(N);
  vi cnt(100010, 0);
  for(lint i=0; i<N; i++){
    cin >> A[i];
    cnt[A[i]]++;
  }
  
  lint ans = 0;
  for(lint i=0; i<100010; i++){
    ans += i * cnt[i];
  }
  
  lint Q;
  cin >> Q;
  
  for(lint i=0; i<Q; i++){
    lint B,C;
    cin >> B >> C;
    
    ans -= B * cnt[B];
    ans += C * cnt[B];
    
    cout << ans << endl;
    
    cnt[C] += cnt[B];
    cnt[B] = 0;
  }
}

  
  
  
  


Measured memory_bytes: 4848
#include<iostream>
using namespace std;
int gcd(int x,int y){
  if(x<y) swap(x,y);
  int b;
  while(x%y!=0){
    b=x;
    x=y;
    y=b%y;
  }
  return y;
}
int main(){
  int x,y;
  cin >> x >> y;
  cout << gcd(x,y) <<endl;
  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

    int tmp = 2;
    ll ans = a[0] - 1;

    for (int i = 1; i < n; i++) {
        if (a[i] < tmp) continue;
        if (a[i] == tmp) tmp += 1;
        else {
            ans += (a[i] - 1) / tmp;
        }
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 640
import heapq
INF = 10**10

def dijkstra(n, edges, s):
    """
    input
        n : 頂点数
        edges : リスト(始点, 終点, コスト)
        s : 始点
    output
        d : 始点からの最短距離
    """
    d = [INF] * n
    used = [False] * n
    d[s] = 0
    used[s] = True
    edgelist = []
    # 初期のやつ
    for v, c in edges[s]:
        # print("v{},c{}".format(v,c))
        # コストを前にしてpushしておく(そこから最小値を取り出すので)
        heapq.heappush(edgelist, (c, v))
    # 空になるまで
    while len(edgelist):
        # コスト最小値を取り出す
        c_min, v_min = heapq.heappop(edgelist)
        # そのエッジがすでに確定していたら終わり
        if used[v_min]:
            continue
        # 確定していなければ、そこから派生するエッジをコスト付与して与える
        d[v_min] = c_min
        used[v_min] = True
        for v, c in edges[v_min]:
            if not used[v]:
                heapq.heappush(edgelist, (c+c_min, v))
    return d
h,w = map(int, input().split())
cij = []
for i in range(10):
    row = list(map(int, input().split()))
    cij.append(row)
A = []
for i in range(h):
    row = list(map(int, input().split()))
    A.append(row)
edges = [[] for i in range(10)]
for i in range(10):
    for j in range(10):
        if i != j:
            edges[i].append((j, cij[i][j]))

ds = []
for i in range(10):
    costs = dijkstra(10,edges,i)
    ds.append(costs[1])
ans = 0
for r in A:
    for e in r:
        if e == -1: continue
        ans += ds[e]
print(ans)

Measured memory_bytes: 9568
import sys
N = int(input())
for h in range(1,3501):
    for n in range(1,3501):
        if  4*n*h-N*(n+h) > 0:
            if N*h*n % (4*n*h-N*(n+h)) == 0:
                print(n,h,int(N*h*n // (4*n*h-N*(n+h))))
                sys.exit()

Measured memory_bytes: 40740
<?php
	fscanf( STDIN, "%d", $n );
	$i = array( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
	$j = array( $i, $i, $i );
	$of = array( $j, $j, $j, $j );
	for( $i=0; $i<$n; $i++ ) {
		fscanf( STDIN, "%d%d%d%d", $b, $f, $r, $v );
		$of[$b-1][$f-1][$r-1] += $v;
	}
	
	$output = array();
	for( $i=0; $i<4; $i++ ) {
		for( $j=0; $j<3; $j++ ) {
			$row = '';
			for( $k=0; $k<10; $k++ ) {
				$row .= ( ' '.$of[$i][$j][$k] );
			}
			array_push( $output, $row );
		}
		if( 3 != $i ) array_push( $output, '####################' );
	}
	print implode( PHP_EOL, $output );
?>

Measured memory_bytes: 6616
#include <iostream>
#include <vector>
#include <algorithm>
#include <memory>

typedef std::unique_ptr<long long[]> smart_array;

long long knapsack(std::pair<long long, long long>* pairs, smart_array* temp, int n, int w, int index = 0) {
	if (index >= n || w <= 0)
		return 0;

	if (temp[index][w] == 0) {
		long long tmp = 0;
		if (pairs[index].first <= w)
		tmp = pairs[index].second + knapsack(pairs, temp, n, w - pairs[index].first, index + 1);

		long long tmp2 = knapsack(pairs, temp, n, w, index + 1);
		
		temp[index][w] = std::max(tmp, tmp2);
	}
	return temp[index][w];
}

int main() {
	using std::cin; using std::cout; using std::endl;
	int n = 0, w = 0; cin >> n >> w;
	std::pair<long long, long long>* pairs = new std::pair<long long, long long>[n] {};

	for (size_t i = 0; i < n; i++)
		cin >> pairs[i].first >> pairs[i].second;

	auto tempArr = std::unique_ptr<smart_array[]>(new smart_array[n + 1]{});
	for (size_t i = 0; i <= n; i++)
		tempArr[i] = smart_array(new long long[w + 1]{});

	cout << knapsack(pairs, tempArr.get(), n, w) << endl;

	delete[] pairs;

	return 0;
}

Measured memory_bytes: 79488
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    string s;
    int k;
    cin >> s >> k;
    forn(i, s.size()) {
        if (s[i] == 'a') continue;
        int d = 26 - (s[i] - 'a');
        if (d <= k) s[i] = 'a', k -= d;
    }
    k %= 26;
    s.back() = 'a' + (s.back() - 'a' + k) % 26;
    cout << s << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

int main(){
  string S,T;
  cin >> S;
  
  reverse(S.begin(), S.end());
  
  string dream = "maerd";
  string dreamer = "remaerd";
  string erase = "esare";
  string eraser = "resare";

  
  while(T != S){
    int countall = 0;
    int count1 = 0;
  for(int i = T.size(); i<T.size()+dream.size(); i++){
    if(S[i] != dream[i-T.size()]){
      count1++;
    }
  }
  if(count1 == 0) T += dream;
  if(count1) countall++;
  if(T == S) {
    cout << "YES" << endl;
    break;
  }

    
  
    int count3 = 0;
  for(int i = T.size(); i<T.size()+erase.size(); i++){
    if(S[i] != erase[i-T.size()]){
      count3++;
    }
  }
  if(count3 == 0) T += erase;
  if(count3) countall++;
  if(T == S){
    cout << "YES" << endl;
    break;
  }
  
    int count4 = 0;
  for(int i = T.size(); i<T.size()+eraser.size(); i++){
    if(S[i] != eraser[i-T.size()]){
      count4++;
    }
  }
  if(count4 == 0) T += eraser;
  if(count4) countall++;
  if(T == S){
    cout << "YES" << endl;
    break;
  }
    
    int count2 = 0;
  for(int i = T.size(); i<T.size()+dreamer.size(); i++){
    if(S[i] != dreamer[i-T.size()]){
      count2++;
    }
  }
  if(count2 == 0) T += dreamer;
  if(count2) countall++;
  if(T == S){
    cout << "YES" << endl;
    break;
  }
  
  if(countall >= 4){
    cout << "NO" << endl;
    break;
  }
  }
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	int a,b,c;
	cin>>a>>b>>c;
	cout<<(c>=a&&c<=a+b?"YES":"NO");
	re 0;
}

Measured memory_bytes: 3660
//Author: AnandRaj anand873
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test(t) int t;cin>>t;while(t--)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define rforn(i,b,a) for(int i=b-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl;

const int MOD = 1e9+7,MAX = 1e6+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
//////////////////Sieve////////////////////

int main()
{
	fastio
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	string p;
	for(int i=0;i<n;i++)
	{
		p+=s[i];
		p+=t[i];
	}
	cout<<p<<endl;
}


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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    sort(a.rbegin(), a.rend());
    int dif = 0;
    for (int i = 0; i < n; i++) dif += i % 2 ? -a[i] : a[i];
    cout << dif << endl;
    return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)

ans = [0] * N

cnt = 0
for i, s in enumerate(S):
    if s == 'R':
        cnt += 1
    else:
        ans[i] += cnt // 2
        ans[i - 1] += (cnt + 1) // 2
        cnt = 0

cnt = 0
ans = ans[::-1]

for i, s in enumerate(S[::-1]):
    if s == 'L':
        cnt += 1
    else:
        ans[i] += cnt // 2
        ans[i - 1] += (cnt + 1) // 2
        cnt = 0

print(*ans[::-1], sep=' ')


Measured memory_bytes: 6508
# 2020/09/19
# AtCoder Beginner Contest 179 - B

# Input
n = int(input())
ans = 'No'
cnt = 0

for i in range(n):
    d1, d2 = map(int,input().split())
    if d1 == d2:
        cnt = cnt + 1
        if cnt >= 3:
            ans = 'Yes'
            break
    else:
        cnt = 0

# Output
print(ans)


Measured memory_bytes: 9160
'use strict'
function Main(input) {
    let num = input.trim();
  	let ans = 1;
    if( num % 2 ){
    	ans = Math.ceil(num/2)/num;
    }else {
        ans = 1/2;
    }
  	console.log(ans);
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21192
//
// Created by hide on 2020/05/15.
//

//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード(アルファベット順,bits/stdc++.hは使わない派閥)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


int main(){
    ll N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i,N){
        cin >> A[i];
    }

    if(K>=N)
        cout << 1 << endl;
    else
        cout << ceil(float(N-1)/(K-1)) << endl;

}


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

int main() {
	int a, b;
	cin >> a >> b;
	if (a <= 0 && 0 <= b)cout << "Zero" << endl;
	else if (0 <= a)cout << "Positive" << endl;
	else if (abs(a - b) % 2)cout << "Positive"<<endl;
	else cout << "Negative" << endl;
}

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

using namespace std;

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

int main(){
    int N,M;
    cin>>N>>M;
    int A[N];
    double total=0;
    rep(i,N){
        cin>>A[i];
        total+=A[i];
    }
    double limit=total/4./M;
    int ko=0;
    rep(i,N){
        if(A[i]>=limit){
            ko++;
            if(ko>=M){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
  
int main(){
  int n;
  ll x, a[100005] = {}, sum = 0;
  cin >> n >> x;
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n - 1; i++){
    if(a[i] + a[i+1] > x){
      sum += a[i] + a[i+1] - x;
      a[i+1] -= a[i] + a[i+1] - x;
      if(a[i+1] < 0) a[i+1] = 0;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <array>
#include <map>
#include <set>

using namespace std;


int main()
{
    int64_t x, y;
    cin >> x >> y;
    int count = 1;
    while (x <= y)
    {
        count++;
        x *= 2;
    }
    cout << (count - 1) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int w[N];
  for(int i=0;i<N;i++) cin >> w[i];

  int sum[N + 1];
  sum[0] = 0;
  for(int i = 1; i <= N; i++){
    sum[i] = sum[i - 1] + w[i - 1];
  }

  int ans = 1000000000;
  for(int i = 0; i <= N; i++){
    ans = min(ans, abs(sum[i] -  (sum[N] - sum[i])));
  }

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


Measured memory_bytes: 256
/* 0-1 knapsack problem (DP) */

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

using namespace std;

int main()
{
	vector<bool> era(1000000,true);
	era[0]=false;
	for(int i=2;i<1000;i++){
		if(era[i])	for(int j=i*i;j<1000000;j+=i)	era[j]=false;
	}

	int menu[30];
	static bool knap[1000001];
	for(int n,bud;cin>>n>>bud,n;){
		for(int i=0;i<n;i++)	cin>>menu[i];

		knap[0]=true;
		for(int i=1;i<=bud;i++)	knap[i]=false;
		for(int i=0;i<n;i++){
			for(int j=0;j<bud;j++){
				if(knap[j] && j+menu[i]<=bud)
					knap[j+menu[i]]=true;
			}
		}

		bool b=false;
		for(int i=bud;i>=0;i--){
			if(knap[i] && era[i]){
				cout<<i<<endl;
				b=true;
				break;
			}
		}
		if(!b)	cout<<"NA"<<endl;
	}

	return 0;
}

Measured memory_bytes: 2004
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;

int main() {
    ll h; cin >> h;
    ll ans = 0; ll cnt = 1;
    while (h) {
        ans += cnt;
        cnt = 2 * cnt;
        h = h / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#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 REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

signed main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;

	int a, z;
	REP(i, s.size()){
		if(s[i] == 'A'){
			a = i;
			break;
		}
	}
	for(int j = s.size()-1;j >= 0;j--){
		if(s[j] == 'Z'){
			z = j;
			break;
		}
	}
	cout << z - a + 1 << endl;
	rtn 0;
}

Measured memory_bytes: 720
using System;

namespace abc114_d
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			int[] arr = new int[25];
			int[] prime = new int[] { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
			for (int i = 2; i <= n; i++)
			{
				int x = i;
				for (int j = 0; j < 25; j++)
				{
					while (x % prime[j] == 0) { arr[j]++; x /= prime[j]; }
				}
			}
			int ret = 0;
			for (int i = 0; i < 25; i++)
			{
				for (int j = i + 1; j < 25; j++)
				{
					for (int k = 0; k < 25; k++)
					{
						if (i == k || j == k) continue;
						if (arr[i] >= 4 && arr[j] >= 4 && arr[k] >= 2)
							ret++;
					}
				}
			}
			for (int i = 0; i < 25; i++)
			{
				for (int j = 0; j < 25; j++)
				{
					if (i == j) continue;
					if (arr[i] >= 4 && arr[j] >= 14) ret++;
					if (arr[i] >= 2 && arr[j] >= 24) ret++;
				}
			}
			for (int i = 0; i < 25; i++) if (arr[i] >= 74) ret++;
			Console.WriteLine(ret);
		}
	}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll q,h,s,d;
  cin>>q>>h>>s>>d;
  ll n;
  cin>>n;
  ll ans=0;
  while(n>=2){
    ans+=min(q*8,min(h*4,min(s*2,d)));
    n-=2;
  }
  while(n>0){
    ans+=min(q*4,min(h*2,s));
    n-=1;
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 384
"use strict";

/**
 * @see https://practice.contest.atcoder.jp/tasks/practice_1
 * @param  {string} input
 * @returns {string}
 */
var main = function(input) {
    const digits = (n) => {
        return n.toString()
            .split("")
            .reduce((a, b) => a + parseInt(b), 0);
    }

    const params = input.split(" ").map(x => parseInt(x));
    const N = params[0];
    const A = params[1];
    const B = params[2];

    return [...Array(N).keys()]
        .map(x => x + 1)
        .filter(x => {
            const d = digits(x);
            return d >= A && d <= B;
        }).reduce((a, b) => a + b, 0);
};

const output = main(require("fs").readFileSync("/dev/stdin", "utf8"));
console.log(output); // console.log outputs with trailing new line!


Measured memory_bytes: 13924
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lf long double
#define vi vector<int>
#define vl vector<long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define in insert
#define all(x) x.begin(),x.end()
#define zapp ios::sync_with_stdio(false);cin.tie(0)
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}
ll power(ll x, ll y) {if (y < 0) return 1; ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll inv(ll x) {return power(x, MOD - 2);}
const int MAXN = 1e5 + 5;
//const bool is_in = container.find(element) != container.end();
int main()
{
	zapp;
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll sum = 0;
	sum += min(k, a);
	k -= min(k, a);
	k -= min(b, k);
	sum -= k * (1);
	cout << sum;
	return 0;
}



Measured memory_bytes: 3616
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n, k = LI()
    a = LI()
    for i in range(k):
        bit = [0] * (n+1)
        for j in range(n):
            bit[max(0, j - a[j])] += 1
            bit[min(n, j + a[j] + 1)] -= 1
        f = 0
        bit = list(itertools.accumulate(bit))
        for j in range(n):
            a[j] = bit[j]
            if a[j] < n:
                f = 1
        if f:
            continue
        break
    print(*a)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 176792
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
ll a[300100];
ll b[300100];
ll c[300100];
int main(){
	scanf("%d",&N);
	for(int i=0;i<3*N;i++){
		scanf("%lld",&a[i]);
	}
	priority_queue<ll,vector<ll>,greater<ll> > q;
	ll sum = 0ll;
	for(int i=0;i<N;i++){
		q.push(a[i]);
		sum += a[i];
	}
	b[N-1]=sum;
	for(int i=N;i<3*N;i++){
		if(q.top()<a[i]){
			sum -= q.top();
			q.pop();
			sum += a[i];
			q.push(a[i]);
		}
		b[i]=sum;
	}
	priority_queue<ll> pq;
	sum = 0ll;
	for(int i=3*N-1;i>=2*N;i--){
		pq.push(a[i]);
		sum += a[i];
	}
	c[2*N]=sum;
	for(int i=2*N-1;i>=0;i--){
		if(pq.top()>a[i]){
			sum -= pq.top();
			pq.pop();
			sum += a[i];
			pq.push(a[i]);
		}
		c[i]=sum;
	}
	ll ans = -LLINF;
	for(int i=N-1;i<2*N;i++){
		ans = max(ans,b[i]-c[i+1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8436
n,m = map(int, input().split())
py=[]
for i in range(m):
    p,y=map(int, input().split())
    py.append([i,p,y])
#py = [list(map(int, input().split())) for i in range(m)]
py.sort(key=lambda x:(x[1],x[2]))
sorted_py = py
num = 1
prev_p = str(sorted_py[0][1])
for i in range(m):
    p = str(sorted_py[i][1])
    if prev_p != p:
        num = 1
        prev_p = p
    str_num = str(num)
    if len(p)!=6:
        p = '0'*(6-len(p))+p
    if len(str_num)!=6:
        str_num = '0'*(6-len(str_num))+str_num
    sorted_py[i].append(p+str_num)
    num+=1
sorted_py.sort()
for i in range(m):
    print(sorted_py[i][3])

Measured memory_bytes: 34460
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define debug(x) cout<<x
#define pb push_back
#include<string.h>
int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);                    
    cout.tie(NULL);
    ll T=1;
    //cin>>T;
    while(T--){
    	ll l,r,d,cnt=0;
    	cin>>l>>r>>d;
    	for(int i=(l+d*((bool)(l%d))-(l%d));i<=r;i+=d) cnt++;
    	cout<<cnt;
    }
   	return 0; 
}

Measured memory_bytes: 3640
#そのまま実行したらTLE.２回目でOK．アイデア次第！

n=int(input())
l = [int(input()) for _ in [0] * n]
m = sorted(l)
a = m[-1] #リストの最大値
b = m[-2] #２番目に大きい値、最大値と重複していてもヒットする
for i in range(n):
    if l[i] == a:
        print(b)
    else:
        print(a)


Measured memory_bytes: 14640
#include <stdio.h>
#define N 300
int main(void)
{
  int i,n,a[N]={},ct=0,flag=1;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf("%d",a+i);
  }
  while(flag==1)
  {
    for(i=0;i<n;i++)
    {
      if(a[i]%2!=0)
      {
        flag=0;
        break;
      }
      else
      {
        a[i]=a[i]/2;
      }
    }
    if(flag==0)
    {
      break;
    }
    ct++;
  }
  printf("%d\n",ct);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include <sstream>
#include <iostream>
#include <cstdlib>

using namespace std;

#define BUF_SIZE 1024
#define ARRAY_SIZE 100


void selectionSort(int array[],int n,int& change_count)
{
	int min;
	for(int i = 0; i < n-1; i++){
		min = i;	//?????????
		for(int j = i+1; j < n; j++){
			if(array[j] < array[min]){
				min = j;
			}
		}
		if(i != min){
			swap(array[i],array[min]);
			change_count++;
		}
	}

}

int main(){

	char buf[BUF_SIZE];
	int n = atoi(fgets(buf,BUF_SIZE,stdin));
	int array[ARRAY_SIZE];
	int change_count = 0;

	for(int i = 0; i < n; i++){
		cin >> array[i];
	}

	selectionSort(array,n,change_count);

	for(int i = 0; i < n; i++){
		if(i != n-1){
			printf("%d ",array[i]);
		}else{
			printf("%d\n",array[i]);
		}
	}
	printf("%d\n",change_count);
}



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

int main(){
  string S;
  cin >> S;
  int L=S.size();
  int Ans1=0, Ans2=0;
  for(int i=0; i<L; i++){
    if(i%2==0){
      if(S.at(i)=='0'){
        Ans1++;
      }
      else{
        Ans2++;
      }
    }
    else{
      if(S.at(i)=='1'){
        Ans1++;
      }
      else{
        Ans2++;
      }
    }
  }
  cout << min(Ans1, Ans2) << endl;
}

Measured memory_bytes: 512
import sys
import math
import numpy as np
import copy

def main():
    n, m, nx, ny = map(int, input().split())
    x = [int(t) for t in input().split()]
    y = [int(t) for t in input().split()]
    x.sort()
    y.sort()
    if x[-1] < y[0] and y[0] > nx and x[-1] < ny:
        print("No War")
    else:
        print("War")

    return 0

if __name__ == '__main__':
    sys.exit(main())

Measured memory_bytes: 12488
/**
*    author:  yuya1234
*    created: 26.06.2020 16:37:44
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

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

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

    int n;
    cin>>n;

    int a[100010];
    REP(i,n)cin>>a[i+1];

    int cnt=0,idx=1,ans=-1;
    REP(i,n)
    {
        idx=a[idx];
        cnt++;
        if(idx==2)
        {
            ans=cnt;
            break;
        }
    } 

    cout<<ans<<endl;

    return 0;
}

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

int mod=1e9+7;
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

   int n;
   cin>>n;
   int a[n];
   int cnt=0;
   int mn=1e9;
   for(int i=0;i<n;i++)
   {
      cin>>a[i];
      if(a[i]<mn)
      {
         cnt++;
         mn=a[i];
      }
   }
   cout<<cnt;
// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 1792
# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-


def main():
    N = int(input())
    S, T = map(list, input().split())
    result = ''
    for s, t in zip(S, T):
        result += s + t
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		String str;
		Scanner scan = new Scanner(System.in);
		str = scan.next();
		String out = "";
		for(int i = 0; i < str.length(); i++) {
			out += "x";
		}
		System.out.println(out);
		scan.close();
	}

}


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

using LL = long long;

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

    string A="";
    for(int i=0; i<b; i++) A += to_string(a);
    string B="";
    for(int i=0; i<a; i++) B+= to_string(b);
    
    if(A<B){
        cout<<A<<endl;
    }else{
        cout<<B<<endl;
    }

    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    int ca = 0;
    int cb = 0;
    for(int i = 0; i < S.size(); ++i){
        if(S[i] == 'A') ca++;
        else cb++;
    }
    if(ca && cb) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {-1,0,1,0}, dy[] = {0,-1,0,1};

bool used[105][105];

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> f(h);
    rep(i, h) cin >> f[i];
    deque<P> deq;
    deq.push_back(P(0,0));
    vector<vector<int>> dist(h, vector<int> (w, INF));
    dist[0][0] = 0;
    while (deq.size()) {
        int i = deq.front().first;
        int j = deq.front().second;
        deq.pop_front();
        if (used[i][j]) continue;
        used[i][j] = true;
        rep(v,4) {
            if (v < 2) continue;
            int ni = i + dx[v], nj = j + dy[v];
            if (ni < 0 || nj < 0 || ni >= h || nj >= w) continue;
            int c = 0;
            if (f[ni][nj] != f[i][j]) c = 1;
            int nd = dist[i][j] + c;
            if (dist[ni][nj] <= nd) continue;
            dist[ni][nj] = nd;
            if (c == 0) deq.emplace_front(ni,nj);
            else deq.emplace_back(ni,nj);
        }
    }
    int ans = dist[h-1][w-1];
    if (f[0][0] == '#') ans++;
    if (f[h-1][w-1] == '#') ans++;
    ans = (ans + 1) / 2;
    cout << ans << endl;
}

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

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

using namespace std;
using ll=long long;

const int INF = 100000;

int main() {
    ll A, B;
    cin >> A >> B;

    for (int i = 1; i < 1100; ++i) {
        if (int(i * 0.08) == A && int(i * 0.1) == B) {
            cout << i;
            return 0;
        }
    }
    cout << -1;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define For(i,a,b) for (int i=a;i<=b;i++)
#define Rep(i,a,b) for (int i=b;i>=a;i--)
using namespace std;
inline ll read()
{
    ll 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*10+ch-'0',ch=getchar();
    return x*f;
}
ll a[200200];
int main()
{
	ll n=read();
	For(i,1,n)
	{
		a[i]=read();
		a[i]+=a[i-1];
	}
	ll ans=1e18;
	For(i,1,n-1)ans=min(ans,abs(a[i]-a[n]+a[i]));
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int main(){
    fast_io

    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    for(int i=0;i<n;i++){
        int  cnt=0;
        for(char c = 'a';c<='z';c++){
            bool left=false;
            bool right = false;
            
            for(int j=0;j<i;j++){
                if(s[j]==c) left=true;
            }
            for(int j=i;j<n;j++){
                if(s[j] == c) right=true;
            }
            if(left&&right) cnt++;
        }
        ans=max(ans, cnt);
    }
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 256