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

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt"); return;
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        long x = long.Parse(input.ReadLine());

        long count = 0;
        long max = 0;

        while (true) {
            max += count+1;
            count++;
            if (max >= x) break;    
        }
        return count;
    }
}


Measured memory_bytes: 11092
package main

import (
	"fmt"
)

func group(a int) int {
	var res int

	switch a {
	case 1, 3, 5, 7, 8, 10, 12:
		res = 0
	case 4, 6, 9, 11:
		res = 1
	default:
		res = 2
	}

	return res
}

func main() {
	var x, y int
	var ans string
	fmt.Scan(&x,&y)
	
	if group(x) == group(y) {
		ans = "Yes"
	} else {
		ans = "No"
	}

	fmt.Println(ans)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
 // freopen("input.txt","r",stdin);
#endif

  string s;
  cin>>s;
  bool flag=0;
  if(s[2]==s[3] && s[4]==s[5])
    flag=1;
  if(flag)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int d;
  cin >> d;
  const int ContestCount = 26;
  vector<int> c(ContestCount);
  rep(i, ContestCount) cin >> c.at(i);
  vector<vector<int>> s(d, vector<int>(ContestCount));
  rep(i, d) {
    rep(j, ContestCount) {
      cin >> s.at(i).at(j);
    }
  }
  vector<int> res(d);
  rep(i, d) {
    res.at(i) = 1;
  }
  rep(i, d) {
    cout << res.at(i) << endl;
  }
  return 0;
}


Measured memory_bytes: 3684
s = input()
k = int(input())
ls = len(s)

word_list = []

a = ""
b = 1

for i, v in enumerate(s):
    if a != v:
        if a != "":
            word_list.append((a,b))
        a = v
        b = 1
    else:
        b += 1
    if i == ls-1:
        word_list.append((a,b))

ans = 0
if len(word_list) == 1:
    ans = (word_list[0][1] * k) // 2
else:
    if word_list[-1][0] != word_list[0][0]:
        for i in word_list:
            ans += (i[1])//2
        ans *= k
    else:
        head, *body, tail = word_list

        for i in body:
            ans += (i[1])//2
        ans *= k
        ans += head[1] // 2
        ans += tail[1] // 2
        headtail = (head[1]+tail[1]) //2 *(k-1)
        ans += headtail

print(ans) 


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(void) {
    int a;
    cin >> a;
    int tst=a%10;
    rep(i,3){
        a/=10;
        if(tst==a%10){cout << "Bad" << endl;return 0;}
        else tst=a%10;
    }
    cout << "Good" << endl;
    return 0;
}


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

