akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin - 1; end <= i; i--)		// repeat reverse

#endif


int main(void)
{
	ll a, b; cin >> a >> b;
	string s; cin >> s;
	bool ans = true;

	rep(i, 0, a)
	{
		if (s[i] < '0' || '9' < s[i])
			ans = false;
	}
	if (s[a] != '-')
		ans = false;
	rep(i, a + 1, a+b+1)
	{
		if (s[i] < '0' || '9' < s[i])
			ans = false;
	}

	if (ans)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}


Measured memory_bytes: 256
import sys
import io


def run(input: io.TextIOBase, output: io.TextIOBase):
    x0 = input.readline()
    x1 = input.readline()
    x2 = input.readline()
    output.write(x0[0] + x1[1] + x2[2] + '\n')


if __name__ == '__main__':
    run(sys.stdin, sys.stdout)

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

int main() {
	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"a < b"<<endl;
      }else if(a>b){
		cout<<"a > b"<<endl;
	  } else {
		cout<<"a == b"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3108
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		int sysoutResult = 0;
		for(int i = 0; i < str.length(); i++){
				if(str.charAt(i) == '+'){
					sysoutResult += 1;
				}
				if(str.charAt(i) == '-'){
					sysoutResult -= 1;
				}
		}
		System.out.println(sysoutResult);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

ll a,b;

int main(){
	cin>>a>>b;
	int cntp=0;
	int cntn=0;
	int ans=0;
	if(a>0 && b>0)ans=1;
	else{
		if(a<=0 && b>=0)ans=0;
		else if(a<0 && b<0){
			if((b-a+1)%2==0)ans=1;
			else ans=-1;
		}
	}
	if(ans==0)cout<<"Zero"<<endl;
	else if(ans==1)cout<<"Positive"<<endl;
	else if(ans==-1)cout<<"Negative"<<endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	s := strings.Split(nextLine(), "")
	if "B" == s[1] {
		fmt.Println("ARC")
	} else {
		fmt.Printf("ABC")
	}
}


Measured memory_bytes: 1772
#include <iostream>
#include <string>
using namespace std;
int main(){
  int n, m, d;
  cin >> n >> m >> d;
  if(d==0)printf("%.10f\n",1.0/n*(m-1));
  else printf("%.10f\n",2.0*(n-d)/n/n*(m-1));
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"

int main(int argc, char const *argv[]) {

  int N, x;
  std::cin >> N>>x;

  std::vector<int> a(N);
  for (size_t i = 0; i < N; i++) {
    std::cin >> a[i];
  }

  std::sort(a.begin(), a.end()) ;

  // for (size_t i = 0; i < N; i++) {
  //   std::cout << a[i] << '\n';
  // }

  int ans = 0;

  long long ac[N+1];
  ac[0] = 0;

  for (size_t i = 0; i < N; i++) {
    // std::cout << a[i] << '\n';
    ac[i+1] = ac[i] + a[i];
    if (ac[i+1] <= x) {
      ans = i + 1;
    }
  }

  if (ans == N && x > ac[N] ) {
    // std::cout << "delim" << '\n';
    ans += -1;
  }
  std::cout << ans << '\n';
  return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int k, x;
    cin >> k >> x;
    if(k * 500 >= x)    cout << "Yes\n";
    else    cout << "No\n";
}

Measured memory_bytes: 256
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
	var N = nextInt();
	var list = {}
	for(var i = 1; i <= 9; i++){
		for(var j = 1; j <= 9; j++){
			list[i.toString() + ":" + j.toString()] = 0;
		}
	}
	for(var i = 1; i <= N; i++){
		var index = i.toString();
		var L = index[0];
		var R = index[index.length - 1];
		if(L == "0" || R == "0"){
			continue;
		}
		list[L + ":" + R]++;
		
	}
	var output = 0;
	for(var i = 1; i <= 9; i++){
		for(var j = 1; j <= 9; j++){
			var LR = i.toString() + ":" + j.toString();
			var RL = j.toString() + ":" + i.toString();
			output += list[LR] * list[RL];
		}
	}
	myout(output);
}


Measured memory_bytes: 30652
// C - XYZ Triplets
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n; cin>>n;
	vector<int> f(n);
	for(int x=1; x*x<n; ++x)
		for(int y=1; y*y<n; ++y)
			for(int z=1; z*z<n; ++z){
				int k = x*x + y*y + z*z + x*y + y*z + z*x;
				if(1<=k && k<=n) f[k]++;
			}
	for(int i=1; i<=n; ++i) cout<< f[i] <<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long 

using namespace std;
const int somod = 1e9 + 7;
const int maxn = 1e6 + 7;
int n, dp[maxn];
void Add(int &a, int b)
{
    a += b;
    if(a >= somod) a -= somod;
    if(a < 0) a += somod;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin);
    cin >> n;
    dp[1] = n;
    dp[0] = 1;
    int sum = 0;
    for(int i = 2; i <= n; i++)
    {
        dp[i] = (dp[i - 1] + (n - 1) * (n - 1) + sum + (n - i + 1)) % somod;

        Add(sum, dp[i - 2]);
    }
    cout << dp[n];
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=1e9+7;
map<int,int>f;
int solve(int n)
{
	if(f[n])
	return f[n];
	return f[n]=(solve(n/2)+solve((n-1)/2)+solve((n-2)/2))%maxn;
}
signed main()
{
	f[0]=1,f[1]=2;
	int n;
	cin>>n;
	cout<<solve(n)%maxn;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,bool> mp;
int a[4][4];
bool vis[4][4];
int main(){
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
			mp[a[i][j]]=1;
		}
	}
	int n;
	cin>>n;
	bool flag=0;
	for(int i=0;i<n;i++){
		int b;
		cin>>b;
		if(mp[b]){
			for(int j=0;j<3;j++){
				for(int k=0;k<3;k++){
					if(a[j][k]==b){
						vis[j][k]=1;
					}
				}
			}
		}
	}
	if(vis[0][0]&&vis[0][1]&&vis[0][2])flag=1;
	if(vis[1][0]&&vis[1][1]&&vis[1][2])flag=1;
	if(vis[2][0]&&vis[2][1]&&vis[2][2])flag=1;
	if(vis[0][1]&&vis[1][1]&&vis[2][1])flag=1;
	if(vis[0][2]&&vis[1][2]&&vis[2][2])flag=1;
	if(vis[0][0]&&vis[1][0]&&vis[2][0])flag=1;
	if(vis[0][0]&&vis[1][1]&&vis[2][2])flag=1;
	if(vis[0][2]&&vis[1][1]&&vis[2][0])flag=1;
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; const ll MOD = 1000000007;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

//---------------------------------------------------------------------------------------------------
void _main() {
    string S;  cin >> S;
    ll MOD = 2019;
    reverse(all(S));
    map<ll, ll> mp;
    mp[0] = 1;
    ll now = 0, ten = 1;
    fore(e, S) {
        now = (now + ( e - '0') * ten) % MOD;
        ten *= 10;
        ten %= 2019;
        mp[now]++;
    }
    ll ans = 0;
    fore(e, mp) {
        ans += e.second * (e.second - 1) /2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3756
import sys 
n = int(input())
arr = input()
ans = 1
arr = list(map(int,arr.split(' ')))
arr.sort()
for i in range(n):
    t = arr[i]
    ans *= t
    if (ans > 1000000000000000000):
        print(-1)
        sys.exit()
print(ans)


Measured memory_bytes: 23560
/* package codechef; // don't place package name! */

import java.util.*;

public class Main {
    
    static int n;
    static int[] nums;
    
	public static void main (String[] args) throws java.lang.Exception {
	    Scanner in = new Scanner(System.in);
	    String s = in.next();
	    n = s.length();
	    nums = new int[n];
	    
	    for (int i = 0; i < n; i++) {
	        nums[i] = new Integer(s.substring(i, i + 1));
	    }
	    
	    long answer = 0;
	    for (int i = 0; i < (1 << (n - 1)); i++) {
	        answer += solve(i);
	    }
	    
	    System.out.println(answer);
	}
	
	public static long solve(int a) {
	    long sofar = 0;
	    long returnv = 0;
	    for (int i = 0; i < n; i++) {
	       // System.out.printf("%d%c", nums[i], (a & (1 << i)) > 0 ? '+' : ' ');

            sofar *= 10;
            sofar += nums[i];
	        

	        if ((a & (1 << i)) > 0) {
	            returnv += sofar;
	            sofar = 0;
	        } else {
	           // sofar *= 10;
	           // sofar += nums[i];
	        }
	    }
	    returnv += sofar;
	   // System.out.printf(": returnv: %d\n", returnv);
	    return returnv;
	}
}


Measured memory_bytes: 20820
#include "bits/stdc++.h"
using namespace std;
int h, w, mv[4][2] = {{-1, 0}, {0, -1}, {0, 1}, {1, 0}};
bool s[400][400], vis[400][400];
pair<int, int> calc(int x, int y)
{
	vis[x][y] = true;
	pair<int, int> total = make_pair(0, 0), t;
	for(int i = 0; i < 4; ++i)
	{
		if(0 <= x + mv[i][0] && x + mv[i][0] < h && 0 <= y + mv[i][1] && y + mv[i][1] < w)
		{
			if(s[x][y] != s[x + mv[i][0]][y + mv[i][1]] && !vis[x + mv[i][0]][y + mv[i][1]])
			{
				t = calc(x + mv[i][0], y + mv[i][1]);
				total.first += t.first;
				total.second += t.second;
			}
		}
	}
	if(s[x][y])
	{
		++total.first;
	}
	else
	{
		++total.second;
	}
	return total;
}
int main()
{
	long long total = 0;
	scanf("%d%d", &h, &w);
	char inp;
	for(int i = 0; i < h; ++i)
	{
		scanf("\n");
		for(int j = 0; j < w; ++j)
		{
			scanf("%c", &inp);
			s[i][j] = inp == '#';
		}
	}
	for(int i = 0; i < h; ++i)
	{
		for(int j = 0; j < w; ++j)
		{
			if(!vis[i][j])
			{
				pair<long long, long long> k = calc(i, j);
				total += k.first * k.second;
			}
		}
	}
	printf("%lld\n", total);
}

Measured memory_bytes: 13056
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int main() {
	int n, prev = 0, ans = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int m;
		cin >> m;
		ans += abs(m - prev);
		prev = m;
	}
	cout << (ans + prev) / 2 << endl;
}

Measured memory_bytes: 256
from fractions import gcd
n,x=map(int,input().split())
a=list(map(int,input().split()))
if n==1:
    print(abs(x-a[0]))
    exit()

for i in range(n-1):
    if i==0:
        D=gcd(abs(x-a[i]),abs(x-a[i+1]))
    else:
        D=min(D,gcd(abs(x-a[i]),abs(x-a[i+1])))
    if D==1:
        break
print(D)

Measured memory_bytes: 16244
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
ll a[100000];
ll dom[100001];
int main(){
  int n,d;
  cin>>n>>d;
  int x[n][d];
  float tmp=0.0000;
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      cin>>x[i][j];
    }
  }
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      tmp=0.000;
      for(int l=0;l<d;l++){
        tmp+=pow(x[i][l]-x[j][l],2);
      }
      tmp=sqrt(tmp);
      //cout<<ceil(tmp)<<" "<<floor(tmp)<<endl;
    if(ceil(tmp)==floor(tmp)) ans++;
    }  
  }
  cout<<ans;
  return 0;
}

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

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))
#define INF (1<<28)
#define pb(i) push_back(i)
#define fs first
#define sc second

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

