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

S = list(map(int, list(input())))[::-1]

l = [0]*2019

tmp = 0
z = 1
for i, s in enumerate(S):
	tmp += s*z
	z = z*10%2019
	l[tmp%2019] += 1
ans = 0
for v in l:
	ans += v*(v-1)//2
print(ans+l[0])


Measured memory_bytes: 13108
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}


ll gcd(ll a, ll b){
    if(b == 0)
        return a;
    return gcd(b, a%b);
}
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

// count from 0
ll get_num(ll x, ll c, ll d){
    return (x+1) - (x / c + x / d - x / lcm(c, d));
}




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

    cout << get_num(b, c, d) - get_num(a-1, c, d) << endl;
    return 0;
}

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

int main(){
  int N;
  string S;
  cin>>N>>S;

  vector<vector<ll>> dp(N,vector<ll>(N,0));
  for(int j=0;j<N;j++){
    dp.at(0).at(j)=1;
  }

  for(int i=1;i<N;i++){
    if(S.at(i-1)=='<'){
      for(int j=0;j<N-i;j++){
        dp.at(i).at(j)+=dp.at(i-1).at(j+1);
        dp.at(i).at(j)%=MOD;
      }
      for(int j=N-2;j>=0;j--){
        dp.at(i).at(j)+=dp.at(i).at(j+1);
        dp.at(i).at(j)%=MOD;
      }
    }else{
      for(int j=0;j<N-i;j++){
        dp.at(i).at(j)+=dp.at(i-1).at(j);
        dp.at(i).at(j)%=MOD;
      }
      for(int j=1;j<N;j++){
        dp.at(i).at(j)+=dp.at(i).at(j-1);
        dp.at(i).at(j)%=MOD;
      }
    }
  }

  cout<<dp.at(N-1).at(0)<<endl;
}


Measured memory_bytes: 70656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            string[] NK = Console.ReadLine().Split(' ');

            int N = int.Parse(NK[0]);
            int K = int.Parse(NK[1]);

            string[] H2 = Console.ReadLine().Split(' ');
            int[] H = new int[H2.Length];

            for(int i = 0; i < H2.Length; i++)
            {
                H[i] = int.Parse(H2[i]);
            }

            int[] dp = new int[N];

            for(int i = 1; i < N; i++)
            {
                dp[i] = int.MaxValue;
            }

            for(int i = 0; i < N; i++)
            {
                for(int j = 1; j <= K; j++)
                {
                    if (i + j < dp.Length)
                    {
                        dp[i + j] = Math.Min(dp[i + j], dp[i] + Math.Abs(H[i] - H[i + j]));
                    }
                    else
                    {
                        break;
                    }
                }
            }

            Console.WriteLine(dp[N - 1]);
        }
    }
}

Measured memory_bytes: 18912
#include <stdio.h>
#include <stdlib.h>

int main(void){
  int a,b,v,w;
  double t;
  scanf("%d %d %d %d %lf",&a, &v, &b, &w, &t);
  if(abs(a-b)/t <= (v-w)){
    printf("YES");
  }
  else{
    printf("NO");
  }
  return 0;
}

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

struct poi
{
    double x,y;
};
poi a[100],b[100];
double dist(poi a,poi b)
{
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int n;
double sum=0;
int tot=0;
bool vis[100];
void dfs(int pos,double ans,int pre)
{
    if(pos==n)
    {
        //cout<<"* "<<ans<<endl;
        sum+=ans;
        tot++;
        return;
    }
    if(pre==-1)
    {
        for(int i=0; i<n; i++)
        {
            if(!vis[i])
            {
                vis[i]=1;
                dfs(pos+1,0,i);
                vis[i]=0;
            }
        }
        return;
    }
    for(int i=0; i<n; i++)
    {
        if(!vis[i])
        {
            vis[i]=1;
            dfs(pos+1,ans+dist(a[pre],a[i]),i);
            vis[i]=0;
        }
    }

}
int main()
{

    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%lf%lf",&a[i].x,&a[i].y);
    }
    //cout<<dist(a[0],a[1])<<endl;
    dfs(0,0,-1);
    printf("%.6f",sum/tot);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
  int x;
  cin>>x;
  if(x>=30)
  {
      cout<<"Yes"<<endl;
  }
  else
  cout<<"No"<<endl;
   
}






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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}

const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

int main()
{
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for(int x = 0; x <= k; ++x) {
    for(int y = 0; y <= k; ++y) {
      if(0 <= s-x-y && s-x-y <= k) ++ans;
    }
  }
  cout << ans << endl;
}

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

int gcd(const int a, const int b) { return b == 0 ? a : gcd(b , a%b); }

