akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.WebSockets;
using System.Numerics;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		public static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush=
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var N = cin.ReadInt;
			var K = cin.ReadInt;
			var score = cin.ReadIntArray(3);
			int R = score[0], S = score[1], P = score[2];
			var raw = cin.ReadLine;
			var spiral = new List<char>[K];
			for(int j = 0; j<K; j++) 
				spiral[j]=new List<char>();
			for(int i = 0; i<N; i++) {
				spiral[i%K].Add(raw[i]);
			}
			Console.WriteLine(spiral.Sum(s => Sequence(R, S, P, s)));
		}

		private long Sequence(int r, int s, int p, List<char> data) {
			long res = 0;
			var lastChar = '0';
			var Corride = false;
			for(int i = 0; i<data.Count(); i++) {
				var c = data[i];
				if(c==lastChar) {
					Corride^=true;
				} else {
					Corride=false;
					lastChar=c;
				}
				if(!Corride) {
					var delta = c switch {
						'r' => p,
						's' => r,
						'p' => s,
						_ => 0
					};
					res+=delta;
				}
			}
			return res;
		}
	}

	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ")
			=> string.Join(separator, X);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator=separator;
			this._stream=stream;
			inputStream=new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count!=0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i<tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i<N; ++i)
				ret[i]=Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i<N; ++i) ret[i]=ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i<N; ++i) ret[i]=ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i<N; ++i) ret[i]=ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek()==-1; }
		}
	}
}


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

const double PI = acos(-1);

int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double th = double(h * 60 + m) / 720 * 2 * PI;
  double tm = double(m) / 60 * 2 * PI;
  double xh = a * cos(th), yh = a * sin(th);
  double xm = b * cos(tm), ym = b * sin(tm);
  // 2乗するので絶対値を取る必要はない
  double dx = xh - xm, dy = yh - ym;
  double ans = sqrt(dx * dx + dy * dy);
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 4008
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while(sc.hasNext()) {
			String[] data = sc.nextLine().split(",");
			bmiCheck(data);
		}
	}

	private static void bmiCheck(String[] data) {
		int student_id = Integer.parseInt(data[0]);
		double w = Double.parseDouble(data[1]);
		double h = Double.parseDouble(data[2]);
		double bmi = w / h / h;

			if (bmi >= 25) {
				System.out.println(student_id);
			}
	}

}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D){
    cout << "Left" << endl;
  }
  
  else if (A + B == C + D){
    cout << "Balanced" << endl;
  }
  
  else if (A + B < C + D){
    cout << "Right" << endl;
  }
}


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

int main() {
  string s;
  cin>>s;
  if(s=="SUN") cout<<7<<endl;
  else if(s=="MON") cout<<6<<endl;
  else if(s=="TUE") cout<<5<<endl;
  else if(s=="WED") cout<<4<<endl;
  else if(s=="THU") cout<<3<<endl;
  else if(s=="FRI") cout<<2<<endl;
  else cout<<1<<endl;
  return 0;
}


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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=1e5+5;
int n,m;
char s[MAXN],t[MAXN];
int main() {
	scanf("%d%d%s%s",&n,&m,s+1,t+1);
	ll L=(ll)n/__gcd(n,m)*m;
	int l1=L/n,l2=L/m;
	ll g=(ll)l1/__gcd(l1,l2)*l2;
	for(int i=0;(ll)i*(g/l1)+1<=n&&(ll)i*(g/l2)+1<=m;++i){
		if(s[i*(g/l1)+1]!=t[i*(g/l2)+1])return puts("-1"),0;
	}
	cout<<L<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

ll solve (ll a, ll c, ll d) {
	ll ca = a / c;
	ll cd = a / d;
	ll lcm = c / gcd(c, d) * d;
	ll res = a - ca - cd + a / lcm;
	return res;
}

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = solve(b, c, d) - solve(a-1, c, d);
	cout << ans << endl;
	// cout << solve(b, c, d) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;




int main(){
    int k;
    cin >> k;
    queue<ll>que, box;
    rep(i, 10){
        if(i == 0)continue;
        que.push(i);
        box.push(i);
    }

    rep(i, k){
        ll now = que.front();
        que.pop();
        ll amari = now % 10;

        if(amari != 0)que.push(now * 10 + amari - 1);
        que.push(now * 10 + amari);
        if(amari != 9)que.push(now * 10 + amari + 1);

        if(amari != 0)box.push(now * 10 + amari - 1);
        box.push(now * 10 + amari);
        if(amari != 9)box.push(now * 10 + amari + 1);
    }

    ll res = 0;
    rep(i, k){
        res = box.front();
        box.pop();
    }
    cout << res << endl;
}



Measured memory_bytes: 4224
fun main(args: Array<String>) {
    val (N, D) = readLine()!!.split(" ").map{it.toInt()}
    val points = (1..N).map{ readLine()!!.split(" ").map { it.toDouble() }}

    fun calcDistance(p:Double, q:Double): Double = kotlin.math.sqrt((p*p + q*q))

    val result = points.filter { D >= calcDistance(it[0], it[1]) }

    println(result.count())
}

Measured memory_bytes: 82084
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
////
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
//typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

using ll = long long;
//#ifdef __int128
//using hll = __int128;
//#endif
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}