int gcd(int a, int b) {
    int q, r;
    if(a < b) {
        int tmp = a;
        a = b;
        b = tmp;
    }
    while(1) {
        q = a / b;
        r = a % b;
        if(r == 0) break;
        a = b;
        b = r;
    }
    return b;
}

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

    int ans = 0;
    for(int a = 1; a <= k; a++) {
        for(int b = 1; b <= k; b++) {
            for(int c = 1; c <= k; c++) {
                ans += gcd(a, gcd(b, c));
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#AOJ GRL_1_A
import sys
input = sys.stdin.readline
from heapq import *

def dijkstra(sta):
    dist = [10**18]*V
    dist[sta] = 0
    pq = []
    heappush(pq, (dist[sta], sta))
    
    while pq:
        d, v = heappop(pq)
        
        if dist[v]<d:
            continue
        
        for nv, w in G[v]:
            if dist[nv]>dist[v]+w:
                dist[nv] = dist[v]+w
                heappush(pq, (dist[nv], nv))
    
    return dist

V, E, r = map(int, input().split())
G = [[] for _ in range(V)]

for _ in range(E):
    s, t, d = map(int, input().split())
    G[s].append((t, d))

dist = dijkstra(r)

for di in dist:
    if di==10**18:
        print('INF')
    else:
        print(di)


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

ll mod=1e9+7;

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> a(m+1);
    for (int i=0;i<m;i++) cin >> a[i];
    a[m]=0;
    int k=0;
    vector<ll> b(n+1);
    b[0]=1;
    for (int j=1;j<n+1;j++) {
        if (j==a[k]) {
            b[j]=0;
            k++;
        }
        else if (j==1) b[j]=b[j-1];
        else b[j]=b[j-1]+b[j-2];
        b[j]=b[j]%mod;
    }
    cout << b[n] << endl;
}

Measured memory_bytes: 1408
import sys
input=sys.stdin.readline

grid = []
for i in range(3):
	aa = list(map(int,input().split()))
	grid.append(aa)

flag = True
for i in range(2):
	for j in range(i+1,3):
		c = grid[i][0] - grid[j][0]
		for k in range(1,3):
			if(c!=(grid[i][1] - grid[j][1]) or c!=(grid[i][2] - grid[j][2]) ):
				flag = False

for i in range(2):
	for j in range(i+1,3):
		c = grid[0][i] - grid[0][j]
		for k in range(1,3):
			if(c!=(grid[1][i] - grid[1][j]) or c!=(grid[2][i] - grid[2][j]) ):
				flag = False

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

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <string>
int main(){
	std::string s;
	std::stringstream ss;
	int a=0,i;
	while(std::cin>>s){
		for(i=0;i<(int)s.size();i++)ss<<((isdigit(s[i]))?s[i]:' ');
		while(ss>>i)a+=i;
		ss.clear();
	}
	std::cout<<a<<"\n";
}

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

using namespace std;

void usain_bolt()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
}

const int N = 1e2 + 5;

long long w[105], p[105], dp[105][100005];

int main()
{
    usain_bolt();

    int n, W;
    int sum = 0;

    cin >> n >> W;
    for(int i = 0; i <= 100; ++i) {
        for(int j = 0; j <= 100000; ++j) {
            dp[i][j] = 2e18;
        }
    }
    dp[0][0] = 0;
    for(int i = 1; i <= n; ++i) cin >> w[i] >> p[i], sum += p[i];
    for(int i = 1; i <= n; ++i) {
        for(int j = 0; j <= sum; ++j) {
            dp[i][j] = dp[i - 1][j];
            if(j >= p[i]) dp[i][j] = min(dp[i][j], dp[i - 1][j - p[i]] + w[i]);
        }
    }
    for(long long i = 100000; i >= 1; --i) {
        if(dp[n][i] <= W) {
            cout << i;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 80256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Sagor
 */

#include <fstream>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define gap                  ' '
#define P_INF                1e10+17
#define N_INF               -1e10+17
#define mod                  1000000007
#define EPS                  0.000000001
#define pi                   2*acos(0.0)
#define fi(i, n)             for(int i=0; i<n; i++)
#define fj(j, n)             for(int j=0; j<n; j++)
#define rfk(k, n)            for(int k=n-1; k>=0; k--)
#define unique(a)            a.resize(unique(a.begin(), a.end()) - a.begin())

typedef double ld;
typedef long long int ll;
typedef unsigned long long int ul;
using namespace std;

class Papers_Please {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n, cnt = 0, evencnt = 0;
        in >> n;
        while (n--) {
            int a;
            in >> a;
            if (a % 2 == 0) {
                evencnt++;
                if (a % 3 == 0 || a % 5 == 0) {
                    cnt++;
                }
            }
        }
        if (evencnt == cnt)
            out << "APPROVED" << endl;
        else
            out << "DENIED" << endl;

    }
};


int main() {
     std::ios_base::sync_with_stdio(0);
     std::cin.tie(nullptr);
     Papers_Please solver;
     std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
     return 0;
}


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

int main() {
    int n,l;
    string s;
    vector<string>v;
    cin>>n>>l;
    while(n--){
        cin>>s;
        v.pb(s);
    }
    sort(v.begin(),v.end());
    for(int i=0; i<v.size(); i++){
        cout<<v[i];
    }cout<<endl;
}


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

int main(){
  int A,B,C,X,Y,e;
  cin >> A >> B >> C >> X >> Y;
  if(0<=2*C-A-B)
    e = 0;
  else
    e = min(X,Y);
  cout << min(A*X+B*Y+e*(2*C-A-B),max(X,Y)*2*C)<< endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm> // std::min, std::max
#include <vector> // std::vector

template <class String>
size_t levenshtein(const String &s0, const String &s1) {
    size_t n0 = s0.size();
    size_t n1 = s1.size();
    const size_t INF = std::max(n0, n1);
    std::vector<std::vector<size_t>> dp(n0 + 1, std::vector<size_t>(n1 + 1, INF));
    dp[0][0] = 0;
    for (size_t i = 0; i <= n0; ++i) {
        for (size_t j = 0; j <= n1; ++j) {
            if (i == 0 && j == 0) {
                continue;
            }
            size_t tmp = INF;
            if (i > 0 && j > 0) {
                // change s0[i - 1] to s1[j - 1];
                tmp = std::min(tmp, 1 + dp[i - 1][j - 1]);
                if (s0[i - 1] == s1[j - 1]) {
                    // do nothing
                    tmp = std::min(tmp, dp[i - 1][j - 1]);
                }
            }
            if (i > 0) {
                // remove s0[i - 1]
                tmp = std::min(tmp, 1 + dp[i - 1][j]);
            }
            if (j > 0) {
                // append s1[j - 1] to s0
                tmp = std::min(tmp, 1 + dp[i][j - 1]);
            }
            dp[i][j] = tmp;
        }
    }
    return dp[n0][n1];
}

int main() {
    using namespace std;

    string s1, s2;
    cin >> s1 >> s2;
    cout << levenshtein(s1, s2) << endl;
    return 0;
}


Measured memory_bytes: 10800
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	int N,i,M;
	cin>>N;
	vector<int> ans;
	M=N;
	if(N!=0){
	while(true){
		if(N==1){
			ans.push_back(1);
			break;
		}else if(N==-1){
			ans.push_back(1);
			ans.push_back(1);
			break;
		}
		if(N<0){
			if(N%2==0){
				//printf("a%d %d\n",N/(-2),N%2);
				ans.push_back(N%2);
				N/=(-2);
			}else{
				//printf("b%d %d\n",N/(-2)+1,-N%2);
				ans.push_back(-N%2);
				N=N/(-2)+1;
			}
		}else{
			//printf("c%d %d\n",N/(-2),N%2);
			ans.push_back(N%2);
			N/=(-2);
		}
	}
	/*if(M>0){
		ans.push_back(1);
	}*/
	for(i=0;i<ans.size();i++){
		cout<<ans.at(ans.size()-1-i);
	}
	}else{
		cout<<0;
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		String[] t = saori.nextHayami().split("");
		boolean flg = false;
		for(int i = 0;i < s.length;i++){
			if(Arrays.equals(s, t)){
				flg = true;
				break;
			}
			String str = s[0];
			for(int j = 0;j < s.length-1;j++){
				s[j] = s[j+1];
			}
			s[s.length-1] = str;
		}
		if(flg){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21332
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e6+5;
int n,k;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>k;
    if(n<1+2*(k-1))cout<<"NO\n";
    else cout<<"YES\n";
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;

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

    if ((n - 1) / b <= a - 1 && a - 1 <= n - b) {
        if (a == 1) {
            for (int i = n; i > 0; i--) {
                if (i != n) cout << " ";
                cout << i;
            }
            cout << endl;
            return 0;
        }
        int ans[300030], idx = 0, front = 1;
        int k = (n - b) / (a - 1), l = (n - b) % (a - 1);
        for (int i = 0; i < a - 1; i++) {
            int end;
            if (l > 0) {
                end = front + k;
                l--;
            }
            else end = front + k - 1; 
            for (int j = end; j >= front; j--) {
                ans[idx] = j;
                idx++;
            }
            front = end + 1;
        }
        front = n;
        while (idx < n) {
            ans[idx] = front;
            idx++;
            front--;
        }
        for (int i = 0; i < n; i++) {
            if (i != 0) cout << " ";
            cout << ans[i];
        }
        cout << endl;
        
    }
    else cout << -1 << endl;

}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
#define LEN(x) ll(x.length()) //lengthをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> g(n+1);
    REP(i, m){
        ll a, b;
        cin >> a >> b;
        g[a].PB(b);
        g[b].PB(a);
    }
    queue<ll> q;
    ll ans = 0;
    vector<bool> is_checked(n+1, false);
    REP(i, n){
        int start = i + 1;
        if(is_checked[start] == false){
            ll cnt = 1;
            q.push(start);
            is_checked[start] = true;
            while(q.empty() != true){
                int v = q.front();
                q.pop();
                for(int x : g[v]){
                    if(is_checked[x] == false){
                        is_checked[x] = true;
                        q.push(x);
                        cnt++;
                    }
                }
            }
            ans = max(ans, cnt);
        }
    }
    cout << ans;
    return 0;
}

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

int main() {
	int n,m;
	queue<int> qu;
	while(1){
		cin >> n >> m;
		if(!n && !m) break;
		for(int i = 1;i <= n;i++) qu.push(i);
		int cnt = 0;
		while(qu.front() != qu.back()){
			int buf = qu.front();
			qu.pop();
			if(++cnt % m != 0) qu.push(buf);
		}
		cout << qu.back() << endl;
		qu.pop();
	}
	return 0;
}

Measured memory_bytes: 1224
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int l=sc.nextInt();
		int min=99999,sum=0;

		for(int i=1;i<=n;i++) {
			if(l+i-1<0) {
				min=-1*Math.min(Math.abs(l+i-1),Math.abs(min));
			}else {
				min=Math.min(Math.abs(l+i-1),Math.abs(min));
			}
			sum+=l+i-1;
		}
		System.out.println(sum-min);


	}
}
/*
 6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40
 */

//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));




Measured memory_bytes: 22096
#include<bits/stdc++.h>
 
using namespace std;
int main(){
  
 int n;
  cin>>n;
  int a[n];
  int sum;
  for(int i=0;i<n;i++)
    cin>>a[i];
  
  int dp[n];
  dp[0]=0;
  if(n==1)
    {cout<<"0";
    return 0;}
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++)
  {
       
      dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    
  }
                
                cout<<dp[n-1];
  
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    int ans = 0;
    vector<int> d(N);
    for(int i = 0; i < N; i++){
    cin >>d[i];
    	for(int j = 0; j < N; j++){
          if(i != j) {
        ans+=d[i]*d[j];
          }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long[] ary = new long[100001];
        long total = 0;
        for(int i=0; i<n; i++){
            int num = Integer.parseInt(sc.next());
            ary[num]++;
            total += num;
        }
        int q = Integer.parseInt(sc.next());
        for(int i=0; i<q; i++){
            int b = Integer.parseInt(sc.next());
            int c = Integer.parseInt(sc.next());
            total -= b * ary[b];
            total += c * ary[b];
            ary[c] += ary[b];
            ary[b] = 0;
            System.out.println(total);
        }
    }
}

Measured memory_bytes: 61328
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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


int n, m;
string s;

int main(){
	cin >> n >> m;
	cin >> s;
	
	int cnt = 0;
	bool ok = 1;
	for(int i = 0; i <= n; i++){
		if(s[i] == '1'){
			cnt++;
		}
		else{
			if(cnt >= m){
				ok = 0;
				break;
			}
			cnt = 0;
		}
	}
	if(cnt >= m) ok = 0;
	if(!ok){
		cout << -1 << endl;
		return 0;
	}
	
	vector<int> v;
	for(int i = n; i > 0;){
		for(int j = min(m, i); j > 0; j--){
			if(s[i-j] == '0'){
				i -= j;
				v.push_back(j);
				break;
			}
		}
	}
	for(int i = v.size()-1; i >= 0; i--){
		cout << v[i] << " ";
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 1144
//----------------------------------------------------
//HEADER
#include<bits/stdc++.h>

//NAMESPACE
using namespace std;

//CONSTANT
const int64_t INF=INT64_MAX;

//FAST I/O
void init(){cin.tie(0);ios::sync_with_stdio(false);}
//----------------------------------------------------

int64_t solve(int n){
  int64_t dept=100000;

  for(int i=0;i<n;i++){
    dept=(int)(dept*1.05);
    if(dept%1000!=0){
      dept+=(1000-dept%1000);
    }
  }

  return dept;
}

int main(){
  init();

  int64_t n;
  cin >> n;

  cout << solve(n) << endl;

  return 0;
}

Measured memory_bytes: 3020
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <bitset>
#include <unordered_map>
#include <tuple>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sys/time.h>

using namespace std;

class UnionFind {
  vector<int> par;
  vector<int> sizes;
  public:
  UnionFind(int n) : par(n), sizes(n, 1) {
    for (int i = 0; i < n; i++) {
      par[i] = i;
    }
  }
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int size(int x) {
    return sizes[find(x)];
  }
};

void solve(long long H, long long W, vector<string> S){
  UnionFind uf(H*W);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (i+1 < H && S[i][j] != S[i+1][j]) {
        uf.unite(i*W+j, (i+1)*W+j);
      }
      if (j+1 < W && S[i][j] != S[i][j+1]) {
        uf.unite(i*W+j, i*W+(j+1));
      }
    }
  }
  vector< vector<long long> > s(H*W, vector<long long>(2, 0));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      s[uf.find(i*W+j)][S[i][j] == '.' ? 1 : 0]++;
    }
  }
  long long ret = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      ret += s[i*W+j][0] * s[i*W+j][1];
    }
  }
  std::cout << ret << std::endl;
}