int main(){
	string s;
	int k;
	cin >> s >> k;
	rep(i,s.length()-1){
		int t = 26 - s[i] + 'a';
		if(t <= k && t != 26) {
			s[i]='a';
			k -= t;
		}
	}
	s[s.length()-1] = ((int)s[s.length()-1] -'a'+ k)%26 + 'a';
	cout << s << endl;
	
	return 0;
}


Measured memory_bytes: 512
n, m, x = map(int, input().split())
c = [0] * n
a = [[0] * m for _ in range(n)]
for i in range(n):
    c[i], *a[i] = map(int, input().split())

ans = float("inf")
for i in range(1<<n):
    t = [0] * m
    cost = 0
    for j in range(n):
        if i & (1<<j):
            cost += c[j]
            for k in range(m):
                t[k] += a[j][k]
    if min(t) >= x:
        ans = min(ans, cost)

if ans == float("inf"):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9120
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

const int N=5e5+50; 

int n,a[N];
long long sum,k;

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	//freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);
#endif
	scanf("%d",&n); 	
	rep(i,1,n){
		scanf("%d",a+i); 
		sum+=a[i];
	}
	long long w=1ll*n*(n+1)/2;
	if(sum%w!=0){
		puts("NO"); 
		return 0; 
	}
	k=sum/w;
	rep(i,1,n){
		int b=a[i%n+1]-a[i];
		if(k-b>=0&&(k-b)%n==0){
			;
		}else{
			puts("NO"); 
			return 0; 
		}
	}	
	puts("YES"); 
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h> 
using namespace std; 
typedef  pair<int, int> iPair; 
//#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,n) for(i=0;i<=n;i++)
 
 
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
   
}
    
