akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"sort"
	"strconv"
)

func main() {
	n := readInt()
	m := make(map[string]int)
	mx := 0
	for i := 0; i < n; i++ {
		s := readString()
		m[s]++
		mx = max(mx, m[s])
	}

	a := make([]string, 0)
	for k, v := range m {
		if v == mx {
			a = append(a, k)
		}
	}
	sort.Strings(a)

	for i := range a {
		fmt.Println(a[i])
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 30720
import sys
import string

def main():
    chars = {x:0 for x in string.ascii_lowercase}

    for line in sys.stdin:
        for ch in line.lower():
            if ch in chars:
                chars[ch] += 1

    for ch in string.ascii_lowercase:
        print(ch+" : "+str(chars[ch]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 6684
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b){
		printf("%d\n",c);
	}
	else if(b==c){
		printf("%d\n",a);
	}
	else if(c==a){
		printf("%d\n",b);
	}
	return 0;
}

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

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());




int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    int x,y,z;
    cin >> x >> y >> z;
    swap(x,y);
    swap(x,z);
    cout << x << " " << y << " " << z;
    return 0;
}


Measured memory_bytes: 256
X, Y = map(int, input().split())

def solver(X, Y):
    if X == 1 and Y == 1:
        print(1000000)
        return
    
    a = 0
    if X == 1:
        a += 300000
    if X == 2:
        a += 200000
    if X == 3:
        a += 100000
    if Y == 1:
        a += 300000
    if Y == 2:
        a += 200000
    if Y == 3:
        a += 100000
    
    print(a)

solver(X, Y)

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

using namespace std;

int swap(int nowAt, int a, int b) {
    if (a == nowAt) {
        return b;
    }
    if (b == nowAt) {
        return a;
    }

    return nowAt;
}

vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

int main() {
    int w, n, i, ii, nowAt;

    cin >> w >> n;

    int results[w];

    // ルートの読み込み
    int routes[n][2];
    for (i = 0; i < n; i++) {
        string buffer;
        cin >> buffer;

        vector<string> splitted = split(buffer, ',');
        routes[i][0] = stoi(splitted[0]);
        routes[i][1] = stoi(splitted[1]);
        vector<string>().swap(splitted); // メモリの解放
    }

    // それぞれあみだくじをやる
    for (i = 0; i < w; i++) {
        nowAt = i+1; // 最初の位置

        // あみだの全節を通る
        for (ii = 0; ii < n; ii++) {
            nowAt = swap(nowAt, routes[ii][0], routes[ii][1]);
        }

        results[nowAt-1] = i + 1;
    }

    for(int goal : results) cout << goal << endl;
}


