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


class Program {

	static long mod = 998244353;
	static int[] ans;
	static void Main(string[] args) {

		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res="";
		int res = 0;
		

		int n = int.Parse(Console.ReadLine());

		int[][] pair = new int[n-1][];
		int[] nums = new int[n];
		int[] conection = new int[n + 1];
		List<List<int>>li = new List<List<int>>();
		for ( int i = 0; i < n+1 ; i++ ) {
			li.Add(new List<int>());
		}


		for ( int i = 0; i < n-1; i++ ) {
			pair[i] = parseAry(Console.ReadLine().Split(cs));
			li[pair[i][0]].Add(pair[i][1]);
			li[pair[i][1]].Add(pair[i][0]);

		}
		search(li,1,1,-1);
			


		nums = parseAry(Console.ReadLine().Split(cs));
		Array.Sort(nums);
		Array.Reverse(nums);




		List<int> cn=new List<int>(nums);
		ans = new int[n+1];

		ans[maxnum] = cn[0];
		cn.RemoveAt(0);
		int k=1;
		write(li, maxnum, cn, -1);


		res = nums.Sum()-nums[0];


		string s = "";
		for ( int i = 1; i < n+1 ; i++ ) {
			s += ans[i]+" ";		
		}
		s = s.Trim();
		Console.WriteLine(res);
		Console.WriteLine(s);

		return;

	}
	static int maxdep = 0;
	static int maxnum = 0;
	
	static void search(List<List<int>>li, int now, int dep,int oya) {
		if ( dep > maxdep ) { maxdep = dep;maxnum=now; }
		List<int> tlis = li[now];
		for ( int i = 0; i < tlis.Count; i++ ) {
			if ( tlis[i] == oya ) { continue; }
			search(li, tlis[i], dep + 1,now);
		}
	
	}
	static void write(List<List<int>> li, int now, List<int> cn,int oya) {

		List<int> tlis = li[now];
		for ( int i = 0; i < tlis.Count; i++ ) {
			int nex = tlis[i];
			if ( nex == oya ) { continue; }
			ans[nex] = cn[0];
			cn.RemoveAt(0);
			write(li, nex, cn, now);
		}

	}



	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}

}

Measured memory_bytes: 39484
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Handstand 2
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

int cs[10][10];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 1; i <= n; i++) {
    int t = i % 10;
    int h = i;
    while (h >= 10) h /= 10;
    cs[h][t]++;
  }

  int sum = 0;
  for (int i = 1; i <= 9; i++)
    for (int j = 1; j <= 9; j++)
      sum += cs[i][j] * cs[j][i];

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


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define INF 20000
#define WHITE 0
#define GRAY 1
#define BLACK 2
void prim();
int w(int,int);
int n,**G,mincost,*d,*pi,*color;
int main(){
  int a,i,j,totalcost;
  scanf("%d",&n);
  G = (int**)malloc(sizeof(int*) * n);
  for(i=0; i<n; i++){
    G[i] = (int*)malloc(sizeof(int) * n);
  }
  d = (int*)malloc(sizeof(int) * n);
  pi = (int*)malloc(sizeof(int) * n);
  color = (int*)malloc(sizeof(int) * n);
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      scanf("%d",&a);
      G[i][j] = (a == -1 ? INF : a);
    }
  }
  prim();
  for(i=0,totalcost=0; i<n; i++){
    totalcost += d[i];
  }
  printf("%d\n",totalcost);
  return 0;
}

void prim(){
  int i,u,v;
  for(i=0; i<n; i++){
    d[i] = INF;
    pi[i] = INF;
    color[i] = WHITE;
  }
  d[0] = 0;
  while(1){
    mincost = INF;
    for(i=0; i<n; i++){
      if(color[i] != BLACK && d[i] < mincost){
        mincost = d[i];
        u = i;
      }
    }
    if(mincost == INF){
      break;
    }
    color[u] = BLACK;
    for(v=0; v<n; v++){
      if(color[v] != BLACK && w(u,v) < d[v]){
        pi[v] = u;
        d[v] = w(u,v);
      }
    }
  }
}

int w(int i,int j){
  return G[i][j];
}

Measured memory_bytes: 640
#include<stdio.h>
int dis(int a){
  if(a > 753){
    return a - 753;
  }
  return 753 - a;
}

int main(){
  long long int s,c;
  int keta = 0,min = 753;
  scanf("%lld",&s);
  c = s;
  while(c > 0){
    c /= 10;
    keta++;
  }
  int a[keta];
  for(int i = 0;i < keta;i++){
    a[i] = s % 10;
    s /= 10;
  }
  for(int i = 2;i < keta;i++){
    int ans = dis(a[i] * 100 + a[i - 1] * 10 + a[i - 2]);
    if(ans < min){
      min = ans;
    }
  }
  printf("%d\n",min);
  return 0;
}