int main()
{
    int A, B, C; cin >> A >> B >> C;
    cout << (C % gcd(A, B) == 0 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        Set<String> set = new HashSet<>();
        set.add(scanner.next());
        set.add(scanner.next());
        set.add(scanner.next());

        System.out.println(set.size() ==2 ? "Yes" : "No");

    }

}

Measured memory_bytes: 23124
using System;
using System.Linq;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            var s = new[] { 6000, 4000, 3000, 2000 };
            for(int i = 0; i < 4; ++i) {
                var d = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                Console.WriteLine(s[d[0] - 1] * d[1]);
            }
        }
    }
}

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

int main(){
    ll n,a,b,c,d,e,ans;
    cin >> n >> a >> b >> c >> d >> e;
    ll mini=min(a,min(b,min(c,min(d,e))));
    if(n%mini==0)
    ans=4+n/mini;
    else
    {
        ans=5+n/mini;
    }
     cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner( System.in );
		
		int N = sc.nextInt();
		int Y = sc.nextInt();
		boolean breakFlag = false;
		
		for ( int i = 0; i < N + 1; i++ ) {
			
			for ( int j = i; j < N + 1; j++ ) {
				int a = i;
				int b = j - i;
				int c = N - j;
				
				if ( 10000 * a + 5000 * b + 1000 * c == Y ) {
					System.out.println(a + " " + b + " " + c);
					breakFlag = true;
					break;
				}
			}
			
			if ( breakFlag ) {
				break;
			}
		}
		
		if (!breakFlag) {
			System.out.println("-1 -1 -1");
		}
		
		sc.close();

	}

}

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

int main() {
  string s, t;
  cin >> s >> t;
  int S = s.size(), T = t.size();

  int dp[S+1][T+1];

  for (int i = 0; i <= S; i++) {
    for (int j = 0; j <= T; j++) {
      if (i == 0 || j == 0) {
        dp[i][j] = 0;
      }
      else if (s[i-1] == t[j-1]) {
        dp[i][j] = dp[i-1][j-1] + 1;
      }
      else {
        (dp[i][j-1] > dp[i-1][j]) ? 
        dp[i][j] = dp[i][j-1]
        : dp[i][j] = dp[i-1][j];
      }
    }
  }
  
  string res = "";
  int i = S, j = T;
  while (i > 0 && j > 0) {
    if (dp[i][j] == dp[i-1][j]) {
      --i;
    }
    else if (dp[i][j] == dp[i][j-1]) {
      --j;
    }
    else {
      res = s[i-1] + res;
      --i, --j;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
char buf[1<<20],*fs,*ft;
inline char getc()
{return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))? 0 : *fs++;}
inline long long read()
{long long s=0,w=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
return s*w;}
char buf1[1<<21],a1[20];int p11,p12=-1;
inline void flush()
{fwrite (buf1,1,p12+1,stdout),p12=-1;}
inline void print(int x)
{if(p12>1<<20) flush();if(x<0) buf1[++p12]=45,x=-x;
do{a1[++p11]=x%10+48;}while(x/=10);
do{buf1[++p12]=a1[p11];}while(--p11);buf1[++p12]='\n';}
int n,val[100100],b[20],ans=0,stat=0;
int sum[(1<<16)],xr[(1<<16)];
int main()
{
	memset(b,0,sizeof(b));
	memset(xr,0,sizeof(xr));
	memset(val,0,sizeof(val));
	n=read();
	int i=1,j=1,k=1;
	while(i<n)
	{
		int u,v,l;
		u=read();
		v=read();
		l=read();
		++u;
		++v;
		val[u]^=l;
		val[v]^=l;
		++i;
	}
	i=1;
	while(i<=n)
	{
		++b[val[i]];
		++i;
	}
	i=1;
	while(i<=15)
	{
		ans+=b[i]/2;
		b[i]%=2;
		stat|=b[i]<<(i-1);
		++i;
	}
	i=1;
	while(i<(1<<15))
	{
		sum[i]=sum[i>>1]+(i&1);
		++i;
	}
	i=1;
	while(i<(1<<15))
	{
		--sum[i];
		++i;
	}
	i=1;
	while(i<(1<<15))
	{
		j=1;
		while(j<=15)
		{
			if(i&(1<<(j-1))) xr[i]^=j;
			++j;
		}
		++i;
	}
	i=1;
	while(i<(1<<15))
	{
		if(!xr[i])
		{
			k=(i-1)&i;
        	while(k)
        	{
            	if(xr[k]==0) sum[i]=min(sum[i],sum[k]+sum[i^k]);
            	k=(k-1)&i;
            }
        }
		++i;
	}
	printf("%d\n",ans+sum[stat]);
	return 0;
}
/*
BZOJ 1833 ZJOI2010 Count
??????
Hdu4734 f(x)
Cf 55D Beautiful Number
Cf 388D Fox and Perfect Sets
2012 Multi-University Training Contest 6 ???????LIS???
TopCoder Rainbow Graph
TopCoder CheeseRolling
AtCoder 058E Iroha and Haiku
AtCoder XOR Tree
Codeforces 165E
*/

Measured memory_bytes: 1024
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    var F = IntArray(N, {
        (1..10).map { sc.nextInt() }.reduce { acc, i -> acc.shl(1) + i }
    })
    var P = Array(N, { Array(11, { sc.nextInt() }) })
    val max = (1..1023)
            .map { state ->
                F.map { it and state }
                        .map { Integer.bitCount(it) }
                        .mapIndexed { index, count -> P[index][count] }
                        .sum()
            }.max()
    println(max)
}