#ifdef _getchar_nolock
#else
#define _getchar_nolock getchar_unlocked
#endif

//#define solvsh
//#define multi

#ifdef solvsh
#else

ll mod = 1e9 + 7;

ll add(ll a, ll b){
    return (a + b) % mod;
}
ll mult(ll a, ll b) {
    return (a * b) % mod;
}


const int MAXN = 2e5 + 120;
const int MAXK = 20 + 3;

vector<int> g[MAXN];

bool usd[MAXN];

int curr = 0;

void dfs(int ver) {
    if (usd[ver]) return;
    usd[ver] = true;
    ++curr;
    for (auto e : g[ver]) dfs(e);
}

void solve() {

    int n, m;
    cin >> n >> m;

    for (int i = 0; i < m; ++ i) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int answ= 0;

    for (int i = 1; i <= n; ++ i) {
        if (!usd[i]) {
            curr = 0;
            dfs(i);
            answ = max(answ, curr);
        }
    }


    cout << answ << '\n';
}

#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
        solve();
        i++;
    }
}

#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifndef ONLINE_JUDGE
//    freopen("../input.in", "r", stdin);
#else

#endif
#ifdef multi
//        gen();
    multisolve();
#else
    solve();
//    gen();
#endif

}


Measured memory_bytes: 21024
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
string s[50];
int n;
bool ok(int k){
    set<string> f;
    REP(i,n){
        string a="";
        a+=s[i][0];
        REP(j,s[i].size()-1){
            if(a.size()==k)break;
            if(s[i][j]=='a'||s[i][j]=='i'||s[i][j]=='u'||s[i][j]=='e'||s[i][j]=='o'){
                a+=s[i][j+1];
            }
        }
        if(f.count(a)==1)return false;
        f.insert(a);
    }
    return true;
}
int main(){
    while(1){
        cin>>n;
        if(n==0)break;
        REP(i,n)cin>>s[i];
        int ans=-1;
        REP(i,50){
            if(ok(i+1)){
                ans=i+1;
                break;
            }
        }
        cout<<ans<<endl;
    }
}

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

int main() {
    int N; cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; ++i) cin >> a[i];

    int cur = 0;
    int res = 0;
    for(int i=0; i<N; ++i) {
        if(a[i] == cur + 1) ++cur;
        else ++res;
    }
    if(cur == 0) cout << -1 << '\n';
    else cout << res << '\n';
}

Measured memory_bytes: 1024
w, h, n = gets.split.map(&:to_i)
l = 0
r = w
b = 0
t = h
for i in 0...n do
  x, y, a = gets.split.map(&:to_i)
  case a
  when 1
    l = x if l < x
  when 2
    r = x if r > x
  when 3
    b = y if b < y
  when 4
    t = y if t > y
  end
end
ww = (l < r) ? (r - l) : 0
hh = (b < t) ? (t - b) : 0
puts ww * hh


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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  if ((10 * g + b) % 4 == 0) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int main()
{
	char s[15];
	bool f=0;
	scanf("%s",s+1);
	if(s[1] != 'A')
		puts("WA");
	else
	{
		for(int i=2;i<=strlen(s+1);i++)
		{
			if(s[i] == 'C' && i != 2 && i != strlen(s+1) && !f)
				f=1;
			else if(s[i] < 'a' && s[i] != 'A')
			{
				puts("WA");
				return 0;
			}
		}
		if(f)
			puts("AC");
		else
			puts("WA");
	}
	return 0;
}

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

int main(void){
    ull n, q, total = 0;
    vector<ull> a, b, c;
    ull check[100005] = {0};
    cin >> n;
    for(int i = 0; i < n; i++){
        ull temp;
        cin >> temp;
        a.push_back(temp);
        check[temp]++;
    }
    for(ull i : a) total += i;
    cin >> q;
    for(ull i = 0; i < q; i++){
        ull temp1, temp2;
        cin >> temp1 >> temp2;
        b.push_back(temp1);
        c.push_back(temp2);
    }
    for(ull i = 0; i < q; i++){
        total += (c[i] - b[i]) * check[b[i]];
        cout << total << endl;
        check[c[i]] += check[b[i]];
        check[b[i]] = 0;
    }
    return 0;
}

Measured memory_bytes: 7100
import bisect