Measured memory_bytes: 128
my $N = <STDIN>;
my @X = split(/ /, <STDIN>);
my @Z = sort {$a <=> $b} @X;
my $A1 = $Z[$N/2-1];
my $A2 = $Z[$N/2];
$A1 =~ s/(\r\n|\r|\n)$//g;
$A2 =~ s/(\r\n|\r|\n)$//g;
if ($A1 == $A2) {
        foreach my $i (@X) {
                print $A1."\n";
        }
} else {
        foreach my $i (@X) {
                if ($i > $A1) {
                        print $A1."\n";
                } else {
                        print $A2."\n";
                }
        }
}

Measured memory_bytes: 51508
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#pragma warning(disable : 4996)

#define MAX_N 20000

struct Lake {
	int begin;
	int end;
	Lake() {
		begin = -1;
		end = -1;
	}
	Lake(int b, int e) : begin(b), end(e) {}
};

char in[MAX_N + 1];
int h[MAX_N + 1];
int max_h[MAX_N + 1];
std::vector<Lake> lakes;
std::vector<int> lakeWater;


int min(int a, int b) {
	if (a < b) {
		return a;
	}
	else {
		return b;
	}
}


int main(void) {
	scanf("%s", &in[0]);

	int n = strlen(in);
	int c = 0;
	h[0] = c;
	for (int i = 0; i < n; ++i) {
		if (in[i] == '\\') {
			h[i+1] = --c;
		}
		else  if (in[i] == '/') {
			h[i+1] = ++c;
		}
		else {
			h[i+1] = c;
		}
	}
	int max = h[n];
	for (int i = 0; i < n+1; ++i) {
		if (max < h[n - i]) {
			max = h[n - i];
		}
		max_h[n - i] = max;
	}
	int b = -1;
	for (int i = 0; i < n; ++i) {
		if (in[i] == '\\') {
			if (b == -1) {
				b = i;
			}
		}
		else if ((i > 0) && (in[i] == '/')) {
			if (b != -1) {
				if (h[b] == h[i+1]) {
					lakes.push_back(Lake(b, i+1));
					b = -1;
				}
				else if(h[i+1] == max_h[i+1]) {
					lakes.push_back(Lake(b, i+1));
					b = -1;
				}
			} 
		}
	}
	int tw = 0;
	for (size_t i = 0; i < lakes.size(); ++i) {
		int begin = lakes[i].begin;
		int end = lakes[i].end;
		int wh = min(h[begin], h[end]);
		int w = 0;
		for (int j = begin; j < end; ++j) {
			int diff = wh - h[j];
			int tw = 0;
			if (diff >= 0) {
				tw += diff * 2;
				if (in[j] == '\\') {
					tw += 1;
				}
				else if (in[j] == '/') {
					tw -= 1;
				}
			}
			w += tw;
		}
		w /= 2;
		tw += w;
		lakeWater.push_back(w);
	}
	printf("%d\n", tw);
	printf("%d", lakes.size());
	for (size_t i = 0; i < lakeWater.size(); ++i) {
		printf(" %d", lakeWater[i]);
	}
	printf("\n");


	return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  ll sum=0;
  ll tmp=n;
  while(tmp){
    sum+=tmp%10;
    tmp/=10;
  }
  if(n%sum==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
#define elif else if
using namespace std;
const int MOD = 1e9 + 7, INF = 1e17;
using vi = vector <int>;
using vvi = vector <vi>;

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

	int ans = 0;
	rep(i, n + 1){
		string va = to_string(i);
		int sum = 0;
		rep(j, va.size())
			sum += va[j] - '0';
		if(a <= sum && sum <= b)
			ans += i;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
//Intersection
//created by rokon 4.43 AM 9 / 3 / 2019

#include<bits/stdc++.h>
using namespace std;

int main()
{
    while(1)
    {
        int a,b;
        cin >> a >> b;
        if(a == 0 || b == 0)break;
        for(int i = 0 ; i < a ; i++){
            for(int j = 0 ; j < b ; j++){
                if((i + j) & 1)cout << ".";
                else cout << "#";
            }cout << endl;
        }cout << endl;
    }
    return 0;
}




Measured memory_bytes: 3084
def main():
    N, M = map(int, input().split())
    skip = (N // 2) // 2 + 1 if N % 2 == 0 else None
    count = 0
    left, right = 0, N + 1
    while count < M:
        left += 1
        if left == skip:
            continue
        right -= 1
        print(left, right)
        count += 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 9276
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
//#define ivorysi
#define MAXN 100005
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 + c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) out(x / 10);
    putchar('0' + x % 10);
}
int N;
int a[1005][1005];
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    read(N);
    int t = 0,k = 0;
    for(int i = 1 ; i <= N ; ++i) {
        t += i;
        if(t >= N) {k = i;break;}
    }
    if(t != N) {puts("No");}
    else {
        puts("Yes");
        out(k + 1);enter;
        int cnt = 0;
        for(int j = 1 ; j <= k ; ++j) {
            for(int i = j ; i <= k ; ++i) {
                a[j][i] = ++cnt;
            }
            for(int i = j + 1 ; i <= k + 1 ; ++i) {
                a[i][j] = a[j][i - 1];
            }
        }
        for(int i = 1 ; i <= k + 1 ; ++i) {
            out(k);
            for(int j = 1 ; j <= k ; ++j) {
                space;out(a[i][j]);
            }
            enter;
        }
    }
    return 0;
}

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

int abs(int n){
  if(n>0) return n;
  else return -n;
}

int main(){
  string S;
  cin >>S;
  int n = S.size();
  vector<int> M(n-2);
  for(int i=0;i<n-2;i++){
    int a,b,c;
    a = S[i] - 48;
    b = S[i+1] - 48;
    c = S[i+2] - 48;
    int sum = 100*a + 10*b + c;
    M[i] = abs(753 - sum);
  }
  sort(M.begin(),M.end());
  cout << M[0] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long target = sc.nextLong();
		long b = sc.nextLong();
		long r = sc.nextLong();
		long sum = r + b;

		if (b == 0 || target == 0) {
			System.out.println(0);
			return;
		}

		//B+RがNよりも小さい場合
		if (target <= sum) {
			if(b <= target) {
				System.out.println(b);
				return;
			}else{
				System.out.println(target);
				return;
			}
		}

		//B+RがNよりも大きい場合
		long count = target / sum;
		long temp = target - (count * sum);

		if (b <= temp) {
			System.out.println(count * b + b);
		} else {
			System.out.println(count * b + temp);
		}

	}
}