Measured memory_bytes: 40704
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin>>a>>b;
  int ans=0;
  for(int i=0;i<2;i++){
    if(b>a) swap(a,b);
    ans +=a;
    a--;
  }
  cout<<ans<<endl;
}

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

using ll = long long;
using pii = pair<int,int>;
const ll MOD = 1000003;

vector<int> G[50010];
int nxt[50010];
map<pii,ll> memo;

ll dfs(int l,int r){
	if(memo.count(pii(l,r))) return memo[pii(l,r)];
	if(r - l <= 2) return 1;
	if(nxt[l] >= r) return 1;
	if(nxt[l] != l) return dfs(nxt[l],r);
	ll ret = dfs(l + 2,r);
	for(int to : G[l]){
		ret = (ret + dfs(l + 1,to) * dfs(to + 1,r)) % MOD;
	}
	return memo[pii(l,r)] = ret;
}

signed main(){
	int n,m;
	while(cin >> n >> m,n){
		memo.clear();
		for(int i = 0;i < n;i++){
			G[i].clear();
			nxt[i] = n;
		}
		for(int i = 0;i < m;i++){
			int a,b;
			cin >> a >> b; a--;b--;
			if(a > b) swap(a,b);
			if((b - a) % 2) G[a].push_back(b);
		}
		G[0].push_back(n - 1);
		if(n % 2){
			cout << 0 << endl;
			continue;
		}
		for(int i = n - 3;i >= 0;i--){
			if(G[i].size()) nxt[i] = i;
			else nxt[i] = nxt[i + 2];
		}
		cout << dfs(0,n) << endl;
	}
}


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

using namespace std;

int n;
int a[1000005];
int res;

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]), res += abs(a[i] - a[i - 1]);
	res += abs(a[n]);
	for(int i = 1; i <= n; i++)
		if((a[i - 1] <= a[i] && a[i] <= a[i + 1]) || (a[i - 1] >= a[i] && a[i] >= a[i + 1]))
			printf("%d\n", res);
		else
			printf("%d\n", res - 2 * min(abs(a[i] - a[i - 1]), abs(a[i] - a[i + 1])));
	return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
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; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int s, w;
    cin >> s >> w;
    if (w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}