Measured memory_bytes: 3156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcorder_yahoo
{
    class Program
    {
        static void Main(string[] args)
        {

            int[] cntArr = new int[4];
            for(int i = 0; i < 3; i++)
            {
                int[] dataArr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                cntArr[dataArr[0] - 1]++;
                cntArr[dataArr[1] - 1]++;
            }

            string ret = "YES";
            for (int i = 0; i < 4; i++)
            {
                if (2 < cntArr[i])
                {
                    ret = "NO";
                    break;
                }
            }

            Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int a, b, c;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b >> c;
  cout << (b-a==c-b ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <iostream>
    #include <vector>
    #include <string>
    #include <algorithm>
    #include <stack>
    #include <queue>
    #include <set>
    #include <map>
    using namespace std;
    #define MOD @
    #define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
    typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;
     
    char S[505050];
    int N, Q;
    int L[101010], R[101010];
    int dp[505050][27];
     
    /*
    int uf[505050];
     
    int root(int p)
    {
    	return uf[p] < 0 ? p : (uf[p] = root(uf[p]));
    }
    void join(int p, int q)
    {
    	p = root(p);
    	q = root(q);
    	if (p != q) {
    		uf[p] += uf[q];
    		uf[q] = p;
    	}
    }
    */
    vector<int> ch[505050];
    int lf[505050], rg[505050];
    int idx;
     
    void visit(int p)
    {
    	if (lf[p] != -1) return;
    	lf[p] = idx++;
    	for (int q : ch[p]) visit(q);
    	rg[p] = idx;
    }
     
    int main()
    {
    	scanf("%s%d", S, &Q);
    	N = strlen(S);
    	for (int i = 0; i < Q; ++i) {
    		scanf("%d%d", L + i, R + i);
    		--L[i];
    	}
    	for (int i = N - 1; i >= 0; --i) {
    		for (int j = 0; j <= 26; ++j) {
    			dp[i][j] = N + 10;
    		}
    		dp[i][S[i] - 'a'] = i + 1;
    		for (int j = 1; j <= 26; ++j) {
    			if (dp[i][j - 1] < N) {
    				int ij = dp[i][j - 1];
    				dp[i][j] = min(dp[i][j], dp[ij][j - 1]);
    			}
    		}
    		if (dp[i][26] < N) {
    			int i26 = dp[i][26];
    			for (int j = 0; j <= 26; ++j) {
    				/*
    				if (j > 0 && dp[i][j - 1] < N) {
    					int ij = dp[i][j - 1];
    					dp[i][j] = min(dp[i][j], dp[ij][j - 1]);
    				}
    				*/
    				if (dp[i26][j] <= N) {
    					dp[i][j] = min(dp[i][j], dp[i26][j]);
    				}
    			}
    		}
    	}
    //	for (int i = 0; i < N; ++i) printf("%d: %d\n", i, dp[i][26]);
    	for (int i = 0; i < N; ++i) if (dp[i][26] <= N) {
    		ch[dp[i][26]].push_back(i);
    	}
    	idx = 0;
    	for (int i = 0; i <= N; ++i) lf[i] = -1;
    	for (int i = N; i >= 0; --i) visit(i);
     
    	for (int i = 0; i < Q; ++i) {
    		int l = L[i], r = R[i];
    		bool isok = lf[r] <= lf[l] && rg[l] <= rg[r];
    		puts(isok ? "Yes" : "No");
    	}
    	return 0;
    }

Measured memory_bytes: 94336
N, K = map(int, input().split())
h_array = list(map(int, input().split()))

dp = [10 ** 5 for i in range(N)]

for i in range(N):
    if i == 0:
        dp[0] = 0
    elif 0 < i <= K:
        tmp = [dp[i - (j + 1)] + abs(h_array[i] - h_array[i - (j + 1)]) for j in range(i)]
        dp[i] = min(tmp)
    elif K < i:
        tmp = [dp[i - (j + 1)] + abs(h_array[i] - h_array[i - (j + 1)]) for j in range(K)]
        dp[i] = min(tmp)
print(dp[N - 1])


Measured memory_bytes: 56544
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;

void solve(long long N, std::vector<long long> A){
  ll c[3] = {0};
  ll ans = 1;
  for(auto x: A) {
    ll cnt = 0;
    for(ll i=0; i<3; i++) {
      if(c[i]==x) {
	if(cnt==0) {
	  c[i]++;
	}
	cnt++;
      }
    }
    ans = (ans * cnt) % MOD;
    // std::cout << cnt <<": ";
    // for(ll i=0; i<3; i++)
    //   std::cout << c[i] << " ";
    // std::cout << std::endl;
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, std::move(A));
  return 0;
}



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

int main(){
    string S, T; cin>>S>>T;
    int A, B; cin>>A>>B;
    string U; cin>>U;

    if(U==S) A--;
    if(U==T) B--;

    cout<<A<<" "<<B<<endl;
}


Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long int;

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

const int mod = 1E+09 + 7;
using modint = ModInt< mod >;

const int N_MAX = 200005;
vector<int> edge[N_MAX];
pair<int, int> E[N_MAX];

int Node[N_MAX];

int dfs(int v, int p){
    int n = 1;
    for(int u : edge[v]){
        if (u == p)continue;
        n += dfs(u, v);
    }
    return Node[v] = n;
}

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        E[i] = make_pair(a, b);
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    dfs(1, -1);

    modint ans(0);
    for(int i = 0; i < n-1; i++){
        int an = min(Node[E[i].first], Node[E[i].second]);
        ans += (modint(1) - (modint(1)/modint(2)).pow(an))*(modint(1) - (modint(1)/modint(2)).pow(n-an));
    }
    ans += (modint(1) - (modint(1)/modint(2).pow(n)));
    ans -= modint(n)/modint(2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 22400
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

bool f(const P& l,const P& r){
    int a = l.second - l.first;
    int b = r.second - r.first;
    if(a > 0 && b <= 0){
        return true;
    }
    if(a <= 0 && b > 0){
        return false;
    }
    if(a > 0 && b > 0){
        return l.first < r.first;
    }if(a < 0 && b < 0){
        return l.second > r.second;
    }
}

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    vector<P> lr(n);
    rep(i,n){
        int l = 0;
        int r = 0;
        rep(j,s[i].size()){
            if(s[i][j] == '('){
                ++r;
            }else{
                if(r > 0) --r;
                else ++l;
            }
        }
        lr[i].first = l;
        lr[i].second = r;
    }

    sort(lr.begin(),lr.end(),f);
    if(lr[0].first!=0){
        cout << "No" << endl;
        return 0;
    }
    int r = 0;
    rep(i,n){
        if(r < lr[i].first){
            cout << "No" << endl;
            return 0;
        }
        r -= lr[i].first;
        r += lr[i].second;
    }
    cout << (r==0?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 42284
#include<stdio.h>
 
int main(void){
	int n,k;
	scanf("%d%d", &n, &k);
	int p[n];
	int i, j;
	int tmp;
	for(i=0;i<n;i++){
		scanf("%d", &p[i]);
	}
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(p[i]>p[j]){
				tmp = p[i];
				p[i] = p[j];
				p[j] = tmp;
			}
		}
	}
	tmp = 0;
	for(i=0;i<k;i++){
		tmp = tmp + p[i];
	}
	printf("%d", tmp);
	return 0;
}

Measured memory_bytes: 1688
s=list(input())
q=int(input())
r=0
m=[]
u=[]
for i in range(q):
    p=list(map(str,input().split()))
    if int(p[0])==1:
        r+=1
    else:
        if (int(p[1])==1 and r%2==0) or (int(p[1])==2 and r%2==1):
            m.append(p[2])
        else:
            u.append(p[2])
if len(m)>0:
    m.reverse()
ans=m+s+u
if r%2==1:
    ans.reverse()
print(''.join(ans))

Measured memory_bytes: 10096
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n, a, b;
	cin >> n >> a >> b;
	cout << min(n*a, b) << endl;
}

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

int main(void) {
 while(1) {
   int H {0};
   int W {0};
   cin >> H >> W;

   if (H == 0 && W == 0) {
       break;
   }

   for(int i = 0; i < H; i++){
     for(int j = 0; j < W; j++){
       if(i != 0 && i != H-1){
           if(j == 0 || j == W-1) {
                cout << "#";
            } else {
                 cout << ".";
            }
       } else {
           cout << "#";
       }
     }
     cout << "\n";
   }
   cout << "\n";
 }
 return 0;
}


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

typedef long long ll;
const ll MOD = 1000000007;

#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define MP make_pair
#define F first
#define S second

ll N;
ll f[200010], inv[200010], finv[200010];
ll pfinv[200010], pC[200010];

vector<plll> graph[200010];

pll *parent[200010];

ll modinv(ll x){
    ll ret=1, po=MOD-2;
    while(po){
        if(po&1) ret = (ret*x)%MOD;
        po>>=1; x=(x*x)%MOD;
    }
    return ret;
}

pll get_ans(ll node, ll prev){
    ll ssize = 1, ret = 1;
    pfinv[node] = pC[node] = 1;
    for(auto &X : graph[node]){
        if(X.F == prev){ parent[node] = &X.S; continue; }
        if(X.S.F==0){
            ll nex = X.F;
            auto a = get_ans(nex, node);
            X.S = a;
        }
        ssize += X.S.F;
        ret = (ret*X.S.S)%MOD;
        ret = (ret*finv[X.S.F])%MOD;
        pfinv[node] = (pfinv[node]*finv[X.S.F])%MOD;
        pC[node] = (pC[node]*X.S.S)%MOD;
    }
    if(prev){
        pfinv[node] = (pfinv[node]*finv[N-ssize])%MOD;
    }
    ret = (ret*f[ssize-1])%MOD;
    return MP(ssize, ret);
}

void get_ans_inv(ll node, ll prev){
    for(auto &X : graph[node]){
        if(X.F == prev) continue;
        ll Si = (N-X.S.F);
        ll nex = X.F;
        parent[nex]->F = Si;
        ll tmp = (((f[Si-1]*pfinv[node])%MOD)*f[X.S.F])%MOD;
        tmp = (((tmp*pC[node])%MOD)*modinv(X.S.S))%MOD;
        parent[nex]->S = tmp;
        pC[nex] = (pC[nex]*tmp)%MOD;
        get_ans_inv(nex, node);
    }
}

int main()
{
    scanf("%lld", &N);
    f[0] = inv[1] = finv[0] = 1;
    for(int i=1; i<=N; ++i) f[i] = (f[i-1]*i)%MOD;
    for(int i=2; i<=N; ++i) inv[i] = ((-inv[MOD%i]*(MOD/i))%MOD + MOD)%MOD;
    for(int i=1; i<=N; ++i) finv[i] = (finv[i-1]*inv[i])%MOD;

    for(int i=1; i<N; ++i){
        ll x, y;
        scanf("%lld%lld", &x, &y);
        graph[x].push_back(MP(y,MP(0,0)));
        graph[y].push_back(MP(x,MP(0,0)));
    }

    get_ans(1,0);
    get_ans_inv(1,0);

    // for(int i=1; i<=N; ++i){
    //     printf("Node: %d\n", i);
    //     for(auto X : graph[i]){
    //         printf("{%lld, {%lld, %lld}},  ", X.F, X.S.F, X.S.S);
    //     }
    //     printf("\n\n");
    // }

    for(int i=1; i<=N; ++i){
        printf("%lld\n", get_ans(i, 0).S);
    }
}

Measured memory_bytes: 29952
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,m,k,cnt=0,time,ia,i,ib, mc=0
    integer(int64), allocatable:: a(:), b(:)
    read*, n, m, k
    allocate(a(n), b(m))
    read*, a(:)
    read*, b(:)
    

    time = sum(a)
    cnt = n
    ia=n

    do while (time > k)
        time = time - a(ia)
        ia=ia-1
        cnt=cnt-1
    end do

    ib=1

    do while (ib <= m)
        if (time+b(ib) > k) exit
        time=time+b(ib)
        ib=ib+1
        cnt=cnt+1
    end do

    mc = cnt

    do i=ia,1,-1
        cnt=cnt-1
        time=time-a(i)
        do while (ib <= m)
            if (time + b(ib) > k) exit
            time=time+b(ib)
            ib=ib+1
            cnt=cnt+1
        end do
        mc = max(mc, cnt)
    end do
    print'(i0)', mc
end program main

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

using namespace std;

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

	int n,k;
	cin >> n >> k;
	vector<int> ar(n);
	for(int i=0;i<n;i++){
		cin >> ar[i];
	}
	for(int i=0;i<n-k;i++){
		cout << (ar[i] < ar[i+k] ? "Yes\n" : "No\n");
	}

	return 0;
}

Measured memory_bytes: 3984
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Int (Int64)
import Data.Coerce
import qualified Data.ByteString.Char8 as BS
import Control.Exception (assert)

main = do
  n <- readLn
  s <- BS.getLine
  assert (BS.length s == 2 * n) $ return ()
  let loop :: N -> Int -> Int -> N
      loop !acc !k !i | BS.length s == i = if k == 0 then acc else 0
                      | BS.index s i == 'W' = if even k
                                              then loop (acc * unsafeFromInt k) (k-1) (i+1)
                                              else loop acc (k+1) (i+1)
                      | otherwise = if even k
                                    then loop acc (k+1) (i+1)
                                    else loop (acc * unsafeFromInt k) (k-1) (i+1)
  print $ loop (product (coerce ([1..fromIntegral n] :: [Int64]) :: [N])) 0 0

--
-- Modular Arithmetic
--

modulo :: Int64
modulo = 10^9+7
addMod, subMod, mulMod :: Int64 -> Int64 -> Int64
addMod !x !y | x + y >= modulo = x + y - modulo
             | otherwise = x + y
subMod !x !y | x >= y = x - y
             | otherwise = x - y + modulo
mulMod !x !y = (x * y) `rem` modulo

newtype N = N { unwrapN :: Int64 } deriving (Eq)
instance Show N where
  show (N x) = show x
instance Num N where
  (+) = coerce addMod
  (-) = coerce subMod
  (*) = coerce mulMod
  fromInteger n = N (fromInteger (n `mod` fromIntegral modulo))
  abs = undefined; signum = undefined

unsafeFromInt :: Int -> N
unsafeFromInt x = N (fromIntegral x)
{-# INLINE unsafeFromInt #-}

{-# RULES
"^9/Int" forall x. x ^ (9 :: Int) = let u = x; v = u * u * u in v * v * v
"^9/Integer" forall x. x ^ (9 :: Integer) = let u = x; v = u * u * u in v * v * v
 #-}


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

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

    string ans = "No";
    if (N <= 81) {
        if (N <= 9) {
            ans = "Yes";
        }
        else {
            for (int i = 9; i > 1; i--) {
                if (N % i == 0) {
                    if (N / i <= 9) {
                        ans = "Yes";
                        break;
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb emplace_back
typedef pair<int,int> pi;

int a,b,c;

int main() {
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	cin >> a >> b >> c;
	if (a + b + 1 >= c) cout << b + c;
	else cout << b + (a + b + 1);
	return 0;
}


Measured memory_bytes: 3608
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
const int N=200;
int a[200];
int32_t main()
{
  #ifndef ONLINE_JUDGE
  freopen("in","r",stdin);
  freopen("out","w",stdout);
  #endif
  int n;cin>>n;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }

  int ans=0;
  while(1)
  {
    bool done=0;bool active=0;
    for(int i=0;i<n;i++)
    {
      if(a[i]>=1 and !active){a[i]--;active=1;ans++;done=1;}
      else if(a[i]>=1 and active){a[i]--;}
      else if(a[i]<=0){active=0;}
    }
    if(!done)break;
  }
  cout<<ans;
  
 
  

}

Measured memory_bytes: 3588
using System;

namespace abc87_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int money = int.Parse(Console.ReadLine());
            int cake = int.Parse(Console.ReadLine());
            int donut = int.Parse(Console.ReadLine());
            int answer;
            answer = money - cake;
            answer = answer % donut;
            Console.WriteLine(answer);
        }
    }
}


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

int main() {
    constexpr i64 inf = 1000000000000;
    int n;
    std::cin >> n;
    i64 sxl = inf, sxr = -inf, syd = inf, syu = -inf,
        posmxl = inf, posmxr = -inf, posmyd = inf, posmyu = -inf,
        negmxl = inf, negmxr = -inf, negmyd = inf, negmyu = -inf;

    for (int i = 0; i < n; i++) {
        i64 x, y; char dir;
        std::cin >> x >> y >> dir;
        if (dir == 'U') {
            sxl = std::min(sxl, x);
            sxr = std::max(sxr, x);
            posmyd = std::min(posmyd, y);
            posmyu = std::max(posmyu, y);
        } else if (dir == 'D') {
            sxl = std::min(sxl, x);
            sxr = std::max(sxr, x);
            negmyd = std::min(negmyd, y);
            negmyu = std::max(negmyu, y);
        } else if (dir == 'R') {
            syd = std::min(syd, y);
            syu = std::max(syu, y);
            posmxl = std::min(posmxl, x);
            posmxr = std::max(posmxr, x);
        } else {
            syd = std::min(syd, y);
            syu = std::max(syu, y);
            negmxl = std::min(negmxl, x);
            negmxr = std::max(negmxr, x);
        }
    }

    auto dx = [&](double t) {
        double ub = std::max({ (double)sxr, posmxr + t, negmxr - t }),
            lb = std::min({ (double)sxl, posmxl + t, negmxl - t });
        return ub - lb;
    };
    auto dy = [&](double t) {
        double ub = std::max({ (double)syu, posmyu + t, negmyu - t }),
            lb = std::min({ (double)syd, posmyd + t, negmyd - t });
        return ub - lb;
    };
    auto f = [&](double t) {
        return dx(t) * dy(t);
    };

    double left = 0, right = 1000000000;
    for (int i = 0; i <= 100; i++) {
        if (f((left * 2 + right) / 3) < f((left + right * 2) / 3)) {
            right = (left + right * 2) / 3;
        } else {
            left = (left * 2 + right) / 3;
        }
    }
    std::cout << std::setprecision(10) << f((left + right) * 0.5) << std::endl;

    return 0;
}


Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repe(i, n) REPN(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
ll in(){ll x; cin >> x; return x;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll m, k;
	cin >> m >> k;

	ll a = (1 << m);
	if(k >= a){
		co(-1);
		return 0;
	}

	if(m == 1 && k == 0){
		coVec({0, 0, 1, 1});
		return 0;
	}else if(m == 1 && k == 1){
		co(-1);
		return 0;
	}

	cosp(k);
	rep(i, a) if(i != k) cosp(i);
	cosp(k);
	repr(i, a) if(i != k) cosp(i);
	cout << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>

#define M 1000003
#define L 14

char H[M][L];

long long h1(long long k){
  return k % M;
}

long long h2(long long k){
  return 1 + (k % (M - 1));
}

long long h(long long k, long long i){
  return (h1(k) + i * h2(k)) % M;
}

int getChar(char ch){
if ( ch == 'A') return 1;
else if ( ch == 'C') return 2;
else if ( ch == 'G') return 3;
else if ( ch == 'T') return 4;
return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int find(char str[]){
  long long key, i, id;

  key = getKey(str);
  i = 0;

  while(true){
    id = h(key, i);
    if(strcmp(H[id], str) == 0) return 1;
    else if(strlen(H[id]) == 0) return 0;
    i++;
  }
  return 0;
}

int insert(char str[]){
  long long key, i, id;

  key = getKey(str);
  i = 0;

  while(true){
    id = h(key, i);
    if(strcmp(H[id], str) == 0) return 1;
    else if(strlen(H[id]) == 0){
      strcpy(H[id], str);
      return 0;
    }
    i++;
  }
  return 0;
}

int main(){

  int n;
  char str[L], command[10];

  for (int i = 0; i < M; i++ ) H[i][0] = '\0';

  scanf("%d", &n);
  for(int i = 0;i < n;i++){
    scanf("%s %s", command, str);

    if(command[0] == 'i') insert(str);
    else{
      if(find(str)) printf("yes\n");
      else printf("no\n");
    }
  }


  return 0;
}



Measured memory_bytes: 16840
#include<iostream>
using namespace std;
int main(){
  for(;;){

    int x,y,z;
    cin >> x;
    cin >> y;
    if(x==0&&y==0){
      break;
    }
    cin >> z;
    int n[x][y];
    for(int i=0; i<x; i++){
      for(int j=0; j<y; j++){
        n[i][j]=0;
      }
    }
    n[0][0]=1;
    int k,l;
     for(int i=0; i<z; i++){
       cin>>k;
       cin>>l;
       n[k-1][l-1]=-1;
     }
     for(int i=0; i<x; i++){
       for(int j=0; j<y; j++){
         if(n[i-1][j]!=-1&&i!=0&&n[i][j]!=-1){
           n[i][j]+=n[i-1][j];
         }
         if(n[i][j-1]!=-1&&j!=0&&n[i][j]!=-1){
           n[i][j]+=n[i][j-1];
         }
       }
     }
     cout<<n[x-1][y-1]<<endl;

  }
}


Measured memory_bytes: 3040
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
#define MP make_pair
#define PB push_back
#define ll long long
#define int long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define ld long double
#define mod 1000000007

int n,m;
vector <pair <int,int> > gp[100005];
int va[100005],su;
int vis[100005];
vector <pair <int,int> > ans;
int dfs(int i,int par)
{
	if(vis[i]==1)
		return 0;
	vis[i]=1;
	int vaa=va[i];
	for(auto &j: gp[i])
	{
		int tem=dfs(j.ff,i);
		j.ss^=tem;
		vaa^=tem;
	}
	for(auto &j: gp[i])
	{
		if(j.ff==par)
		{
			j.ss^=vaa;
		}
	}
	return vaa;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m;
	f(i,0,m)
	{
		int a,b;
		cin>>a>>b;
		gp[a].push_back({b,1});
		va[a]^=1;
		gp[b].push_back({a,0});
	}
	if(m%2!=0)
	{
		cout<<"-1\n";
		return 0;
	}
	dfs(1,0);
	f(i,1,n+1)
	{
		for(auto j: gp[i])
		{
			if(j.ss==1)
				cout<<i<<" "<<j.ff<<'\n';
		}
	}
	return 0;
}

Measured memory_bytes: 17792
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 998244353LL;
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void debug() { cerr << "ok" << endl; }
template <class T>
void printv(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void readv(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    ll res = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 && i % 5) {
            res += i;
        }
    }
    cout << res << '\n';
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <utility>
#include <cstdlib>

using namespace std;
int main(){
    int n; cin>>n;
    vector<int>d(n);
    for(int i=0;i<n;i++){
        cin>>d.at(i);
    }
    
    sort(d.begin(),d.end());
    
    if(d.at(n/2-1)!=d.at(n/2)){
        cout<<d.at(n/2)-d.at(n/2-1)<<endl;
    }
    else{
        cout<<0<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 640
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
    	new B().doIt();
    }
    class B{
    	int dp[] = new int[301];
    	void dp_table(){
    		dp[0] = 1;
			for(int i = 1;i < 17;i++){
				for(int j = 0;j < 301;j++){
					if(j+(i*i) > 300)break;
					dp[j+(i*i)] = dp[j+(i*i)] + dp[j];
				}
			}
		}
    	void doIt(){
    		dp_table();
            while(true){
            	int n = sc.nextInt();
            	if(n == 0)break;
            	System.out.println(dp[n]);
            }
        }
    }
}

Measured memory_bytes: 26196
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define TE 2e6+5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	string s; cin >> s;
	int len = s.size();
	int mx = pow(2, len-1);

	ll ans = 0;
	for (int i = 0; i < mx; i++) {
		int left = 0;
		string temp;
		for (int j = 0; j < len - 1; j++) {
			if (i & 1 << j) {
				temp = s.substr(left, j - left + 1);
				ll ad = 0, tl = temp.size();
				for (int k = 0; k < tl; k++) {
					ad *= 10;
					ad += temp[k] - '0';
				}
				ans += ad;
				left = j + 1;
			}
			
		}

		temp = s.substr(left, (len - 1) - left + 1);
		ll ad = 0, tl = temp.size();
		for (int k = 0; k < tl; k++) {
			ad *= 10;
			ad += temp[k] - '0';
		}
		ans += ad;

		//cout << "ans=" << ans << endl;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4008
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repp(i, n) for(int i = 1; i <= (int)(n); i++)
#define co(x) cout<<x<<endl
typedef long long int lint;

int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  rep(i,N){
    cin >> S.at(i);
  }
  sort(S.begin(),S.end());
  S.erase(unique(S.begin(), S.end()), S.end()); 
  co(S.size());
}

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

int main(){
  int a,b,k;
  cin>>a>>b>>k;
  int cur=100;
  int pos=0;
  while(pos<k){
    if(a%cur==0 && b%cur==0){
      pos++;
    }
    cur--;
  }
  cout<<cur+1<<endl;
}

Measured memory_bytes: 256
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    cnt0 = 0
    cnt1 = 0
    cnt2 = 0
    cnt3 = 0
    for _ in range(n):
        ans = input().rstrip()
        if ans == "AC":
            cnt0 += 1
        elif ans == "WA":
            cnt1 += 1
        elif ans == "TLE":
            cnt2 += 1
        elif ans == "RE":
            cnt3 += 1

    print("AC x " + str(cnt0))
    print("WA x " + str(cnt1))
    print("TLE x " + str(cnt2))
    print("RE x " + str(cnt3))

resolve()

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

int main(){
  int N, M;
  vector<int> D;
  vector<int> T;
  cin >> N;
  for(int i=0; i<N; i++){
    int d; cin >> d;
    D.push_back(d);
  }
  cin >> M;
  for(int i=0; i<M; i++){
    int t; cin >> t;
    T.push_back(t);
  }
  if(D.size()<T.size()){
    cout << "NO" << endl;
    return 0;
  }
  sort(D.begin(),D.end());
  sort(T.begin(),T.end());
  int idx=0;
  for(int i=0; i<T.size(); i++){
    while(idx<D.size()){
      if(T[i]==D[idx]){
        idx++;
        break;
      }
      else idx++;
      if(idx==D.size()){
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 2548
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

void IO(){
#ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout); 
#endif 
}

const int MX=1e5+10;
int N,K;
int dp[101][MX];


/*int solve(int x, int y){
	if(x==R-1 && y==C-1) return 1;
	if(x<0 || y<0 || x>=R || y>=C || g[x][y]=='#') return 0;
	if(memo[x][y]!=-1) return memo[x][y];
	return memo[x][y]=(solve(x,y+1)+solve(x+1,y))%MOD;
}*/

int32_t main(){
   boost;
   IO();

   //memset(dp,-1,sizeof(dp));
   /*cin>>N>>W;
   for(int i=0; i<N;i++) cin>>w[i]>>v[i];

   for(int i=100000; i>=0; i--) if(solve(0,i)<=W){cout << i << endl; return 0;}*/

   cin>>N>>K;
   int t[N];
   for(int i=0; i<N; i++) cin>>t[i];

   for(int i=0; i<=K; i++) dp[0][i]=0;
   for(int i=K; i>=K-t[0]; i--) dp[0][i]=1;
   for(int i=1; i<=K; i++) dp[0][i]+=dp[0][i-1],dp[0][i]%=MOD;

	for(int i=1; i<N; i++) for(int j=0; j<=K; j++){
		dp[i][j]+=dp[i-1][min(K,j+t[i])];
		if(j) dp[i][j]-=dp[i-1][j-1];
		dp[i][j]=(dp[i][j]+MOD)%MOD;
		if(j<K) dp[i][j+1]+=dp[i][j]; dp[i][j+1]%=MOD;
	}

	cout << dp[N-1][0] << endl;

   return 0;
}



Measured memory_bytes: 81720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;cin>>n;
    ll lpp=2,lp=1;
    ll l=0;
    if(n==1){
        cout<<lp<<endl;
    }
    else{
        for(int i=1;i<n;i++){
            l=lpp+lp;
            lpp=lp;
            lp=l;
        }
        cout<<l<<endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int n = sc.nextInt();
        int v = Math.max(h, w);
        int ans = (n % v == 0) ? n / v : n / v + 1;
        System.out.println(ans);
    }
}

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

int main(){
	int n, m;
	int max = 0;
	string s;
	unordered_map<string, int> mp;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> s;
		mp[s]++;
	}
	cin >> m;
	for(int i=0; i<m; i++){
		cin >> s;
		mp[s]--;
	}
	for(auto itr= mp.begin(); itr != mp.end(); itr++){
		if(itr->second > max) max = itr->second;
	}
	cout << max;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main() {
    long long x;
    cin >> x;
    long long ansa, ansb;
    for (long long i = -1000; i <= 1000; i++) {
        for (long long j = -1000; j <= 1000; j++) {
            long long a = i;
            long long b = j;
            if (a * a * a * a * a - b * b * b * b * b == x) {
                ansa = i;
                ansb = j;
                goto last;
            }
        }
    }
    last:
    cout << ansa << " " << ansb << endl;
}

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

int main(){
    int n, k;
    std::cin >> n >> k;

    std::vector<int> sticks(n);
    for(int i = 0; i < n; ++i){
        std::cin >> sticks.at(i);
    }

    std::sort(sticks.begin(), sticks.end());
    std::reverse(sticks.begin(), sticks.end());

    int ans = 0;
    for(int i = 0; i < k; ++i){
        ans += sticks.at(i);
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.io.PrintWriter;

class Main {
    static long[] rain(int n, int[] a) {
        long sum = 0;
        long even_sum = 0;

        int i = 0;
        for (i = 0; i < n; i++) {
            sum += a[i];
            if (i % 2 == 1) even_sum += a[i]; // 0 originなので
        }
        even_sum *= 2;
        long[] m = new long[n];
        m[0] = sum - even_sum;

        for (i = 1; i < n; i++) {
            m[i] = a[i - 1] * 2 - m[i - 1];
        }

        return m;
    }


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

        int n = Integer.parseInt(sc.nextLine());
        int a[] = new int[n];
        int i = 0;
        for (i = 0; i < n; i ++) {
            a[i] = Integer.parseInt(sc.next());
        }

        long m[] = rain(n, a);
        for (i = 0; i < n - 1; i ++) {
            out.print(m[i] + " ");
        }
        out.println(m[n-1]);
        out.flush();
    }
}


Measured memory_bytes: 51092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque> 
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype> 
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<long long> a(N), b(N), c(M), d(M);
    for (int i=0; i<N; i++) {
        cin >> a.at(i) >> b.at(i);
    }
    for (int i=0; i<M; i++) {
        cin >> c.at(i) >> d.at(i);
    }
    for (int i=0; i<N; i++) {
        long long dist=0,min=2e10+1;
        int ans=0;
        for (int j=0; j<M; j++) {
            dist=abs(a.at(i)-c.at(j))+abs(b.at(i)-d.at(j));
            if (dist<min) {
                min=dist;
                ans=j+1;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val xy = (0 until n).map { sc.next().toDouble() to sc.next().toDouble() }
    val ml : MutableList<Int> = mutableListOf()
    val p = permutation((0..n-1).toList(),ml)
    //println(xy)
    //println(p)
    
    var distsum = 0.0
    p.forEach {
        for (j in 1 until n) {
            val dx = Math.pow(xy[it[j]].first - xy[it[j-1]].first,2.0)
            val dy = Math.pow(xy[it[j]].second - xy[it[j-1]].second,2.0)
            distsum += Math.sqrt(dx + dy)
        }
    }
    println(distsum / p.size)
}

fun permutation(q:List<Int>,ans: MutableList<Int>) : MutableList<MutableList<Int>> {
    // Base Case
    val ret :MutableList<MutableList<Int>> = mutableListOf()
    if(q.size <= 1) {
        ans.add(q[0])
        ret.add(ans)
        //println(ans)
    }
    // General Case
    else {
        for (i in 0 until q.size ) {
            //print(i)
            //print(q)
            //println(ans)
            val n = ans.toMutableList()
            n.add(q[i])
            //println(n)
            ret.addAll(permutation(q.subList(0,i).plus(q.subList(i+1,q.size)),n))
        }
    }
    return ret
}

Measured memory_bytes: 59148
# coding: utf-8
# Your code here!

cats = [0 for i in range(101)]
stack = []

L = int(input())
c = [int(i) for i in input().split()]

ans = -1
for i in range(L):
    if c[i] > 0:
        if cats[c[i]] == 1:
            ans = i + 1
            break
        else:
            cats[c[i]] = 1
            stack.append(c[i])
    else:
        if cats[-c[i]] == 0:
            ans = i + 1
            break
        else:
            cats[-c[i]] = 0
            if(stack.pop() != -c[i]):
                ans = i + 1
                break
if ans < 0:
    print("OK")
else:
    print(ans)



Measured memory_bytes: 5628
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll n=in();
    vector<ll>x(n);
    for(int i=0;i<n;++i)x[i]=in();

    ll ans=numeric_limits<ll>::max();
    for(int i=1;i<=100;++i){
        ll tmp=0;
        for(auto xx:x)tmp+=(xx-i)*(xx-i);
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
}


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

int main() {
    int x, y;
    cin >> x >> y;
    
    for (int i = 0; i < x+1; i++) {
        int sum_l = 2*i + 4*(x-i);
        if (sum_l == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>

int main(){


	int hours, minutes, seconds, total_sec;
	scanf("%d", &total_sec);
	minutes = total_sec/60;
	hours = minutes/60;
	seconds = total_sec%60;
	minutes = minutes%60;
	

	printf("%d:%d:%d\n",hours,minutes,seconds);

return 0;
}

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

int main() {
  int N;
  int cnt = 0;
  bool cont = true;
  cin >> N;
  int a[N];
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  
  while(cont){
  	for(int i = 0; i < N; i++){
   	  if(a[i] % 2 == 0)
      	a[i] /= 2;
      else{
        cont = false;
        break;
      }
  	}
    cnt++;
  }
  cout << cnt - 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

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

    map<int, int> num;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        num[a]++;
    }

    int ans = 0;
    for (auto i = num.begin(); i != num.end(); i++) {
        int val = i->first, cnt = i->second;
        if (val < cnt) ans += cnt - val;
        else if (val > cnt) ans += cnt;
    }

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

Measured memory_bytes: 4736