Measured memory_bytes: 23632
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
#define MOD 1000000007
int main()
{   
    ll N ;
    cin >> N ;
    ll a[N] ;
    for(ll i = 0 ; i < N ; i++){
        cin >> a[i] ;
    }

    sort(a, a+N) ;
    cout << a[N-1] << " ";
    ll max = a[N-1] ;
    ll b[N] ;
    ll max2 = 0 ;
    for(ll i = 0 ; i < N ; i++){
        b[i] = min(a[i] , max-a[i]) ;
        if(max2 < b[i]){
            max2 = b[i] ;
        }
    }

    for(ll i = 0 ; i < N ; i++){
        if(max2 == b[i]){
             cout << a[i] << endl;
             return 0 ;
        }
    }
    return 0;
}

Measured memory_bytes: 5208
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(){
    string s,t;
    cin >> s;
    cin >> t;
    map<char,int> m1,m2;
    bool ans = true;
    
    for(int i = 0; i < s.size(); i++){
        if(m1[s[i]] == 0){
            m1[s[i]] = t[i];
        }else{
            if(m1[s[i]] != t[i]){
                ans = false;
                break;
            }
        } 
    }

    if(!ans){
        cout << "No" << endl;
    }else{
        for(int i = 0; i < s.size(); i++){
                if(m2[t[i]] == 0){
            m2[t[i]] = s[i];
            }else{
                if(m2[t[i]] != s[i]){
                    ans = false;
                    break;
                }
            } 
        }

        if(ans){
            cout << "Yes" << endl;
        }else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 776
/* C */

#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int n;
	cin >> n;
	int x[n], y[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> x[i];
		y[i] = x[i];
	}
	sort(y,y+n);
	int a = y[n/2-1], b = y[n/2];
	for (int i = 0; i < n; ++i)
	{
		if(x[i]<b) cout << b << endl;
		else cout << a << endl;
	}

	return 0;

}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
void update(vector<vector<int>> &v, vector<vector<int>> &m, int n)
{
    rep(i, 3) rep(j, 3)
    {
        if (v[i][j] == n)
        {
            m[i][j] = 1;
        }
    }
}

bool check(vector<vector<int>> &m)
{
    bool ret = false;
    bool cur = true;
    rep(i, 3)
    {
        rep(j, 3) cerr << m[i][j];
        cerr << endl;
    }
    rep(i, 3)
    {
        cur = true;
        rep(j, 3)
        {
            cur &= (m[i][j] == 1 ? true : false);
        }
        ret |= cur;
    }
    rep(i, 3)
    {
        cur = true;
        rep(j, 3)
        {
            cur &= (m[j][i] == 1 ? true : false);
        }
        ret |= cur;
    }
    cur = true;
    rep(j, 3)
    {
        cur &= (m[j][j] == 1 ? true : false);
    }
    ret |= cur;
    cur = true;
    rep(j, 3)
    {
        cur &= (m[j][2 - j] == 1 ? true : false);
    }
    ret |= cur;
    return ret;
}
int main(int argc, char const *argv[])
{
    vector<vector<int>> v(3, vector<int>(3, 0));
    auto m = v;
    rep(i, 3) rep(j, 3) cin >> v[i][j];
    int n;
    cin >> n;
    rep(i, n)
    {
        int t;
        cin >> t;
        update(v, m, t);
    }
    if (check(m))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String O = sc.next();
		String E = sc.next();
		for(int i = 0;i < O.length() - 1;i ++) {
			System.out.print(O.charAt(i));
			System.out.print(E.charAt(i));
		}
		System.out.print(O.charAt(O.length() - 1));
		if(O.length() == E.length()) {
			System.out.println(E.charAt(E.length() - 1));
		}
	}
}