int main(){
  long long H;
  long long W;
  scanf("%lld",&H);
  vector<string> S(H);
  scanf("%lld",&W);
  for(int i = 0 ; i < H ; i++){
    cin >> S[i];
  }
  solve(H, W, S);
  return 0;
}


Measured memory_bytes: 10624
import java.io.*;
import java.lang.Math;
import java.util.*;

class Main{
  public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);
    int[] a=new int[1000];
    String[] op=new String[1000];
    int[] b=new int[1000];
    int count=0;
    for(int i=0;i<a.length;i++){
      a[i]=Integer.parseInt(scan.next());
      op[i]=scan.next();
      b[i]=Integer.parseInt(scan.next());

      if(op[i].equals("?")){
        break;
      }
      count++;
    }

    for(int i=0;i<count;i++){

      if(op[i].equals("+")){
        int ans=a[i]+b[i];
        System.out.println(ans);
      }else if(op[i].equals("-")){
        int ans=a[i]-b[i];
        System.out.println(ans);
      }else if(op[i].equals("*")){
        int ans=a[i]*b[i];
        System.out.println(ans);
      }else if(op[i].equals("/")){
        int ans=a[i]/b[i];
        System.out.println(ans);
      }

    }
  }
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N, A[101010], B[101010];
ll i,j,k,ans;
int main(){
    scanf("%lld", &N);
    fornum(i,0,N+1){
        scanf("%lld", &A[i]);
    }
    fornum(i,0,N){
        scanf("%lld", &B[i]);
    }
    fornum(i,0,N){
        ll b = B[i];
        ans += min(b, A[i]);
        if(b>A[i]){
            b -= A[i];
            ans+=min(b,A[i+1]);
            A[i+1]-=b;
            A[i + 1] = 0 < A[i + 1] ? A[i + 1] : 0;
        }
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String s = sc.next();
      int needLeft = 0;
      int openCnt = 0;
      for(int i = 0; i < s.length(); i++) {
        if(s.charAt(i) == '(')
          openCnt++;
        else {
          if(openCnt == 0)
            needLeft++;
          else 
            openCnt--;
        }
      }

      StringBuilder sb = new StringBuilder();
      for(int i = 0; i < needLeft; i++)
        sb.append('(');
      sb.append(s);
      for(int i = 0; i < openCnt; i++)
        sb.append(')');
      System.out.println(sb.toString());
  }
}