ll maxl(ll a,ll b){
    if(a>b)return a;
    return b;
}
 
ll minl(ll a,ll b){
    if(a>b)return b;
    return a;
}
 
ll mod = 998244353;
 
ll mulmod(ll a, ll b,ll c){ 
    ll res = 0; 
    a = a % c; 
    while (b > 0){ 
        if (b % 2 == 1){ 
            res = (res + a) % c;
        }
        a = (a * 2) % c; 
        b /= 2; 
    } 
    return res % c; 
}
 
int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
        if (arr[mid] == x) 
            return mid; 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    } 
    return -1; 
} 
 
int a[100005];
int tree[200005];
 
void build(int st,int low,int high){
    if(low==high){
        tree[st] = a[high]%2;
        return;
    }
    int mid = low+(high-low)/2;
    build(2*st,low,mid);
    build(2*st+1,mid+1,high);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
void update(int st,int start,int end,int ind,int val){
    if(start==end){
        tree[st] = val%2;
        return;
    }
    int mid = start+(end-start)/2;
    if(ind<=mid){
        update(2*st,start,mid,ind,val);
    }
    else update(2*st+1,mid+1,end,ind,val);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
int query(int st,int start,int end,int low,int high){
    if(start>high || end<low)return 0;
    int mid = start + (end-start)/2;
    if(start==low && end==high){
        return tree[st];
    }
    if(low>mid)return query(2*st+1,mid+1,end,low,high);
    if(high<=mid)return query(2*st,start,mid,low,high);
    return query(2*st,start,mid,low,mid)+query(2*st+1,mid+1,end,mid+1,high);
}

int main()
{
        ios_base::sync_with_stdio(false);
        int n;
        cin >> n;
        int k;
        cin >> k;
        int count = 0;
        for(int i=0;i<n;i++){
            int temp;
            cin >> temp;
            if(temp>=k)count++;
        }
        cout << count << endl;
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long val=1000000007;
char arr[1001][1001];

int h,w;
long long dp[1001][1001];
int func(int i,int j)
{
    if(i==h && j==w)return 1;
    if(i>h || j>w)return 0;
    if(dp[i][j]!=-1)return dp[i][j];
    long long ans1=0,ans2=0;
    if(j+1<=w && arr[i][j+1]!='#') {
        ans1=func(i,j+1);
        if(ans1>=val)ans1%=val;
    }
     if(i+1<=h && arr[i+1][j]!='#') {
        ans2=func(i+1,j);
        if(ans2>=val)ans2%=val;
     }
     dp[i][j]=(ans1+ans2);
    if(dp[i][j]>=val)return dp[i][j]%=val;
    return dp[i][j];


}
int main()
{

    cin>>h>>w;
    for(int i=1;i<=h;i++) {
        for(int j=1;j<=w;j++) {
            cin>>arr[i][j];
        }
    }
    memset(dp,-1,sizeof(dp));
    long long ans=func(1,1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9088
#include <stdio.h>
#include <stdlib.h>
 
int main(void) {
 
  // 入力
  int n;
  scanf("%d",&n);

  int result;
  if(n<10){
    result=n;
  }else if(n<100){
    result=9;
  }else if(n<1000){
    result=9+(n-99);
  }else if(n<10000){
    result=909;
  }else if(n<100000){
    result=909+(n-9999);
  }else if(n<1000000){
    result=90909;
  }
  

  printf("%d\n",result);
 
  return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int ans = inf;
int n;
int a, b, c;
vi l(10);

void dfs(int u, int a0, int b0, int c0, int score) {
  if (u == n) {
    if (a0 == 0 || b0 == 0 || c0 == 0) return;
    score -= 30;
    score += abs(a0 - a);
    score += abs(b0 - b);
    score += abs(c0 - c);
    ans = min(ans, score);
    return;
  }
  rep (i, 4) {
    if (i == 0) {
      dfs(u + 1, a0 + l[u], b0, c0, score + 10);
    }
    else if (i == 1) {
      dfs(u + 1, a0, b0 + l[u], c0, score + 10);
    }
    else if (i == 2) {
      dfs(u + 1, a0, b0, c0 + l[u], score + 10);
    }
    else if (i == 3) {
      dfs(u + 1, a0, b0, c0, score);
    }
  }
}

int main() {
  cin >> n;
  cin >> a >> b >> c;
  rep (i, n) cin >> l[i];
  dfs(0, 0, 0, 0, 0);
  cout << ans << endl;
}



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

int main() {
	int a, b; cin >> a >> b;
	string ans = "IMPOSSIBLE";
	for (int i = 0; i < 1000000000; i++) {
		if (abs(a - i) == abs(b - i)) {
			ans = to_string(i);
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)
	

N = int(stdin.readline())
ans = 0
ans += 1000*(N//500)
mod = N%500
ans += 5*(mod//5)
print(ans)


Measured memory_bytes: 5100
import math
n,d=map(int,input().split())
x,y,z=[],[],[]
flag=0
co=0
i,j,u=0,1,0
for l in range(n):
 x=x+(list(map(int,input().split())))
while i < n-1:
 while j < n:
  co+=1
  y=x[i*d:(i+1)*d]
  z=x[j*d:(j+1)*d]
  for l in range(len(y)):
   u+=(y[l]-z[l])*(y[l]-z[l])
  u=math.sqrt(u)
  if str(u)[len(str(u))-1] == "0":
   flag+=1
  u=0
  j+=1
 i+=1
 j=i+1
print(flag)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n, m;

int calc(vector<int> a, vector<int> t){
    int res = 0;
    rep(i, 0, n){
        if(a[i] == t[i]) continue;
        int tmp = INF;
        rep(j, i + 1, n){
            if(a[j] == t[i]){
                tmp = j - i;
                swap(a[i], a[j]);
                break;
            }
        }
        if(tmp == INF) return INF;
        res += tmp;
    }
    return res;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    vector<int> b(n), p(m);
    rep(i, 0, n) cin >> b[i];
    rep(i, 0, m) cin >> p[i];
    vector<int> t, s;
    rep(i, 0, m){
        rep(j, 0, p[i]){
            t.push_back(i % 2);
            s.push_back((i + 1) % 2);
        }
    }
    int ans = min(calc(b, t), calc(b, s));
    cout << ans << endl;
}


Measured memory_bytes: 3212
import java.util.ArrayList;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;





public class Main {
	   static int N=200010;
	   
	  
	   static int[] fa1=new int[N];
	   static int[] fa2=new int[N];
	   
       public static void main(String[] args) {
    	   
          Scanner input=new Scanner( System.in);
         
          int n=input.nextInt();
          for(int i=1;i<=n;i++)
          {
        	  fa1[i]=i;
        	  fa2[i]=i;
          }
          int k=input.nextInt();
          int l=input.nextInt();
          
          for(int i=1;i<=k;i++)
          {
        	  int u=input.nextInt(),v=input.nextInt();
        	  merge1(u,v);
          }
          
          for(int i=1;i<=l;i++)
          {
        	  int u=input.nextInt(),v=input.nextInt();
        	  merge2(u,v);
          }
          HashMap<Node, Integer> map=new HashMap<Node, Integer>();
          for(int i=1;i<=n;i++)
          {
        	  Node temp=new Node(find1(i), find2(i));
        	  if(map.containsKey(temp))
        	  {
        		 map.put(temp, map.get(temp)+1); 
        	
        	  }
        	  else
        	  {
        		  map.put(temp, 1); 
        	  }
          }
          for(int i=1;i<=n;i++)
          {
        	  Node temp=new Node(find1(i), find2(i));
        	  System.out.print(map.get(temp)+" ");
          }
      
	}

       
       
	private static void merge1(int u, int v) {
		int fu=find1(u);
		
		int fv=find1(v);
		if(fu!=fv)
		{
			fa1[fv]=fu;
		}
		// TODO 自动生成的方法存根
		
	}

	private static int find1(int x) {
		// TODO 自动生成的方法存根
		if(x==fa1[x])
			return x;
		else 
			return fa1[x]=find1(fa1[x]);
		
	}
	private static void merge2(int u, int v) {
		int fu=find2(u);
		int fv=find2(v);
		if(fu!=fv)
		{
			fa2[fv]=fu;
		}
		// TODO 自动生成的方法存根
		
	}

	private static int find2(int x) {
		// TODO 自动生成的方法存根
		if(x==fa2[x])
			return x;
		else 
			return fa2[x]=find2(fa2[x]);
		
	}

}
class Node
{
	int x,y;

	public Node(int x, int y) {
		super();
		this.x = x;
		this.y = y;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + x;
		result = prime * result + y;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Node other = (Node) obj;
		if (x != other.x)
			return false;
		if (y != other.y)
			return false;
		return true;
	}
	
	
}


Measured memory_bytes: 139316
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <sstream>
#include <fstream>
#include <iomanip>

#define rep(i,a,b) for(long long i=a;i<b;i++)
using namespace std;

int main(void) {

	long long N = 0, D = 0, A = 0, B = 0, C = 0;
	//char x[100] = {‘+’,’*’,’x’}

	string s;

	cin >>s >>N;

for(int i=0;i<s.length();i=i+N)
cout << s[i];


cout <<endl;
	return 0;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using LL = long long;

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

    LL dp[W + 1];
    fill(dp, dp + W + 1, 0);

    LL w, v;
    for (int i = 0; i < N; i++) {
        cin >> w >> v;
        for (int j = W; j >= w; j--) {
            dp[j] = max(dp[j], dp[j - w] + v);
        }
    }

    cout << dp[W] << endl;
}

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

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		int[] A = new int[N];
		long sum=0;
		for(int i=0;i<N;i++) {
			A[i] = sc.nextInt();
			sum += A[i];
		}
		Arrays.sort(A);

		int[][] bc = new int[M][2];
		for(int i=0;i<M;i++) {
			bc[i][0] = sc.nextInt();
			bc[i][1] = sc.nextInt();
		}
		Arrays.sort(bc,(a,b)->Integer.compare(b[1], a[1]));

		int aj = 0,j = 0;
		for(int i=0;i<M;i++) {
//			System.out.println("i:"+i+" ,aj:"+aj+" "+A[aj]+" "+bc[i][1]);
			if(A[aj] > bc[i][1]) break;
			for(j=aj;j<aj+bc[i][0] && j<N;j++) {
				if(A[j] < bc[i][1]) {
//					System.out.print("j:"+j+" "+A[j] + " ");
					sum -= A[j];
					A[j] = bc[i][1];
					sum += A[j];
//					System.out.println(bc[i][1] + " " + sum);
				}else {
					break;
				}
			}
			aj = j;
			if(j >= N) aj = N-1;
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 95300
#include<bits/stdc++.h>
 
using namespace std;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l, r) uniform_int_distribution<int>(l, r)(rng)
 
#define LL long long int
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int N = 3e5 + 5;
const int oo = 1e9 + 5;
const LL ooll = (LL)1e18 + 5;
const int MOD = 1e9 + 7;
const int M = 1e6 + 5;
 
clock_t start = clock();

int v[N];
void solve() {
	int n, k;
	cin >> n >> k;
	for (int i=0;i<n;++i) cin >> v[i];
	for (int i=k;i<n;++i) {
		cout << (v[i] > v[i-k] ? "Yes\n" : "No\n");
	}
}
 
int main() {
	FASTIO;
	int T = 1;
	// pre();
	// cin >> T;
	while(T--) {
		solve();
	}
	// cout << fixed << setprecision(10);
	// cout << (clock() - start) / ((double)(CLOCKS_PER_SEC)) << " s\n";
	return 0;
} 

Measured memory_bytes: 4428
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long a = long.Parse(input[0]);
		long b = long.Parse(input[1]);
    Console.WriteLine("100 100");
    a--;
    b--;
    for(long i = 0; i < 50; i++)//各行
    {
      string answer = "";
      for(long j = 0; j < 100; j++)
      {
        if(i % 2 == 0 && j % 2 == 0 && a > 0)
        {
          answer += ".";
          a--;
        }else
        {
          answer += "#";
        }
      }
      Console.WriteLine(answer);
    }

    for(long i = 50; i < 100; i++)//各行
    {
      string answer = "";
      for(long j = 0; j < 100; j++)
      {
        if(i % 2 == 1 && j % 2 == 0 && b > 0)
        {
          answer += "#";
          b--;
        }else
        {
          answer += ".";
        }
      }
      Console.WriteLine(answer);
    }
    
	}
}

Measured memory_bytes: 13140
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

xs,ys,xt,yt = map(int,readline().split())
n, = map(int,readline().split())

xyr = [tuple(map(int,readline().split())) for _ in range(n)] + [(xs,ys,0),(xt,yt,0)]


"""
d: 隣接行列に対する Dijkstra
O(N^2)
"""
def Dijkstra_matrix(d,start):
    n = len(d)
    #INF = 1<<61
    INF = float("inf")
    dist = d[start][:] #startからの最短距離

    used = [0]*n # 最短距離が決まった頂点
    used[start] = 1
    for _ in range(n-1):
        d0  = INF
        idx = -1
        for i in range(n):
            if not used[i] and dist[i] < d0:
                idx = i
                d0  = dist[i]
        if idx == -1:
            return dist
        else:
            used[idx] = 1
            for j in range(n):
                if not used[j] and dist[j] > dist[idx]+d[idx][j]:
                    dist[j] = dist[idx]+d[idx][j]
    return dist

from math import hypot
d = [[max(0.0,hypot((xi-xj),(yi-yj))-ri-rj) for xj,yj,rj in xyr] for xi,yi,ri in xyr]

#print(d)
dist = Dijkstra_matrix(d,n)
print(dist[-1])
#print(dist)








Measured memory_bytes: 49812
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e14;

LL dist_L[201][201];
LL dist_S[201][201];
LL dp[1001][201];
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M, R;
  while(cin >> N >> M, N){
	fill((LL*)dist_L, (LL*)dist_L+201*201, INF);
	fill((LL*)dist_S, (LL*)dist_S+201*201, INF);

	REP(i,N) dist_L[i][i] = dist_S[i][i] = 0;
	REP(i,M){
	  LL x, y, t; char c;
	  cin >> x >> y >> t >> c;
	  --x, --y;
	  if(c == 'L')
		dist_L[x][y] = dist_L[y][x] = min(dist_L[x][y], t);
	  else
		dist_S[x][y] = dist_S[y][x] = min(dist_S[x][y], t);
	}
	
	REP(k,N) REP(i,N) REP(j,N){
	  dist_L[i][j] = dist_L[j][i] = min(dist_L[i][j], dist_L[i][k]+dist_L[k][j]);
	  dist_S[i][j] = dist_S[j][i] = min(dist_S[i][j], dist_S[i][k]+dist_S[k][j]);
	}

	cin >> R;
	VI RS(R);
	REP(i,R){
	  cin >> RS[i];
	  --RS[i];
	}

	// dp[i][j] :<=> i番目まで訪問が終わって船の位置がjのときの最小コスト
	fill((LL*)dp, (LL*)dp+1001*201, INF);
	dp[0][RS[0]] = 0;
	REP(i,R-1){
	  REP(u,N){
		REP(v,N){
		  dp[i+1][v] = min(dp[i+1][v],
						   // Rs[i] -> uを陸で、u -> vを海で、v->RS[i+1]を陸で移動
						   dp[i][u]+dist_L[RS[i]][u] + dist_S[u][v]+dist_L[v][RS[i+1]]
						   );
		}
		//陸のみ
		dp[i+1][u] = min(dp[i+1][u], dp[i][u]+dist_L[RS[i]][RS[i+1]]);
	  }
	}

	LL ans = INF;
	REP(u,N) ans = min(ans, dp[R-1][u]);
	cout << ans << endl;
  }  
  
  return 0;
}

Measured memory_bytes: 5384
MOD = 10 ** 9 + 7


def main():
  L = input().strip()
  l = len(L)
  assert l > 0

  dp1 = [-1] * l
  dp2 = [-1] * l
  dp1[0] = 1
  dp2[0] = 2
  for k in range(1, l):
    dp1[k] = dp1[k - 1] * 3 % MOD

    if L[k] == '1':
      dp1[k] += dp2[k - 1]
      dp2[k] = dp2[k - 1] * 2 % MOD
    else:
      dp2[k] = dp2[k - 1]

  return (dp1[-1] + dp2[-1]) % MOD


if __name__ == '__main__':
  print(main())

Measured memory_bytes: 11080
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  ll N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  ll mn = min({A, B, C, D, E});
  ll ans = (N + mn - 1) / mn + 4;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

void freq(unsigned ara[], unsigned size, unsigned frequency[]) {for(int x=0; x<size; x++) frequency[ara[x]]++;} //Initialize frequency array first

int main()
{
unsigned n, i, ara[200001]={}, frq[200001]={};
scanf("%u", &n);
for(i=1; i<n; ++i) scanf("%u", &ara[i]);
freq(ara, n, frq);
for(i=1; i<=n; ++i) printf("%u\n", frq[i]);
return 0;
}


Measured memory_bytes: 3248
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node {
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while(1){
    if ( cur == nil ) return 0;
    if ( cur->key == key ) return cur;
    cur = cur->next;
  }
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

void delete(int key){
  NodePointer t = listSearch(key);
  if ( t == 0 ) return;
  deleteNode(t);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  x->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
    if ( com[6] == 'F' ) deleteFirst();
    else if ( com[6] == 'L' ) deleteLast();
      } else {
    delete(key); nd++;
      }
      size--;
    }
  }

  printList();
  return 0;
}

Measured memory_bytes: 31788
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n,m;
    std::cin >> n >> m;
    std::vector<int> x(m),b(m-1);
    for (int i = 0; i < m; i++) {
        std::cin >> x[i];;
    }
    sort(x.begin(),x.end());
    
    for(int i=0;i<m-1;i++){
        b[i]=x[i+1]-x[i];
    }
    int ans=0;
    sort(b.begin(),b.end());
    for (int i = 0; i < m-n; i++) {
        ans+=b[i];
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  string ans = "";
  REP(i, ty - sy) { ans += "U"; }
  REP(i, tx - sx) { ans += "R"; }
  REP(i, ty - sy) { ans += "D"; }
  REP(i, tx - sx) { ans += "L"; }
  ans += "L";
  REP(i, ty - sy + 1) { ans += "U"; }
  REP(i, tx - sx + 1) { ans += "R"; }
  ans += "D";
  ans += "R";
  REP(i, ty - sy + 1) { ans += "D"; }
  REP(i, tx - sx + 1) { ans += "L"; }
  ans += "U";
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
p1, p2 = 0, 0
for i in range(N):
	max_A = max(A)
	if i % 2 == 0:
		p1 += max_A
	else:
		p2 += max_A
	A.remove(max_A)
print(p1 - p2)

Measured memory_bytes: 9092
#include <iostream>
#include <string>
#include <vector>

int main() {
    long long n, ret = 400000;
    std::string s;

    std::cin >> n >> s;
    std::vector<long long> v(n + 1, 0);

    for (auto i = 1ll; i <= n; i++) {
        if (s[i - 1] == 'W') v[i] = v[i-1] + 1;
        else v[i] = v[i-1];
    }

    for (auto i = 1ll; i <= n; i++) {
        ret = std::min(ret, v[i - 1] + (n - i) - (v[n] - v[i]));
    }

    std::cout << ret << std::endl;

    return 0;
}

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

namespace D_ABC163
{
    class MainClass
    {

        static long[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), long.Parse);
            long D = 1000000007;
            var minl = new long[s[0] + 2];
            var maxl = new long[s[0] + 2];
            var sum = 0L;
            for (int i = 1; i <= s[0]+1; i++)
            {
                minl[i] = (minl[i - 1] + i-1) ;
                maxl[i] = (maxl[i - 1] + s[0] + 1  - (i)) ;
                // WriteLine("minl : {0} maxl : {1} ",minl[i],maxl[i]);
                if (i >= s[1]) sum = (sum +  (maxl[i] - minl[i] + 1)%D)%D;
                // WriteLine(sum);
            }
            WriteLine(sum);

        }
    }
}


Measured memory_bytes: 30768
import itertools,math,numpy as np
def I(): return int(input())
def LI(): return list(map(int,input().split()))
N = I()
xy = np.array(sorted([LI() for _ in range(N)]))
sum_norm = 0
dict_norm = {}
for a in itertools.permutations(range(N)):
    for i in range(len(a)-1):
        vector = tuple(xy[a[i+1]]-xy[a[i]])
        if not vector in dict_norm:
            dict_norm[vector] = np.linalg.norm(vector)
        sum_norm += dict_norm[vector]
print(sum_norm/math.factorial(N))


Measured memory_bytes: 12452
def hoge(n):
    for i in range(40):
        if(minList[i] <= n and n <= maxList[i]):
            break
    return i

N = int(input().strip())

minList = [0]
maxList = [1]
for d in range(1, 40):
    minList.append(min(minList[-1] + (-2)**d, minList[-1]))
    maxList.append(max(maxList[-1], maxList[-1] + (-2)**d))
    
residual = N
index = hoge(residual)
ans = [0 for i in range(index + 1)]
ans[0] = 1
residual = residual - (-2)**index

while(residual != 0):
    index = hoge(residual)
    ans[len(ans) - 1 - index] = 1
    residual = residual - (-2)**index

if(N == 0):
    ans = [0]
    
print("".join(str(e) for e in ans))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <limits>

using namespace std;

int count;

void pre(vector<vector<int> > &tree,int now)
{
	cout << " " << tree[now][0];
	for(int i=1;i<3;i++)
	{
		if(tree[now][i] != numeric_limits<int>::min())
		{
			pre(tree,tree[now][i]);
		}
	}
}

void ino(vector<vector<int> > &tree,int now)
{
	int size = tree[now].size();
	if(tree[now][1] == numeric_limits<int>::min() && tree[now][2] == numeric_limits<int>::min())
	{
		cout << " " << tree[now][0];
	}
	else
	{
		if(tree[now][1]!=numeric_limits<int>::min())
		{
			ino(tree,tree[now][1]);
		}
		cout << " " << tree[now][0];
		if(tree[now][2]!=numeric_limits<int>::min())
		{
			ino(tree,tree[now][2]);
		}
	}
}

void print(vector<vector<int> > &tree)
{
	ino(tree,0);
	cout << endl;
	pre(tree,0);
	cout << endl;
}

void insert(vector<vector<int> > &tree,int key,int now)
{
	if(count == 0)					//root none
	{
		tree[0][0] = key;
	}
	else
	{
		if(tree[now][0] > key)		//left
		{
			if(tree[now][1] == numeric_limits<int>::min())	//child none
			{
				tree[now][1] = count;
				tree[count][0] = key;
			}
			else											//child exist
			{
				insert(tree,key,tree[now][1]);
			}
		}
		else						//right
		{
			if(tree[now][2] == numeric_limits<int>::min())	//child none
			{
				tree[now][2] = count;
				tree[count][0] = key;
			}
			else
			{
				insert(tree,key,tree[now][2]);
			}
		}
	}
}

int main(void)
{
	count = 0;
    vector<vector<int> > tree;
	int n,num;
	string command;
	cin >> n;
    tree = vector<vector<int> >(n,vector<int>(3,numeric_limits<int>::min()));

	for(int i=0;i<n;i++)
	{
		cin >> command;
		if(command == "insert")
		{
			cin >> num;		//input node num
			insert(tree,num,0);
			count++;
		}
		else if(command == "print")
		{
			print(tree);
		}
	}

	return 0;
}

Measured memory_bytes: 57424
a,b,c=map(int,input().split())
l=[]
count=0
if any([a%2==1,b%2==1,c%2==1]):
    print(0)
    exit()
while True:
    a,b,c=a//2,b//2,c//2
    a,b,c,=b+c,a+c,a+b
    count+=1
    if any([a%2==1,b%2==1,c%2==1]):
        print(count)    
        exit()
    elif [a,b,c]in l:
        print(-1)
        exit()
    l.append([a,b,c])

Measured memory_bytes: 38384
import sys
import os
from collections import defaultdict
adj = defaultdict(list)
vis =[0 for i in range(1000000)]
dis =[0 for i in range(1000000)]
def dfs(u, p):
	for v, w in adj[u]:
		if v==p:
			continue
		dis[v]=dis[u]+w
		dfs(v, u)

def main():
	n = int(input())
	for i in range(n-1):
		a, b, w = map(int , input().split())
		adj[a].append((b, w))
		adj[b].append((a, w))

	q, k = map(int , input().split())
	sys.setrecursionlimit(1000000)
	dfs(k , 0)
	for i in range(q):
		x, y  =map(int , input().split())
		print(dis[x]+dis[y])
#	rec_limit= sys.getrecursionlimit()
#	print(rec_limit)


if __name__ == "__main__":
	main()

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

int main(){

  int A = 0;
  int B = 0;

  cin >> A >> B;

  if (A != 1 && B != 1) {
    cout << 1 << endl;
  } else if (A != 2 && B != 2) {
    cout << 2 << endl;
  } else if (A != 3 && B != 3) {
    cout << 3 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
 
int main()
{
  int N;
  vector<int> a(100001), b(100001);
  cin >> N;
  rep(i,N){cin >> a.at(i);}
  b.at(0)=a.at(0);
  rep(j,N)
  {
    if(j>0)
    {
      b.at(j)=a.at(b.at(j-1)-1);
    }
    if(b.at(j)==2)
    {
      cout << j+1 << endl;
      return 0;
    }
  }
  rep(k,N)
  {
    if((b.at(N)-1)!=2)
    {
      cout << -1 << endl;
      break;
    }
  }
}

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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int gcd(int x,int y){
  if(x<=y){
    swap(x,y);
  }
  if(x%y==0) return y;
  else{
    return(gcd(y,x%y));//最大公約数
  }
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
    }
    int ans = a[0];
    FOR(i,1,n){
        ans = gcd(ans,a[i]);
    }
    cout << ans << endl;
    return 0;
}    


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N;
  cin>>N;
  vector<ll> A(N);
  vector<ll> B(N);
  vector<ll> C(N);
  for(ll i=0;i<N;i++) {
cin>>A[i]>>B[i]>>C[i];
  }
  vector<vector<ll>> dp(N,vector<ll>(3));
  dp[N-1][0]=A[N-1];
  dp[N-1][1]=B[N-1];
  dp[N-1][2]=C[N-1];
  
  for(ll i=N-2;i>=0;i--) {
dp[i][0]=max(dp[i+1][1]+A[i],dp[i+1][2]+A[i]);
    dp[i][1]=max(dp[i+1][0],dp[i+1][2])+B[i];
    dp[i][2]=max(dp[i+1][0],dp[i+1][1])+C[i];
  }
  
  
  ll ans=0;
  for(ll i=0;i<3;i++) {
ans=max(ans,dp[0][i]);
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 11148