Measured memory_bytes: 23764
#include <cstdio>
#include <algorithm>
using namespace std;

const int N = 105;

int a[N];

int main() {
	int n, x;
	scanf("%d%d", &n, &x);
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	sort(a, a + n);
	int c = 0;
	int i;
	for (i = 0; i < n; i++) {
		x -= a[i];
		if (x >= 0) {
			c++;
		}
		else {
			break;
		}
	}
	if (x > 0 && i == n)
		--c;
	printf("%d\n", c);
	return 0;
}

Measured memory_bytes: 128
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
  s <- B.getLine
  B.putStrLn $ f s

pickOdds
  :: [a] -> [a]
pickOdds = map snd . filter fst . zip (cycle [True, False])

f as = B.pack [ x | let l = B.length as
                  , i<- [0,2 .. l-1]
                  , let x = B.index as i ]


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


int main() {
	//A=65/Z=90
	int N;
	char S[10001] = "";
	int NUM[10000] = { 0 };
	int length = 0;

	cin >> N;
	cin >> S;
	length = strlen(S);


	for (int n = 0; n < length; n++) {
		S[n] = (65 + ((int(S[n]) + N) - 65) % 26);
		
	}

	cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define str string
#define optimizator ios_base::sync_with_stdio(0);
using namespace std;
int main(){
	optimizator;
		int n,m;
		cin>>n>>m;
		if(n<10){
			m+=100*(10-n);
		}
		cout<<m;
}

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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;




int main(){
  int n; cin>>n;
  for(int i = 1; i <=3500; i++){
      for(int j = i; j <= 3500; j++){
          double k = (double) n * i * j/(4 * i * j - n * i - n * j);
          if((int) k > 0 &&floor(k) == ceil(k)){
              cout<<i<<" "<<j<<" "<<(int)k<<endl;
              return 0;
          }
      }
  }
}


Measured memory_bytes: 3620
import sys
import numpy as np
import itertools

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
N, K = map(int,input().split())
#A = list(map(int,input().split()))

m = np.arange(1,N+2)
m1 = np.arange(N+1,0,-1)

for i in range(1,len(m)):
    m[i] = (m[i] + m[i-1])%mod
    m1[i] = (m1[i] + m1[i-1])%mod

#m = np.array(list(itertools.accumulate(m)))
#m1 = np.array(list(itertools.accumulate(m1)))
#m = m % mod
#m1 = m1 % mod

ans = 0
for i in range(K-1,N+1):
    ans += m1[i] - m[i] + 1
    ans %= mod

print(ans)

Measured memory_bytes: 29696
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin >> n;
  long long a[n],odd[n/2],even[n/2];
  pair<long long,int> p1[n/2],p2[n/2];
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(i%2==0){
      odd[i/2]=a[i];
    }else{
      even[i/2]=a[i];
    }
  }
  sort(odd,odd+n/2);
  int cnt=1,cntt=0;
  for(int i=1;i<n/2;i++){
    if(odd[i]!=odd[i-1]){
      p1[cntt]=make_pair(cnt,odd[i-1]);
      cntt++;
      cnt=0;
    }
    cnt++;
    if(i==n/2-1)p1[cntt]=make_pair(cnt,odd[i]);
  }
  sort(even,even+n/2);
  cnt=1,cntt=0;
  for(int i=1;i<n/2;i++){
    if(even[i]!=even[i-1]){
      p2[cntt]=make_pair(cnt,even[i-1]);
      cntt++;
      cnt=0;
    }
    cnt++;
    if(i==n/2-1)p2[cntt]=make_pair(cnt,even[i]);
  }
  sort(p1,p1+n/2);
  reverse(p1,p1+n/2);
  sort(p2,p2+n/2);
  reverse(p2,p2+n/2);
  if(p1[0].second!=p2[0].second){
    cout << n-p1[0].first-p2[0].first << endl;
    return 0;
  }
  cout << min(n-p1[0].first-p2[1].first , n-p1[1].first-p2[0].first) << endl;
  return 0;
}

Measured memory_bytes: 3456
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,x,a[100010];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	x=a[1];
	for(int i=2;i<=n-1;i++)
	{
		int y=min(a[i],a[n]-a[i]),k=min(x,a[n]-x);
		if(y>k) x=a[i];
	}
	printf("%d %d",a[n],x);
}