Measured memory_bytes: 21972
#include<iostream>
#include<string>
#include<map>
#include<vector>
using namespace std;
int main()
{
	long long g;
	long long n;
	cin >> n;
	vector<long long>a;
	for (long long i = 0; i < n; i++) {
		cin >> g;
		a.push_back(g);
	}
	long long k;
	k = n;
	if (n % 2 == 0) {
	
		for (long long i = 0; i < n/2; i++) {
			cout << a[k-1]<<" ";
			k -=2;

		}
		for (long long i = 0; i < n / 2; i++) {
			cout << a[i*2]<<" ";

		}
	}
	else {


		for (long long i = 0; i < n / 2+1; i++) {
			cout << a[k - 1] << " ";
			k -= 2;

		}
		for (long long i = 0; i < n / 2 ; i++) {
			cout << a[i * 2+1] << " ";

		}
	}

	

		
}


Measured memory_bytes: 3824
import java.util.Scanner;

public class Main {
	
	private static int[][][] dp = new int[41][410][410];
	private static int[] a = new int[41];
	private static int[] b = new int[41];
	private static int[] c = new int[41];
	
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		int i , j , k , n , ma , mb;
		n = scan.nextInt();
		ma = scan.nextInt();
		mb = scan.nextInt();
		
		for (i = 0;i < 41;i ++)
			for (j = 0;j < 410;j ++)
				for (k = 0;k < 410;k ++) {
					dp[i][j][k] = - 1;
				}
		
