akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class fight
    {
        public int hp;

        public string battle()
        {
            string kekka = "";
            if (hp <= 0)
            {
                kekka = "Yes";
            }
            else
            {
                kekka = "No";
            }
            return kekka;
        }

    }
    class Program
    {
        static void Main(string[] args)
        {
            fight monster = new fight();
            string[] input1 = Console.ReadLine().Split();
            monster.hp = int.Parse(input1[0]);
            string[] input2 = Console.ReadLine().Split();
            int[] round = new int[input2.Length];
            for(int i = 0; i < input2.Length; i++)
            {
                round[i] = int.Parse(input2[i]);
                monster.hp -= round[i];
            }
            Console.WriteLine(monster.battle());
            Console.Read();
        }
    }
}


Measured memory_bytes: 16480
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string x;
	cin>>x;
	set<char>my;
	for(int i=0;i<x.length();++i)
		my.insert(x[i]);
	for(char c='a';c<='z';++c)
	{
		if(my.find(c)==my.end())
		{
			cout<<c<<'\n';
			return 0;
		}
	}
	cout<<"None\n";
}

Measured memory_bytes: 512
# coding: utf-8
n, m = map(int, input().split())
data = [list(map(int, input().split())) for i in range(n)]
std_data = sorted(data)
j = 0
min_total = 0
bought_num = 0
while True:
    bought_num += std_data[j][1]
    min_total += std_data[j][0] * std_data[j][1]
    if bought_num >= m:
        min_total -= std_data[j][0] * (bought_num - m)
        break
    else:
        j += 1
print(min_total)


Measured memory_bytes: 28648
def inverse(a):
    return pow(a, mod - 2, mod)

def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    if a[0] > 0:
        print(sum(a) - 2 * a[0])
        tmp = a[0]
        for i in range(1, n-1):
            print(tmp, a[i])
            tmp -= a[i]
        print(a[-1], tmp)
        return
    if a[-1] < 0:
        print(-sum(a) + 2 * a[-1])
        tmp = a[-1]
        for i in range(n-1):
            print(tmp, a[i])
            tmp -= a[i]
        return
    mid = lsearch(0, a) + 1
    print(sum(abs(i) for i in a))
    for i in range(mid+1, n):
        print(a[0], a[i])
        a[0] -= a[i]

    for i in range(mid):
        print(a[mid], a[i])
        a[mid] -= a[i]


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def lsearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] < x:
            lft = mid
        else:
            rgt = mid
    return lft


main()

Measured memory_bytes: 14088
import bisect
N=int(input())
M=10**9+7
ans=1
prime=[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, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
k=bisect.bisect(prime,N)
for i in range(k-1,-1,-1):
  x=0
  j=1
  while N//(prime[i]**j)>0:
    x+=N//(prime[i]**j)
    j+=1
  ans*=x+1
  ans%=M
print(ans)

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

int main(){
  int N;
  string S;
  cin>>N;
  cin>>S;
  vector<int> x(N,0);
  
  //白.0、黒#1
  int wnum=0;
  for(int i=0;i<N;i++){
    if (S[i]=='#'){
      x[i]=1;//黒
    }else{
      wnum++;
    }
  }
  
  
  //ひだりから白に塗りつぶしていく
  int minwnum=wnum;
  for(int i=0;i<N;i++){
    if (x[i]==0){//白だったら、本当は塗りつぶさなくても良かったのに塗りつぶしてしまっていた
      wnum--;
    }else{
      wnum++;//黒なら白に塗りつぶさないと行けない
    }
    if (wnum<minwnum)
      minwnum=wnum;
  }
  
  cout<<minwnum<<endl;
  return 0;
}

Measured memory_bytes: 1412
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int Q = scanner.nextInt();

        if (K > Q) {
            for (int i=0; i<N; i++) {
                System.out.println("Yes");
            }
            return;
        }

        int[] result = new int[N];
        for (int i=0; i<N; i++) {
            result[i] = K - Q;
        }

        for (int i=0; i<Q; i++) {
            result[scanner.nextInt()-1]++;
        }

        for (int i=0; i<N; i++) {
            System.out.println(result[i] > 0 ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 54916
#include<iostream>

using namespace std;

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

	if (a > b) {
		cout << "a > b\n";
	}	else if(a==b){
		cout << "a == b\n";
	}
	else {
		cout << "a < b\n";
	}
	return 0;
	}

Measured memory_bytes: 2956
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (lli i = 0; i < (lli)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n,W;
    cin>>n>>W;
    vvi dp(n+1,vi(100010,INF));
    vi w(n),v(n);
    rep(i,n) cin>>w[i]>>v[i];
    dp[0][0]=0;
    rep(i,n){
        rep(j,100010){
            if(j>=v[i])
            dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
            else dp[i+1][j]=dp[i][j];
        }
    }
    lli ans=0;
    rep(i,100010){
        if(dp[n][i]<=W){
            ans=max(ans,i);
        }
    }
    out(ans);
}

Measured memory_bytes: 80256
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);

	//0223
	static class StrayTwins {
		void print_minTime() {
			for(;;) {
				int w = sc.nextInt(), h = sc.nextInt();
				if(w == 0 && h == 0) break;
				int stx = sc.nextInt()-1, sty = sc.nextInt()-1,
					skx = sc.nextInt()-1, sky = sc.nextInt()-1;
				int[][] field = new int[h][w];
				boolean[][][][] marker = new boolean[h][w][h][w];
				for(int i=0; i<h; i++) {
					for(int j=0; j<w; j++) {field[i][j] = sc.nextInt();}
				}

				Queue<TwinsPoint> que = new LinkedList<TwinsPoint>();
				que.offer(new TwinsPoint(sty,stx,sky,skx,0));
				marker[sty][stx][sky][skx] = true;

				int[] dir_ty = {-1, 0, 1, 0}, dir_tx = { 0, 1, 0,-1},
					  dir_ky = { 1, 0,-1, 0}, dir_kx = { 0,-1, 0, 1};
				int ans = -1;
				while(!que.isEmpty()) {
					TwinsPoint pt = que.poll();
					if(pt.time == 100) break;
					if(pt.ty == pt.ky && pt.tx == pt.kx) {
						ans = pt.time;
						break;
					}
					for(int i=0; i<4; i++) {
						int nty = pt.ty + dir_ty[i], ntx = pt.tx + dir_tx[i],
							nky = pt.ky + dir_ky[i], nkx = pt.kx + dir_kx[i];
						TwinsPoint npt = new TwinsPoint(pt.ty, pt.tx, pt.ky, pt.kx, pt.time);
						npt.time++;
						if(nty >= 0 && ntx >= 0 && nty < h && ntx < w && field[nty][ntx] != 1) {
							npt.ty = nty; npt.tx = ntx;
						}
						if(nky >= 0 && nkx >= 0 && nky < h && nkx < w && field[nky][nkx] != 1) {
							npt.ky = nky; npt.kx = nkx;
						}
						if(!marker[npt.ty][npt.tx][npt.ky][npt.kx]) {
							marker[npt.ty][npt.tx][npt.ky][npt.kx] = true;
							que.offer(npt);
						}
					}
				}
				if(ans == -1) System.out.println("NA");
				else System.out.println(ans);
			}
		}
	}

	static class TwinsPoint {
		public int ty, tx, ky, kx, time;
		public TwinsPoint(int ty, int tx, int ky, int kx, int time) {
			this.ty = ty; this.tx = tx;
			this.ky = ky; this.kx = kx;
			this.time = time;
		}
	}

	public static void main(String[] args) {
		StrayTwins st = new StrayTwins();
		st.print_minTime();
	}
}

