akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)

int main(void){
    int N,M;
    cin>>N>>M;
    vector<int> a(M);
    vector<int> b(M);
    vector<vector<int>> c(M);
    rep(i,M){
        cin>>a[i]>>b[i];
        c[i].resize(b[i]);
        rep(j,b[i]){
            cin>>c[i][j];
        }
    }
    int dp[4097];
    rep(i,4097){
        dp[i]=INT32_MAX;
    }
    dp[0]=0;
    vector<int> check;
    check.push_back(0);
    rep(i,M){
        int c_tmp=0;
        for(int item:c[i]){
            c_tmp+=(1<<(item-1));
        }
        
        for(int k=0;k<check.size();k++){
            int item=check[k];
            if(dp[item|c_tmp]==INT32_MAX){
                check.push_back(item|c_tmp);
            }
            dp[item|c_tmp]=min(dp[item|c_tmp],dp[item]+a[i]);
        }
    }
    int ans=dp[(1<<N)-1];
    if(ans==INT32_MAX){ans=-1;}
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 384
# coding: utf-8
# Your code here!
N,K=map(int,input().split())
R,S,P=map(int,input().split())
point=[R,S,P]
T=input()

myhand=[]
for item in T:
    if item == "r":
        myhand.append("p")
    elif item == "s":
        myhand.append("r")
    else:
        myhand.append("s")

for i in range(N-K):
    if myhand[i]==myhand[i+K]:
        myhand[i+K]="-"
    
print(myhand.count("r")*R+myhand.count("s")*S+myhand.count("p")*P)






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

int main() {
    int n, k, ans = 0, cnt = 1, num;
    string s;
    cin >> n >> k >> s;
    for (int i = 1; i < s.size(); i++) {
        if (s[i - 1] != s[i]) cnt++;
    }
    num = cnt - 2 * k;
    ans = n - num;
    cout << min(ans, n - 1) << endl;
    return 0;
}

Measured memory_bytes: 512
while True:
    po = input()
    if po == '#':
        break
    y,m,d = [int(i) for i in po.split()[1:]]
    if y > 31 or (y == 31 and m > 4):
        print(f"? {y-30} {m} {d}")
    else:
        print(f"HEISEI {y} {m} {d}")
        



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

int main() {
  i64 n, r;
  while(cin >> n >> r, n && r) {
    vector<i64> a(n);
    rep(i,0,n) {
      a[i] = n - i;
    }
    rep(R, 0, r) {
      i64 p, c;
      cin >> p >> c;
      p--;
      vector<i64> tmp(c);
      rep(i,0,c) {
        tmp[i] = a[p + i];
      }
      for(i64 i = p - 1;i >= 0;i--) {
        a[i + c] = a[i];
      }
      rep(i,0,c) {
        a[i] = tmp[i];
      }
    }
    cout << a.front() << endl;
  }
}



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

int main(void){
string f;
string t;
int count=0;
cin >> f;
cin >> t;
for(int i=0;i<3;i++){
    if(f[i]==t[i]){
        count+=1;
    }
}
cout<<count<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
int gi() { 
	int res = 0, w = 1; 
	char ch = getchar(); 
	while (ch != '-' && !isdigit(ch)) ch = getchar(); 
	if (ch == '-') w = -1, ch = getchar(); 
	while (isdigit(ch)) res = res * 10 + ch - '0', ch = getchar(); 
	return res * w; 
} 
const int MAX_N = 2e5 + 5; 
int N, V[20], t; 
int x[MAX_N], L[20][MAX_N], R[20][MAX_N]; 
int sl[1 << 19], sr[1 << 19], cr[MAX_N]; 
void chkmax(int &x, int y) { if (x < y) x = y; } 
void chkmin(int &x, int y) { if (x > y) x = y; } 
int main () { 
#ifndef ONLINE_JUDGE 
    freopen("cpp.in", "r", stdin); 
#endif 
	N = gi(), V[0] = gi(); 
	for (int i = 1; i <= N; i++) x[i] = gi(); 
	while (V[t]) V[t + 1] = V[t] >> 1, ++t; 
	for (int i = 0; i <= t; i++) { 
		L[i][1] = 1, R[i][N] = N; 
		for (int j = 2; j <= N; j++) 
			if (x[j] - x[j - 1] <= V[i]) L[i][j] = L[i][j - 1]; 
			else L[i][j] = j; 
		for (int j = N - 1; ~j; j--) 
			if (x[j + 1] - x[j] <= V[i]) R[i][j] = R[i][j + 1]; 
			else R[i][j] = j; 
	}
	for (int i = 1; i < 1 << t; i++) sl[i] = 1, sr[i] = N; 
	sl[0] = 0, sr[0] = N + 1; 
	for (int s = 0; s < 1 << t; s++) { 
		for (int i = 1; i <= t; i++) 
			if (!(s >> (i - 1) & 1)) { 
				chkmax(sl[s | 1 << (i - 1)], R[i][sl[s] + 1]); 
				chkmin(sr[s | 1 << (i - 1)], L[i][sr[s] - 1]); 
			} 
	} 
	for (int i = 0; i <= N; i++) cr[i] = 1e9; 
	int S = (1 << t) - 1; 
	for (int i = 0; i < 1 << t; i++) chkmin(cr[sl[i]], sr[S ^ i]); 
	for (int i = N - 1; ~i; i--) chkmin(cr[i], cr[i + 1]); 
	for (int i = 1; i <= N; i++) puts(cr[L[0][i] - 1] <= R[0][i] + 1 ? "Possible" : "Impossible"); 
    return 0; 
} 

Measured memory_bytes: 36920
#include<stdio.h>
#include<memory.h>
int n, m, atari, d;
char bar[30][12];
int check(){
	int y, x=m;
	for(y = 0; y < d; y ++){
		if(bar[y][x-1] == '1')
			x --;
		else if(bar[y][x] == '1')
			x ++;
	}
	return x==atari;
}
int main(){
	int y, x;
	while(scanf("%d%d%d%d", &n, &m, &atari, &d),n){
		memset(bar, 0, sizeof(bar));
		for(y = 0; y < d; y ++){
			scanf("%s", &bar[y][1]);
		}
		if(check()) {
			puts("0");
		} else {
			for(y = 0; y < d; y ++) {
				for(x = 1; x <= n-1; x ++) {
					if(bar[y][x] == '0' && bar[y][x-1] != '1' && bar[y][x+1] != '1') {
						bar[y][x] = '1';
						if(check()) {
							printf("%d %d\n", 1+y, x);
							goto next;
						}
						bar[y][x] = '0';
					}
				}
			}
			puts("1");
next:;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x, y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x, y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;

ll mode=pow(10,9)+7;
bool cmp(pair<ll,ll> x, pair<ll, ll> y){
    return x.S<y.S;
}
ll n,k,m;
bool check2(string ans, string s){
	for (int i=0;i<n;i++){
		ll aa=s[i];
		ll bb=ans[i];
		if (aa>bb) return false;
	}
	return true;
}

int main(){ 
    
  //  #ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
  //  #endif
    
    ios::sync_with_stdio(0);
    cin.tie(0);
	
	
	ll a,b;
	cin>>a>>b;
	
	if (a==1 && b==2) cout<<3<<endl;
	else if (a==2 && b==1) cout<<3<<endl;
	else if (a==1 && b==3) cout<<2<<endl;
	else if (a==3 && b==1) cout<<2<<endl;
	else if (a==2 && b==3) cout<<1<<endl;
	else cout<<1<<endl;
		
    return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List

solve :: Int -> [Int] -> (Int,Int)
solve n as = (p, q)
  where
    p:ps = sortOn (* (-1)) as
    (_, q) = minimum $ map g ps
      where g a = (f a, a)
            f a | p `mod` 2 == 1 = abs (((p + 1) `div` 2) - a)
                | 2 * a <= p     = p `div` 2 - a
                | otherwise      = a - ((p `div` 2) + 1)

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> (Int,Int)
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_n]:remLines1 = remLines0
      n = readBInt bs_n
      line2:remLines2 = remLines1
      as = map readBInt line2
  in solve n as

outAnswer :: (Int,Int) -> IO ()
outAnswer (x,y) = putStrLn $ unwords $ map show [x,y]

main :: IO ()
main = outAnswer . tmain =<< B.getContents


Measured memory_bytes: 26876
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll D = 1000000007;
int main(){
  	int N, M;
  	cin >> N >> M;
    bool safe[N+1];
    for(int i=0;i<=N;i++) safe[i] = true;

    for(int i=0;i<M;i++){
        int a;
        cin >> a;
        safe[a] = false;
    }

    ll pat[N+1];
    pat[0] = 1;
    if(safe[1]){
        pat[1] = 1;
    }else{
        pat[1] = 0;
    }

    for(int i=2;i<=N;i++){
        if(safe[i]){
            pat[i] = pat[i-1] + pat[i-2];
            pat[i] = pat[i]%D;
        }else{
            pat[i] = 0;
        }
    }
    cout << pat[N] <<endl;
 	
    
  	return 0;
}


Measured memory_bytes: 1152
//https://atcoder.jp/contests/nomura2020/tasks/nomura2020_d
#include<bits/stdc++.h>
using namespace std;
#define nn 65536*16
#define int long long

int cnt[nn],n,suf[nn];
int ans=0;

void dfs(int x,int now){
	ans+=now;//cout<<now<<"\n";
	if(x==n) {
		if(cnt[x]!=now) ans=-1;
		return ;	
	}
	now-=cnt[x];if(now<=0) {
		ans=-1;return ;
	}
	dfs(x+1,min(now*2,suf[x+1]));
}

signed main(){
	scanf("%lld",&n);for(int i=0;i<=n;i++) scanf("%lld",&cnt[i]),suf[i]=cnt[i];
	for(int i=n;i>=0;i--) suf[i]+=suf[i+1];
	dfs(0,1);
	printf("%lld\n",ans);	
	return 0;
} 

Measured memory_bytes: 5372
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
vector<pair<ll,ll>> adj[100001];
vector<ll> ans(100005);

void dfs(ll u , ll p=-1 , ll prev=-1){
	ll ps=1;
	for(auto x: adj[u]){
		ll v=x.f;
		ll idx=x.s;
		if(v==p)continue;
		if(ps==prev)ps++;
		ans[idx]=ps++;
		dfs(v , u , ans[idx]);
	}
}

int main(){
	//mahakal(),fast;
	
	ll n ;
	cin>> n ;
	for(ll i=1,a,b ; i< n ; i++){
		cin>>a>>b ;
		adj[a].pb({b,i});
		adj[b].pb({a,i});
	}	
	ll mx =0 ;
	for(ll i=1;i<=n;i++){
		mx=max(mx , (ll)adj[i].size());
	}
	dfs(1);
	cout<<mx<<endl;
	for(ll i=1;i<n ; i++)cout<<ans[i]<<"\n";

	return 0;
}

Measured memory_bytes: 11008
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>

using namespace std;

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

  int ans = 0 ;
  int i = 1 ;

  while(1){
      int ans = i*i ;
      if(ans>n) break ;
      i++ ;
  }

  cout << (i-1)*(i-1) << endl ;  
  
}

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



int main()
{
	long long x, y, prev, end = 1, cnt = 1;

	cin >> x >> y;

	prev = x;

	while (end){
		if ((prev *= 2) > y)
			end = 0;
		else
			cnt++;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val num = listOfString().joinToString(separator = "").toInt()
    println(when{
        num % 4 == 0 -> "YES"
        else -> "NO"
    })
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 36012
#include <iostream>
#include <string>
#include <vector>
//#include <stack>
#include <cstdlib>

typedef class Stack{
private:
  std::vector<int> * v;
public:
  Stack(){
    v = new std::vector<int>();
  }
  ~Stack(){
    delete v;
  }

  int top(){
    return v->back();
  }

  void pop(){
    v->erase(v->end()-1);
  }

  void push(int p){
    return v->push_back(p);
  }

} Stack;

// without standard stack
int main(){
  //const int STACK_SIZE 200;
  std::string s;
  Stack stack;
  while(std::cin >> s){
    if (s == "+" || s == "*" || s == "-"){
      const int var2 = stack.top(); stack.pop();
      const int var1 = stack.top(); stack.pop();
      int res;
      
      if (s == "+"){
	res = var1 + var2;
      }
      else if (s == "*"){
	res = var1 * var2;
      }
      else if (s == "-"){
	res = var1 - var2;
      }
      stack.push(res);
    }
    else{
      stack.push(atoi(s.c_str()));
    }
  }
  
  std::cout << (stack.top()) << std::endl;
}

Measured memory_bytes: 1216
from math import sqrt

MAX = 10**5 + 10
x = int(input())

nums = [i for i in range(1, MAX)]

for i in range(2, int(sqrt(MAX))+1):
    nums = [j for j in nums if j % i != 0 or j == i]
l = 0
r = len(nums)-1
while r - l > 1:
    mid = (r + l)//2
    if nums[mid] <= x:
        l = mid
    else:
        r = mid
if nums[l] == x:
    print(x)
else:
    print(nums[r])



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

using LL = long long;

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

    LL x;
    cin >> x;

    if(x<1200){
        cout << "ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*-----------------------------------------------,
|  __                                       __   |
| |  |--.-----.---.-.----.----.-----.-----.|  |_ |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _||
| |_____|_____|___._|____|____|_____|   __||____||
|                                   |__|         |
`-----------------------------------------------*/
#include<algorithm>
#include<array>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long ll; typedef long double ld ;using namespace std;
#define INF 1000000000000
#define MOD 10000007
#define ALL(name) (name).begin(),(name).end()
#define REP(counter, limit) for (long long counter = 0; counter < limit; counter++)
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){ios::sync_with_stdio(0);cin.tie(nullptr); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

  ll n;
  cin>>n;
  cout<<(n*(n-1))/2<<endl;

}


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

int main(void)
{
    int n, i, s[1000], k=0;
    double m, a[1000], sum;
    
    while(1){
        scanf("%d", &n);
        if(n==0) break;
        for(i=0; i<n; i++){
            scanf("%d", &s[i]);
        }
        
        //平均値を求める
        sum=0;
        for(i=0; i<n; i++){
            sum+=s[i];
        }
        m=sum/n;
        
        //標準偏差を求める
        sum=0;
        for(i=0; i<n; i++){
            sum+=pow(s[i]-m,2);
        }
        a[k]=sqrt(sum/n);
        k++;
    }
    
    for(i=0; i<k; i++){
        printf("%lf\n", a[i]);
    }
    
    return 0;
}


Measured memory_bytes: 2112
<?php
 
  
fscanf(STDIN,"%d%d",$h,$w);
$a_li = array();
for($i=0;$i<$h;$i++){
  $a = trim(fgets(STDIN));
  if($a != str_repeat(".",$w)){
    $a_li[] = $a;
  }
}

$c=0;

for($i=0;$i<$w;$i++){
  foreach($a_li as $a){
    if($a[$i] == "."){
      $c++;
    }
  }
  
  if($c==count($a_li)){
    for($j=0;$j<count($a_li);$j++){
      $a_li[$j][$i] = '@';
   	  
    }
  }
  $c=0;
}


foreach($a_li as $a){
  for($i=0;$i<strlen($a);$i++){
    if($a[$i] != '@'){
      echo $a[$i];
    }
  }
  echo "\n";
}



Measured memory_bytes: 4728
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define MODD 1000000007
#define ll long long
using namespace std;

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

    vector<int> A;
    for (int shift=0;shift<=2*N-1;shift++) {

        int ans;
        if (shift <= N-2)
            ans = N+shift;
        if (shift == N-1)
            ans = 2*N-2;
        if (shift == N)
            ans = 2;
        if (shift >= N+1)
            ans = shift-N+1;
        
        
        if (ans == x) {
            for(int i=0;i<2*N-1;i++) {
                int x = (i+shift)%(2*N-1)+1;
                A.push_back(x);
            }
            break;
        }
        
        
    }
    
    if (A.empty())
        printf("No\n");
    else {
        printf("Yes\n");
        for(int i=0;i<A.size();i++)
            printf("%d\n",A[i]);
    }
    
    
    // N+shift for shift =
    
    
    
    

    
}

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

const int MOD = 2019;

int main() {
	ios_base::sync_with_stdio(0); // making cin faster
	cin.tie(0); // making cin faster
	
	string s;
	cin >> s;
	int n = s.length();
	
	int suf = 0;
	int power_of_ten = 1;
	vector<int> cnt_suf(MOD);
	// Suf[j] - Suf[i] = 0
	long long answer = 0;
	cnt_suf[suf]++;
	
	for(int i = n - 1; i >= 0; --i) {
		int digit = s[i] - '0';
		suf = (suf + digit * power_of_ten) % MOD;
		power_of_ten = 10 * power_of_ten % MOD;
		answer += cnt_suf[suf];
		cnt_suf[suf]++;
	}
	cout << answer << "\n";
}


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

int main(){
  int N;
  cin>>N;
  int count=0;
  
  for(int i=0;i<=N;i++)
    for(int j=0;j<=N;j++)
      if(4*i+7*j==N)
        count++;
  
  if(count>0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		try {

			String str = br.readLine();
			String[] strArr = str.split(" ");

			int r = Integer.parseInt(strArr[0]);
			int c = Integer.parseInt(strArr[1]);

			int[][] set = new int[r + 1][c + 1];
			for (int i = 0; i < r; i++) {

				str = br.readLine();
				strArr = str.split(" ");

				for (int j = 0; j < c; j++) {
					set[i][j] = Integer.parseInt(strArr[j]);

					// ????¨????????¨????
					set[i][c] += set[i][j]; // ???
					set[r][j] += set[i][j]; // ???
					set[r][c] += set[i][j]; // ?????????????¨?
				}
			}

			for (int i = 0; i < set.length; i++) {
				for (int j = 0; j < set[i].length; j++) {
					System.out.print(set[i][j]);
					if (j < c)
						System.out.print(" ");
				}
				System.out.println();
			}

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (br != null) {
					br.close();
				}
			} catch (IOException ioe) {
			}

		}
	}
}

Measured memory_bytes: 25612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    string s;
    rep(i,3){
        cin>>s;
        cout<<char(s[0]-'a'+'A');
    }
    cout<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int h = s/(60*60);
        s = s%(60*60);
        int m = s/60;
        s = s%60;
        System.out.println(h + ":" + m + ":" + s);
    }
}


Measured memory_bytes: 26384
void main()
{
    long n = rdElem;

    long limit = 55555;
    auto sieve = new Prime(limit);
    long cnt;
    foreach (i; 1.iota(limit+1).stride(5))
    {
        if (sieve.isPrime(i))
        {
            i.write;
            ++cnt;
            if (cnt >= n)
            {
                writeln;
                break;
            }
            else
            {
                " ".write;
            }
        }
    }
}

struct Prime
{
    bool[] flags;

    this(long limit)
    {
        flags = makeSieve(limit);
    }

    bool[] makeSieve(long limit)
    {
        long len = (limit - 1) / 2;
        bool[] result = new bool[len];
        result[] = true;
        foreach (i; 0 .. len)
        {
            if (!result[i]) continue;

            long prime = 3 + 2 * i;
            foreach (j; iota(prime+i, len, prime))
            {
                result[j] = false;
            }
        }
        return result;
    }

    bool isPrime(long number)
    in
    {
        assert((number - 1) / 2 <= flags.length);
    }
    body
    {
        if (number < 2)
            return false;
        else if (number == 2)
            return true;
        else if (number % 2 == 0)
            return false;
        else
            return flags[(number-3)/2];
    }
}

T rdElem(T = long)()
{
    //import std.stdio : readln;
    //import std.string : chomp;
    //import std.conv : to;

    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;

dchar[] rdDchar()
{
    //import std.conv : to;

    return rdStr.to!(dchar[]);
}

T[] rdRow(T = long)()
{
    //import std.stdio : readln;
    //import std.array : split;
    //import std.conv : to;

    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    //import std.stdio : write, writeln;

    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <cctype>
#include <cstdio>
#include <iomanip>
#include <functional>
#include <stack>
#include <numeric>
#define PI 3.1415926535
#define FOR(i,n) for (int i=0; i<(n) ;i++)

using namespace std;

int r, c, t, d[100][100] = { 0 } , sum = 0;

int main(){
	cin >> r >> c;
	FOR(i, r)
		FOR(j, c) {
		cin >> t;
		d[i][j] = t;
	}
	FOR(i, r){
		FOR(j, c)
			cout << d[i][j] << " ";
		cout << accumulate(d[i], d[i] + c, 0) << endl;
	}
	FOR(i, c) {
		t = 0;
		FOR(j, r) t += d[j][i];
		cout << t << " ";
		sum += t;
	}
	cout << sum << endl;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kai(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}

int main(){
  ll X,Y;cin>>X>>Y;
  ll v,w;
  v=2*Y-X;w=2*X-Y;
  if(v%3==0&&w%3==0){
    v/=3;w/=3;
    if(v==0&&w==0)cout<<0<<endl;
    else if(v<0 ||w<0) cout<<0<<endl;
    else cout<<(  (kai(v+w)*modpow(kai(v),MOD-2,MOD))%MOD)*modpow(kai(w),MOD-2,MOD)%MOD<<endl;
  }
  else cout<<0<<endl;
  
}

  


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <tuple>
#include <set>
#include <string>

using namespace std;

#define int long long

signed main() {
	map<char, int> colorID;
	colorID.emplace('R', 0);
	colorID.emplace('Y', 1);
	colorID.emplace('B', 2);
	colorID.emplace('M', 3);
	colorID.emplace('G', 4);
	colorID.emplace('C', 5);

	while (true) {
		int n;
		cin >> n;
		if (n == 0)break;

		vector<vector<int>> colors(n, vector<int>(6));
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 6; j++) {
				string s;
				cin >> s;
				colors[i][j] = colorID[s[0]];
			}

			while (colors[i][0] != 0) {
				int zeroI = 0;
				for (; zeroI < 6; zeroI++) {
					if (colors[i][zeroI] == 0)break;
				}

				if (zeroI == 2 || zeroI == 3 || zeroI == 5) {
					swap(colors[i][3], colors[i][0]);
					swap(colors[i][0], colors[i][2]);
					swap(colors[i][2], colors[i][5]);
				}
				else {
					swap(colors[i][4], colors[i][0]);
					swap(colors[i][0], colors[i][1]);
					swap(colors[i][1], colors[i][5]);
				}
			}

			int sideMin = min(
				min(colors[i][1], colors[i][2]),
				min(colors[i][3], colors[i][4]));
			while (colors[i][1] != sideMin) {
				swap(colors[i][1], colors[i][2]);
				swap(colors[i][2], colors[i][4]);
				swap(colors[i][4], colors[i][3]);
			}
		}

		set<vector<int>> color_set;
		for (int i = 0; i < n; i++)color_set.emplace(colors[i]);

		cout << n - color_set.size() << endl;
	}
}


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

int main(){
    int a, b, c;
    cin>>a>>b>>c;
    int kazu=a*100+b*10+c;
    if(kazu%4==0){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int):
    ret = 0

    for i in range(1, int(sqrt(N)) + 1):
        m = (N-1) // i
        if m == 0:
            continue
        if (N // m) == (N % m):
            ret += m
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    result = solve(N)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()



Measured memory_bytes: 5756
#include "bits/stdc++.h"
using namespace std;
typedef pair<int,int> P;

bool operator <(const pair<int,P> &lhs,const pair<int,P> &rhs)
{
	if(lhs.first==rhs.first)
	{
		return lhs.second.first*lhs.second.second<rhs.second.first*rhs.second.second;
	}
	return lhs.first<rhs.first;
}
vector<pair<int,P> > vec;
vector<int> res;//結果
int main()
{
	int n,w,d;
	while(1)
	{
		cin>>n>>w>>d;
		if(w==0)
			break;
		vec.clear();
		res.clear();
		vec.push_back(make_pair(0,P(w,d)));
		for(int i=0;i<n;i++)
		{
			int c,s;
			cin>>c>>s;
			c--;
			//カット位置を特定する
			bool tate=true;//切る向きが縦かどうか
			while(1)
			{
				if(tate)
				{
					if(s<vec[c].second.first)
						break;
					s-=vec[c].second.first;
					tate^=true;
				}else{
					if(s<vec[c].second.second)
						break;
					s-=vec[c].second.second;
					tate^=true;
				}
			}
			if(tate)
			{
				vec.push_back(make_pair(i+1,P(s,vec[c].second.second)));
				vec.push_back(make_pair(i+1,P(vec[c].second.first-s,vec[c].second.second)));
			}else{
				vec.push_back(make_pair(i+1,P(vec[c].second.first,s)));
				vec.push_back(make_pair(i+1,P(vec[c].second.first,vec[c].second.second-s)));
			}
			vec.erase(vec.begin()+c);//元のピースを削除
			sort(vec.begin(),vec.end());
		}
		for(int i=0;i<vec.size();i++)
			res.push_back(vec[i].second.first*vec[i].second.second);
		sort(res.begin(),res.end());
		for(int i=0;i<res.size();i++)
		{
			cout<<res[i];
			if(i<res.size()-1)
				cout<<" ";
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 2992
#include <stdio.h>

long n,p;

int check(long x){
   long i,s;

   s=1;
   for (i=0;i<n;i++) {
      s*=x;
      if (s>p) return 0;
   }
   if (p%s==0) {
      p=p/s;
      return 2;
   } else
      return 1;
}

int main(){
   long i,j;
   int k;

   scanf("%ld %ld",&n,&p);
   if (n==1) {
      printf("%ld\n",p);
      return 0;
   }
   j=1;
   for (i=2;(k=check(i))>0;) 
      if (k==2) {
         j=j*i;
         i=2;
      } else if (i==2) i=3;
      else i+=2;
   printf("%ld\n",j);
   return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;
long double a, b, c, d, e, f;
long double i, j, k, l, imax, jmax, kmax, lmax;
long long tot, sugar;
long double maxim=-1, total;

int main()
{
    cin>>a>>b>>c>>d>>e>>f;
    imax=f/(100*a)+5;
    jmax=f/(100*b)+5;
    for (i=0; i<=imax; i++)
    {
        for (j=0; j<=jmax; j++)
        {
            kmax=min((i*a+j*b)*e/c, (f-100*a*i-100*b*j)/c)+5;
            lmax=min((i*a+j*b)*e/d, (f-100*a*i-100*b*j)/d)+5;
            for (k=0; k<=kmax; k++)
            {
                for (l=0; l<=lmax; l++)
                {
                    total=i*100*a+j*100*b+k*c+l*d;
                    if (total==0) continue;
                    if (total<=f && k*c+l*d<=e*(i*a+j*b))
                    {
                        if (100*(k*c+l*d)/total>maxim)
                        {
                            maxim=100*(k*c+l*d)/total;
                            tot=total;
                            sugar=k*c+l*d;
                        }
                    }
                    else
                        break;
                }
            }
        }
    }
    cout<<tot<<" "<<sugar;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <stack>
#include <queue>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  std::string s;
  std::cin >> s;

  const int n = s.size();
  const int m = 13;
  std::vector<std::vector<long long>> dp(n + 1, std::vector<long long>(m, 0));
  dp[0][0] = 1;

  for (int i = 0; i < n; ++i) {
    if (s[i] != '?') {
      // 数字の場合
      for (int k = 0; k < m; ++k) {
        dp[i + 1][(10 * k + (s[i] - '0')) % m] += dp[i][k];
        dp[i + 1][(10 * k + (s[i] - '0')) % m] %= MOD;
      }
    } else {
      // `?` の場合
      for (int v = 0; v < 10; ++v) {
        for (int k = 0; k < m; ++k) {
          dp[i + 1][(10 * k + v) % m] += dp[i][k];
          dp[i + 1][(10 * k + v) % m] %= MOD;
        }
      }
    }
  }

  std::cout << dp[n][5] << std::endl;

  return 0;
}


Measured memory_bytes: 13696
d = {}
while True:
    try:
        w, p = input().split()
        if w in d:
            d[w].append(int(p))
        else:
            d[w] = [int(p)]
    except:
        break
for k in sorted(d.items(), key=lambda x: x[0]):
    print(k[0])
    print(*sorted(k[1]))



Measured memory_bytes: 5608
n = int(input())
lists = [input() for i in range(n)]

count_ac = 0
count_wa = 0
count_tle = 0
count_re = 0

for i in lists:
    if i == 'AC':
        count_ac += 1
    elif i == 'WA':
        count_wa += 1
    elif i == 'TLE':
        count_tle += 1
    elif i == 'RE':
        count_re += 1

print('AC x ' + str(count_ac))
print('WA x ' + str(count_wa))
print('TLE x ' + str(count_tle))
print('RE x ' + str(count_re))


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

int main()
{
    int a,b;
    cin >> a >> b;
    if(a>b) cout << "a > b" << endl;
    if(a==b) cout << "a == b" << endl;
    if(a<b) cout << "a < b" << endl;
    
    return 0;
}


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

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int N = scanner.nextInt();
        int max = 0;
        int min = 100000;
        for (int i = 0; i < N; i++) {
            int a = scanner.nextInt();
            max = max(max, a);
            min = min(min, a);
        }
        System.out.println(max - min);
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {
                    line = br.readLine();
                }
                s = line.split(reg, 0);
                i = 0;
                return s[i++];
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public int nextInt() {
            try {
                return Integer.parseInt(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public double nextDouble() {
            try {
                return Double.parseDouble(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public long nextLong()  {
            try {
                return Long.parseLong(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }
    }
}


Measured memory_bytes: 21204
import java.util.Scanner;

public class Main {

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

		char[] cs = sc.next().toCharArray();
		cs[3] = '8';

		for (char c : cs) {
			System.out.print(c);
		}
		System.out.println();

		sc.close();
	}

}




Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <stack>
#include <list>

using namespace std;

typedef pair<int, int> P;

void dfs(vector<vector<P>> &tree, vector<char> &color, int now, int dis) {
  for (auto e : tree[now]) {
    if (color[e.first]) continue;
    if ((dis + e.second) % 2 == 0) {
      color[e.first] = '0';
    } else {
      color[e.first] = '1';
    }
    dfs(tree, color, e.first, dis + e.second);
  }
}

int main() {
  int n;
  cin >> n;
  vector<vector<P>> tree(n);
  int u, v, w;
  vector<char> color(n);
  for (int i = 0; i < n-1; i++) {
    cin >> u >> v >> w;
    u--;
    v--;
    P p1 = make_pair(v, w);
    P p2 = make_pair(u, w);
    tree[u].push_back(p1);
    tree[v].push_back(p2);
  }
  color[0] = '0';
  dfs(tree, color, 0, 0);
  for (auto c : color) {
    cout << c << endl;
  }
}


Measured memory_bytes: 7936
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <limits>

int main()
{
    std::string s, t, u;
    std::cin >> s >> t;
    int a{}, b{};
    std::cin >> a >> b;
    std::cin >> u;
    if (s == u) a--;
    if (t == u) b--;
    std::cout << a << ' ' << b;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
	int A, B;
	
	scanf("%d %d", &A, &B);

	if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
		printf("Possible");
	}

	else {
		printf("Impossible");
	}
}

Measured memory_bytes: 128
/// ****** Property of vipulks ****** \

#include <stdio.h>
#include <limits.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define ll long long

int main(){
	ll t,n,i,j,k,a,b;
	//double b;
	t=1;//scanf("%lld",&t);
	while(t--){
		scanf("%lld",&a);
		scanf("%lld",&b);
		ll ans=a*b;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1732
// 2012/05/14 Tazoe

#include <iostream>
#include <string>
#include <stack>
using namespace std;

int main()
{
	while(true){
		string str;
		getline(cin, str);

		if(str==".")
			break;

		stack<char> S;

		bool flg = true;
		for(int i=0; flg&&str[i]!='.'; i++){
			if(str[i]=='('){
				S.push(str[i]);
			}
			else if(str[i]=='['){
				S.push(str[i]);
			}
			else if(str[i]==')'){
				if(S.empty()||S.top()!='('){
					flg = false;
				}
				else{
					S.pop();
				}
			}
			else if(str[i]==']'){
				if(S.empty()||S.top()!='['){
					flg = false;
				}
				else{
					S.pop();
				}
			}
		}

		if(flg&&S.empty()){
			cout << "yes" << endl;
		}
		else{
			cout << "no" << endl;
		}
	}

	return 0;
}

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

int main()
{
    string *SUN,*MON,*TUE,*WED,*THU,*FRI,*SAT;
    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
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, k;
    cin >> a >> b >> k;
    for(int i = a; i >= 1; i--){
        if(a % i == 0 && b % i == 0){
            k--;
            if(k == 0){
                cout << i << '\n';
                return 0;
            }
        }
    }
}


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

using namespace std;
typedef long long ll;

int n;
int a[3];
int x;
double dp[333][333][333];
double f(int ones, int twos, int threes)
{
    if (ones + twos + threes == 0) return 0;
    double &ret = dp[ones][twos][threes];
    if (ret == ret) return ret;
    ret = 0;
    if (ones)
    {
        ret += (f(ones-1, twos, threes) + (n * 1.0 /(ones+twos+threes))) * (ones * 1.0 /(ones+twos+threes));
    }
    if (twos)
    {
        ret += (f(ones+1, twos-1, threes) + (n * 1.0 /(ones+twos+threes))) * (twos * 1.0 /(ones+twos+threes));
    }
    if (threes)
    {
        ret += (f(ones, twos+1, threes-1) + (n * 1.0 /(ones+twos+threes))) * (threes * 1.0 /(ones+twos+threes));
    }
    return ret;
}
int main()
{
    memset(dp, -1, sizeof dp);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &x), a[x-1]++;
    printf("%.12f\n", f(a[0], a[1], a[2]));

    return 0;
}


Measured memory_bytes: 288768
#include<bits/stdc++.h>
#define m 1000000007
using namespace std;

long long dp[2005];

long long done(int n){
    if(n<0){
        return 0;
    }
    if(n==0){
        return 1;
    }
    if(dp[n]!=-1) return dp[n];
    long long ans=0;
    for(int i=3; i<=n; i++){
        ans+=done(n-i);
    }
    dp[n]=(ans%m);
    return (ans%m);
}

int main(){
	int n;
	cin>>n;
	memset(dp, -1, sizeof(dp));
	cout<<done(n)<<endl;
}


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

int main() {
  string s;
  cin >> s;
  int count = 0;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == '1'){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  string S;
  cin >> S;

  string s("");
  REP(i, 0, S.size()) {
    switch (S[i]) {
      case '1':
        s += "1";
        break;
      case '0':
        s += "0";
        break;
      default:
        if (!s.empty()) {
          s.erase(s.size() - 1, 1);
        }
    }
  }
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 3656
N, M = map(int, input().split())
a_list = [int(input()) for _ in range(M)]

mod = 10 ** 9 + 7

dp = [0] * (N + 100)
dp[0] = 1
a_set = set(a_list)

for i in range(N):
    if i in a_set:
        continue
    else:
        dp[i + 1] += dp[i]
        dp[i + 1] %= mod
        dp[i + 2] += dp[i]
        dp[i + 2] %= mod

print(dp[N] % mod)


Measured memory_bytes: 13960
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
struct YPO
{
    int x;
    int y;
};
bool cmp(struct YPO a,struct YPO b)
{
    return a.x<b.x;
}
struct YPO a[100050];
int main()
{
    int n;
    scanf("%d",&n);
    int i;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i].x);
        a[i].y=i+1;
    }
    sort(a,&a[n],cmp);
    for(i=0;i<n;i++)
    {
        printf("%d",a[i].y);
        if(i!=n-1)
            printf(" ");
    }
    printf("\n");
    return 0;
}


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

#define ll long long int
#define ull unsigned long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define module 1000000007


int main(){
    IOS;
   int n,k;
   cin>>n>>k;
   int h;
   int count=0;
  
   for(int i=0;i<n;i++){
       cin>>h;
       if(h>=k){
           count++;
       }
   }
   cout<<count<<endl;
return 0;    
}


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

typedef vector<vector<long long int> > Matrix;

const long long int INF = 100000000000000;
Matrix d; // グラフの距離を格納した2次元配列（隣接行列）
		  // d[u][v]は辺e=(u,v)のコスト（辺が存在しない場合はINF、ただしd[i][i]=0）

void warshall_floyd(int n) { // nは頂点数
	for (int i = 1; i < n; i++)      // 経由する頂点
		for (int j = 1; j < n; j++)    // 開始頂点
			for (int k = 1; k < n; k++)  // 終端
				d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}



long long int e[305][305];
void warshall_floyd2(int n) { // nは頂点数
	for (int i = 1; i < n; i++)      // 経由する頂点
		for (int j = 1; j < n; j++)    // 開始頂点
			for (int k = 1; k < n; k++)  // 終端
				e[j][k] = min(e[j][k], e[j][i] + e[i][k]);
}






int main() {
	int n, m, L;
	cin >> n;

	d = Matrix(n + 1, vector<long long int>(n + 1, INF));
	
	for (int i = 0; i < n + 1; i++)
		d[i][i] = 0;

	cin >> m >> L;

	for (int i = 0; i < m; i++) {
		int from, to, cost;
		cin >> from >> to >> cost;
		if (cost <= L) {
			d[from][to] = cost;
			d[to][from] = cost;
		}
	}



	warshall_floyd(n + 1);

	for (int i = 1; i < n + 1; i++)
		for (int j = 1; j < n + 1; j++) {

			
				e[i][j] = INF;

		}


	for(int i = 1; i < n+1; i++)
		for (int j = 1; j < n + 1; j++) {

			if (d[i][j] <= L)
				e[i][j] = 1;

		}


	warshall_floyd2(n + 1);

	int Q;

	cin >> Q;

	vector<int> out;
	for (int i = 0; i < Q; i++) {

		int s, t;

		cin >> s >> t;

		if (e[s][t] != INF)
			out.push_back(e[s][t] - 1);
		else
			out.push_back(-1);

	}
	
	for (int i = 0; i < Q; i++)
		cout << out[i] << endl;

	return 0;
}

Measured memory_bytes: 2432
import math

while True:
    try:
        N = int(input())
        m = int(math.log(N, 10))

        ans = 0
        for exp in range(0, m, 2):
            ans += 9 * 10 ** exp
        
        if (m%2 == 0):
            ans += min(N, 10**(m+1)-1) - 10**m + 1
        print(ans)
            
    except:
        break

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long>a(n);
  vector<long>b(n);
  int i;
  for(i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  long ans = 0;
  for(i=n-1;i>=0;i--){
    a[i] += ans;
    if(a[i]%b[i]!=0)ans += b[i]-a[i]%b[i];
  }
  cout << ans;
}


Measured memory_bytes: 1792
n=int(input())
v=list(map(int,input().split()))
v.sort(reverse=True)
ans=0
for i in range(n):
    if i!=n-1:
        ans+=(1/2)**(i+1)*v[i]
    else:
        ans+=(1/2)**(i)*v[i]
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] ; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll n, m;
    cin >> n >> m;
    char a[n+2][m+2];
    rep(i, n+2) rep(j, m+2) a[i][j] = '#';
    rep(i, n)
    rep(j, m) cin >> a[i+1][j+1];
    printm(a, n+2, m+2);
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256