def main():
    num = int(input())
    data = list(map(int, input().split()))
    data.sort()

    ans = 0
    ans_list = []

    for i in range(num - 1, num):
        left_ind = max(bisect.bisect_left(data, data[i] // 2) - 1, 0)
        if left_ind + 1 >= i:
            right_ind = left_ind
        else:
            right_ind = left_ind + 1

        ans_kari_1 = min(data[left_ind], data[i] - data[left_ind])
        ans_kari_2 = min(data[right_ind], data[i] - data[right_ind])


        if ans_kari_1 > ans_kari_2:
            ans_list = [data[i], data[left_ind]]
        else:
            ans_list = [data[i], data[right_ind]]

    print(ans_list[0], ans_list[1])






if __name__ == '__main__':
    main()



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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int N, R;

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

    if (N > 10) N = 10;

    int ans = R + (100 * (10 - N));

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

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

int main() {
	string S, T;
	cin >> S >> T;
	int ANS = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] != T[i]) ANS++;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 3920
#include<stdio.h>
#include<stdlib.h>
#define ll long long
typedef struct pair{
    ll a, b;
}drink;
int cmp(const void*p,const void *q){return ((drink*)p)->a-((drink*)q)->a;}
int main(){
    int n, m;
    scanf("%d%d",&n,&m);
    drink p[n];
    for(int i = 0; i < n; i++)
        scanf("%lld%lld",&p[i].a,&p[i].b);
    qsort(p,n,sizeof(drink),cmp);
    ll ans = 0;
    int in = 0;
    while(m > 0){
        if(m > p[in].b){
            m -= p[in].b;
            ans += p[in].a * p[in].b;
        }
        else{
            ans += p[in].a * m;
            m = 0;
        }
        in++;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3324
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

A, B, C, D, E, F =  MAP()
A *= 100
B *= 100
# 溶ける最大濃度
limit = E / (100+E)

# dp[i][j] := 水i、砂糖jの状態を実現可能か
dp = list2d(F+1, F+1, 0)
dp[0][0] = 1
for i in range(F+1):
    for j in range(F+1):
        # 枝刈り
        if i+j > F:
            break
        # 実現可能な状態なら、4つの行動を遷移させる
        if dp[i][j]:
            if i+A <= F:
                dp[i+A][j] = 1
            if i+B <= F:
                dp[i+B][j] = 1
            if j+C <= F:
                dp[i][j+C] = 1
            if j+D <= F:
                dp[i][j+D] = 1

ans1 = ans2 = 0
mx = -1
for a in range(F+1):
    for b in range(F+1):
        if a == b == 0:
            continue
        if a+b > F:
            break
        if dp[a][b]:
            x = b / (a+b)
            # 濃度が濃すぎて溶け切らない
            if x > limit:
                continue
            # 最大濃度の更新
            if mx < x:
                mx = x
                ans1 = a + b
                ans2 = b
print(ans1, ans2)


Measured memory_bytes: 107740
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

int64_t R,C,K;
int64_t item[3010][3010];
int64_t dp[3010][3010][5];

void chmax(int r, int c, int g, int64_t val)
{
    if (dp[r][c][g] < val) {
        dp[r][c][g] = val;
    }
}

int main()
{
    int i,r,c,g;
    int _;
    int64_t curval,ans;
    i=r=c=g=curval=0;
    _=scanf("%ld%ld%ld", &R,&C,&K);
    for (i=0; i<K; i++) {
        _=scanf("%d%d%ld", &r,&c,&curval);
        item[r][c] = curval;
    }
    i=r=c=g=curval=0;
    dp[1][1][0] = 0;
    if (item[1][1] > 0) {
        dp[1][1][1] = item[1][1];
    }
    for (r=1;r<=R;r++) {
        for (c=1;c<=C;c++) {
            for (g=0;g<=3;g++) {
                curval = dp[r][c][g];
                if (c < C) {
                    /* right */
                    if ((item[r][c+1]) && (g < 3)) {
                        chmax(r,c+1,g+1,curval+item[r][c+1]);
                    }
                    chmax(r,c+1,g,curval);
                }
                if (r < R) {
                    /* down */
                    if (item[r+1][c]) {
                        chmax(r+1,c,1,curval+item[r+1][c]);
                    }
                    chmax(r+1,c,0,curval);
                }
            }
        }
    }
    ans = dp[R][C][0];
    if (dp[R][C][1] > ans) ans = dp[R][C][1];
    if (dp[R][C][2] > ans) ans = dp[R][C][2];
    if (dp[R][C][3] > ans) ans = dp[R][C][3];
    printf("%ld\n",ans);
    return 0;
}

Measured memory_bytes: 424956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll H, W, K;
  cin >> H >> W >> K;
  vector<string> s(H);
  vector<vector<ll>> ans(H, vector<ll>(W, 0));
  vector<bool> hit(H, false);
  REP(i, H) {
    cin >> s[i];
    REP(j, W) {
      if (s[i][j] == '#') {
        hit[i] = true;
      }
    }
  }

  ll cnt = 1;
  REP(i, H) if (hit[i]) {
    REP(j, W) {
      ans[i][j] = cnt;
      if (s[i][j] == '#') {
        cnt++;
      }
    }

    if (s[i][W - 1] == '#') {
      continue;
    }
    ll p = W - 1;
    while (s[i][p] == '.') {
      ans[i][p] = cnt - 1;
      p--;
    }
  }

  REP(i, H) if (!hit[i]) {
    ll p = i;
    while (p < H && !hit[p]) {
      p++;
    }
    //上からコピー
    if (p == H) {
      p = i;
      while (p>0 && !hit[p]) {
        p--;
      }
    }
    REP(j, W) { ans[i][j] = ans[p][j]; }
    hit[i] = true;
  }

  REP(i, H) {
    REP(j, W) { cout << ans[i][j] << " \n"[j == W - 1]; }
  }
}

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

long mpow(long a, long b, long mod) {
  long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}

int f(int n) {
  return n % __builtin_popcount(n);
}

int main() {
  int N;
  string S;
  cin >> N >> S;
  int cnt = count(S.begin(), S.end(), '1');
  int mod1 = cnt - 1;
  int mod2 = cnt + 1;
  reverse(S.begin(), S.end());
  int now1 = 1, sum1 = 0;
  if (mod1) {
    for (int i = 0; i < N; i++) {
      sum1 += (S.at(i) - '0') * now1;
      sum1 %= mod1;
      now1 *= 2;
      now1 %= mod1;
    }
  }
  int now2 = 1, sum2 = 0;
  for (int i = 0; i < N; i++) {
    sum2 += (S.at(i) - '0') * now2;
    sum2 %= mod2;
    now2 *= 2;
    now2 %= mod2;
  }
  reverse(S.begin(), S.end());
  for (int i = 0; i < N; i++) {
    if (S.at(i) == '1') {
      if (cnt == 1) {
        cout << 0 << "\n";
        continue;
      }
      int tmp = sum1;
      tmp -= mpow(2, N - i - 1, mod1);
      while (tmp < 0) tmp += mod1;
      int ans = 1;
      while (tmp) tmp = f(tmp), ans++;
      cout << ans << "\n";
    } else {
      int tmp = sum2;
      tmp += mpow(2, N - i - 1, mod2);
      tmp %= mod2;
      int ans = 1;
      while (tmp) tmp = f(tmp), ans++;
      cout << ans << "\n";
    }
  }
}

Measured memory_bytes: 3700
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	static int dp[][] = new int[(1 << 21) + 1][21];
	static int dist[][] = new int[21][21];

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s1[] = br.readLine().split("");
		String s2[] = br.readLine().split("");

		int ans = 0;
		for (int i = 0; i < s1.length; i++) {
			if (!s1[i].equals(s2[i])) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 349996
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int x = sc.nextInt();

			if (x < 1200) {
				System.out.println("ABC");
			} else {
				System.out.println("ARC");
			}

		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 23764
fn main() {
    let v = read_vec::<usize>();
    let a = v[0];
    let b = v[1];
    let s = read::<String>();

    if s.chars().take(a).all(|c| c.is_digit(10))
    && s.chars().skip(a).take(1).all(|c| c=='-')
    && s.chars().skip(a+1).all(|c| c.is_digit(10)) {
        println!("Yes");
    } else {
        println!("No");
    }
}


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
                    .map(|e| e.parse().ok().unwrap())
                    .collect()
}

Measured memory_bytes: 4352
H, W = map(int, input().split())
hw = [list(input()) for i in range(H)]

# print(hw)
yoko_new = []
for x in range(H):
    # print(hw[x])
    yoko_check = True
    for y in range(W):
        if hw[x][y] == "#":
            yoko_check = False
    if not yoko_check:
        yoko_new.append(hw[x])

yoko_new_len = len(yoko_new)

tate_new = [["-1" * W] * yoko_new_len]

z = 0
while z < len(yoko_new[0]):
    # for z in range(W):
    tate_check = True
    for w in range(yoko_new_len):
        if yoko_new[w][z] == "#":
            tate_check = False
    if tate_check:
        for w in range(yoko_new_len):
            yoko_new[w].pop(z)
    else:
        z += 1
for v in yoko_new:
    print("".join(v))


Measured memory_bytes: 39280
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;


int main() {

  string S;
  cin >> S;

  int ans = 1000;
  for (int i = 0; i <= S.size()-3; i++) {
    int num = (S[i] - '0')*100  + (S[i+1] - '0')*10 + S[i+2] - '0';
    ans = min(abs(753-num), ans);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int LL;
typedef LL ll;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); } 
const ll M=2e3+5,LG=19,SM=4000+5,inf=1e18+1;
ll mod=1e9+7;

ll a[M];
ll cs[M],cs2[M];
ll n,x;

int main()
{
	ios::sync_with_stdio(0);
    cin >> n >> x;
    ll res=inf;
    For(i,0,n) cin >> a[i];
    For(i,0,n) cs2[i]=a[i];
    For(i,0,n)
    {
        ll su=i*x;
        For(j,0,n)
        {
            cs[j]=cs2[j];
            su+=cs[j];
        }   
        smin(res,su);
        For(j,1,n)
        {
            cs2[j]=min(cs[j-1],a[j]);
        }
        cs2[0]=min(a[0],cs[n-1]);
    }
    RET(res);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
  char S[11],T[12];
  int count1=0;
  int count2=0;
  scanf("%s",S);
  scanf("%s",T);
  for(int i=0;i<strlen(S);i++)
  {
    if(S[i]==T[i])
    {
      count1++;
    }
    else
    {
      count2++;
    }
  }
  if(count1==strlen(S))
  printf("\nYes");
  else
  printf("\nNo");
  
}  

Measured memory_bytes: 1732
def main():
    n,k = [int(i) for i in input().split()]
    candles = [int(i) for i in input().split()]
    i = 0
    res=1<<60;
    while i+k-1<n:
        left = candles[i]
        right = candles[i+k-1]
        res = min(res,min(abs(left),abs(right))+right-left)
        i+=1
    print(res)

if __name__ == '__main__':
    main()

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

  
}

Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2242>
 問題文============================================================
 
 =================================================================
 解説=============================================================
 ================================================================
 */
int N,Q;
struct Era{
    string name;
    int from,to;
    Era(string era = "",int from = 0,int to = 0):name(era),from(from),to(to){};
    bool operator <(const Era& o) const{ return from < o.from; }
};
void solve(){
    vector<Era> Eras(N);
    for(int i = 0; i < N;i++){
        string name;int x,y; cin >> name >> x >> y;
        Eras[i] = Era(name,y-x+1,y);
    }
    sort(Eras.begin(),Eras.end());
    while(Q--){
        int year; cin >> year;
        [&]{
            for(int i = 0; i < N;i++){
                if(Eras[i].from <= year && year <= Eras[i].to){
                    cout << Eras[i].name << " " << year - Eras[i].from + 1 << endl;
                    return;
                }
            }
            cout << "Unknown" << endl;
        }();
    }
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> N >> Q,N){
        solve();
    }
    return 0;
}