		for (i = 0;i < n;i ++) {
			a[i] = scan.nextInt();
			b[i] = scan.nextInt();
			c[i] = scan.nextInt();
		}
		
		dp[0][a[0]][b[0]] = c[0];
		dp[0][0][0] = 0;
		
		for (i = 1;i < n;i ++) {
			for (j = 0;j <= 400;j ++)
				for (k = 0;k <= 400;k ++) {
					dp[i][j][k] = dp[i - 1][j][k];
				}
			for (j = 0;j <= 400;j ++)
				for (k = 0;k <= 400;k ++) {
					if (dp[i - 1][j][k] >= 0) {
						int temp = dp[i - 1][j][k] + c[i];
						int x = j + a[i];
						int y = k + b[i];
						if (dp[i][x][y] < 0 || temp < dp[i][x][y]) {
							dp[i][x][y] = temp;
						}
					}
				}
		}
		int ans = - 1;
		for (i = 1;i <= 400;i ++)
			for (j = 1;j <= 400;j ++) {
				if (dp[n - 1][i][j] >= 0) {
					if (i * mb == ma * j) {
						if (dp[n - 1][i][j] < ans || ans < 0)
							ans = dp[n - 1][i][j];
					}
				}
			}
		System.out.println(ans);
		
	}
	
}





Measured memory_bytes: 58404
package main

import (
	"fmt"
	"time"
)