Measured memory_bytes: 640
#ifdef LOCAL111
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	LL l, r;
	const int mo = 2019;
	while(cin >> l >> r) {
		if(r - l > mo) {
			cout << 0 << endl;
		} else {
			l = l % mo;
			r = r % mo;
			int ans = INF;
			DEBUG(l);
			FOR(i, l, r + 1) FOR(j, l, i){
				chmin(ans, i * j % mo);
			}
			cout << ans << endl;

		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

int main () {
  int H, W, K;
  cin >> H >> W >> K;
  vvi dp(H+1,vi(W,0));
  dp[0][0] = 1;
  rep(i,H) {
    rep(j,W) {
      rep(k,1<<(W-1)) {
        // 2つの横線がつながっていないか調べる
        bool ok = true;
        rep(l,W-2) {
          if (((k>>l) & 1) && (k>>(l+1)) & 1) ok = false;
        }
        if (ok) {
          if (j >= 1 && ((k>>(j-1)) & 1)) {
            // 左方向に横線をたどるケース
            dp[i+1][j-1] += dp[i][j];
            dp[i+1][j-1] %= mod;
          }
          else if (j <= W-2 && ((k>>j) & 1)) {
            // 右方向に横線をたどるケース
            dp[i+1][j+1] += dp[i][j];
            dp[i+1][j+1] %= mod;
          }
          else {
            // 横線をたどらないケース
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= mod;
          }
        }
      }
    }
  }
  cout << dp[H][K-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<string>
#include<queue>
#include<set>
#include<stack>
#include<map>

using namespace std;

int main(){
    int N;
    cin>>N;
    int b[101];
    for(int i=1;i<=N;i++){
        cin>>b[i];
    }
    vector<int> ans;
    for(int t=N;t>=1;t--){
        int tmp=t;
        for(int i=N;i>=1;i--){
            if(b[i]==tmp){
                ans.push_back(tmp);
                b[i]=-1;
                break;
            }else if(b[i]!=-1){
                tmp--;
            }
        }
    }
    if(ans.size()==N){
        for(int i=ans.size()-1;i>=0;i--){
            cout<<ans[i]<<endl;
        }
    }else{
        cout<<(-1)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int a[] = { 0, 0, 0 };
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[2] - a[0] << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W = map(int, input().split())
    S = [list(input()) for _ in range(H)]

    start = []
    for h in range(H):
        for w in range(W):
            if S[h][w] != "#":
                start.append([h, w])

    res = 0
    for sh, sw in start:
        maze = [[f_inf] * W for _ in range(H)]
        maze[sh][sw] = 0
        que = deque([[sh, sw]])
        while que:
            h, w = que.popleft()
            for dh, dw in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
                next_h, next_w = h + dh, w + dw
                if next_h < 0 or next_h >= H or next_w < 0 or next_w >= W:
                    continue
                elif S[next_h][next_w] == "#":
                    continue
                else:
                    if maze[next_h][next_w] > maze[h][w] + 1:
                        maze[next_h][next_w] = maze[h][w] + 1
                        que.append([next_h, next_w])
        ma = 0
        for h in range(H):
            for w in range(W):
                if S[h][w] != "#":
                    ma = max(ma, maze[h][w])
        res = max(res, ma)
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 74868
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define ll long long
#define ull  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 1100000;
int b[N], a[N], c[N], d[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++){
        cin >> b[i];
    }
    int ans = 0;
    for (int i = 0; i < 29; i++){
        int k = (1 << (i + 1));
        int m = k / 2;
        for (int j = 1; j <= n; j++){
            c[j] = a[j] % k;
            d[j] = b[j] % k;
        }
        sort(c + 1, c + n + 1);
        sort(d + 1, d + n + 1);
        ll f = 0;
        for (int i = 1; i <= n; i++){
            int l = 0;
            int r = n + 1;
            int p1, p2, p3;
            while(r - l > 1){
                int mid = (r + l) / 2;
                if (d[mid] + c[i] < m) l = mid; else r = mid;
            }
            p1 = l;
            r = n + 1;
            l = 0;
            while(r - l > 1){
                int mid = (r + l) / 2;
                if (d[mid] + c[i] < m + m) l = mid; else r = mid;
            }
            p2 = l;
            r = n + 1;
            l = 0;
            while(r - l > 1){
                int mid = (r + l) / 2;
                if (d[mid] + c[i] < m + m + m) l = mid; else r = mid;
            }
            p3 = l;
            f += max(p2 - p1, 0);
            f += max(n - p3, 0);
        }
        ans += m * (f % 2);
    }
    cout << ans;
}


Measured memory_bytes: 7168
#include<cstdio>
#include<cstring>
const int N=200005;
int n,s[N],t,a;char c[N];
int main()
{
	scanf("%s",c+1),a=n=strlen(c+1);
	for(int i=1;i<=n;++i)
		if(t&&s[t]=='S'&&c[i]=='T')--t,a-=2;
		else s[++t]=c[i];
	return printf("%d",a),0;
}

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

int main(){
string w;
string t;
int al=0;
cin>>w;
while(cin>>t){
for(int i=0;i<t.size();i++){
if(isupper(t[i])){t[i]=tolower(t[i]);}
}

if(t==w){
al++;
}}

cout<<al<<endl;
return 0;
}


Measured memory_bytes: 3144
def main():
    N = int(input())
    points = [None] * N
    for i in range(N):
        x, y = map(int, input().split())
        points[i] = (x, y)
    ans = 0
    points.sort(reverse=True)
    topright = points[0][0] + points[0][1]
    bottomright = points[0][0] - points[0][1]
    for i in range(N):
        tr = points[i][0] + points[i][1]
        br = points[i][0] - points[i][1]
        ans = max([ans, abs(topright - tr), abs(bottomright - br)])
        topright = max(topright, tr)
        bottomright = max(bottomright, br)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 79068
n,x,y = map(int,input().split())
b = [0]*n

for i in range(1,n+1):
    for j in range(i+1,n+1):
        dist1 = j-i
        dist2 = abs(x-i)+abs(y-j)+1
        dist3 = abs(y-i)+abs(x-j)+1
        d = min(dist1,dist2,dist3)
        b[d] += 1

for i in range(1,n):
    print(b[i])


Measured memory_bytes: 9172
/* include */
#include "bits/stdc++.h"
/* namespace */
using namespace std;

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define pb push_back              // push_back
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

void Main(void)
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (true)
    {
        c -= b;
        if (c <= 0)
        {
            cout << "Yes" << endl;
            return;
        }
        a -= d;
        if (a <= 0)
        {
            cout << "No" << endl;
            return;
        }
    }
}

int main(int argc, char *argv[])
{
    // cin, coutの高速化、ただしcのIOと一緒にしない
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // fixed -> 少数の形で出力、setprecision -> 少数第n位まで出力
    cout << fixed << setprecision(15);
    // main実行
    Main();

    return 0;
}


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

using ll = long long;
#define pq priority_queue
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int main() {
   int n;
   while (cin >> n, n) {
      int o = 1000 - n;
      int cnt = 0;
      while (o != 0) {
         if (o >= 500) {
            o -= 500;
         } else if (o >= 100) {
            o -= 100;
         } else if (o >= 50) {
            o -= 50;
         } else if (o >= 10) {
            o -= 10;
         } else if (o >= 5) {
            o -= 5;
         } else if (o >= 1) {
            o -= 1;
         }
         cnt++;
      }
      cout << cnt << endl;
   }

   return 0;
}


Measured memory_bytes: 2972
#include<bits/stdc++.h>
using namespace std;
int ord(int n){
  int ret=0;
  while(n){
    n/=10;
    ret++;
  }
  return ret;
}
int main(){
  int n,ans=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    if(ord(i)%2==1){ans++;}
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
  char s[4];
  char *w[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  scanf("%s",s);
  int checker;
int i;
  for(i=0;i<7;i++){
    checker=strcmp(s,w[i]);
    //printf("%s\n",w[i]);
    //printf("%d\n",checker);
    if(checker==0){
      printf("%d",7-i);
      return 0;
    }
  }

return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<string.h>
#include<functional>
using namespace std;

#define INF 1<<21
#define DIV 1000000007

typedef pair<int, int>P;


int w, h;
int cnt;
char f[21][21];
int dx[] = { 1,-1,0,0 }, dy[] = { 0,0,1,-1 };

void rec(int x, int y) {
  f[y][x] = '#';
  cnt++;

  for (int i = 0; i < 4; i++) {
	int nx = x + dx[i];
	int ny = y + dy[i];

	if (nx <= 0 || w < nx || ny <= 0 || h < ny||f[ny][nx]!='.')continue;

	rec(nx, ny);
  }
}

int main(){
  while (cin >> w >> h,(w || h)) {
	int sx, sy;
	cnt = 0;
	for (int y = 1; y <= h; y++) {
	  for (int x = 1; x <= w; x++) {
		cin >> f[y][x];
		if (f[y][x] == '@') {
		  sx = x;
		  sy = y;
		}
	  }
	}
	rec(sx, sy);
	cout << cnt << endl;
  }
}

Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <cassert>
#include <random>
#include <stack>
#include <ctime>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

long times[101010];

int main() {
    VI ones = {1};
    times[1] = 1;
    for (int i = 6; i < 101010; i *= 6) {
        ones.push_back(i);
        times[i] = 1;
    }
    for (int i = 9; i < 101010; i *= 9) {
        ones.push_back(i);
        times[i] = 1;
    }
    
    REPI(j,1,1000) {
        VI as;
        REP(i,101010) {
            if (times[i] == j) {
                as.push_back(i);
            }
        }
        for (auto a: as) {
            for (auto o: ones) {
                if (a + o < 101010 && times[a + o]) {
                    times[a + o] = min(times[a + o], j + 1);
                } else if (a + o < 101010) {
                    times[a + o] = j + 1;
                }
            }
        }
    }
    int n;
    cin >> n;
    cout << times[n] << endl;
}


Measured memory_bytes: 1452
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll A[MAX_N];
ll L[MAX_N], R[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N + 1) cin >> A[i];
	L[N] = R[N] = A[N];
	rer(i, N, 0) {
		L[i] = (L[i + 1] + 1) / 2 + A[i];
		R[i] = R[i + 1] + A[i];
	}
	if(L[0] <= 1 && 1 <= R[0]) {
		ll node = 1;
		ll res = 1;
		rep(i, 1, N + 1) {
			node = min(node * 2, R[i]);
			res += node;
			node -= A[i];
		}
		cout << res << "\n";
	}
	else{
		cout << -1 << "\n";
	}
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 6212
# Problem 
# Python 3rd Try 
yes = "Odd"
no = "Even"
if __name__ == "__main__" :    
    answer = ""
    a,b = map(int,input().split(' '))
    if (a*b)%2 == 1:
        print(yes)
    else:
        print(no)
    print(answer)   

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.ABC123.C
{
    class Program
    {
        static void Main()
        {
            var N = long.Parse(Console.ReadLine());
            var limits = new long[5];
            for (var i = 0; i < 5; ++i)
            {
                limits[i] = long.Parse(Console.ReadLine());
            }
            var time = (Math.Ceiling((((Decimal)N) / Min(limits)))) + 4;
            Console.WriteLine(time);
        }

        static long Min(long[] nums)
        {
            var min = long.MaxValue;
            foreach (var n in nums)
            {
                min = min < n ? min : n;
            }
            return min;
        }
    }
}



Measured memory_bytes: 13140
include Math

def koch(n, a, b)
	return if n == 0

	th = PI * 60.0 / 180.0
	s = {}
	t = {}
	u = {}
	s[:x] = (2.0 * a[:x] + 1.0 * b[:x]) / 3.0
	s[:y] = (2.0 * a[:y] + 1.0 * b[:y]) / 3.0
	t[:x] = (1.0 * a[:x] + 2.0 * b[:x]) / 3.0
	t[:y] = (1.0 * a[:y] + 2.0 * b[:y]) / 3.0
	u[:x] = (t[:x] - s[:x]) * cos(th) - (t[:y] - s[:y]) * sin(th) + s[:x]
	u[:y] = (t[:x] - s[:x]) * sin(th) + (t[:y] - s[:y]) * cos(th) + s[:y]

	koch(n - 1, a, s)
	printf("%.8f %.8f\n", s[:x], s[:y])
	koch(n - 1, s, u)
	printf("%.8f %.8f\n", u[:x], u[:y])
	koch(n - 1, u, t)
	printf("%.8f %.8f\n", t[:x], t[:y])
	koch(n - 1, t, b)
end


n = gets.to_i

a = {:x => 0, :y => 0}
b = {:x => 100, :y => 0}

printf("%.8f %.8f\n", a[:x], a[:y])
koch(n, a, b)
printf("%.8f %.8f\n", b[:x], b[:y])

Measured memory_bytes: 9608
#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
	int a,b,c,d;
	while(cin>>a>>b>>c>>d){
		if(a+b>c+d)
		{
			cout<<"Left\n";
		}
		else if(a+b==c+d){
			cout<<"Balanced\n";
		}
		else{
			cout<<"Right\n";
		}
	}
	return 0;
}

Measured memory_bytes: 256
"""
食べるのにかかる時間順にソートしてナップサックするのがよい。
dp[i][j]
"""
N,T = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[0])
dp = [[0]*(T) for _ in range(N+1)]
for i in range(1,N+1):
    a,b = AB[i-1]
    for j in range(1,T):
        if j-a >= 0:
            dp[i][j] = max(dp[i-1][j-a]+b,dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]

ans = 0
for i in range(1,N):
    a,b = AB[i]
    ans = max(ans,dp[i][-1]+b)
print(ans)

Measured memory_bytes: 145920
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <iomanip>

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    int N;
    cin >> N;

    int res = 0, ren = 1;
    int be = 99999;
    REP(i,N)
    {
        int a;
        cin >> a;

        if(be == a)
        {
            ++ren;
        }
        else
        {
            be = a;
            res += ren/2;
            ren = 1;
        }
    }
    res += ren/2;

    cout << res << endl;
    return 0;
}



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

int main(){
  int N;
  cin >> N;
  int S[7]={2,4,8,16,32,64,128};
  int i=0;
  int ans=1;
  while(S[i]<=N){
    ans=S[i];
    i++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//Name: Temperature Difference
//Level: 1
//Category: やるだけ
//Note:

/**
 * 問題文のとおりにやるだけ。
 */
#include <iostream>

using namespace std;

bool solve() {
    for(int i = 0; i < 7; ++i) {
        int a, b;
        cin >> a >> b;
        cout << a-b << endl;
    }
    return false;
}

int main() {

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1192
n = int(input())
memo = [-1 for i in range(n+1)]

def fib(n):
    if n == 0 or n == 1:
        memo[n] = 1
        return memo[n]
    if memo[n] >= 0:
        return memo[n]
    memo[n] = fib(n - 2) + fib(n - 1)
    return memo[n]

print(fib(n))


Measured memory_bytes: 5604
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }

const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
int h, w, c;
int visited[8][8];

void change(vector<vector<int> >& board, const int to, const int prev, int x = 0, int y = 0) {
	board[y][x] = to;
	for(int i = 0; i < 4; ++i) {
		const int nx = x + dx[i], ny = y + dy[i];
		if(nx < 0 || ny < 0 || nx >= w || ny >= h)
			continue;

		if(board[ny][nx] == prev)
			change(board, to, prev, nx, ny);
	}
}

int dfs(const vector<vector<int> >& board, int x, int y) {
	visited[y][x] = true;
	int res = 1;

	for(int i = 0; i < 4; ++i) {
		const int nx = x + dx[i], ny = y + dy[i];
		if(nx < 0 || ny < 0 || nx >= w || ny >= h)
			continue;

		if(!visited[ny][nx] && board[ny][nx] == board[y][x])
			res += dfs(board, nx, ny);
	}

	return res;
}

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

	while(cin >> h >> w >> c, h) {
		vector<vector<int> > board(h, vector<int>(w));
		for(int i = 0; i < h; ++i)
			for(int j = 0; j < w; ++j)
				cin >> board[i][j];

		int ans = 0;
		for(int i = 1; i <= 6; ++i) {
			if(i == board[0][0])
				continue;

			vector<vector<int> > one(board);
			change(one, i, board[0][0]);
			for(int j = 1; j <= 6; ++j) {
				if(j == i)
					continue;

				vector<vector<int> > two(one);
				change(two, j, two[0][0]);
				for(int k = 1; k <= 6; ++k) {
					if(k == j)
						continue;

					vector<vector<int> > three(two);
					change(three, k, three[0][0]);
					for(int l = 1; l <= 6; ++l) {
						if(l == k || l == c)
							continue;

						vector<vector<int> > four(three);
						change(four, l, four[0][0]);
						change(four, c, four[0][0]);
						memset(visited, false, sizeof(visited));
						chmax(ans, dfs(four, 0, 0));
					}
				}
			}
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1228
import sys
n = int(input())
prev_time = 0
prev_x = 0
prev_y = 0
for i in range(n):
  time, x, y = map(int,input().split())
  diff = (time - prev_time) - (x-prev_x) - (y - prev_y)
  if diff >= 0 and diff % 2 == 0:
    prev_time = time
    prev_x = x
    prev_y = y
  else:
    print("No")
    sys.exit()
print("Yes")

Measured memory_bytes: 44264
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = if n <= m then  List.range n `To m else []
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (0 ++^ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv
let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv
let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'
let itoa n = Char.chr (n + Char.code '0')

let between n x m = n <= x && x < m


(* ===== MAIN ===== *)

let a, b, c, k = scan "%d %d %d %d" (fun a b c k -> a, b, c, k)

let () =
  let ans =
    if a >= k then k
    else if (a+b) >= k then a
    else a - (k-a-b)
  in
    Printf.printf "%d\n" ans


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

int main(int argc, char const *argv[])
{
	//ifstream cin("input.txt");
	cout.sync_with_stdio(false);
	cin.tie(0);
	int n,m,k;
	cin>>n>>m>>k;
	vector<ll> A(n);
	vector<ll> B(m);

	if(n > 0)
		cin>>A[0];
	rep(i, 1, n-1){
		cin>>A[i];
		A[i] += A[i-1];
	}

	if(m > 0)
		cin>>B[0];
	rep(i, 1, m-1){
		cin>>B[i];
		B[i] += B[i-1];
	}

	ll count = upper_bound(A.begin(), A.end(), k) - A.begin();
	if(count > n)
		count = 0;
	rep(i , 0, m-1)
	{
		ll rem = k - B[i];
		if(rem < 0)
			break;
		ll bound = upper_bound(A.begin(), A.end(), rem) - A.begin();

		count = max(count, (i + 1 + bound));
	}

	cout<<count;	
}

Measured memory_bytes: 6352