Measured memory_bytes: 3668
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int record[10001][721];
int main()
{
	int N, M;
	while (cin >> N >> M, N || M) {
		int r, q;
		REP(i, 0, M) {
			REP(j, 0, 721) {
				record[i][j] = 0;
			}
		}

		cin >> r;
		REP(i, 0, r) {
			int t, n, m, s;
			cin >> t >> n >> m >> s;
			t -= 540;
			n--;
			m--;
			if (s == 1) record[m][t]++;
			else record[m][t]--;
		}

		REP(i, 0, M) {
			REP(j, 0, 720) {
				record[i][j + 1] += record[i][j];
			}
		}

		cin >> q;
		REP(i, 0, q) {
			int start, end, m, sum = 0;;
			cin >> start >> end >> m;
			start -= 540;
			end -= 540;
			m--;

			REP(j, start, end) {
				if (record[m][j] != 0) sum++;
			}

			cout << sum << endl;
		}

	}

	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> ii;

const int N = 1e5 + 5;

int n,t,ans = 99999999;

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

  cin >> n >> t;

  for (int i = 1 ; i <= n ; i++) {
    int c,t2;
    cin >> c >> t2;
    if (t2 <= t) 
      ans = min(ans,c);
  }

  if (ans == 99999999) {
    cout << "TLE" << endl;
    return 0;
  }

  cout << ans << endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[40001];
char s[40001];
int s1[40001],s2[40010],s3[40001];
long long ans;
int main(){
	scanf("%d",&n);
	cin>>s;
	for(int i=0;i<n;++i){
		if(s[i]=='R')a[i+1]=1;
		else if(s[i]=='G')a[i+1]=2;
		else a[i+1]=3;
	}
	for(int i=1;i<=n;++i){
		if(a[i]==1){
			s1[i]=s1[i-1]+1;
			s2[i]=s2[i-1],s3[i]=s3[i-1];
		}
		else if(a[i]==2){
			s2[i]=s2[i-1]+1;
			s1[i]=s1[i-1],s3[i]=s3[i-1];
		}
		else {
			s1[i]=s1[i-1];s2[i]=s2[i-1];
			s3[i]=s3[i-1]+1;
		}
	}
	for(int i=1;i<=n-2;++i){
		for(int j=i+1;j<n;++j){
			int N=j-i;
			if(a[j]==a[i])continue;
			if(a[i]+a[j]==3)ans+=s3[n]-s3[j]-(a[j+N]==3);
			else if(a[i]+a[j]==4)ans+=s2[n]-s2[j]-(a[j+N]==2);
			else if(a[i]+a[j]==5)ans+=s1[n]-s1[j]-(a[j+N]==1);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3888
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+10;
int n,cnt[N],q,a[N],sum;
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>a[i],sum+=a[i],cnt[a[i]]++;
	cin>>q;
	for(int i=1,x,y;i<=q;i++){
		cin>>x>>y;	sum+=(y-x)*cnt[x]; cnt[y]+=cnt[x]; cnt[x]=0;
		cout<<sum<<'\n';
	}
	return 0;
}


Measured memory_bytes: 5156
import math

N = int(input())
x = list()
y = list()
sum = 0

def dist(i,j):
    dx = x[i] - x[j]
    dy = y[i] - y[j]
    return math.sqrt(dx*dx + dy*dy)

if __name__ == '__main__':
    for i in range(N):
        x_i,y_i = map(int,input().split())
        x.append(x_i)
        y.append(y_i)

    for i in range(N):
        for j in range(N):
            sum += dist(i,j)

    print(sum/N)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(2e5) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main(){
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    if(b*2 > h || a*2 > w){
        cout << "No" << endl;
    }
    else{
        for(int i=0;i<b;i++){
            for(int j=0;j<w;j++){
                cout << (j<a ? '0' : '1');
            }
            cout << endl;
        }
        for(int i=b;i<h;i++){
            for(int j=0;j<w;j++){
                cout << (j<a ? '1' : '0');
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1280
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(long long n) {
        if (n & 0x1) {
            return 0;
        }

        long long twos = n / 2;

        auto count = [&](long long n, long long p) {
            long long res = 0;
            while (n > 0) {
                res += n / p;
                n /= p;
            }
            return res;
        };

        twos += count(n / 2, 2);
        long long fives = count(n / 2, 5);

        long long res = min(twos, fives);
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    long long n;
    cin >> n;
    Solution sol;
    cout << sol.solve(n) << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	string s;
	cin>>s;
	int lc=0, rc=0;
	for(int i=1;i<s.size();i++){
		if(s[i]!=s[i-1]) lc++;
	}
	for(int i=s.size()-1;i>0;i--){
		if(s[i]!=s[i-1]) rc++;
	}
	
	cout<<min(lc,rc)<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <assert.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define fi first
#define sc second
typedef pair<int,int> P;
int h,w;
int f[32][32];
int ans ;

void rec(int cx,int cy,int nxt){
	if(ans <= nxt) return;
	int dx[4]={0,0,1,-1};
	int dy[4]={1,-1,0,0};
	rep(k,4){
		int nx = cx+dx[k], ny = cy+dy[k];
		if(0<=nx&&nx<h&&0<=ny&&ny<w&&f[nx][ny]!=1){
			int curx = cx+dx[k], cury = cy+dy[k];
			while(0<=curx&&curx<h&&0<=cury&&cury<w){
				if(f[curx][cury] == 3){
					ans = min(ans,nxt);
					return;
				}
				else if(f[curx][cury] == 1){
					f[curx][cury] = 0;
					rec(curx-dx[k],cury-dy[k],nxt+1);
					if(ans <= nxt) return;
					f[curx][cury] = 1; goto nxt;
				}
				else{
					curx += dx[k];
					cury += dy[k];
				}
			}
		nxt:;
		}
	}
}
				

int main(){
	while(1){
		cin >> w >> h;
		if(w == 0) return 0;
		rep(i,h) rep(j,w) cin >> f[i][j];
		ans = 11;
		int cx,cy;
		rep(i,h) rep(j,w) if(f[i][j]==2) {cx=i,cy=j;}
		rec(cx,cy,1);
		if(ans == 11) ans = -1;
		cout << ans << endl;
	}
}



Measured memory_bytes: 3092
import math
import sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from functools import lru_cache, reduce
from heapq import heapify, heappop, heappush
from itertools import chain, combinations, permutations, product
from typing import List, Dict

# import numpy as np

sys.setrecursionlimit(10**6 + 1)
input = sys.stdin.readline
write = sys.stdout.write


def read_item(cls=int):
    return cls(input())


def read_n_item(cls=int) -> list:
    return [cls(s) for s in input().split()]


def list2d(row, col, init_val=0) -> List[list]:
    return [[init_val] * col for _ in range(row)]


MOD = 10**9 + 7
INT_MAX = 10**9
# MOD = 998244353


N = read_item()
vals = read_n_item()
graph = defaultdict(list)

for _ in range(N-1):
    u, v = read_n_item()
    u -= 1
    v -= 1
    graph[u].append(v)
    graph[v].append(u)

ans = [0] * N
ans[0] = 1
dp = [vals[0]]


def dfs(cur, pre):
    ans[cur] = len(dp)

    for nxt in graph[cur]:
        if nxt == pre:
            continue
        i = bisect_left(dp, vals[nxt])
        if i < len(dp):
            temp = dp[i]
            dp[i] = vals[nxt]
            dfs(nxt, cur)
            dp[i] = temp
        else:
            dp.append(vals[nxt])
            dfs(nxt, cur)
            dp.pop()


dfs(0, -1)
print(*ans, sep='\n')


Measured memory_bytes: 233228
N, M = map(int, input().split())
switches = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** N):
    tmp = [0]*N
    for k in range(N):
        if 1 & i>>k:
            tmp[k] = 1
    flg = True
    for k in range(M):
        count = 0
        for l in range(1,switches[k][0]+1):
            if tmp[switches[k][l]-1] == 1:
                count += 1
        if count % 2 != p[k]:
            flg = False
    if flg:
        ans += 1
print(ans)


Measured memory_bytes: 42352
# -*- coding: utf-8 -*-
import sys

#n= int(input())
#tmp= float(input())
#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))

min=1000000
max=-1000000
total=0

#fst=0
while(1):
    tmp = input().split()
    h,w = list(map(lambda a: int(a), tmp))
    if((h==0)and(w==0)):
        sys.exit()
    for i in range(h):
        tmp=""
        for j in range(w):
            if((i==h-1)or(i==0)or(j==w-1)or(j==0)):
                tmp+="#"
            else:
                tmp+="."
        print(tmp)
    print("")





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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int n; cin >> n;
    vector<int> d(n);
    REP(i, n) cin >> d[i];
    ASC(d);
    int ans = d[n / 2] - d[(n / 2) - 1];
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

typedef long long ll;


int main(){
  ll n,x=1,y=1;
  cin >> n;

  for(int i=0;i<n;i++){
    ll tx,ty;
    cin >> tx >> ty;

    if(y / ty  >= x / tx){
      //xが少ない
      while((y % ty) != 0){
	y++;
      }
      x = (y / ty) * tx;
    }
    else{
      while((x % tx)!=0){
	x++;
      }
      y = (x / tx) * ty;
    }
    
  }
  cout << (x+y) << "\n";
  return 0;
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
  int i,j,k,l,a,m,n;
  char s[51][51];
  
  cin>>m>>n;
  for(i=0;i<m;i++){
    cin>>s[i];
  }
  
  for(i=0;i<m;i++){
    for(j=0;j<n;j++){
      if(s[i][j]=='.'){
        a=0;
        for(k=i-1;k<i+2;k++){
          for(l=j-1;l<j+2;l++){
            if(s[k][l]=='#')
              a++;
          }
        }
        cout<<a;
      }
      else
        cout<<"#";
    }
    cout<<endl;
  }
  return 0;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, Q;
string s;

int main() {
    cin >> n >> s >> Q;
    V<set<int>> v(26, set<int>());
    REP(i, n) {
        v[s[i] - 'a'].insert(i);
    }

    REP(q, Q) {
        int mode; cin >> mode;
        if (mode == 1) {
            int i; char c;
            cin >> i >> c;
            i--;
            if (s[i] == c) continue;
            v[s[i] - 'a'].erase(i);
            v[c - 'a'].insert(i);
            s[i] = c;
        } else if (mode == 2) {
            int l, r;
            cin >> l >> r;
            l--; r--;
            int cnt = 0;
            REP(i, 26) {
                auto iter = v[i].lower_bound(l);
                if (iter != v[i].end() && *iter <= r) cnt++;
            }
            printf("%d\n", cnt);
        }
    }

    return 0;
}


Measured memory_bytes: 24196
s = input()
flag = True
flag = flag and s[0] == 'A'
Ccount = 0
for i in range(1,len(s)):
  if ord('a') <= ord(s[i]) and ord(s[i]) <= ord('z'): continue
  if s[i] == 'C' and 2 <= i and i <= len(s)-2:
    Ccount += 1
  else:
    flag = False
print("AC" if flag and Ccount == 1 else "WA")


Measured memory_bytes: 3060
#include<stdio.h>



int main() {
    //変数の宣言
    int n, m, l;
    int A[101][101], B[101][101];
    long long C[101][101], total;
    int i, j, k; //処理用
    
    
    //初期化
//    for (i=0; i<101; i++) {
//        for (j=0; j<101; j++) {
//            A[i][j] = 0;
//            B[i][j] = 0;
//            C[i][j] = 0;
//        }
//    }
    
    
    
    //入力
    scanf("%d %d %d", &n, &m, &l);
    //A n*m
    for (i=0; i<n; i++) {
        for (j=0; j<m; j++) {
            scanf("%d", &A[i][j]);
        }
    }
    //B m*l
    for (i=0; i<m; i++) {
        for (j=0; j<l; j++) {
            scanf("%d", &B[i][j]);
        }
    }
    
    //Cは n * l
    for (i=0; i<n; i++) {
        for (j=0; j<l; j++) {
            total = 0; //初期化
            for (k=0; k<m; k++) { //こんなけぶん回数totalに突っ込む
                total += A[i][k] * B[k][j];
            }
            //終わったらCに回収
            C[i][j] = total;
        }
    }
    
//    //Cを出力
//    for (i=0; i<n; i++) {
//        for (j=0; j<l; j++) {
//            if (j != 0) {
//                printf(" ");
//            }
//            printf("%d", C[i][j]);
//        }
//        printf("\n"); //改行
//    }
    
    for (i = 0; i < n; i++) {
        printf("%lld", C[i][0]);
        for (j = 1; j < l; j++) printf(" %lld", C[i][j]);
        putchar('\n');
    }
    
    
    return 0;
}



Measured memory_bytes: 2108
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S=sc.next();
		String T=sc.next();
		sc.close();
		char[] s = S.toCharArray();
		char[] t = T.toCharArray();
		int count=0;
		for(int i=0;i<S.length();i++) {
			if(s[i]!=t[i])
				count++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 41764
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))+[0]
ans = 0

for i in range(N+1):
  sa = min(A[i],B[i-1])
  A[i]-=sa
  B[i-1]-=sa
  ans+=sa
  
  sa = min(A[i],B[i])
  A[i]-=sa
  B[i]-=sa
  ans+=sa
print(ans)

Measured memory_bytes: 18476
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		if (a < b) {
			if (b <= c) {
				System.out.println(a + " " + b + " " + c);
			} else if (c <= a) {
				System.out.println(c + " " + a + " " + b);
			} else {
				System.out.println(a + " " + c + " " + b);
			}
		} else {
			if (a <= c) {
				System.out.println(b + " " + a + " " + c);
			} else if (c <= b){
				System.out.println(c + " " + b + " " + a);
			} else {
				System.out.println(b + " " + c + " " + a);
			}
		}
	}
}

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

class FirstGrader{
public:
	FirstGrader(int _N);
	~FirstGrader();

	long long int Execute(){ return correctEq(0, num[0]); }

private:
	int N;
	int num[100];
	long long int memo[100][21];
	enum PM{Plus, Minus};
	long long int correctEq(int index, int sum);
};

FirstGrader::FirstGrader(int _N) : N(_N){
	for (int i = 0; i < _N; i++){
		cin >> num[i];
	}
	// memoを-1で初期化
	for (int i = 0; i < 100; i++){
		for (int j = 0; j < 21; j++){
			memo[i][j] = -1;
		}
	}
}
FirstGrader::~FirstGrader(){};

long long int FirstGrader::correctEq(int index, int sum){
	if (index == N-2) {
		if (sum == num[N-1]) return 1;
		else return 0;
	}
	if (memo[index][sum] >=0) return memo[index][sum];

	memo[index][sum] = 0;
	if (sum + num[index + 1] <= 20) memo[index][sum] += correctEq(index+1, sum+num[index+1]);
	if (sum - num[index + 1] >= 0)  memo[index][sum] += correctEq(index+1, sum-num[index+1]);

	return memo[index][sum];
}

int main(){
	int N;
	cin >> N;
	
	FirstGrader* fg = new FirstGrader(N);
	cout << fg->Execute() << endl;
	
	delete fg;
	return 0;
}

Measured memory_bytes: 1212
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        k: u64,
        n: usize,
        aa: [u64;n]
    }
    let a1 = aa[0];
    let mut aa = aa;
    aa.push(k + a1);
    let mut d = 0;
    for i in 1..n+1 {
        // println!("{}", aa[i] - aa[i-1]);
        d = std::cmp::max(d, aa[i] - aa[i-1]);
    }
    println!("{}", k-d);
}


Measured memory_bytes: 10492
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
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 main(void){
	ll n,i,ans=0ll,c,j;
	std::cin >> n;
	for(i=2ll; i*i<=n; ++i){
		c = 0ll;
		while(!(n%i)){
			n /= i;
			++c;
		}
		j = 1ll;
		while(c>=j){
			c -= j;
			++ans; ++j;
		}
	}
	if(n>1ll){
		++ans;
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
constexpr ll INF = 1LL<<60;

int main() {
    ll r;
    cin >> r;
    cout << fixed << setprecision(9) << 2 * r * acos(-1) << endl;

    return 0;
}


Measured memory_bytes: 3792
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let mut vs = scan!(usize;;);
    vs.sort();
    println!("{}", vs.iter().take(2).sum::<usize>());
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
ll d_sum(ll d) {
	ll t = d;

	ll sum = 0;
	while (t > 0) {
		sum += t % 10;
		t /= 10;
	}
	return sum;
}

int main() {
	ll N; cin >> N;
	ll minV = 1 << 29;
	rep(A, 1, N) {
		ll B = N - A;
		minV = min(minV, d_sum(A) + d_sum(B));
		if (minV == 1) {
			cout << endl;
		}
	}
	cout << minV << endl;

	return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n, ans = 0; cin >> n;
    vector<P> r(n), b(n);
    vector<bool> used(n);
    rep(i, n) {
        ll a, b; cin >> a >> b;
        r[i] = make_pair(b, a);
    }
    rep(i, n) {
        ll c, d; cin >> c >> d;
        b[i] = make_pair(c, d);
    }
    sort(ALL(b));
    sort(ALL(r), greater<P>());

    rep(i, n) {
        rep(j, n) {
            if(r[j].first < b[i].second && r[j].second < b[i].first && !used[j]) {
                used[j] = true;
                ans++;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 3612
n = int(input())
l0 = 2
l1 = 1
count = 2

if n == 1:
    print(1)
    exit()

for i in range(2, 86+1):
    li = l1 + l0
    if count == n:
        print(li)
        exit()

    l0, l1 = l1, li
    count += 1

Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int a[]=new int[3];
	for(int i=0;i<3;i++){
		a[i]=sc.nextInt();
	}
		Arrays.sort(a);
		for(int i=0;i<2;i++){
			System.out.print(a[i]+" ");
		}System.out.println(a[2]);
	
	}
}

Measured memory_bytes: 17168
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000],cnt[1000000],ass[1000000];
int main()
{
	long long n,i,j,k,f,ans;
	cin>>n;
	f=0;
	for (i=0;i<n;i++)
	{
		cin>>arr[i];
		cnt[arr[i]]++;
	}
	ans=0;
	for (i=0;i<=n;i++)
	{
		if (cnt[i]>=1)
		{
			f=1;
			ans=ans+(cnt[i]*(cnt[i]-1))/2;
		}
	}
	//cout<<ans<<endl;
	for (i=0;i<=n;i++)
	{
		if (cnt[i]>=2)
		{
			ass[i]=ans-((cnt[i]*(cnt[i]-1))/2);
			//cout<<ass[i]<<endl;
			ass[i]=ass[i]+(((cnt[i]-2)*(cnt[i]-1))/2);
			//cout<<ass[i]<<endl;
		}
		else
		{
			ass[i]=ans;
		}
	} 
	for (i=0;i<n;i++)
	
	{
			cout<<ass[arr[i]]<<endl;
	}
}

Measured memory_bytes: 12288
n, m = gets.chomp.split.map(&:to_i)
k = gets.chomp.split.map(&:to_i).sort
# p k
# n>=Mのときは単純に初期状態でm箇所にn個置けるので0
if n>=m
  puts 0
  exit
end

# となりあう二つの要素の差（m-1個ある）
arr = Array.new(m-1, 0)
(m-1).times do |idx|
  arr[idx] =(k[idx] - k[idx+1]).abs
end
# 差の大きいところから順にコマを置くことにすればいい
arr.sort!.reverse!
# p arr
# p [0, arr[n, arr.size-n]]
p [0, arr[n-1, arr.size-n+1].inject(&:+)].max

Measured memory_bytes: 11120
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
	public static void main(String args[]){
	      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	      String s;
	      int n,p;
	      int m[] = new int[55];

	      try{
	    	  while(!(s = br.readLine()).equals("0 0")){
	    		  for(int i = 0; i < 55; i++) m[i] = 0;

	    		  String ss[] = s.split(" ");
	    		  n = Integer.parseInt(ss[0]);
	    		  p = Integer.parseInt(ss[1]);

	    		  for(int i = 0; true; i = (i+1)%n){
    				  
	    			  if(p == 0){
	    				  p = m[i];
	    				  m[i] = 0;
	    			  }else{
	    				  p--;
	    				  m[i]++;
	    			  }
	    			  
/*
    				  for(int j = 0; j < n; j++){
    					  System.out.print(" "+ m[j]);
    				  }
    				  System.out.println("  + " + p);
	*/
	    			  
	    			  if(p == 0){
	    				  int c = 0;
	    				  for(int j = 0; j < n; j++){
	    					  //System.out.print(" "+ m[j]);
	    					  if(m[j] != 0) c++;
	    				  }
	    				  //System.out.println(" = " + c);
	    				  if(c <= 1){
	    					  System.out.println(i);
	    					  break;
	    				  }
	    			  }
	    		  }
	    	  }

	      }catch(Exception e){
	    	  System.out.println("Exception :" + e);
	      }
	}
}

Measured memory_bytes: 19564
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int K,N;
    cin >> K >> N;
    vector<int> A(N) ;
    int longest;
    for(int i=0;i<N;i++){
        cin>> A[i] ;
    }
    for(int i=1;i<=N;i++){
        if(i==1){
            longest = abs(A[i] - A[i-1]);
        } 
        else if((i>1)&&(i<N)){
            int distance = abs(A[i]- A[i-1]);
            if(distance > longest){
                longest = distance;
            }
        }
        else if(i==N){
            int distance = abs(A[0]+ abs(K - A[i-1]));
            if(distance > longest){
                longest = distance;
            }
        }
    }
    int ans = K - longest;
    cout << ans << endl;
}

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

#define int long long
#define debug(x) cout<<#x<<" "<<x<<endl;

const int N=1e6+5;
const double eps=1e-9;
const int INF=1e18;

int a[N];

signed main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+1+n,greater<int>());
    for(int i=1;i<=k;i++){
        a[i]=0;
    }
    int ans=0;
    for(int i=1;i<=n;i++) ans+=a[i];
    cout<<ans<<endl;
    return 0;
}

//Created Time  :2020/1/26 20:09:32


Measured memory_bytes: 1920
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

std::string calc(std::string str, std::string str2){

	std::string res;

	std::reverse(str.begin(), str.end());
	std::reverse(str2.begin(), str2.end());

	bool up = 0;
	const int max = std::max(str.size(), str2.size());
	for (int i = 0; i < max || up; i++){
		int a = 0, b = 0;
		if (str.size() > i)a = str[i] - '0';
		if (str2.size() > i)b = str2[i] - '0';

		if (a + b + up >= 10){
			res += (a + b + up - 10 + '0');
			up = 1;
		}
		else{
			res += (a + b + up + '0');
			up = 0;
		}
	}
	std::reverse(res.begin(), res.end());

	return res;
}

int main(){

	std::string str;

	while (std::cin >> str){

		std::vector<std::string>shiki;

		for (int i = 0, j = 0; i <= str.size(); i++){
			if (i == str.size() || str[i] == '+' || str[i] == '='){
				shiki.push_back(str.substr(j, i - j));
				j = i + 1;
			}
		}

		for (int i = 0; i <= 9; i++){
			std::vector<std::string>shiki_copy(shiki);

			for (int j = 0; j < shiki_copy.size(); j++){
				for (int k = 0; k < shiki_copy[j].size(); k++){
					if (shiki_copy[j][k] == 'X'){
						if (i == 0 && k == 0 && shiki_copy[j].size() != 1)goto end;
						shiki_copy[j][k] = (i + '0');
					}
				}
			}
			if (calc(shiki_copy[0], shiki_copy[1]) == shiki_copy[2]){
				std::cout << i << std::endl;
				break;
			}
			if (i == 9)std::cout << "NA" << std::endl;
		end:;
		}
	}
	return 0;
}

Measured memory_bytes: 1200