func main() {
	var s string
	fmt.Scan(&s)
	t1, _ := time.Parse("2006/01/02", s)
	t2, _ := time.Parse("2006/01/02", "2019/04/30")
	if t1.After(t2) {
		fmt.Println("TBD")
	} else {
		fmt.Println("Heisei")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll a,b;
    cin>>a>>b;
    if(a>2*b){
        cout<<a-b-b<<endl;

    }
    else{
        cout<<0<<endl;
    }
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  int ans = 1;
  while (ans * 2 <= N) {
    ans *= 2;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int s(int);

int main(){
  int n;
  int i;
  int A[10000];
  int ans=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  for(i=0;i<n;i++){
    ans+=s(A[i]);
  }

  printf("%d\n",ans);


}

int s(int a){
  int i;
  if(a==2){
    return 1;
  }

  if(a<2 || a%2==0){
    return 0;
  }

  i=3;
  while(i<=sqrt(a)){
    if(a%i==0){
      return 0;
    }
    i=i+2;
  }
  
  return 1;
}
      
		     



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

int main()
{
	int n,res,k,o,ans;
	cin >> n;
	res = -100000;
	for( int i = 1; i <= n; i++ )
	{
		o = i;
		k = 0;
		while(1)
		{
			if( o % 2 != 0 )
			{
				break;
			}
			else if( o % 2 == 0 )
			{
				k++;
				o = o / 2;
			}
		}
		if( res < k )
		{
			res = k;
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const ll inf  = 1e7+5;
typedef pair<int, bool> pib;
bool visited [inf];
int dist[inf];
int main() {
  double n,m; cin >> n >> m;
  double per = m*2+1;
  cout << ceil(n/per);
}



Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    int n;
    cin >> n;
    int i = 1;
    while (i <= 9) {
        if (n % i == 0 && n / i <= 9) {
            cout << "Yes" << endl;
            break;
        }
        i++;
    }
    if (i == 10) cout << "No" << endl;
    return 0;
}

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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    double t, x;
    cin2(t,x);
    cout <<fixed<< t/x<<endl;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    static char s[200000];

    scanf("%s", s);

    int cnt = 0;
    int ans = 0;
    Rep(i,strlen(s)){
        if( s[i] == 'S'){
            cnt++;
        }else{
            if( cnt ){
                cnt--;
                ans += 2;
            }
        }
    }

    printf ("%d\n", strlen(s) - ans);


    return 0;
}



Measured memory_bytes: 384
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Map<Integer, List<Integer>> routes = new HashMap<>(n);
        for (int i = 1; i <= n; i++) {
            routes.put(i, new ArrayList<>());
        }

        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            routes.get(a).add(b);
            routes.get(b).add(a);
        }

        boolean canReach = false;
        for (Integer firstStop : routes.get(1)) {
            List<Integer> secondStops = routes.get(firstStop);
            if (secondStops.contains(n)) {
                canReach = true;
                break;
            }
        }

        System.out.println(canReach ? "POSSIBLE" : "IMPOSSIBLE");
    }
}

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

using namespace std;


int main() {
  long int N,count = 0;
  
  cin >> N;
  string str;
  cin >> str;
  long int r = 0;
  long int g = 0;
  long int b = 0;
 

  for(int i = 0; i < str.size(); i++){
    
        if (str.at(i) == 'R') {
      r++;
          continue;
    }
    else     if (str.at(i) == 'G') {
      g++;
      continue;
    }
    else
      b++;
    continue;
  }
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){    
        if(i < j){
          if(2*j - i < N){
          if(str.at(i)!=str.at(j) && str.at(i)!=str.at(2*j - i)&& str.at(j)!=str.at(2*j - i)){
          
              count++;
            }
          }
        }
      }
    }
  
cout << r*g*b - count <<endl;
  
    
 
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int N = 2e3+5;
bitset<N*N> B;
int n, sm, rt;
int main(){
    B.set(0);
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        int a; scanf("%d", &a);
        B |= B<<a;
        sm+=a;
    }
    for(int i=((sm+1)>>1);;i++) if(B[i]) return !printf("%d", i);
}

Measured memory_bytes: 1664
#include <iostream>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define MOD 1000000007
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

//nCr,nPr,modの逆元
class Combination {
public:
	Array fact;//n！
	Array inv;//n!の逆元
	ll mod;
	Combination(ll n, ll _mod) {
		mod = _mod;
		fact.resize(n + 1);
		fact[0] = 1;
		REP(i, n) {
			fact[i + 1] = (fact[i] * (i + 1LL)) % mod;
		}
		inv.resize(n + 1);
		inv[n] = mod_inv(fact[n]);
		for (int i = n; i > 0; i--) {
			inv[i - 1] = inv[i] * i % mod;
		}
	}
	//modの逆元
	ll mod_inv(ll x) {
		ll n = mod - 2;
		ll res = 1LL;
		while (n > 0) {
			if (n & 1) res = res * x % mod;
			x = x * x % mod;
			n >>= 1;
		}
		return res;
	}
	ll nCr(ll n, ll r) {
		return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod;
	}
	ll nPr(ll n, ll r) {
		return (fact[n] * inv[n - r]) % mod;
	}
	ll nHr(ll n, ll r) {
		//重複組み合わせ：n種類のものからr個取り出す組み合わせ
		return nCr(r + n - 1, r);
	}
};

ll pow2_m(ll x, ll n, ll mod) { //x^n 計算量O(logn)
	ll ans = 1ll;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x % mod;
		}
		x = x * x % mod; //一周する度にx, x^2, x^4, x^8となる
		n >>= 1; //桁をずらす n = n >> 1
	}
	return ans;
}

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

	ll mod = 998244353;
	ll n;
	cin >> n;
	Combination com(n, mod);
	ll sum = pow2_m(3, n, mod);

	Array m2(n + 1, 1);
	REP(i, n) (m2[i + 1] = m2[i]*2) %= mod;

	ll sum2=0;
	for (ll i = n / 2 + 1; i < n + 1; i++) {
		(sum2 += com.nCr(n, i)*m2[n-i]) %= mod;
	}

	sum = (sum - sum2 + mod) % mod;
	sum = (sum - sum2 + mod) % mod;

	cout << sum << endl;


	return 0;
}

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