Measured memory_bytes: 28000
#include <stdio.h>

int main(){

int n[2];
int temp;

scanf("%d %d %d", &n[0], &n[1], &n[2]);

if (n[0] > n[1]){
        temp = n[0];
        n[0] = n[1];
        n[1] = temp;
}
if (n[1] > n[2]){
        temp = n[1];
        n[1] = n[2];
        n[2] = temp;
}
if (n[0] > n[1]){
        temp = n[0];
        n[0] = n[1];
        n[1] = temp;
}
printf("%d %d %d\n", n[0], n[1], n[2]);

return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;

int main() {
  ll n,m;
  cin>>n>>m;
  if(n==1){
            if(m==1){
              cout<<1<<endl;
            }
     		else if(m==2){
              cout<<0<<endl; 
            }
 			else{
              cout<<m-2<<endl;
            }
    }//n=1
   else if(n==2){
     cout<<0<<endl;
   }
  else{
    				if(m==1){
                      cout<<n-2<<endl; 
                    }
    				else if(m==2){
                      cout<<0<<endl;
                    }
    else{
      cout<<(n-2)*(m-2)<<endl; 
    }
  }
}

Measured memory_bytes: 256
import collections
import itertools
N=int(input())
#P=list(map(int,input().split()))
st=[]
for i in range(N):
    s=str(input())
    st.append(s)
c = collections.Counter(st)
count=c.most_common()
max=count[0][1]
min=count[-1][1]
if max==min:
    st=list(set(st))
    st.sort()
    for k in st:
        print(k)
    exit()
ret=[]
for letter,cou in count:

     if cou == max:
         ret.append(letter)
     else:
         break
ret.sort()
for r in ret:
    print(r)


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int a[4]= {}, n;
    string s[4] = {"AC", "WA", "TLE", "RE"}, t;
    cin>> n;


    for(int i=0; i<n; i++)
    {
        cin>> t;

        for(int j=0; j<4; j++)
        {
            if(t== s[j])
            {
                a[j]++;
                break;
            }
        }
    }

     for(int i=0; i<4; i++)
        cout<< s[i]<< " x " << a[i] << '\n';

    return 0;
}




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

