akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        a: i64, b: i64, c: i64, d: i64,
    }
    puts!("{}\n", if (c + b - 1) / b <= (a + d - 1) / d { "Yes" } else { "No" });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2244
N = int(input())
l = [[0]*3]*(N+1)
for n in range(N):
    l[n+1] = list(map(int, input().split()))

flag = True
for i in range(len(l)-1):
    d = l[(i+1)][0] - l[i][0]
    d_x = l[(i+1)][1] - l[i][1]
    d_y = l[(i + 1)][2] - l[i][2]
    distance = abs(d_x)+abs(d_y)
    if distance > d:
        flag = False
    elif distance % 2 != d % 2:
        flag = False

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 27300
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>

#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;


int main(int argc, char *argv[]) {
	
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22)
		cout << "bust" << endl;
	else
		cout << "win" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        n -= a;
    }
    if (n < 0) cout << -1 << endl;
    else cout << n << endl;
    return 0;
}


Measured memory_bytes: 3636
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int N;
    int[] a;

    private void solve() {
        N = nextInt();
        a = new int[N];
        for(int i = 0;i < N;i++) {
            a[i] = nextInt();
        }

        double avg = 0;
        for(int i = 0;i < N;i++) {
            avg += a[i];
        }
        avg /= N;

        double minDiff = Double.MAX_VALUE;
        int ans = 0;
        for(int i = 0;i < N;i++) {
            double diff = Math.abs(avg - a[i]);

            if (diff < minDiff) {
                minDiff = diff;
                ans = i;
            }
        }

        out.println(ans);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define se set<ll>
#define vec vector<ll>
#define inf 10000000000000000
bool mark[100005];
vec adj[100005];
ll counter;
vec cnt;
vector<string> forsubs;


         
   



int main()
{    
 

   #ifdef APNA_IO
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
   #endif
          ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 

ll n,k;
cin>>n>>k;

ll a[n];
char b[k+1];
b[0]='L';

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

for(ll i=1;i<=k;i++)
{
   for(ll j=0;j<n;j++)
   {  
    ll c=0;

      if(i-a[j]>=0)
      {
      if(b[i-a[j]]=='L')
         {  
            b[i]='W';
            c++;
            break;
          
         }
       }

       if(c==0)
        b[i]='L';

 }
}

 if(b[k]=='W')
   cout<<"First"<<"\n";
else
   cout<<"Second"<<"\n";


}

Measured memory_bytes: 2688
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int h, w;
	string c[100];
	cin >> h >> w;
	for (int i = 0; i < h; i++)
	{
			cin >> c[i];
	}
	for (int i = 0; i < h; i++)
	{

			cout << c[i] << endl;
			cout << c[i] << endl;

	}
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=200005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
ll a[MAXN],n,b[MAXN];
ll ans;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	forn(i,n)
	{
		cin>>b[i];
		a[b[i]]++;
	}
	for(int i=1;i<=n;i++)
		ans+=a[i]*(a[i]-1)/2;
	forn(i,n)
	{
		cout<<ans-a[b[i]]*(a[b[i]]-1ll)/2ll+(a[b[i]]-1ll)*(a[b[i]]-2ll)/2ll<<endl;
	}
	return 0;
}


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

int main(){
    int a, b, c, t; //一度置き換えないと値が正確に更新できない
    cin >> a >> b >> c;
    
    if (a > b) {
        t = a;
        a = b;
        b = t;
    }

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

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

    if (a > b) {  //もう一回aとbを比較すれば良い
        t = a;
        a = b;
        b = t;
    }
    
    cout << a << " " << b << " " << c << endl;
    return 0;
}


Measured memory_bytes: 3092
S=input()


num=input().split()
num_m=map(int,num)
order=list(num_m)

abso=[]

m=int(S)

for i in range(m):
    abso.append(abs(sum(order[0:i])-sum(order[i:m])))