int main() {
    int N, a, b, ans = 1;
    bool first = true, up;
    cin >> N >> a;
    rep(i, N-1) {
        cin >> b;
        if (a == b) continue;
        if (first) {
            up = a < b;
            first = false;
        }
        if (up) {
            if (a > b) {
                up = false;
                ans++;
                first = true;
            }
        } else {
            if (a < b) {
                up = true;
                ans++;
                first = true;
            }
        }
        //printf("%d %d %d %d\n", i, a, b, ans);
        a = b;
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){

   int p[1001];
   int k, n;
   int ans = 0;

   cin >> n >> k;

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

   sort(p, p + n);

   for(int i = 0; i < k; i++){
      ans += p[i];
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 3640
n,a,b,c = map(int,input().split())
mod = 10**9 + 7

## nCkのmodを求める関数
# テーブルを作る(前処理)
max = 2 * 10**5 + 100
fac, finv, inv = [0]*max, [0]*max, [0]*max

def comInit(max):
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,max):
      fac[i] = fac[i-1]* i% mod
      inv[i] = mod - inv[mod%i] * (mod // i) % mod
      finv[i] = finv[i-1] * inv[i] % mod

comInit(max)

# 二項係数の計算
def com(n,k):
    if(n < k):
        return 0
    if( (n<0) | (k < 0)):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

# if(c==0):
#     ex_a,ex_b = 1,1
# else:
#     ex_a = (pow(c,mod-2,mod) * 100)%mod
#     ex_b = (pow(c,mod-2,mod) * 100)%mod
ex_a = (pow(100-c,mod-2,mod) * 100)%mod
ex_b = (pow(100-c,mod-2,mod) * 100)%mod

win_a = (pow((a+b),mod-2,mod) * a)%mod
win_b = (pow((a+b),mod-2,mod) * b)%mod

inv = [0] * 101
for i in range(101):
    inv[i] = pow(i,mod-2,mod)

exp_a = [1] * (n+1)
exp_b = [1] * (n+1)

for i in range(1,n+1):
    exp_a[i] = (exp_a[i-1] * win_a)%mod
    exp_b[i] = (exp_b[i-1] * win_b)%mod

ans = 0
for i in range(n):
    #高橋くんwin E(n,i)
    tmp = com(i+n-1,i) * exp_a[n] * exp_b[i] * (ex_a*n + ex_b*i)
    ans += tmp

    #青木くんwin E(i,n)
    tmp = com(i+n-1,i) * exp_b[n] * exp_a[i] * (ex_a*i + ex_b*n)
    ans += tmp

    ans %= mod

print(ans)

Measured memory_bytes: 82652
n, q = map(int, input().split())
s = input()
A = [0 for _ in range(n+1)]
for i in range(n-1):
  A[i+1] = A[i] + (1 if s[i:i+2] == 'AC' else 0)
for j in range(q):
  l, r = map(int, input().split())
  print(A[r-1] - A[l-1])

Measured memory_bytes: 7772
N=int(input())
L=[input() for _ in range(N)]
ans=[]

for i in range(26):
  x=chr(ord('a') + i)
  count=50
  for l in L:
    count =min(count,l.count(x))
  else:
    ans.append(x*count)
  
print(''.join(ans))

Measured memory_bytes: 9076
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct Station {
    string name;
    int time;
    Station() {}
    Station(string name, int time) : name(name), time(time) {}
};

int main()
{
    int N, T;
    char a[55], b[55];
    int h1, d1, h2, d2;
    string s;
    vector<Station> st;

    cin >> N >> T;
    cin >> s >> s;
    for (int i = 0; i < N - 1; ++i) {
        scanf("%d:%d %s %d:%d %s", &h1, &d1, a, &h2, &d2, b);
        int time = (h2 * 60 + d2) - (h1 * 60 + d1);
        if (time >= T)
            st.push_back(Station(a, time));
    }
    cin >> s >> s;

    cout << st.size() << "\n";
    for (size_t i = 0; i < st.size(); ++i)
        cout << st[i].name << " " << st[i].time << "\n";

    return 0;
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
//typedef pair<int, int> P;

int main() {
    int n; cin >> n;
    vector<string> s(n);
    vector<int> p(n);
    vector<pair<int, pair<string, int> > > info(n);
    set<string> st;
    rep(i, n) {
        cin >> s[i] >> p[i];
        info[i] = make_pair(p[i], make_pair(s[i], i+1));
        st.insert(s[i]);
    }
    sort(all(info), greater<pair<int, pair<string, int> > >());
    for (auto ite = st.begin(); ite!=st.end(); ite++) {
        rep(i, n) {
            if (*ite == info[i].second.first) {
                cout << info[i].second.second << endl;
            }
        }
    }
}


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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

ll aa[252525];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a;
	cin>>n;
	REP(i, n){
		cin>>a;
		aa[i]=a-i-1;
	}
	sort(aa, aa+n);
	ll b=aa[n/2];
	ll tmp=0;
	REP(i, n){
		tmp+=abs(aa[i]-b);
	}
	ll ans=tmp;
	if(n&1==1){
		b=aa[n/2-1];
		REP(i, n){
			tmp+=abs(aa[i]-b);
		}
		ans=min(ans, tmp);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
  int main(){
	  int i,k,n,m,j;
   int a,q;
   
   int c,d[100];
   for(i=0;i<100;i++){
	   d[i] = 0;
   }
   scanf("%d",&n);
   scanf("%d %d",&a,&q);
   scanf("%d",&c);
   for(i=0;i<n;i++){
	   scanf("%d",&d[i]);
   }
   for(j=0;j<n;j++){
	   for(k=0;k<n-1;k++){
		   if(d[k]<d[k+1]){
              m = d[k+1];
			  d[k+1] =d[k];
			  d[k] = m;
		   }
	   }
   }
   
   for(i=0;i<n;i++){
	   if(c/(a+i*q)< d[i]/q){
		 c += d[i];
	   }else{
		   int x = c/(a+i*q);
		   printf("%d\n",x);
		   break;
	   }
   }
   return 0;
  }

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

int main(){
    string S;
    cin >> S;
    bool res = true;

    for (size_t i = 0; i < S.size(); i++)
    {
        if(i%2 == 0)
        {
            if(S.at(i) == 'L') res = false;
        } else {
            if (S.at(i) == 'R') res = false;
        }
    }
    
    if (res) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

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

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

bool ptest(ll n){
  bool is_prime=true;
  if(n==1)is_prime=false;
  for(ll i=2;i*i<=n;i++){
    if(n%i==0){
      is_prime=false;
      break;
    }
  }
  return is_prime;
}

int main(){

  ll x;
  cin >> x;

  while(!ptest(x)){
    x++;
  }

  cout << x << endl;


}

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

int main() {
    ll n, ans = 0;
    cin >> n;

    for (int i=1; i<=n; i++) {
        if (i >= 3 && i%3 == 0) {continue;}
        if (i >= 5 && i%5 == 0) {continue;}
        ans += i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <functional>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -----------------------------------------------------------------------*/
#define ALL(a)				(a).begin(),(a).end()
#define REP(i, n)			for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)		for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF					(1000 * 1000 * 1000 * 2)
#define MOD					(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)			(((((x))+((n)-1))/n))	/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)			(((((x))+((n)-1))/n)*n)	/* Nの倍数に切り上げ */
#define FloorN(x, n)		((x)-(x)%(n))			/* Nの倍数に切り下げ */
#define IsOdd(x)			(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)			(!IsOdd((x)))						
#define	BitSetV(Val,Bit)	((Val) |= (Bit))			
#define	BitTstV(Val,Bit)	((Val) & (Bit))				
#define M_PI				3.14159265358979323846
typedef long long			ll;
typedef pair<ll, ll>		P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
/* 素数判定 */
bool isPrime(ll p) 
{
	for (ll i = 2; i <= sqrt(p); i++) if (p % i == 0) return false;
	return p > 1;
}

// メイン
int main()
{
	ll X;
	cin  >> X;
	REPN(i, X, INF) {
		if (isPrime(i)) {
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}



Measured memory_bytes: 256
N,M,R=gets.split.map(&:to_i)
r=gets.split.map(&:to_i).map!{|x|x-1}
$ans=MAX=1e12
$node=Array.new(N){Array.new(N,MAX)}
N.times{|i|$node[i][i]=0}
def dfs(re,n,sum)
  if re.size==0 then
    $ans=[$ans,sum].min
    return
  end
  re.each{|e|
    d=Marshal.load(Marshal.dump(re))
    d.delete(e)
    if n==-1 then
      dfs(d,e,sum)
    else
      dfs(d,e,sum+$node[n][e])
    end
  }
end
M.times{
  a,b,c=gets.split.map(&:to_i)
  $node[a-1][b-1]=$node[b-1][a-1]=c
}
N.times{|k|
  N.times{|i|
    N.times{|j|
      t=$node[i][k]+$node[k][j]
      $node[i][j]=t if $node[i][j]>t
    }
  }
}
dfs(r,-1,0)
puts $ans


Measured memory_bytes: 3068
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong(), y = sc.nextLong();
		sc.close();
		long ans = 0;
		long n = y / x;
		int i = 0;
		while(true) {
			long tmp = (long)Math.pow(2,  i);
			if(tmp > n) {
				ans = i;
				break;
			}
			++i;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
long long int i,n,x,f,c;
int main()
{
    cin>>n;
    f=0;
    c=0;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        if(x%4==0)f++;
        else if(x%2==0)c++;
    }
    f=f+(c/2);
    n=n/2;
    if(f>=n)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 384