int main(){
    int n; cin>>n;
    vector<int> t(n);
    for(int i=0;i<n;i++) cin>>t[i];
    int m; cin>>m;
    vector<vector<int>> d(m,vector<int>(2));
    for(int i=0;i<m;i++){
        for(int j=0;j<2;j++) cin>>d[i][j];
    }

    for(int i=0;i<m;i++){
        int ans=0;
        for(int j=0;j<n;j++){
            if(d[i][0]==j+1){
                ans+=d[i][1];
                continue;
            }
            ans+=t[j];
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>

auto& in = std::cin;
auto& out = std::cout;

int32_t H,W;
std::string map[510];
std::string map2[510];
std::string map3[510];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> H>>W;
	for (int32_t i = 0; i < H; i++)
	{
		in >> map[i];
	}

	for (int32_t i = 0; i < W; i++) { out << '.'; }out << endl;
	for (int32_t i = 1; i < H - 1; i++) {
		out << '.';
		for (int32_t j = 1; j < W - 1; j++) {
			if (i & 1) { out << '#'; }
			else { out << ((j != W - 2) ? map[i][j] : '#'); }
		}
		out << '.'; out << endl;
	}
	for (int32_t i = 0; i < W; i++) { out << '.'; }out << endl;

	out<< endl;

	for (int32_t i = 0; i < W; i++) { out << '#'; }out << endl;
	for (int32_t i = 1; i < H - 1; i++) {
		out << '#';
		for (int32_t j = 1; j < W-1; j++) {
			if (i & 1) { out << map[i][j]; }
			else { out << ((j != W - 2) ? '#' : map[i][j]); }
		}
		out << '#'; out << endl;
	}
	for (int32_t i = 0; i < W; i++) { out << '#'; }out << endl;

	return 0;
}
#endif


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> H(N);
  for (int i = 0; i < N; i++) cin >> H[i];
  sort(H.rbegin(), H.rend());
  ll ans = 0;
  for (int i = K; i < N; i++)
  {
    ans += H[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(){
	int a=0;
	int b=0;
	cin >> a >> b;
	if(a%3==0||b%3==0||(a+b)%3==0){
		cout << "Possible" << endl;
	}else{
		cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : g
// Date        : Wed Feb 20 14:06:02 CST 2019
// Author      : landcold7
// Description : Actions speak louder more than words
//============================================================================
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define mst(x, y) memset(x, y, sizeof(x))
#define pvar(x) cout << #x << ": "
#define fora(e, c) for (auto &e : c)
#define fori(i, a, b) for (int i = a; i < b; ++i)
#define ford(i, a, b) for (int i = a; i > b; --i)
#define output(v) cout << (v) << '\n'
#define prt(x, a, n) { cout << x[a]; if (a < n - 1) cout << " "; }
#define pvi(x, v) if(v) pvar(x); fora(a, x) cout << a << " "; cout << "\n"
#define par(x, s, n, v) if(v) pvar(x); fori(y, s, n) prt(x, y, n) cout << "\n"

#ifndef __has_trace
#define trace(...)
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int maxn = (int) 1e5 + 7;
vi gg[maxn];
int dp[maxn];

int dfs(int u) {
    if (dp[u] != -1) return dp[u];
    int ret = 0;
    fora (v, gg[u]) {
        ret = max(ret, dfs(v));
    }
    dp[u] = ret + 1;
    return dp[u];
}

void solve() {
    int n, m; cin >> n >> m;
    fori (i, 0, m) {
        int u, v; cin >> u >> v;
        gg[u].pb(v);
    }

    mst(dp, -1);
    fori (i, 1, n + 1) {
        if (dp[i] == -1) {
            dfs(i);
        }
    }
    // par(dp, 0, n + 1, 1);
    int ret = *max_element(dp + 1, dp + n + 1);
    output(ret - 1);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}



Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int a,b,c,x,ans=0;
    cin>>a>>b>>c>>x;
    REP(i,a+1){
        REP(j,b+1){
            REP(k,c+1){
                if((500*i)+(100*j)+(50*k)==x)ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        long x = Long.parseLong(sc.next());
        sc.close();

        // 主処理
        long countA = (a - 1) / x;
        Long countB = b / x;
        long result = countB - countA;
        if (a == 0 && x % 2 == 0) {
            result++;
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 2e5 + 7, maxm = 31;
int n;
long long cnt[maxm], ans;
char s[maxn];

int main() {
	scanf("%d", &n);
	scanf("%s", s + 1);
	for (int i = 1; i <= n; ++i) ++cnt[s[i] - 'a'];
	ans = 1;
	for (int i = 0; i < 26; ++i) ans = ans * (cnt[i] + 1) % mod;
	ans = (ans + mod - 1) % mod;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3896
'use strict';
const main = val => {
  const n = parseInt(val[0], 10);
  let b = val[1].split(' ').map(p => parseInt(p, 10));
  let c = new Array(n);
  c[0] = b[0], c[n-1] = b[n-2];
  for (let i = 0; i < b.length-1; i++) {
    c[i+1] = Math.min(b[i], b[i+1]);
  }
  var ans = c.reduce((x,y) => x+y);
  console.log(ans);
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 9420
n = int(input())
h = list(map(int , input().split()))

dp = [10**10 for i in range(n)]
dp[0] = 0
for i in range(n):
    for j in range(i+1,i+3):
        if j<n:
            dp[j] = min(dp[j] , dp[i] + abs(h[i] - h[j]))
# print(dp)
print(dp[n-1])

Measured memory_bytes: 52728
#include <iostream>
#include <vector>

using namespace std;

bool IsMM(char c1, char c2) {
  if (c1 == '0') {
    if (c2 == '0') { return false; }
    return true;
  } else if (c1 == '1') {
    if (c2 == '0' || c2 == '1' || c2 == '2') {
      return true;
    }
  }
  return false;
}

bool IsYY(char c1, char c2) {
//  if (c1 == '0' && c2 == '0') {
//    return false;
//  }
  return true;
}

int main() {
  string S;
  cin >> S;
  const char* s = S.c_str();

  bool is_mm0 = IsMM(s[0], s[1]);
  bool is_mm1 = IsMM(s[2], s[3]);
  bool is_yy0 = IsYY(s[0], s[1]);
  bool is_yy1 = IsYY(s[2], s[3]);

  if ((is_mm0 && is_yy1) && (is_yy0 && is_mm1)) {
    cout << "AMBIGUOUS" << endl;
  } else if (is_yy0 && is_mm1) {
    cout << "YYMM" << endl;
  } else if (is_mm0 && is_yy1) {
    cout << "MMYY" << endl;
  } else {
    cout << "NA" << endl;
  }

  return 0;
}

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if ((a < b) && (b < c))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main(void)
{
    //freopen("input.txt", "r", stdin);
 
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    
    double pi = 3.14159265358979323846;
    double ans2 = (double)m/60;
    double ans1 = ((double)h+ans2)/12;
    
    double ans3 = abs(ans1*2*pi - ans2*2*pi);
    
    double ans4 = (a*a)+(b*b);
    double ans5 = ans4 - 2*a*b*cos(ans3);
    double ans6 = sqrt(ans5);
    
    cout<<setprecision(21)<<fixed;
    cout<<ans6<<"\n";
 
    return 0;
}

Measured memory_bytes: 4188
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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; }

int main()
{
    ll x; cin >> x;
    ll ans = x / 11;
    x -= ans*11;
    ans *= 2;
    if(x > 6) ans+=2;
    else if(x > 0) ans++;
    pr(ans);
    return 0;}

Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter writer = new PrintWriter(System.out);
        
        String[] str = br.readLine().split(" ");
        
        Object ans;
        if(str[0].equals(str[1])) ans = str[2];
        else if(str[1].equals(str[2])) ans = str[0];
        else ans = str[1];
        
        writer.println(ans);
        
        br.close();
        writer.close();
    }
}

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

void ztobit(vector<int> &state,int i){
    int count=0;
    while(i>0){
        state.at(count)=i%2;
        i/=2;  
        count++;      
    }
}

int main(){
    int N,M;
    cin>>N>>M;
    vector<int> k(M);
    vector<vector<int> > s(M,vector<int>(0));
    vector<int> p(M);

    for(int i=0;i<M;i++){
        cin>>k.at(i);
        for(int j=0;j<k.at(i);j++){
            int m;
            cin>>m;
            s.at(i).push_back(m);
        }
    }
    for(int i=0;i<M;i++){
        cin>>p.at(i);
    }

    vector<int> state(N,0); //電球のon/off 1/0
    int sum=0;
    for(int i=0;i<pow(2,N);i++){ //iが元2bitの整数
        ztobit(state,i);
        bool jg=false;
        for(int j=0;j<M;j++){ //jは電球
            int sum2=0; //スイッチがついてる個数
            for(int k=0;k<s.at(j).size();k++){ //kは各スイッチ
                sum2+=state.at( s.at(j).at(k) -1 );
            }

            if((sum2%2)!=p.at(j)){
                jg=false;
                break;
            }
            else{
                jg=true;
            }
        }
        if(jg==true){
            sum++;
            /*for(int i=N-1;i>=0;i--){
                cout<<state.at(i);
            }
            cout<<endl;*/
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(double);
		void decrement(void);
		void decrement(double);
		double getResult(void);
	private:
		double result;
	};
	void Ans::showResult(void) {
		printf("%.0lf\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(double value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(double value) {
		this->result -= value;
	}
	double AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void input(Str* str) {
		str->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				str->push_back(row);
				row = "";
			} else {
				row += buf[i];
			}
		}
		str->push_back(row);
	}
	void input(Num* num) {
		num->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				num->push_back(std::atoi(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		num->push_back(std::atoi(row.c_str()));
	}
	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::Num s;
	AtCoder::input(&s);

	const int n = s[0];

	AtCoder::Ans* ans = new AtCoder::Ans();

	for (int i = 0; i < n; i++) {
		for (int ii = 0; ii < n; ii++) {
			for (int iii = 0; iii < n; iii++) {
				ans->increment();
			}
		}
	}

	ans->showResult();

	delete(ans);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define w(t) int t;cin>>t;while(t--)
#define pb   push_back
#define mk   make_pair
#define u_s  unordered_set
#define endl "\n"
#define prDouble(x) cout<<fixed<<setprecision(10)<<x
#define ll long long int
#define ipair pair<int,int>
#define all(x) (x).begin(), (x).end()

const int mod=pow(10,9)+7;

bool compare(pair<int,int>p1,pair<int,int>p2){
    return p1.second<p2.first;
}
/*
  ll C(ll n,ll k){
  
  if(k>n)return 0;
  
  ll ans=1;

  if(k>n-k)
    k=n-k;
  for(ll i=1;i<=k;i++)
    ans*=(n-i+1),ans/=i;

  return ans;
  }
  unsigned long long fact(long long a)
  {
  unsigned long long res=1;
  for(long long i=a;i>0;i--)
    res*=i;
  return res;
  }
  unsigned long long comb(long long a,long long b)
  {
  if((a-b)<b) b=a-b;
  if(a<=19) return fact(a)/(fact(a-b)*fact(b));
  if(a==b||b==0) return 1;
  if(b==1) return a;
  return comb(a-1,b-1)+comb(a-1,b);
  }
*/


int main(){


    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr);
    
    int n; cin>>n;
    vector<int>A(n); for(int i=0;i<n;i++)cin>>A[i];
    ll dp[n+1];
    for(int i=0;i<=n;i++)dp[i]=0;
    dp[0]=0;
    dp[1]=abs(A[0]-A[1]);

    for(int i=2;i<n;i++){
    
       dp[i]=min( dp[i-1]+abs(A[i]-A[i-1]) ,dp[i-2]+abs(A[i]-A[i-2]) );
    }
    cout<<dp[n-1];

    return 0;  
    
}


Measured memory_bytes: 4416
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

signed main() {
    int N, K;
    cin >> N >> K;
    
    if (N > K) N %= K;
    cout << min(abs(N - K), N) << endl;
    return 0;
}


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;
using P = pair<int, int>;

int main()
{
  int n;
  cin >> n;
  rep(i, n)
  {
    int a;
    cin >> a;
    if (a % 2 == 0)
    {
      if (a % 3 == 0 || a % 5 == 0)
      {
        continue;
      }
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

long long *fact, *inv;

template <typename T, typename U, typename V>
auto pow(T x_, U n_, V mod_) {
    std::common_type_t<T, U, V> ret = 1, x = x_, n = n_, mod = mod_;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

template <typename T, typename U>
auto inverse(T x, U p) { return pow(x, p - 2, p); }

void init_factorial(int n, long long mod) {
    fact = new long long[n + 1];
    inv = new long long[n + 1];
    fact[0] = 1;
    for (long long i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % mod;
    inv[n] = inverse(fact[n], mod);
    for (long long i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}

int main() {
    constexpr i64 mod = 1000000007;
    int n;
    std::string s;
    std::cin >> n >> s;
    if (s.front() == 'W' || s.back() == 'W') {
        std::cout << 0 << std::endl;
        return 0;
    }
    init_factorial(n, mod);
    std::deque<std::pair<char, int>> q;
    std::vector<int> v(2 * n);
    for (int i = 0; i < 2 * n; i++) {
        auto c = s[i];
        if (!q.empty() && q.back().first == c) {
            v[i] = 1;
            q.pop_back();
        } else {
            if (q.empty() && c == 'W') {
                std::cout << 0 << std::endl;
                return 0;
            }
            q.emplace_back(c, i);
        }
    }

    i64 ret = q.empty() ? fact[n] : 0, w = 0;
    for (int i = 0; i < 2 * n; i++) {
        if (v[i]) ret = ret * w-- % mod;
        else w++;
    }

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

    return 0;
}


Measured memory_bytes: 3588
import Data.List  -- sort

isRightTriangle sides = a * a + b * b == c * c
        where [a,b,c] = sort sides

main = do { n <- readLn ; main' n }
main' 0 = return ()
main' n = do s <- getLine
             printYN . isRightTriangle . map read . words $ s
             main' (n - 1)

printYN cond = putStrLn (if cond then "YES" else "NO")

Measured memory_bytes: 4008
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define reg register
using namespace std;
const int N=1e5+5;
int n,w[N],cnt[20],ans,st,f[1<<15],sum[1<<15];
inline int read()
{
	int x=0,w=1;
	char c=getchar();
	while (!isdigit(c)&&c!='-') c=getchar();
	if (c=='-') c=getchar(),w=-1;
	while (isdigit(c))
	{
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*w;
}
int main()
{
	n=read();
	for (reg int i=1;i<n;i++)
	{
		int x=read()+1,y=read()+1,z=read();
		w[x]^=z; w[y]^=z;
	}
	for (reg int i=1;i<=n;i++) ++cnt[w[i]];
	for (reg int i=1;i<=15;i++) ans+=cnt[i]/2,st|=((cnt[i]&1)<<(i-1));
	for (reg int i=1;i<(1<<15);i++) f[i]=f[i>>1]+(i&1);
	for (reg int i=1;i<(1<<15);i++) --f[i];
	for (reg int i=1;i<(1<<15);i++)
	  for (reg int j=1;j<=15;j++)
	    if ((i>>j-1)&1) sum[i]^=j;
	for (reg int i=1;i<(1<<15);i++)
	{
		if (sum[i]) continue;
		for (reg int j=i&(i-1);j;j=i&(j-1))
		  if (!sum[j]) f[i]=min(f[i],f[j]+f[i^j]);
	}
	printf("%d\n",ans+f[st]);
	return 0;
}

Measured memory_bytes: 768
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
int main() {
	double a;
	std::cin >> a;
	std::cout << std::fixed;
	double P = M_PI * a * a;
	double L = M_PI * a * 2;
	std::cout  << std::setprecision(20) << P << ' ' << L << std::endl;
	return 0;
}


Measured memory_bytes: 3272
import sys
import fractions

sys.setrecursionlimit(10**9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return [int(x) for x in input().split()]
MOD = 10**9 + 7

N, X = LIST()

x = LIST()

dx = [abs(i - X) for i in x]

def gcd_all(n):
    if len(n) == 1:
        return n[0]

    tail = n.pop(-1)
    return fractions.gcd(tail, gcd_all(n))

print(gcd_all(dx))


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

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

	if(a.at(a.size()-1) == b.at(0) && b.at(b.size()-1) == c.at(0)){
		cout << "YES" << "\n";
	} else cout << "NO" << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
const int64_t MAX = 1000000000000000000;
int64_t gcd(int64_t a, int64_t b)
{
    if (b == 0)
    {
        return a;
    }
    else
    {
        return gcd(b, a % b);
    }
}

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

}

int64_t lcm_array(int64_t *data_array, int N)
{
    if (N==1){
        return data_array[0];
    }
    else{
    int64_t tmp = data_array[0];
    for (int i = 1; i < N; i++)
    {
        
        tmp = lcm(tmp, data_array[i]);
    }
    return tmp;
    }
}



int main()
{   
    int N;
    std::cin >> N;
    int64_t T[N];
    int64_t ans;
    for (int i = 0; i < N; i++)
    {
        std::cin >> T[i];
        
        

        }
    
    for (int i = 0; i < N; i++)
    {
        if (T[i] == MAX)
        {
            ans = MAX;
            std::cout << ans << std::endl;
            
        return 0;
        }
        
    }
    
    ans = lcm_array(T, N);

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

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;

int count(int n, int base) {
    int sum = 0;
    while(n > 0) {
        sum += n % base;
        n /= base;
    }
    return sum;
}
int main(int argc, char **argv) {
    int N;
    cin >> N;
    int res = INF;
    for(int i = 0; i <= N; ++i) {
        res = min(res, count(i, 6) + count(N - i, 9));
    }
    
    cout << res << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int i;
  char c[3],d[3];
  scanf("%s",c);
  scanf("%s",d);
  if((c[0]==d[2] && c[1]==d[1])&&c[2]==d[0]){
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}


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

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

#define vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<ll,ll> 
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;
using ll = long long;
ll md=MD;

ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(ll a,ll b){if(a<b)return a; return b;}
ll Max(ll a,ll b){if(a>b)return a; return b;}
int32_t main() {
    IOS;

        ll n,a;
        cin>>n;
        vec(vll) adj(n);
        rep(i,1,n-1)
        {
        	cin>>a; --a;
        	adj[a].pb(i);
        }
        rep(i,0,n-1)cout<<adj[i].size()<<endl;
        
    return 0;
}

Measured memory_bytes: 14196
/*
memo for solution
*/
#include <cstdlib> 
#include <numeric>
#include <cstring>
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <cmath> 
#include <climits> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <iomanip>
#include<sys/time.h>
using namespace std; 
double e_time(void){static struct timeval now;gettimeofday(&now, NULL);return (double)(now.tv_sec  + now.tv_usec/1000000.0);}
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
#define fe(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr != (c).end();itr++)
#define BITSHIFT(X)     ( (1<<(X)) )
#define CONTAIN(S,X) ( ((S)&BITSHIFT(X)) != 0)
typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 
typedef vector<int> vint;
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  
template<class T> T ceilUp(const T& a,const T& b){return (a+b-1)/b;}
const ll mod =   1000000009;
inline ll modadd(ll a,ll b){a %= mod;b %= mod;return (a+b)%mod;}
inline ll modsub(ll a,ll b){a %= mod;b %= mod;a-=b;a%=mod;if (a<0)a+=mod;return a;}
inline ll modmul(ll a,ll b){a %= mod;b %= mod;return (a*b)%mod;}
inline ll modeq(ll a,ll b,ll m){a = (a%m+m)%m; b = (b%m+m)%m;return a == b;}
//ll modpow(ll n,ll p){if (p == 0)return 1;if (p == 1)return n;ll ret=mypow(n,p/2);ret=ret*ret%mod;if (p&1)ret=ret*n%mod;return ret;}
//ll getinv(ll a){return mypow(a,mod-2);}
ll mypow(ll n,ll p){
  if (p == 0)return 1;
  if (p == 1)return n;
  ll ret=mypow(n,p/2);
  ret=ret*ret;
  if (p&1)ret=ret*n;
  return ret;
}


int main(){
  int n,k;
  string in;
  cin >> n >> k >> in;
  in[k-1] = tolower(in[k-1]);
  cout << in << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  for (int i = 0; i < n; i++) {
	cin >> l[i];
  }
  sort(l.begin(), l.end(), greater<int>());
  int ans = 0;
  for (int i = 0; i < k; i++) {
	ans += l[i];
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    
    int max = Math.max(Math.max(A, B), C);
    int gap = 3 * max - A - B - C;
    
    System.out.println(gap % 2 == 0 ? gap / 2 : (gap+3) / 2);
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define re register
#define ll long long
using namespace std;
const int maxn=400+10;
template<typename T> void read(T &x){
	T f=1;x=0;
	char c=getchar();
	while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	x*=f;
}
int n;
ll a[maxn];
ll f[maxn][maxn],dp[maxn][maxn];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	read(n);
	for(re int i=1;i<=n;i++){
		read(a[i]);
	}
	memset(f,0x3f3f3f3f,sizeof f);
	memset(dp,0x3f3f3f3f,sizeof dp);
	for(re int i=1;i<=n;i++) f[i][i]=dp[i][i]=a[i]; 
	for(re int i=2;i<=n;i++){
		for(re int j=1;j<=n-i+1;j++){
			for(re int k=j;k<=j+i-1;k++){
				f[j][j+i-1]=min(f[j][j+i-1],f[j][k]+f[k+1][j+i-1]);
				dp[j][j+i-1]=min(dp[j][j+i-1],dp[j][k]+dp[k+1][j+i-1]+f[j][k]+f[k+1][j+i-1]);
			} 
		} 
	}
	cout<<dp[1][n]-f[1][n]<<endl;
	return 0;
}


Measured memory_bytes: 2816
using System;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var imp = Console.ReadLine().Split(' ');
            int N = int.Parse(imp[0]);
            int i = int.Parse(imp[1]);
            
            Console.Write((N-1)*(i-1));
           
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
 
using namespace std;
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>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()

#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
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

char albt[26] = {'a','b','c','d','e','f','g','h','i','j','k','l',
                 'm','n','o','p','q','r','s','t','u','v','w','x',
                 'y','z'};

//vector<ll> g[202020];
//fill(score, score+202020, 0);
//vector<ll> v[505];

int main(){
  ll n;
  cin >> n;
  ll H[n];
  for(int i=0;i<n;i++) cin >> H[i];
  ll r[n];
  r[n-1] = 0;
  ll max = 0;
  for(int i=n-2;i>=0;--i){
    if(H[i]>=H[i+1]) r[i] = r[i+1]+1;
    else r[i] = 0;
    if (r[i]>max) max = r[i];
  }
  
  cout << max << endl;
}

Measured memory_bytes: 1792
void main() {
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], m = tmp[1];
    int[] a = new int[n], b = new int[n];
    foreach (i; 0 .. n) {
        tmp = readln.split.to!(int[]);
        a[i] = tmp[0], b[i] = tmp[1];
    }
    int[] c = new int[m], d = new int[m];
    foreach (i; 0 .. m) {
        tmp = readln.split.to!(int[]);
        c[i] = tmp[0], d[i] = tmp[1];
    }
    foreach (i; 0 .. n) {
        int point;
        int distance = int.max;
        foreach (j; 0 .. m) {
            int len = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (len < distance) {
                point = j + 1;
                distance = len;
            }
        }
        point.writeln;
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

int main() {
  int D,N;
  cin >> D >> N;
  if (D==0&&N!=100) {
    cout << N << endl;
  }
  else if (D==0&&N==100) {
    cout << 101 << endl;
  }
  else if (D==1&&N!=100) {
    cout << 100*N << endl;
  }
  else if (D==1&&N==100) {
    cout << 10100 << endl;
  }
  else if (D==2&&N!=100) {
    cout << 10000*N << endl;
  }
  else {
    cout << 1010000 << endl;
  }
}


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

int main() {
  int N;
  cin >> N;
  
  if ( N % 2 == 0 && N != 1 ){
    cout << "0.5" << endl;
  }
  else if ( N % 2 == 1 && N != 1 ){
    cout << ( double )( N / 2 + 1 ) / N << endl;
  }
  else if ( N == 1 ){
    cout << 1.0000000000 << endl;
  }
}


Measured memory_bytes: 256
import itertools
import copy
from collections import deque
import heapq
n = int(input())
ma = []
mi = []
for i in range(n):
    a,b = map(int,input().split())
    mi.append(a)
    ma.append(b)
mi.sort()
ma.sort()
if n % 2 == 1:
    ans = ma[(n+1)//2-1]-mi[(n+1)//2-1] + 1
else:
    ans = (ma[n//2]+ma[n//2-1]-mi[n//2]-mi[n//2-1])+1
print(ans)


Measured memory_bytes: 25996
#include<bits/stdc++.h>
#define ll long long
#define ljc 1000000007
using namespace std;
ll dp[404040][3][3];//1100
int n;
char s[404040];
signed main(){
	cin>>(s+1);
	n=strlen(s+1);
	dp[0][0][0]=1;
	for (int i=1;i<=n;i++){
		if (s[i]!='0'){
			for (int j=0;j<3;j++){
				for (int k=0;k<3;k++){
					if (k) dp[i][j][k-1]=(dp[i][j][k-1]+dp[i-1][j][k])%ljc;
					else dp[i][min(j+1,2)][k]=(dp[i][min(j+1,2)][k]+dp[i-1][j][k])%ljc;
				}
			}
		}
		if (s[i]!='1'){
			for (int j=0;j<3;j++){
				for (int k=0;k<3;k++){
					if (k==2) dp[i][j][1]=(dp[i][j][1]+dp[i-1][j][k])%ljc;
					else dp[i][j][k+1]=(dp[i][j][k+1]+dp[i-1][j][k])%ljc;
				}
			}
		}
	}
	ll ans=0;
	for (int j=0;j<3;j++){
		for (int k=0;k<=j;k++){
			ans=(ans+dp[n][j][k])%ljc;
		}
	}
	cout<<ans;
	return 0;
}

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 




int main() {

int N;
cin >> N;

vector<ll>A(N);
REP(i, N) cin >> A.at(i);

int cnt = 0;
while(true){
  REP(i, N){
    if(A.at(i) % 2 != 0){
    cout << cnt << endl;
    return 0;
  }else A.at(i) /= 2;
}
  cnt++;
}

}

Measured memory_bytes: 256
//AtCoder ABC075 C - Bridge
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
struct Node{
    bool enable=true;
    vector<ll> edges;
};
int main() {
    ll N,M;
    cin>>N>>M;
    vector<Node> nodes(N+1);
    for(int i=0;i<M;++i){
        ll a,b;
        cin>>a>>b;
        nodes[a].edges.push_back(b);
        nodes[b].edges.push_back(a);
    }
    //探索
    ll ans=0;
    bool found=true;
    while(found){
        found=false;
		for(ll i = 1; i <= N; ++i) {
			if(nodes[i].edges.size() == 1) {
				auto no = nodes[i].edges[0];
				nodes[i].edges.clear();
				auto it =
					find(nodes[no].edges.begin(), nodes[no].edges.end(), i);
				nodes[no].edges.erase(it); //連結消す
				++ans;
				found=true;
				break;
			}
		}
	}
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.string;

enum arrow { L,R,U,D };

void main(){
	int n = readln.chomp.to!int();
	const arrow[dchar] toArrow = [ 'L':arrow.L, 'R':arrow.R, 'U':arrow.U, 'D':arrow.D ];
	foreach(i; 0..n){
		auto score =  readln.chomp.map!(a=>toArrow[a])();
		writeln(score.isNatural? "Yes": "No");
	}
}

bool isNatural(T)(T score){
	arrow prev = cast(arrow)-1;
	bool startLeft = true;
	bool startRight = true;
	bool startFoot = true;
	foreach(s; score){
		if(prev == s) return false;
		if(s == arrow.L){
			startLeft = startLeft && startFoot;
			startRight = startRight && !startFoot;
		}else if(s == arrow.R){
			startLeft = startLeft && !startFoot;
			startRight = startRight && startFoot;
		}
		if(!(startLeft || startRight)) return false;
		prev = s;
		startFoot ^= true;
	}
	return true;
}

Measured memory_bytes: 1472
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,r;
  cin >> s >> r;
  if(s.at(0)==r.at(2)&&s.at(1)==r.at(1)&&s.at(2)==r.at(0)){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3580
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

using namespace std;

inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }

const int maxn=1e5+10;

int book[maxn];

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	for(int x=1;x<=100;x++)
	{
		for(int y=1;y<=100;y++)
		{
			int t1=x+y;
			for(int z=1;z<=100;z++)
			{
				int t2=y+z;
				int t3=x+z;
				
				int to= (t1*t1+t2*t2+t3*t3)>>1;
				
				book[to]++;
			}
		}
	}
	
	int n;
	while(cin>>n)
	{
		for(int i=1;i<=n;i++)
		{
			cout<<book[i]<<endl;
		}
	}
	
	return 0;
}

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





vector<string>finall;
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){
    string str;
    cin>>str;
    sort(str.begin(),str.end());
    finall.push_back(str);

}



long long int counter=1;
long long int res=0;
sort(finall.begin(),finall.end());
//for(auto x: finall)cout<<x<< " ";
string str2="";
for(int i=0;i<n;i++){

    if(str2==finall[i])counter++;
    else {
            res+=((counter*(counter-1))/2);
              counter=1 ;}

    str2=finall[i];

}
res+=((counter*(counter-1))/2);
cout<<res<<endl;






}

Measured memory_bytes: 7796
import sys
from operator import itemgetter
read = sys.stdin.read

N, *P = map(int, read().split())
p = sorted(enumerate(P), key=itemgetter(1))

length = []
cnt = 1
for i in range(N - 1):
    if p[i + 1][0] < p[i][0]:
        length.append(cnt)
        cnt = 1
    else:
        cnt += 1

length.append(cnt)

print(N - max(length))

Measured memory_bytes: 35840