ans=min(abso)
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main{
    
    public static final int MOD = (int)1e9+7;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        long n = Long.parseLong(sc.next());
        
        long ans = 0;
        for(long i=1; i*i<=n; i++){
            long x = (n-i)/i;
            if(x!=0 && n%x==i){
                ans += x;
            }
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
#include <iostream>
using namespace std;
int N,x;
int a[100000];
long long int ans=0;
int main(){
  cin >> N >> x;
  for(int i=0;i<N;i++) cin >> a[i];
  if(a[0]>x){
    ans+=(a[0]-x);
    a[0]=x;
  }
  for(int i=1;i<N;i++){
    if(a[i]+a[i-1]>x){
      int temp=a[i]+a[i-1]-x;
      a[i]-=temp;
      ans+=temp;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int h[n];
	for(int i = 0; i < n; i++) cin >> h[i];
	int dp[n];
	dp[0] = 0, dp[1] = abs(h[1] - h[0]);
	for(int i = 2; i < n; i++)
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	cout << dp[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 4436
#include<iostream>
using namespace std;
 
int main() {
  int a,b;
  int flag = 0;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b;
    if(b%2==0){
        if(b%3!=0 && b%5!=0){
            cout<<"DENIED"<<endl;
            flag = 1;
            break;
        }
    }    
  }
  if(flag == 0){
      cout<<"APPROVED"<<endl;
  }

//  cout<<(a==b&&b==c||a!=b&&b!=c&&c!=a?"No":"Yes")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define mmm 1000000007
#define pb push_back
									//nestedcode


 int main(){
	ios::sync_with_stdio(false);
  	cin.tie(0); cout.tie(0);
  	ll n,k,ans = 0,i,a;
  	cin>>n>>k;
  	for(i=0;i<n;i++){
  		cin>>a;
  		if(a>=k){
  			ans++;
		  }
	  }cout<<ans;
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)


string a = "ATCG";
string b = "TAGC";

int main() {
	map<char, char> m;
	rep(i, 4) {
		m[a[i]] = b[i];
	}
	char c;
	cin >> c;
	cout << m[c] << endl;

	return 0;
}


Measured memory_bytes: 256
def magic(n, a, b):
    if sum(a) < sum(b):
        return(-1)

    d = []
    for i in range(n):
        d.append(a[i] - b[i])
    d.sort()
    if d[0] >= 0:
        return(0)

    em = 0
    cm = 0
    for i in range(n):
        if d[i] < 0:
            em += d[i]
            cm += 1
    d.sort(reverse=True)
    ep = 0
    cp = 0
    for i in range(n):
        ep += d[i]
        cp += 1
        if ep >= abs(em):
            break
    return(cm + cp)

n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

print(magic(n, a, b))


Measured memory_bytes: 18492
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
using pp=pair<int,pair<int,int>>;
#define MAX 200003
#define MOD 1000000007
#define INF 1000000000000000000

int D;
vector<ll> c(26);
vector<vector<ll>> s;

ll score(vector<int> t){
  vector<ll> last(26,0);
  ll ans=0;
  for(ll i=0;i<D;i++){
    ans+=s.at(i).at(t.at(i));
    last.at(t.at(i))=i+1;
    for(ll j=0;j<26;j++){
      ans-=c.at(j)*((i+1)-last.at(j));
    }
  }
  return ans;
}


int main(){
  clock_t start,end;
  start=clock();
  cin>>D;
  for(int i=0;i<26;i++){
    cin>>c.at(i);
  }
  s.resize(D);
  for(int i=0;i<D;i++){
    s.at(i).resize(26);
    for(int j=0;j<26;j++){
      cin>>s.at(i).at(j);
    }
  }

  vector<ll> last(26,0);
  vector<int> t(D);
  for(ll i=0;i<D;i++){
    int k=0;
    for(int j=0;j<26;j++){
      if(1*c.at(j)*c.at(j)*((i+1)-last.at(j))*((i+1)-last.at(j))-s.at(i).at(j)>1*c.at(k)*c.at(k)*((i+1)-last.at(k))*((i+1)-last.at(k))-s.at(i).at(k)){
        k=j;
      }
    }
    t.at(i)=k;
    last.at(k)=i+1;
  }
  ll ans=score(t);

  vector<int> nt=t;
  for(int i=0;i<D;i++){
    int k=0;
    for(int j=0;j<26;j++){
      if(s.at(i).at(k)<s.at(i).at(j)){
        k=j;
      }
    }
    nt.at(i)=k;
    ll sub=score(nt);
    if(sub>ans){
      t=nt;
    }
    end=clock();
  }

  for(int i=0;i<D;i++){
    cout<<t.at(i)+1<<endl;
  }

  /*
  for(int i=0;i<D;i++){
    cout<<i%26+1<<endl;
  }
  */
}


Measured memory_bytes: 3768
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort()
B.sort()
C.sort()

import bisect
ans = 0
for b in B:
    idx_a = bisect.bisect_left(A,b)
    idx_c = bisect.bisect_right(C,b)
    
    ans += idx_a*(N-idx_c)
    
print(ans)

Measured memory_bytes: 23456
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
 
int main(){
  long long L,R;
  cin >> L >> R;
  if(R >= L+2019){
    R = L+ 2019;
  }
  long long m=0, ans =20100008;
  for(long long i =L; i<R ;i++){
    for(long long j = i+1; j <R+1; j++){
      m =i*j%2019;
      ans=min(ans,m);
    }
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 256
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

@functools.lru_cache(maxsize=None)
def Luca(n):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    else:
        return Luca(n-1)+Luca(n-2)

N = I()
print(Luca(N))

Measured memory_bytes: 12488
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}
vector<ll int>id[26];
void solve(){
	string s;
	string t;
	cin>>s>>t;
	ll int n=s.length(),m=t.length();
	rep(i,n)id[s[i]-'a'].pb(i);
	ll int pre=-1,ans=0;
	rep(i,m){
		auto it=upper_bound(id[t[i]-'a'].begin(), id[t[i]-'a'].end(),pre);
		if(it==id[t[i]-'a'].end()){
			pre=-1;
			it=upper_bound(id[t[i]-'a'].begin(), id[t[i]-'a'].end(),pre);
			if(it==id[t[i]-'a'].end()){cout<<-1;return;}
			pre=*it;
			ans+=n;
		}
		else pre=*it;
	}
	cout<<pre+ans+1ll;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 1736
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n, k = input_int_list()
    sections = []
    MOD = 998244353
    for _ in range(k):
        li, ri = input_int_list()
        sections.append((li, ri))
    dp = [0] * (n + 1)
    dpsum = [0] * (n + 1)
    dp[1] = 1
    dpsum[1] = 1
    for i in range(2, n + 1):
        for li, ri in sections:
            left = i - ri
            right = i - li
            if right < 0:
                continue
            left = max(1, left)
            dp[i] += dpsum[right] - dpsum[left - 1]
            dp[i] %= MOD
        # 累積和の更新を行う
        dpsum[i] = dpsum[i - 1] + dp[i]
        dpsum[i] %= MOD
    print(dp[n])

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 76892
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int l[2222];

int main(void){
	int n,i,j,k;
	ll ans = 0ll;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> l[i];
	}
	sort(l,l+n);
	for(i=0; i<n; ++i){
		for(j=0; j<i; ++j){
			for(k=0; k<j; ++k){
				if(l[i]<l[j]+l[k]){
					++ans;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d', $n, $k);
$ans = '';
do {
    $mod = $n % $k;
    $ans .= $mod;
    $n = floor($n / $k);
    //var_dump($ans, $n);
} while($n != 0);
//var_dump($ans);
echo strlen($ans), PHP_EOL;

Measured memory_bytes: 4728
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char str[120];
int a[27],b[27];
int main()
{
    int n;
    scanf("%d%s",&n,str);
    int num1,num2,num3,num=0;
    for(int i=0;i<n;i++)
    {
        num1=0,num2=0,num3=0;
        memset(a,0, sizeof(a));
        for(int j=0;j<=i;j++)
        {
            if(a[str[j]-'a']==0)
            {
                num1++;
                a[str[j]-'a']=1;
            }
        }
        memset(b,0, sizeof(b));
        for(int j=i+1;j<n;j++)
        {
            if(b[str[j]-'a']==0)
            {
                num2++;
                b[str[j]-'a']=1;
            }
        }
        for(int i=0;i<27;i++)
            if(a[i]==b[i]&&a[i]!=0)
                num3++;
        num=max(num,num3);
    }
    printf("%d",num);
    return 0;
}

Measured memory_bytes: 128
import numpy as np
N = int(input())
X = np.array(list(map(int, input().split())))
a = int(np.mean(X))
sum1 = 0
sum2 = 0
for x in X:
    sum1 += (x - a) * (x - a)
    sum2 += (x - (a + 1)) * (x - (a + 1))
if sum1 < sum2:
    print(sum1)
else:
    print(sum2)

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

void c2s(char str[]){
	int i;
	for(i = 0; str[i] != '\0'; i++){
		if(str[i] == ','){
			str[i] = ' ';
		}
	}
}

int main(void){
	int num;
	char str[MAX];
	char type[3];
	
	int a_ = 0;
	int b_ = 0;
	int o_ = 0;
	int ab = 0;

	while(1){
		if(scanf("%s",str) == EOF){break;}
		c2s(str);
		sscanf(str,"%d%s",&num,type);
		if(!strcmp(type,"A")){a_++;}
		else if(!strcmp(type,"B")){b_++;}
		else if(!strcmp(type,"O")){o_++;}
		else if(!strcmp(type,"AB")){ab++;}
	}
	printf("%d\n%d\n%d\n%d\n",a_,b_,ab,o_);
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 305


int main(){
  int n,max_p=-INF;
  int p[SIZE][SIZE] = {};
  int p_h[SIZE][SIZE] = {},p_v[SIZE][SIZE] = {};

  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      scanf("%d",p[i]+j);
      p_h[i][j] = p_v[i][j] = p[i][j];
      max_p = max(p[i][j],max_p);
    }
  }

  if(max_p <= 0){
    printf("%d\n",max_p);
    return 0;
  }

  for(int i=0;i<=n;i++){
    for(int j=1;j<=n;j++){
      p_h[i][j] += p_h[i][j-1]; 
    }
  }
  for(int i=0;i<=n;i++){
    for(int j=1;j<=n;j++){
      p_v[j][i] += p_v[j-1][i]; 
    }
  }

  int v[SIZE];
  int ans = 0;
  
  for(int i=1;i<=n;i++){
    
    for(int j=1;j<=n;j++){
      for(int k=j;k<=n;k++){
        ans = max(ans, p_v[k][i]-p_v[j-1][i]);
      }
    }
    
    for(int j=i+1;j<=n;j++){
      //[i,j]

      for(int k=0;k<=n;k++){
        v[k] = p_h[k][j-1]-p_h[k][i]; //[i+1,j-1]
      }

      int s = 0;

      for(int k=0;k<=n;k++){
        s += p[k][j] + p[k][i];

        v[k] += s;
      }

      for(int k=n;k>0;k--){
        v[k-1] = max(v[k],v[k-1]);
      }

      s = 0;
      
      for(int k=1;k<=n;k++){
        if(k<n){
          ans = max(ans, v[k+1]+(p_h[k][j-1]-p_h[k][i])+s);
        }
        
        ans = max(ans, p_h[k][j]-p_h[k][i-1]);

          s -= p[k][j]+p[k][i];
      }
    }
  }

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

Measured memory_bytes: 4324
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
int mod = (int) 1e9 + 7;

int main(){
    
    int k;
    string s;
    cin >> k >> s;
    
    if(k >= s.size()){
        cout << s;
    } else {
        rep(i,k) cout << s[i];
        cout << "...";
    }
    
    cout << "\n";
    
    return 0;
}


Measured memory_bytes: 3108
// 2020-07-05 21:05:08
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int h, w, k, black;
  cin >> h >> w >> k;
  vector<vector<int> > c(h, vector<int>(w, 0));
  // vector<int> sumw(h, 0), sumh(w, 0);
  rep(hi, h) {
    string s;
    cin >> s;
    rep(wi, w) {
      if (s[wi] == '#') {
        black++;
        c[hi][wi] = 1;
      }
      // if (s[wi] == '#') {
      //   sumw[hi]++;
      //   sumh[wi]++;
      // }
    }
  }
  int ans = 0;
  rep(hk, (1<<h)) {
    rep(wk, (1<<w)) {
      int cur = 0;
      rep(hi, h) {
        rep(wi, w) {
          if((hk>>hi)&1) if((wk>>wi)&1) if(c[hi][wi]) {
            cur++;
          }
        }
      }
      if(cur == k) ans++;
    }
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N; cin >> N;
	VL a(N + 10);
	a[0] = 2, a[1] = 1;
	FOR(i, 2, N+1) {
		a[i] = a[i - 1] + a[i - 2];
	}

	LL ans = a[N];
	cout << ans << endl;


	return 0;
}


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

int main() {
    long long k, a, b;
    cin >> k >> a >> b;
    if (b - a <= 2) {
        cout << k + 1 << endl;
    } else {
        if ((k - (a - 1)) % 2 == 0) {
            cout << ((k - (a - 1)) / 2 - 1) * (b - a) + b << endl;
        } else {
            cout << ((k - (a - 1)) / 2 - 1) * (b - a) + b + 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#define ll long long
#define vi vector<long long>
#define pb push_back
#define po pop_back
#define pi pair<long long ,long long>
#define vp vector<pair<long long,long long> >
#define mkp make_pair
#define in(i,n) for(i=0;i<n;i++)
#define fon(i,n,m) for(i=n;i<m;i++)
#define rfon(i,n,m) for(i=n;i>=m;i--)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);
#define map map<long long,long long>
#define inm1(b)  memset(b,1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define M  1000000007
#define I 10000000001
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
using namespace std;
ll gcd(ll a, ll b) {  if (a == 0)  return b; return gcd(b % a, a); }
ll power(ll x, ll y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}
int main()
{
    jaldi
    #ifndef ONLINE_JUDGE 
    //TakeInput
    #endif
        
    ll n,m;
    cin>>n>>m;
    ll i,j,k;

    ll a[n];
    in(i,n){
        cin>>a[i];
    }
    bool dp[m+1];
    in(i,m+1)
    dp[i]=false;
    in(i,m+1){
        for (auto x : a){
            if(i>=x && !dp[i-x]){
                dp[i]=true;
            }
        }
    }
    if(dp[m])cout<<"First";
    else cout<<"Second";


}
 
 








 



Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    while (true) {

      String str = scan.next();
      if(str.equals("-")) {
        break;
      }
      
      int m = scan.nextInt();

      for (int i = 0; i < m; i++) {
        int h = scan.nextInt();
        str = String.join("", str.substring(h, str.length()), str.substring(0, h));
      }

      System.out.println(str);

    }

  }

}


Measured memory_bytes: 26688
N = int(input())
Tlist = [int(input()) for _ in range(N)]


def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x


print(lcm(Tlist))


Measured memory_bytes: 5040
n = gets.to_i
aa =  gets.chomp.split('')
bb =  gets.chomp.split('')
cc =  gets.chomp.split('')
ans = 0
 
aa.zip(bb, cc).each do |a, b, c|
  if a != b && b != c && c != a
    ans += 2
  elsif a == b && b == c
    #nothing
  else
    ans += 1
  end
end
 
puts ans 


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

int len;
string s;

int solve(){
    int j,k,ans=-1;
    for(k=1;k<len;++k){
        int t=0,m=0;
        for(j=0;j+k<len;++j){
            if(s[j]==s[j+k]){
                t+=1;
                m=max(m,min(t,k));
            }else{
                t=0;
            }
        }
        ans=max(ans,m);
    }
    return ans;
}

void _prepare(){
    cin>>len>>s;
}

int main(){
    _prepare();
    cout<<solve()<<endl;
    return 0;
}


Measured memory_bytes: 256
n11, n12, n13 = map(int,input().split())
n21, n22, n23 = map(int,input().split())
n31, n32, n33 = map(int,input().split())
lines = [[n11,n12,n13],
         [n21,n22,n23],
         [n31,n32,n33],
         [n11,n21,n31],
         [n12,n22,n32],
         [n13,n23,n33],
         [n11,n22,n33],
         [n13,n22,n31]]
nums = {}
r = input()
for i in range(int(r)):
  nums[int(input())] = 0
flag = False
for l in lines:
  if l[0] in nums:
    if l[1] in nums:
      if l[2] in nums:
        flag = True
if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"_,w,*s=open(0).read().split();t=['#'*(int(w)+2)];a=t+['#'+t+'#'for t in s]+t;print(*a)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3280
#include <stdio.h>

int main()
{
	int a[101][101] = { 0 };
	int r, c;
	scanf("%d %d", &r, &c);
	for (int i = 0; i<r; i++)
	{
		for (int j = 0; j<c; j++)
		{
			scanf("%d", &a[i][j]);
		}
	}
	for (int i = 0; i<r; i++)
	{
		for (int j = 0; j<c; j++)
		{
			a[i][c] = a[i][c] + a[i][j];
		}
	}
	for (int j = 0; j <= c; j++)
	{
		for (int i = 0; i<r; i++)
		{
			a[r][j] = a[r][j] + a[i][j];
		}
	}

	for (int i = 0; i <= r; i++)
	{
		for (int j = 0; j <= c; j++)
		{
			printf("%d", a[i][j]);
			if (j != c) printf(" ");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1080
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
using namespace std;
using ll =long long;
const int MOD = 1000000007;

int main() {
	ll N,K;
	ll hand=1;
	cin >> N>>K;
	ll sum=0;
	for (ll i = K; i <= N+1; i++) {
		sum += (N + 1) * N / 2 - (N - i) * (N - i + 1) / 2 - i * (i - 1) / 2+1;

		sum = sum % MOD;
	}
	cout << sum;
	
}

Measured memory_bytes: 3632
import std.stdio, std.conv, std.algorithm, std.range, std.array, std.string, std.uni, std.bigint;                                                                                                                                                                                            void main() {                                                                                    auto A = BigInt(readln.chomp);                                                                 auto B = BigInt(readln.chomp);                                                                 if (A > B) {                                                                                     writeln("GREATER");                                                                          } else if (A < B) {                                                                              writeln("LESS");                                                                             } else {                                                                                         writeln("EQUAL");                                                                            }                                                                                            }       

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

typedef long long ll;
const int N = 2e5 + 10;
const int p = 2019;
char s[N];
int cnt[2020];

int main()
{
	scanf("%s", s + 1);
	
	cnt[0] = 1;
	ll j = 1, now = 0, res = 0;
	for(int i = strlen(s + 1); i >= 1; i--) {
		int v = s[i] - '0';
		now = (now + j * v) % p;
		res += cnt[now];
		cnt[now]++;
		j = j * 10 % p;
	}
	
	printf("%lld\n", res);
	
	return 0;
}

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

int main(){
  string s;
  int sum = 700;
  cin >> s;

  for(int i=0; i<3; i++){
    if(s[i] == 'o'){
      sum = sum + 100;
    }else if(s[i]== 'x'){

    }
  }
  cout << sum;
}

Measured memory_bytes: 256
#if defined(__GNUC__)
#include <bits/stdc++.h>
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#if defined(__GNUC__)
#define __int32 __int32_t
#endif // __GNUC__

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) std::sort(ALL(x))
#define RSORT(x, T) std::sort(ALL(x), greater<T>())
#define REVERCE(x) std::reverce(ALL(x))

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)

itn main() {
	std::ios::sync_with_stdio(false);

	int a, b, res;
	char op;

	cin >> a >> op >> b;

	if(op == '+'){
		res = a + b;
	}
	else {
		res = a - b;
	}

	cout << res;

	return 0;
}

Measured memory_bytes: 256
import math
if __name__ == "__main__": 
	string = input()
	l = string.split(" ")
	a = int(l[0])
	b = int(l[1])
	n = int(l[2])
	ans = 0
	ni = min(n,b-1)
	f = math.floor((a*(ni))/b)
	s = math.floor((ni)/b)
	temp = int(f) - (a*int(s))
	ans = temp
	# if(n>b):
	# 	f = math.floor((a*(b-1))/b)
	# 	s = math.floor((b-1)/b)
	# 	temp = int(f) - (a*int(s))
	# 	ans = temp
	# else:
	# 	f = math.floor((a*(n))/b)
	# 	s = math.floor((n)/b)
	# 	temp = int(f) - (a*int(s))
	# 	ans = temp
	print(ans)
	

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

int charToint(char s) {
    return s - '0';
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string str;
    int ans = 10000;
    cin >> str;
    for(int i = 0;i < str.size()-2;i++) {
        int num = (charToint(str[i])*100+charToint(str[i+1])*10+charToint(str[i+2]));
        ans = min(ans, abs(num-753));
    }

    cout << ans << endl;
}

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

using i64 = int64_t;

using Graph = vector<vector<int>>;

int dfs(int root, const Graph &graph){
    if(graph[root].size() == 0)return 0;
    vector<int> v;
    for(auto to: graph[root]){
        int tmp = dfs(to, graph);
        v.push_back(tmp);
    }
    sort(v.rbegin(), v.rend());
    int maxi = 0;
    for(int i=0;i<v.size();++i){
        maxi = max(maxi, v[i]+i+1);
    }
    return maxi;
}

int main(){
    int n;
    cin >> n;
    Graph graph(n, vector<int>());
    for(int i=1;i<n;++i){
        int a;
        cin >> a;
        graph[a-1].push_back(i);
    }

    cout << dfs(0, graph) << endl;

    return 0;
}

Measured memory_bytes: 15104
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

count = 0
for i in range(N):
  if A[i] >= B[i]:
    count += B[i]
    A[i] -= B[i]
  else:
    if A[i+1] >= B[i] - A[i]:
      count += B[i]
      A[i+1] -= B[i] - A[i]
      A[i] = 0
    else:
      count += A[i] + A[i+1]
      A[i] = 0
      A[i+1] = 0

print(count)

Measured memory_bytes: 19284
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX =10000;
static const int INFTY =(1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK =2;
int n;
vector<pair<int, int> > adj[MAX];

void dijkstra(){
  priority_queue<pair<int, int> >PQ;
  int color[MAX];
  int d[MAX];
  for ( int i = 0;i < n; i++) {
    d[i] =INFTY;
    color[i] =WHITE;
  }
  d[0] = 0;
  PQ.push(make_pair(0,0));
  color[0] =GRAY;
  while ( !PQ.empty()){
    pair <int, int> f= PQ.top();
    PQ.pop();
    int u=f.second;
    color[u] = BLACK;
    if(d[u] < f.first*(-1))continue;
    for (int j =0;j <adj[u].size();j++){
      int v=adj[u][j].first;
      if(color[v]==BLACK)continue;
      if(d[v] > d[u]  + adj[u][j].second){
	d[v] = d[u] + adj[u][j].second;
	PQ.push(make_pair(d[v] *(-1),v));
	color[v] =GRAY;
      }}}
  for(int i=0;i<n;i++){
    cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
  }}
int main(){
  int k,u,v,c;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>> u >>k;
    for (int j =0;j < k;j++){
      cin >> v >> c;
      adj[u].push_back(make_pair(v,c));
    }}
  dijkstra();
  return 0;
}

Measured memory_bytes: 1504
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const int k=38,n=k*(k-1)+1;
int a[k];

void Out(){
	for(int i=0;i<k;i++){
		if(i) cout<<' ';
		cout<<a[i]+1;
	}
	cout<<endl;
}

int main(){
	cout<<n<<' '<<k<<endl;
	for(int i=0;i<k;i++){
		for(int j=1;j<k;j++) a[j]=i*(k-1)+j;
		Out();
	}
	for(int i=1;i<k;i++){
		a[0]=i;
		for(int j=0;j<k-1;j++){
			int t=j;
			for(int l=1;l<k;l++){
				a[l]=l*(k-1)+t+1;
				(t+=i)%=k-1;
			}
			Out();
		}
	}
}

Measured memory_bytes: 512
import collections
import sys
N = int(input())
A = map(int,input().split(" "))
count_input = collections.Counter(A)
del count_input[" "]
judge = True
m1 = 0
m2 = 0
count = 0
temp_max=0
for k,v in sorted(count_input.items(),reverse = True):#,reverse = True
    # print(k)
    if temp_max<=k:
        temp_max=k
    # if m1 < int(k) and int(v) >= 2:
        # m2 = m1
        # m1 = int(k)
    if int(v) >= 4 and temp_max<=k:
        print(k**2)
        sys.exit()
    elif int(v) >= 2:
        m2 = m1
        m1 = int(k)
        count += 1
        if count ==2:
            print(m1*m2)
            sys.exit()
print("0")


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

using namespace std;

constexpr int MAXN = 2e5 + 5, MOD = 1e9 + 7;

template<typename T>
inline void read(T& x, T f = 1, char ch = getchar()) {
    x = 0;
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

int tc, n, m, ans;
array<int, MAXN> a, pre;
string s, t;

signed main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++)
        (pre[i] = pre[i - 1] + a[i]) %= MOD;
    for (int i = 1; i <= n; i++)
        ans = (ans + a[i] * (pre[n] - pre[i] + MOD) % MOD) % MOD;
    cout << (ans + MOD) % MOD << endl;
    return 0;
}

Measured memory_bytes: 6772
#include <stdio.h>
 
int answer(char ch[])
{
    int sum = 0;
    int i;
     
    for(i=0;;i++){
        if(ch[i] == 0){
            break;
        }
        sum += ((int)ch[i]-48);
    }
     
    return sum;
}
int main()
{
    char ch[1001];
     
    while(1){
     
        scanf("%s",ch);
         
        if(answer(ch) == 0){
            break;
        }
     
        printf("%d\n",answer(ch));
 
    }
    return 0;
}

Measured memory_bytes: 536
#16D8103010K
#ALDS_5_C

import math

def koch(n,p1,p2):
	if n==0:
		return
	s=[0 for i in range(2)]
	t=[0 for i in range(2)]
	u=[0 for i in range(2)]
	
	s[0]=(2*p1[0]+1*p2[0])/3
	s[1]=(2*p1[1]+1*p2[1])/3
	t[0]=(1*p1[0]+2*p2[0])/3
	t[1]=(1*p1[1]+2*p2[1])/3
	
	rad=math.radians(60)
	
	u[0]=(t[0]-s[0])*math.cos(rad)-(t[1]-s[1])*math.sin(rad)+s[0]
	u[1]=(t[0]-s[0])*math.sin(rad)+(t[1]-s[1])*math.cos(rad)+s[1]
	
	koch(n-1,p1,s)
	#pr8(s)
	print(*s)	
	koch(n-1,s,u)
	#pr8(u)
	print(*u)
	koch(n-1,u,t)
	#pr8(t)
	print(*t)
	koch(n-1,t,p2)
	
n=int(input())
p1=[0,0]
p2=[100,0]

print(*p1)
koch(n,p1,p2)
print(*p2)


Measured memory_bytes: 5792
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
 
    UnionFind(int n = 1) {
        init(n);
    }
 
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }
 
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
 
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
 
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

    
  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  COMinit();
  
  ll n,m;
  cin >> n >> m;
  vector<P>vec(m);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    vec[i]=P(b,a);
  }
  sort(vec.begin(),vec.end());
  ll now=0;
  ll cnt=0;
  rep(i,m){
    if(vec[i].second<now)continue;
    cnt++;
    now=vec[i].first;
  }
  cout << cnt << endl;
}


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

int main(void) {
    int         N;
    double      average = 0;
    vector<int> a;

    cin >> N;
    a.reserve(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        average += (double)a[i];
    }
    average /= (double)N;
    if(average - (int)average > 0) average += 1;

    int ans = 0;
    for(int i = 0; i < N; i++) {
        ans += (a[i] - (int)average) * (a[i] - (int)average);
    }

    int ans2 = 0;
    average -= 1;
    for(int i = 0; i < N; i++) {
        ans2 += (a[i] - (int)average) * (a[i] - (int)average);
    }

    cout << (ans < ans2 ? ans : ans2);

    return 0;
}

Measured memory_bytes: 256
import java.util.*
import kotlin.collections.HashMap
import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main() {
    val (n, k) = readInts()
    println(readInts().sorted().take(k).sum())
}


Measured memory_bytes: 40664
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int ans = 0;

		for (int i = 0; i < 100000; i++) {
			if (x <= i * (i + 1) / 2) {
				ans = i;
				break;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21716
def check(a):
    for i in range(n):
        if a[i] % 2 == 0:
            if (a[i] % 3 != 0) and (a[i] % 5 != 0):
                return "DENIED"
    return "APPROVED"


n = int(input())
a = list(map(int, input().split()))

print(check(a))

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


int main(){
  int n;
  cin>>n;
  vector<pair<pair<string,int>, int> >p(n);
  for(int i=0;i<n;i++){
    cin>>p[i].first.first>>p[i].first.second;
    p[i].first.second-=2*p[i].first.second;
    p[i].second=i+1;
  }
  sort(p.begin(),p.end());
  for(int i=0;i<n;i++){
    cout<<p[i].second<<"\n";
  }
  return 0;
}


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

int main() {
  ll N, K, d, A, cnt = 0;
  cin >> N >> K;
  vector<bool> S(N, 0);
  for(ll i = 0; i < K; i++) {
    cin >> d;
    for(ll j = 0; j < d; j++) {
      cin >> A;
      S.at(A - 1) = 1;
    }
  }
  for(ll i = 0; i < N; i++) {
    if(S.at(i) == 0) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
ll n,x;
int main(){
read(n),read(x);
write((n-__gcd(n,x))*3);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define MX 100005
int N,D,X,i,j,K[15][15],dp[MX+1],dp2[MX+1];
#define max(a,b) (a)>(b)?(a):(b)
int np(int d,int w)
{
	int i,j,r=0;
	memset(dp2,0,sizeof(dp2));
	for(i=0;i<N;i++)
	{
		for(j=K[d][i];j<=w;j++)
		{
			dp2[j]=max(dp2[j],dp2[j-K[d][i]]+K[d+1][i]);
			r=max(r,dp2[j]+w-j);
		}
	}
	return r>MX?0:r;
}

int main()
{
	scanf("%d%d%d",&N,&D,&X);
	for(i=0;i<D;i++)
		for(j=0;j<N;j++)
			scanf("%d",&K[i][j]);
	dp[X]=1;
	for(i=0;i<D;i++)
	{
		for(j=MX;j>=0;j--)
			if(dp[j])
				dp[np(i,j)]=1;
	}
	for(i=MX;i>=0;i--)if(dp[i])break;
	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 1268