Measured memory_bytes: 3132
N,x=map(int,input().split())
a=list(map(int,input().split()))

a=[0]+a
cnt=0
for i in range(N):
    if a[i]+a[i+1]>x:
        diff=min(a[i+1]+a[i]-x,a[i+1])
        cnt+=diff
        a[i+1]-=diff
print(cnt)


Measured memory_bytes: 14052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int; //任意長整数 
using Real32 = mp::number<mp::cpp_dec_float<32>>;
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
using Rat = boost::rational<Bint>;//有理数*/
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
ll mod = 1000000007;
ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);


signed main(){
    int n,m,q;
    cin>>n>>m>>q;
    vector<vector<int>> v(n+1,vector<int>());
    for(int i=0;i < m;i++)
    {
        int l,r;
        cin>>l>>r;
        v.at(l).pb(r);
    }

    for(int i=0;i < n+1;i++)
    {
        sort(v.at(i).begin(),v.at(i).end());
    }//計算量わからん

    for(int i=0;i < q;i++)
    {
        int p,q,ans=0;
        cin>>p>>q;
        for(int j=p;j < q+1;j++)
        {
            ans+=(lower_bound(all(v.at(j)),q+1)-v.at(j).begin());//itr→int
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 2176
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    T A
    ---

    0 0 0
    1 1 0
    0 0 1

    number of 0s >= number of 1s
    p = 1
    g = 0

    N <= 10**5

    0 0
    0 0
    1 0
    1 0
    0 0
    0 1
    0 1
    1 1
    0 1
    0 1

    1. N/2 1's will be used
    """
    s = input().strip()
    N = len(s)
    score = 0
    for i in range((N+1)//2):
        if s[i] == 'p':
            score -= 1
    for i in range((N+1)//2, N):
        if s[i] == 'g':
            score += 1
    return score



if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 66140
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int a[3];
	int ans=0;
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	ans=a[2]-a[1];
	a[0]=a[0]+(a[2]-a[1]);
	ans+=(a[2]-a[0])/2;
	a[0]+=(a[2]-a[0])/2*2;
	if (a[0]!=a[2]) ans+=2;
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
void swap(int *num1,int *num2)
{
  int num3;
  num3 = *num1;
  *num1 = *num2;
  *num2 = num3;
}
int main(void)
{
	int num1,num2,num3;
    char str[16];
  	
  	fgets(str,sizeof(str),stdin);
  	sscanf(str,"%d%d%d",&num1,&num2,&num3);
  
  	if(num1 < num2)
    {
      swap(&num1,&num2);
    }
 	if(num2 < num3)
    {
      swap(&num2,&num3);
    }
  	if(num1 < num2)
    {
      swap(&num1,&num2);
    }
  
  printf("%d",num1-num3);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

const int N = 207;
bool g[N][N];
bool used[N];

int n;
bool c[N];
void dfs(int u) {
    used[u] = 1;
    for (int v = 1; v <= n; ++v) {
        if (!used[v] && g[u][v]) {
            c[v] = c[u] ^ 1;
            dfs(v);
        }   
    }   
}   

int dist[N];
int max_dist(int s) {
    for (int i = 0; i < N; ++i)
        dist[i] = N;
    queue <int> q;
    q.push(s);
    dist[s] = 0;
    while (q.size()) {
        int u = q.front();
        q.pop();
        for (int v = 1; v <= n; ++v) {
            if (g[u][v] && dist[u] + 1 < dist[v]) {
                dist[v] = dist[u] + 1;
                q.push(v);
            }   
        }   
    }   
    int mx = 0;
    for (int i = 1; i <= n; ++i)
        mx = max(mx, dist[i]);        
    return mx;
}   

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            char c; cin >> c;
            g[i][j] = c == '1';
        }
    }
    dfs(1);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (g[i][j] && c[i] == c[j]) {
                cout << "-1" << endl;
                exit(0);
            }   
        }   
    }   
    int mx = 0;
    for (int i = 1; i <= n; ++i)
        mx = max(mx, max_dist(i));
    cout << mx + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long int
#define lld double
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<pii, ll>
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define ppb pop_back
#define d0(x) cout<<x<<" "
#define d1(x) cout<<x<<"\n"
#define d2(x,y) cout<<x<<" "<<y<<"\n"
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n"
#define d5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<endl
using namespace std;
const ll mod = 1e9+7;
 

void init();
void solve(int T);
int main(int argc, char* argv[])
{
    ios_base::sync_with_stdio ( false );cin.tie(0);cout.tie(0);
    int t1=1;
    init();
    //cin>>t1;
    for(int T=1;T<=t1;T++)
    {
        solve(T);
    }
}



void init()
{

}
void solve(int T)
{
    ll N,R;
    cin>>N>>R;
    ll ans = R + 100LL*max(0LL,10LL-N);
    d1(ans);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int n, m;
  cin >> n >> m;
  vector<int64_t> a(n), b(n);
  vector<pair<int64_t,int>> ab(n);
  rep(i,n) {
    cin >> a.at(i) >> b.at(i);
    ab.at(i) = make_pair(a.at(i),b.at(i));
  }
  sort(ab.begin(),ab.end());
  int64_t ans=0;
  rep(i,n) {
    int p = min(m,ab.at(i).second);
    ans += p * ab.at(i).first;
    m -= p;
  }
  cout << ans;
}

Measured memory_bytes: 3328
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 30 11:46:57 2018
ABC071D
@author: maezawa
"""

n = int(input())
s1 = input()
s2 = input()
mod = 10**9+7

comb = 1
adj = 0
i = 0
while i < n:
    if i < n-1 and s1[i] == s1[i+1]:
        if adj == 2:
            comb *= 3
        else:
            comb *= 3 - adj
            comb *= 3 - adj -1
        i += 2
        adj = 2
    else:
        comb *= 3 - adj
        i += 1
        adj = 1

print(comb%mod)
        


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

ll sum(ll n) {
    return n * (n + 1) / 2;
}

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

    ll N;
    cin >> N;
    ll ans = 0, sqr;
    for (int i = 1; i * i <= N; ++i) {
        ll tmp = N / i;
        ans += sum(tmp) * i;
        sqr = i;
    }
    ll r = N;
    for (int i = 1; i * i <= N; ++i) {
        ll tmp = N / (i + 1);
        ans += (sum(r) - sum(tmp)) * sum(i);
        r = tmp;
    }
    if (N / sqr == sqr)
        ans -= sum(sqr) * sqr;

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


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

namespace ABC059A
{
    class Program
    {
        static void Main(string[] args)
        {
            var st = Console.ReadLine().Split(' ').ToArray();

            Console.WriteLine(st[0].ToUpper()[0].ToString() + st[1].ToUpper()[0].ToString() + st[2].ToUpper()[0].ToString());
        }
    }
}


Measured memory_bytes: 13268
s=list(input())
dic=[]
for i in range(26):
    dic.append([chr(i+97),0])
#print(dic)
num=lambda x:ord(x)-ord("a")
for i in range(len(s)):
    if dic[num(s[i])][1]==0:
        dic[num(s[i])][1]=1
exit=0
ans=0
for i in range(26):
    if dic[i][1]==0:
        exit=1
        ans=i
        break
print(dic[i][0] if exit==1 else "None")

Measured memory_bytes: 3956
//
//  main.cpp

#include <iostream>
using namespace std;


int main(){
	
	while(1){
		int n,m;
		cin >> n >> m;
		if(n == 0 && m == 0)break;
		
		int sugoroku[1001]={},saikoro[1001]={};
		
		for(int i=1;i<=n;i++){
			cin >> sugoroku[i];
		}
		for(int i=0;i<m;i++){
			cin >> saikoro[i];
		}
		
		int now=1;
		for(int i=0;i<m;i++){
			now += saikoro[i];
			now += sugoroku[now];
			
			if(now >= n){
				cout << i+1 << endl;
				break;
			}
		}
	}
	
	return 0;
}

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

const int MAX = 500000;
const int ArSize = 35;

struct Node
{
	int key;
	Node * pa;
	Node * left, *right;
};

char ins[ArSize];
Node * rec_tree[MAX];
unsigned cnt = 0;

Node * root = nullptr;

void insert(Node *);
Node * find(int v);
bool del_node(Node * target);
void print();
void pre_print(Node *);
void in_print(Node *);
void post_print(Node *);

int main()
{
	ios::sync_with_stdio(false);
	int m;
	cin >> m;

	for (int i = 0; i < m; i++)
	{
		cin >> ins;
		if (ins[0] == 'i')
		{
			int v;
			cin >> v;
			Node * self = new Node({ v, nullptr, nullptr, nullptr });

			rec_tree[cnt++] = self;
			insert(self);
		}
		else if (ins[0] == 'f')
		{
			int v;
			cin >> v;
			Node * ans = find(v);
			if (ans == nullptr)
				cout << "no" << endl;
			else
				cout << "yes" << endl;
		}
		else if (ins[0] == 'd')
		{
			int v;
			cin >> v;
			Node * target = find(v);
			del_node(target);

		}
		else
		{
			print();
		}

		for (int i = 0; i < ArSize; i++)
			ins[i] = 0;
	}

	for (int i = 0; i < cnt; i++)
		delete rec_tree[i];

// 	int junk;
// //	while (true)
// 		cin >> junk;
	return 0;
}

void insert(Node * self)
{
	Node * pa_can = nullptr;
	Node * self_can = root;

	while (self_can != nullptr)
	{
		pa_can = self_can;
		if (self->key < pa_can->key)
			self_can = pa_can->left;
		else
			self_can = pa_can->right;
	}

	self->pa = pa_can;
	if (self->pa == nullptr)
		root = self;
	else if (self->key < self->pa->key)
		self->pa->left = self;
	else
		self->pa->right = self;

	return;
}

Node * find(int v)
{
	Node * cur = root;
	while (cur != nullptr && cur->key != v)
	{
		if (v < cur->key)
			cur = cur->left;
		else
			cur = cur->right;
	}
	return cur;
}

Node * get_succ(Node * cur)
{
	cur = cur->right;
	while (cur->left != nullptr)
		cur = cur->left;
	return cur;
}

bool del_node(Node * target)
{
	if (target == nullptr)
		return false;

	if (target->left == nullptr && target->right == nullptr)
	{
		if (target == root)
			root = nullptr;
		else if (target->key < target->pa->key)
			target->pa->left = nullptr;
		else
			target->pa->right = nullptr;
	}
	else if (target->left != nullptr && target->right != nullptr)
	{
		Node * to_del = get_succ(target);
		target->key = to_del->key;
		del_node(to_del);
	}
	else
	{
		Node * child = target->left != nullptr ? target->left : target->right;
		if (target == root)
			root = child;
		else
		{
			if (target == target->pa->left)
				target->pa->left = child;
			else
				target->pa->right = child;
		}

		child->pa = target->pa;
	}
	return true;
}

void print()
{
	in_print(root);
	cout << endl;

	pre_print(root);
	cout << endl;

// 	post_print(root);
// 	cout << endl;
}

void pre_print(Node * cur)
{
	if (cur == nullptr)
		return;

	cout << " " << cur->key;
	pre_print(cur->left);
	pre_print(cur->right);
}

void in_print(Node * cur)
{
	if (cur == nullptr)
		return;

	in_print(cur->left);
	cout << " " << cur->key;
	in_print(cur->right);
}

void post_print(Node * cur)
{
	if (cur == nullptr)
		return;

	post_print(cur->left);
	post_print(cur->right);
	cout << " " << cur->key;
}

Measured memory_bytes: 25012
#include<iostream>
 #include<cmath>
 #include<cstdio>
 #include<cstring>
 #include<string>
 #include<algorithm>
 #include<map>
 using namespace std;
 const int maxn = 100005;
 map<int,int> Q;
 int sum,ans,n,x;
 int a[maxn];
 int main()
 {
     cin>>n;
     for(int i=1;i<=n;i++)
     {
         cin>>x;

         if(!Q.count(x))
         {
             a[ans++]=x;
         }
         Q[x]++;
         if(Q[x]>x)
         {
             Q[x]--;
             sum++;
         }
     }
     for(int i=0;i<ans;i++)
     {
         if(a[i]!=Q[a[i]])sum+=Q[a[i]];
     }
     cout<<sum<<endl;
 }


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

int main() {
	int N;
	cin>>N;
	vector<long long int> L(N+1);
	if(N==1){
		cout<<1<<endl;
	}
	else if(N==2){
		cout<<3<<endl;
	}
	else{
		L.at(0)=2;
		L.at(1)=1;
	for(int i=2;i<N+1;i++){

		L.at(i)=L.at(i-1)+L.at(i-2);
	}
	cout<<L.at(N)<<endl;
	}
	return 0;
}

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

using namespace std;

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

    map<string, int> S;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;

        S[s] += 1;
    }

    int maxv = 0;
    for (const auto &x : S) {
        int v = x.second;
        if (v > maxv) maxv = v;
    }

    for (auto it = S.begin(); it != S.end(); it++) {
        if (it->second == maxv) {
            cout << it->first << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 25216
#include<cstdio>
#include<iostream>
using namespace std;
const int N=22;
const int mod=1e9+7;
const int S=1<<20;
int go[S][N],put[S];
int f[S],n,m,k,a,b,c;
int need1[S],need2[S],ans;
void upd(int &a,int b)
{
	a=a+b;
	if (a>=mod) a-=mod;
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for (int i=1;i<=k;i++)
	{
		scanf("%d%d%d",&a,&b,&c);
		need1[a]|=(1<<b-1);
		need2[a]|=c*(1<<b-1);
	}
	n--;
	for (int T=0;T<(1<<n);T++)
	{
		for (int i=0;i<n;i++) go[T][i]=-1;
		int id=0;
		for (int i=0;i<n;i++)
		{
			if (T&(1<<i))
			{
				if (i>0&&!(T&(1<<i-1))) go[T][id]=T^(1<<i)^(1<<i-1);
				id++;
			}
		}
	}
	for (int T=0;T<(1<<n);T++)
	{
		put[T]=-1;
		for (int i=n-1;i>=0;i--)
			if (!(T&(1<<i))) {put[T]=T^(1<<i);break;}
	}
	f[0]=1;
	for (int i=1;i<=m;i++)
	{
		for (int T=0;T<(1<<n);T++)
			if (put[T]!=-1) upd(f[put[T]],f[T]);
		for (int id=0;id<n;id++)
			for (int T=(1<<n)-1;T>=0;T--)
				if (go[T][id]!=-1) upd(f[go[T][id]],f[T]);
		for (int T=0;T<(1<<n);T++)
			if ((need1[i]&T)!=need2[i]) f[T]=0; 
	}
	for (int i=0;i<(1<<n);i++) upd(ans,f[i]);
	printf("%d",ans);
}

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

using namespace std;

int main(){

    string s;  
    map<string, int> m;

    int n;
    cin >> n;

    for(int i=0;i<n;i++){
        cin >> s;
        if(m[s])m[s]++;
        else m[s]=1;
    }

    printf("AC x %d\n",m["AC"]);
    printf("WA x %d\n",m["WA"]);
    printf("TLE x %d\n",m["TLE"]);
    printf("RE x %d\n",m["RE"]);


    
    return 0;
}

Measured memory_bytes: 3728
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

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

  ll yuta = 0;
  rep(i, n) {
    ll a;
    cin >> a;
    if (a >= k) yuta++;
  }

cout << yuta << endl;

  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename F>
static inline constexpr decltype(auto) fix(F&& f) noexcept {
  return [f = std::forward<F>(f)](auto&&... args) {
    return f(f, std::forward<decltype(args)>(args)...);
  };
}
template<typename T>
static inline T fin() { T t; cin >> t; return std::move(t); }

int main() {
  let N = fin<i64>();
  let A = [N](){ vector<i64> a(N); for(auto& x: a) cin >> x; return std::move(a); }();
  let ans = [N, &A]() {
    vector<i64> vec(N);
    vec[0] = [N, A]() {
      i64 sum = 0;
      for(int i = 0;i < N;i++) {
        sum += A[i];
        if(i & 1) {
          sum -= A[i] * 2;
        }
      }
      return sum;
    }();
    for(int i = N - 1;0 < i;i--) {
      vec[i] = A[i] * 2 - vec[(i + 1) % N];
    }
    return std::move(vec);
  }();
  for(auto x: ans) {
    cout << x << " ";
  }
  cout << endl;
}


Measured memory_bytes: 2928
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if ((a == 5 && b == 5 && c == 7) || (a == 7 && b == 5 && c == 5) || (a == 5 && b == 7 && c == 5)) {

			System.out.println("YES");

		} else {

			System.out.println("NO");

		}
	}
}

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

#define fir first
#define sec second

struct node {
  int fir;
  int sec;

  node(int fir=0, int sec=0):
    fir(fir), sec(sec) {}

  node(pair<int,int> p):
    fir(p.first), sec(p.second) {}

    bool operator==(const node& a) const {
      return fir==a.fir && sec==a.sec;
    }
};

struct MyHash {
  size_t operator()(const node& a) const {
        return 1LL*a.fir*100005+a.sec;
    }
};

typedef long long LL;
typedef node pii;
pii g[3][3];
pii dir[9][9];
int ID[3][3];
int h, w, n;

inline bool judge(int x, int y) {
  return x<=0 || x>h || y<=0 || y>w;
}

inline bool judge(const pii& p) {
  return p.fir<=0 || p.fir>h || p.sec<=0 || p.sec>w;
}

void init() {
  int c = 0;

  for (int i=0; i<3; ++i) {
    for (int j=0; j<3; ++j) {
      g[i][j].fir = i;
      g[i][j].sec = j;
      ID[i][j] = c++;
    }
  }

  for (int id=0; id<9; ++id) {
    int x = id / 3;
    int y = id % 3;
    int z = 0;
    for (int i=0; i<3; ++i) {
      for (int j=0; j<3; ++j) {
        dir[id][z] = make_pair(g[i][j].fir-x, g[i][j].sec-y);
        ++z;
      }
    }
  }
}

int main() {
  LL c[10];
  pii p;
  init();

  scanf("%d %d %d", &h, &w, &n);
  unordered_set<pii, MyHash> st;
  LL tot = 1LL * (h - 2) * (w - 2);
  for (int i=0; i<n; ++i) {
    scanf("%d %d", &p.fir, &p.sec);
    st.insert(p);
  }
  memset(c, 0, sizeof(c));

  int x, y, xx, yy, cnt;
  bool flag;

  for (auto iter=st.begin(); iter!=st.end(); ++iter) {
    x = iter->fir;
    y = iter->sec;
    for (int id=0; id<9; ++id) {
      flag = true;
      cnt = 0;
      for (int k=0; k<9; ++k) {
        p.fir = x + dir[id][k].fir;
        p.sec = y + dir[id][k].sec;
        if (judge(p)) {
          flag = false;
          break;
        }
        cnt += st.count(p)>0;
      }
      if (flag)
        c[cnt]++;
    }
  }

  c[0] = tot;
  for (int i=1; i<=9; ++i) {
    c[i] /= i;
    c[0] -= c[i];
  }

  for (int i=0; i<10; ++i) {
    cout << c[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, k;
    cin >> n >> k;
    int ans = 0;
    REP(i,n) {
        int a; cin >> a;
        ans += min(abs(k-a),a) * 2;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256