akhauriyash/Code-Regression huggingface dataset:
// ProblemURL : https://atcoder.jp/contests/abc096/tasks/abc096_d
// ---------------------------------------------
package main

import "fmt"

func isPrime(n int) bool {
	if n == 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	var n int
	fmt.Scan(&n)

	ans := make([]int, 0, n)
	for i := 1; i <= 55555; i++ {
		if i%5 == 1 && isPrime(i) {
			ans = append(ans, i)
		}
	}

	for i := 0; i < n; i++ {
		if i == n-1 {
			fmt.Printf("%d\n", ans[i])
		} else {
			fmt.Printf("%d ", ans[i])
		}
	}
}


Measured memory_bytes: 640
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;

//#[proconio::fastout]
fn main() {
    input! {
        s: Bytes,
    }

    let len = s.len();
    let a = (s.len() - 1) / 2;
    let b = (0..a).all(|i| s[i] == s[a - 1 - i] && s[i] == s[a + 1 + i] && s[i] == s[len - 1 - i]);

    println!("{}", if b { "Yes" } else { "No" });
}


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

int main() {
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0; i < S.size(); i++) {
	  if (S[i] == '0') {
		  ans++;
		}
	  else {
		  ans--;
		}
	}
  cout << S.size() - abs(ans) << endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    string s;
    cin >> s;
int n=s.length(); char a[n];
for(int i=0;i<n;i++) a[i]=s[i];
sort(a,a+n);
string ans="yes";
for(int i=0;i<n-1;i++){
if(a[i]==a[i+1]) ans="no";
}
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
S = []
for _ in range(n):
    A = list(map(int, input().split()))
    S.append(A)

Dp = [[] for _ in range(n)]


for i in range(3):
    Dp[0].append(S[0][i])

for i in range(1, n):
    #当日の選択
    for j in range(3):
        #当日選んでいない2つの選択肢に基づくDp
        New_Dp = []
        #1日前の選択
        for k in range(3):
            if j==k:
                continue
            else:
                new_dp = Dp[i-1][k] + S[i][j]
                New_Dp.append(new_dp)
        dp = max(New_Dp)
        Dp[i].append(dp)

ans = max(Dp[-1])
print(ans)

Measured memory_bytes: 47368
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

int main() {
    ll N, A;

    cin >> N >> A;

    ll res = N % 500;
    if (res <= A) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
// const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int h, n;
  cin >> h >> n;
  vt<int> a(n), b(n);
  rep(i, 0, n) cin >> a[i] >> b[i];

  vvt<int> dp(n + 1, vt<int>(h + 1, INF));
  dp[0][h] = 0;
  rep(i, 0, n) {
    for(int j = h; j >= 0; --j) {
      dp[i + 1][j] = dp[i][j];
      dp[i][max(0, j - a[i])] = min(dp[i][max(0, j - a[i])], dp[i][j] + b[i]);
    }
  }
  cout << dp[n][0] << endl;
}

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

using i64 = int64_t;
i64 INF = 1ll << 60;

void chmin(i64 &a, i64 b){
  if(a > b)
    a = b;
}

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> h(110000);
  for(int i = 0; i < n; i++)
    cin >> h[i];
  
  vector<i64> cost(110000);
  for(int i = 0; i < cost.size(); i++)
    cost[i] = INF;
  cost[0] = 0;
  
  for(int i = 0; i < n; i++){
    for(int j = 1; j <= k; j++)
      chmin(cost[i+j], cost[i]+abs(h[i]-h[i+j]));
  }
  
  cout << cost[n-1] << endl;
  
  return 0;
  
}

Measured memory_bytes: 1536
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char[] c = scanner.next().toCharArray();
        int k = scanner.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 0;i < c.length;i += k){
            sb.append(c[i]);
        }
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 22228
from sys import stdin

def main():

    input = stdin.readline

    N = int(input())

    ichi = N % 10

    if ichi == 3:
        print("bon")
    elif (ichi == 0) | (ichi == 1) | (ichi == 6) | (ichi == 8):
        print("pon")
    else:
        print("hon")

    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9124
#include<iostream>
using namespace std;
int main() {
	int n; cin >> n;
	int cnt = 1, ans = 1;
	for (int i = 0; i < n; i++) {
		int k; cin >> k;
		if (k)cnt++;
		else {
			if (cnt > ans)ans = cnt;
			cnt = 1;
		}
	}if (cnt > ans)ans = cnt;
	cout << ans << endl;
	return 0;
}


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

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

ll count(ll n, ll m) {
	if (m <= 2 * n) {
		return m / 2;
	}
	else {
		return (m - 2 * n) / 4 + n;
	}
}

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


	cout << count(n, m) << endl;
	return 0;
}

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

class saikoro
{
	private:
		int up, down, right, left, before, behind;
	public:
		saikoro(int a, int b, int c, int d, int e, int f);
		void W(void);
		void S(void);
		void E(void);
		void N(void);
		void turnrl(void);
		void turnud(void);
		int which_up(void);
		int which_right(void);
		int which_before(void);
};

int main(void)
{
	using namespace std;
	int a, b, c, d, e, f, n;
	string str;
	cin >> a >> b >> c >> d >> e >> f >> n;
	saikoro sai(a, b, c, d, e, f);
	while(n--)
	{
		int m, n;
		cin >> m >> n;
		for(int i = 0; i < 3; i++)
		{
			sai.turnud();
			if(sai.which_up() == m)
			{
				while(sai.which_before() != n)
					sai.turnrl();
				cout << sai.which_right() << endl;
				break;
			}
		}
		if(sai.which_up() != m)
		{
			sai.E();
			while(sai.which_up() != m)
				sai.turnud();
			while(sai.which_before() != n)
				sai.turnrl();
			cout << sai.which_right() << endl;
		}
	}
	return 0;
}

saikoro::saikoro(int a, int b, int c, int d, int e, int f)
{
	up = a;
	before = b;
	behind = e;
	right = c;
	left = d;
	down = f;
}

void saikoro::W(void)
{
	int temp = left;
	left = up;
	up = right;
	right = down;
	down = temp;
}

void saikoro::S(void)
{
	int temp = before;
	before = up;
	up = behind;
	behind = down;
	down = temp;
}

void saikoro::E(void)
{
	int temp = right;
	right = up;
	up = left;
	left = down;
	down = temp;
}

void saikoro::N(void)
{
	int temp = behind;
	behind = up;
	up = before;
	before = down;
	down = temp;
}

void saikoro::turnrl(void)
{
	int temp = left;
	left = before;
	before = right;
	right = behind;
	behind = temp;
}

void saikoro::turnud(void)
{
	int temp = up;
	up = before;
	before = down;
	down = behind;
	behind = temp;
}

int saikoro::which_up(void)
{
	return up;
}

int saikoro::which_right(void)
{
	return right;
}

int saikoro::which_before(void)
{
	return before;
}


Measured memory_bytes: 3112
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int A, B, K;
    cin >> A >> B >> K;

    if ((K - 1) * 2 >= B - A) {
        for (int i = A; i <= B; i++) {
            cout << i << endl;
        }
    } else {
        for (int i = A; i < A + K; i++) {
            cout << i << endl;
        }
        for (int i = B - K + 1; i <= B; i++) {
            cout << i << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int W,H,N;
    cin>>W>>H>>N;
    vector<int> x(N),y(N),a(N);
    pair<int,int> wll={0,0};
    pair<int,int> wru={W,H};
    rep(i,N){
        cin>>x.at(i)>>y.at(i)>>a.at(i);
    }
    rep(i,N){
        if(a.at(i)==1){
            wll.first=max(wll.first,x.at(i));
        }else if(a.at(i)==2){
            wru.first=min(wru.first,x.at(i));
        }else if(a.at(i)==3){
            wll.second=max(wll.second,y.at(i));
        }else if(a.at(i)==4){
            wru.second=min(wru.second,y.at(i));
        }
    }
    cout << max(0,wru.first-wll.first)*max(0,wru.second-wll.second)<<endl;
    return 0;
}

Measured memory_bytes: 256
mondai = input()

mondai = mondai.rstrip().split(" ")
kazu=[]
for i in range(3):
    if int(mondai[i])>=10:
        kazu.append(mondai[i])
        i +=1
    else:
        mondai[i]="0"+str(mondai[i])
        kazu.append(mondai[i])
        i +=1
kazu.sort(reverse=True)
#print(kazu)
sa1=int(kazu[0])-int(kazu[1])
sa2=int(kazu[0])-int(kazu[2])

if (int(kazu[1]) + int(kazu[2]))%2==0:
    print(int((int(sa1)+int(sa2))/2))
else:
    print(int((int(sa1)+int(sa2)-1)/2+2))

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

int a[100050];

void solve()
{
    int n;
    ll ans=1,m=1,sum=0;
    cin>>n;
    for(int i=0;i<=n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(n>0&&a[0]>0||n==0&&a[0]>1)
    {
        cout<<"-1\n";
        return;
    }
    for(int i=1;i<=n;i++)
    {
        m=min(m<<1,sum);
        ans+=m;
        if(a[i]>m)
        {
            cout<<"-1\n";
            return;
        }
        m-=a[i];
        sum-=a[i];
    }
    cout<<ans<<'\n';
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
#define INF LLONG_MAX

typedef long long ll;

struct Edge {
    int to;
    int cost_coin;
    int cost_time;
};

struct City {
    vector<Edge> edge;
    int ex_coin;
    int ex_time;
    ll min_time;
};

struct State {
    int station;
    int coin;
    ll time;
    bool operator>(const State &s) const { return time > s.time; }
};

int main(int, char**)
{
    int n, m, s;
    cin >> n >> m >> s;

    City cities[50];

    int u, v, a, b;
    int a_max = 0;
    for (int i = 0; i < m; i++) {
        cin >> u >> v >> a >> b;
        --u; --v;
        cities[u].edge.push_back(Edge{v, a, b});
        cities[v].edge.push_back(Edge{u, a, b});
        if (a > a_max) a_max = a;
    }
    const int COIN_MAX = a_max * (n-1);
    s = min(s, COIN_MAX);
    int c, d;
    for (int i = 0; i < n; i++) {
        cin >> c >> d;
        cities[i].ex_coin = c;
        cities[i].ex_time = d;
        cities[i].min_time = INF;
    }

    vector< vector<ll> > min_times(n, vector<ll>(COIN_MAX+1, INF)); // 頂点, 銀貨枚数ごとに最小時間を記録する変数
    min_times[0][s] = 0;
    cities[0].min_time = 0;

    priority_queue<State, vector<State>, greater<State>> que;
    que.push(State{0, s, 0});

    int next_st, next_co, next_time;
    while(!que.empty()) {
        State s = que.top();
        que.pop();
        if (min_times[s.station][s.coin] < s.time) continue;
        City c = cities[s.station];
        vector<State> next_s;
        for (Edge e : c.edge) {
            if (s.coin >= e.cost_coin) {
                next_s.push_back(State{e.to, s.coin - e.cost_coin, s.time + e.cost_time});
            }
        }
        next_s.push_back(State{s.station, min(COIN_MAX, s.coin + c.ex_coin), s.time + c.ex_time});
        for (State s : next_s) {
            if (min_times[s.station][s.coin] > s.time) {
                min_times[s.station][s.coin] = s.time;
                if (s.time < cities[s.station].min_time) cities[s.station].min_time = s.time;
                que.push(State{s.station, s.coin, s.time});
            }
        }
    }

    for (int i = 1; i < n; i++) {
        cout << cities[i].min_time << endl;
    }

    return 0;
}

Measured memory_bytes: 6212
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m; cin >> n >> m;
	vi a(m), b(m), dp(1 << n, inf);
	rep(i, m){
		cin >> a[i];
		int k, x; cin >> k;
		rep(j, k){
			cin >> x;
			b[i] |= 1 << x - 1;
		}
	}
	
	dp[0] = 0;
	rep(i, 1 << n) if(dp[i] < inf) rep(j, m) dp[i | b[j]] = min(dp[i | b[j]], dp[i] + a[j]);
	cout << (dp[(1 << n) - 1] < inf ? dp[(1 << n) - 1] : -1) << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
const long long mod=1000000007;
long long s,sum,dp[4];
int main(){
	scanf("%lld",&s);
	if(s<3){
		printf("0\n");
		return 0;
	}
	sum=1;
	for(int i=3;i<=s;++i){
		sum=(sum+dp[3])%mod;
		dp[0]=sum;
		for(int i=3;i>0;--i)dp[i]=dp[i-1];
	}
	printf("%I64d\n",dp[1]);
	return 0;
}


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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 2e5 + 5;

const int k = 40;
int n;
int a[ N ];
int MX[ N ][ k ], MN[ N ][ k ];
int lg[ N ];

void Build_Table( ) {
        for( int i = 1; i <= n; i++ ) MN[i][0] = MX[i][0] = a[i];
        for( int i = 2; i <= n; i++ ) lg[i] = lg[i/2] + 1;
        for( int j = 1; ( 1 << j ) <= n; j++ ) {
                for( int i = 1; i + ( 1 << j ) - 1 <= n; i++ ) {
                        MN[i][j] = min( MN[i][j-1] , MN[ i + ( 1 << (j-1) ) ][j-1] );
                        MX[i][j] = max( MX[i][j-1] , MX[ i + ( 1 << (j-1) ) ][j-1] );
                }
        }
}
int Q( int l , int r ) {
        if( l > r || l < 1 || r > n ) return 0;
        int k = lg[r-l+1];
        int mn = min( MN[l][k] , MN[ r - ( 1 << k ) + 1 ][k] );
        int mx = max( MX[l][k] , MX[ r - ( 1 << k ) + 1 ][k] );
        return mx;
}
int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        cin >> n;
        for( int i = 1; i <= n; i++ ) cin >> a[i];
        Build_Table();
        for( int i = 1; i <= n; i++ )
            cout << max( Q( 1 , i - 1 ) , Q( i + 1 , n ) ) <<endl;
        return 0;
}










Measured memory_bytes: 65664
//#if 1
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
//#endif
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main() {

	int H, W;
	char a[120][120];
	int flag[120][120];
	int cnt = 0, f = 0;
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> a[i][j];
			flag[i][j] = 0;
		}
	}
	
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (a[i][j] == '.')cnt++;
		}
		if (cnt == W) {
			for (int j = 0; j < W; j++) {
				flag[i][j] = 1;
			}
		}
		cnt = 0;
	}
	for (int j = 0; j < W; j++) {
		for (int i = 0; i < H; i++) {
			if (a[i][j] == '.')cnt++;
		}
		if (cnt == H) {
			for (int i = 0; i < H; i++) {
				flag[i][j] = 1;
			}
		}
		cnt = 0;
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (flag[i][j] == 0) {
				cout << a[i][j];
				f = 1;
			}
		}
		if(f==1)cout << endl;
		f = 0;
	}




	return(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string HEX = "0123456789ABCDEF";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")
 
int main(void) {
    string s,t;
    cin >> s;
    t="000111222333444555666777888999";
    Yn(t.find(s.substr(0,3))!=-1||t.find(s.substr(1,3))!=-1);
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        char[] c=fsc.next().toCharArray();
        fsc.close();
        int l=c.length;
        int ans=0;
        for(int i=0;i<l/2;i++){
            if(c[i]!=c[l-i-1]) ans++;
        }
        System.out.println(ans);
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 22996
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#else
#define debug(fmt, ...)
#endif

int dfs(vector<vector<int>>& graph, map<pii, int>& colors, int node, int parent) {
    map<int, int> used;
    if(parent != -1) {
        int c = colors[make_pair(node, parent)];
        used[c] = 1;
    }
    int idx = 1;
    for(int elem: graph[node]) {
        if(elem == parent) continue;
        while(used[idx]) { idx++; }
        // paint
        colors[make_pair(elem, node)] = idx;
        colors[make_pair(node, elem)] = idx;
        used[idx++] = 1;
        dfs(graph, colors, elem, node);
    }
    return idx;
}

int main(void) {
    int vs;
    cin >> vs;
    vector<vector<int>> graph(vs);
    int es = vs-1;
    map<pii, int> colors;
    vector<pii> edges(es);
    vector<int> deg(vs);
    for(int i = 0; i < es; i++) {
        int v1, v2;
        cin >> v1 >> v2;
        // 1-indexed -> 0-indexed
        v1--; v2--;
        graph[v1].push_back(v2);
        graph[v2].push_back(v1);
        edges[i] = make_pair(v1, v2);
        deg[v1]++;
        deg[v2]++;
    }

    dfs(graph, colors, 0, -1);
    int k = *(max_element(deg.begin(), deg.end()));
    // presentation
    cout << k << endl;
    for(int i = 0; i < es; i++) {
        cout << colors[edges[i]] << endl;
    }
    return 0;
}

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

class Dice
{
public:
	enum Pos{TOP, FRONT, RIGHT};

private:
	typedef Pos PosInfo[3];
	unsigned mFront, mBack, mLeft, mTop, mRight, mBottom;

	void RotationFromL(unsigned& a, unsigned& b, unsigned& c, unsigned& d)
	{ d=c; c=b; b=a; a=7-c; }

public:
	Dice(Pos _1=TOP, Pos _2=FRONT, Pos _3=RIGHT)
	{
		if(_1==_2 || _2==_3)
		{ _1=TOP; _2=FRONT; _3=RIGHT; }
	
		PosInfo posinfo={_1,_2,_3};
		for(int i=0; i<3; i++)
			switch(posinfo[i])
			{
			case TOP   : mBottom = 7-(mTop=i+1);    break;
			case FRONT : mBack   = 7-(mFront=i+1);  break;
			case RIGHT : mLeft   = 7-(mRight=i+1);  break;
			}
	}
	unsigned Front()const{ return mFront; }
	unsigned Back()const{ return mBack; }
	unsigned L()const{ return mLeft; }
	unsigned R()const{ return mRight; }
	unsigned T()const{ return mTop; }
	unsigned B()const{ return mBottom; }

	void ToNorth(){ RotationFromL(mTop, mBack , mBottom, mFront); }
	void ToSouth(){ RotationFromL(mTop, mFront, mBottom, mBack ); }
	void ToEast (){ RotationFromL(mTop, mRight, mBottom, mLeft ); }
	void ToWest (){ RotationFromL(mTop, mLeft, mBottom, mRight ); }
	void Turn_R (){ RotationFromL(mRight, mFront, mLeft, mBack); }
	void Turn_L (){ RotationFromL(mRight, mBack, mLeft, mFront); }
};


int main(void)
{
	string cmd;
	const string
		N("North"), E("East"), W("West"), S("South"),
		L("Left"), R("Right");

	while(1)
	{
		Dice d;
		int n, sum=1;
		cin >> n;
		if(n==0)break;
		
		for(int i=0; i<n; i++)
		{
			cin >> cmd;
			if(cmd == N)d.ToNorth();
			if(cmd == E)d.ToEast();
			if(cmd == W)d.ToWest();
			if(cmd == S)d.ToSouth();
			if(cmd == L)d.Turn_L();
			if(cmd == R)d.Turn_R();
			sum += d.T();
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
/*

*/
int main(){
  ll N,K; cin>>N>>K;
  vector<ll> A(N,0);
  rep(i,N) cin>>A[i];
  for(ll i=K; i<N; i++){
    if(A[i]>A[i-K]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

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

int main()
{
	long long n,a[3000005],b[3000005],l,r;
	cin>>n;
	
	for(int i=1;i<=n;i++)
	   cin>>a[i]>>b[i];
	   
	sort(a+1,a+n+1);
	
	sort(b+1,b+n+1);
	   
	
	if(n%2==1)
	{
		l=b[(n+1)/2];
		r=a[(n+1)/2];
	}
	else
	{
		l=(b[n/2]+b[n/2+1]);
		r=(a[n/2]+a[n/2+1]);
	}
	
	cout<<l-r+1;
	  
	return 0;
	
}

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

s = sum(a)
x = a[0]
res = abs(s - 2 * x)
for i in range(1, N - 1):
    x += a[i]
    y = s - x
    if res > abs(y - x):
        res = abs(y - x)
print(res)


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

int main(){
	int x,t=0,y;
	double p=0,q=0,PI=atan(1)*4,n;
	while(1){
		scanf("%d,%d",&x,&y);
		if(x==0&&y==0) break;
		n=(double)t*PI/180.0;
		p+=(double)x*sin(n);
		q+=(double)x*cos(n);
		t+=(int)y;
		}
	printf("%d\n%d\n",(int)p,(int)q);
	return 0;
}

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

n,m = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for _ in range(n)]

a.sort(key=lambda x: x[0])

#print(a)

c=0
ans = 0
i=0
while(c<m):
    if m-c <= a[i][1]:
        ans += (m-c)*a[i][0]
        c += m-c
    else:
        ans += a[i][1]*a[i][0]
        c+=a[i][1]
    i+=1

print(ans)
    

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr double EPS = 1e-10;
constexpr int INF = 1001001001;
//constexpr ll INF = 1001001001001001001ll;


template<class Abel> struct WUF {
    vector<int> par, rank;
    vector<Abel> diff_weight;

    WUF(int n, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }
    void init(int n, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
        }
    }

    int root(int x) {
        if (par[x] == x) return x;
        else {
            int r = root(par[x]); //ここで再帰
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    Abel weight(int x) {
        root(x); //diff_weight[x]の計算
        return diff_weight[x];
    }

    bool unite(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};


int main() {
    ll N, M;

    while (1) {
        cin >> N >> M;

        if (N == 0) break;

        WUF<ll> wuf(N);
        rep(i, M) {
            char x;
            ll a, b, w;
            cin  >> x;
            if (x == '!') {
                cin >> a >> b >> w;
                a--, b--;
                wuf.unite(a, b, w);
            }
            else {
                cin >> a >> b;
                a--, b--;
                if (wuf.same(a, b)) cout << wuf.diff(a, b) << endl;
                else cout << "UNKNOWN" << endl;
            }
        }
    }
}



Measured memory_bytes: 4384
#include <iostream>
#include <stdio.h>
//#include <math.h>

using namespace std;

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

	 int d = a / b;
	 int r = a % b;
	 double f = (double)a / (double)b;

	 printf("%d %d %lf", d, r, f);

}

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

public class Main {

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

		char letter = info.charAt(0);
		char next = (char) (letter+1);
		if(letter==122) {
			System.out.println("a");
		}else {
			System.out.println(next);
		}
	}
}


Measured memory_bytes: 21076
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
using namespace std;
 
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)

int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

const int MAX = 1000000;
bool prime[MAX];

void isPrime(){
  fill(prime,prime + MAX,true);
  prime[0] = prime[1] = false;
  rep(i,MAX){
    if(prime[i]){
      for(int j = i + i ; j < MAX ; j += i)
	prime[j] = false;
    }
  }
} 


int main(void){
  isPrime();
  int n ;

  while(cin >> n, n) {
    int ans = 0;
    for(int i = 2; i <= n/2; i++) {
      if(prime[i] && prime[n-i]) ans++;
    }
    cout << ans << endl;
  } 
}

Measured memory_bytes: 2136
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int mod=998244353;
int n,a[100001],ans;

int gcd(int a,int b) {return (!b)?a:gcd(b,a%b);} 

int main()
{
	scanf("%d",&n); ans=1;
	for (int i=1; i<=n; i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for (int i=1; i<=n; i++) ans=1ll*ans*gcd(i-1,a[i])%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
    int x,y,c;
cin>>y>>x>>c;
if((y==5&&x==5&&c==7)||(x==5&&y==7&&c==5)||(x==7&&y==5&&c==5))
cout<<"YES";
else 
cout<<"NO";

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		long n = scan.nextInt();
		long k = scan.nextInt();
		scan.close();
		
		long ans = 0;
		for(long i = k; i <= n+1; i++) {
			long max = n*(n+1)/2 - (n-i)*(n-i+1)/2;
			long min = i*(i-1)/2;
			ans += max - min + 1;
			ans %= (long)Math.pow(10, 9) + 7;
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 35864
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	ll a, t=0, ans=0;
	for(int i=0; i<n; i++){
		cin >> a;
		if(a==0){
			ans+=t/2;
			t=0;
		}else{
			t+=a;
		}
	}
	ans+=t/2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
arr = [[str(i) for i in input()] for _ in range(N)]

arr_sort = [ "".join(sorted([i for i in l])) for l in arr]

dict = {}
for i in arr_sort:
    if i in dict.keys():
        dict[i] += 1
    else:
        dict[i] = 0
        dict[i] += 1
        
ans = 0
for v in dict.values():
    ans += v * (v-1) / 2
    
print(int(ans))

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


int main(){
	int n;
	string a;
	string command;
	map<string,int> m;
	cin >> n;
	while(n--){
		cin >> command;
		if(command == "insert"){
			cin >> a;
			m.insert(map<string,int>::value_type(a,0));
		}else if(command == "find"){
			cin >> a;
			map<string,int>::iterator ma = m.find(a);
			if(ma != m.end()){
				cout << "yes"<<endl;
			}else{
				cout << "no"<<endl;
			}
		}
	}
	return 0;
}

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

int main() {
	// your code goes here
	long A = 0;
	long B = 0;
	long C = 0;
	long long K = 0;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> K;

	int res = A - B;
	if (res < 0)
	{
		res = res * -1;
	}
	long long compare = pow(10, 18);
	if (res > compare)
	{
		cout << "Unfair";
	}
	else
	{
		res = A - B;
		if (K % 2 != 0)
		{
			res = res * -1;
		}
		cout << res;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

void END(){
	cout<< -1 <<endl;
	exit(0);
}

int get(int n){
	return (n-2)*(n-1)/2;
}

vector<P>v;

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

	if(get(n)<m)END();

	int t=get(n);

	r(i,n-1){
		v.push_back(P(0,i+1));
	}

	for(int i=1;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(t==m)goto L;
			v.push_back(P(i,j));
			t--;
		}
	}

	L:;

	cout<<v.size()<<endl;
	r(i,v.size()){
		cout<<v[i].first+1<<' '<<v[i].second+1<<endl;
	}
}

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

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    vector<int> div_num;
    for (int i = 1; i <= min(A, B); i++) {
        if (A % i == 0 && B % i == 0) {
            div_num.push_back(i);
        }
    }
    cout << div_num[div_num.size() - K] << endl;
    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=(n)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

ll pri(ll num){
    if(num%2 == 0){
        return 2;
    }

    double sqrt_of_num = sqrt(num);
    for(int i=3;i<=sqrt_of_num;i+=2){
        if(num%i == 0){
            return i;
        }
    }
    return 0;
}

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

    ll x=max(a,b),y=min(a,b),z=1;
    while(z!=0){
        z=x%y;
        x=y;
        y=z;
    }

    int ans=1;
    ll p;

    while(x!=1){
        p=pri(x);
        ans++;
        if(p==0)break;
        while(x%p==0){
            x/=p;
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 2000009
#define ll long long
#define ld long double
#define ff first
#define ss second
#define inf 1000000005
#define mod 1000000007
using namespace std;
ll in[59][59], n;
struct matrix {
    int dim;
    vector<vector<ll> > a;

    matrix(int sz) {
	    dim = sz;
	    a.resize(dim);
	    for(int i=0;i<dim;i++)
            a[i].resize(dim);
	}

    void make_matrix() {
        for(int i=0;i<dim;i++) {
            for(int j=0;j<dim;j++)
                a[i][j] = in[i][j];
        }
    }
    void unit() {
        for(int i=0;i<dim;i++) {
            a[i][i] = 1ll;
        }
    }
    matrix operator* (matrix b) {
        matrix c = matrix(dim);
        for(int i=0;i<dim;i++) {
            for(int j=0;j<dim;j++) {
                for(int k=0;k<dim;k++) {
                    c.a[i][j] = (c.a[i][j] + a[i][k] * b.a[k][j]) % mod;
                }
            }
        }
        return c;
    }
};

matrix bin_pow(matrix a, ll k) {
    if(k == 1ll)
        return a;
    matrix res = bin_pow(a, k / 2);
    res = res * res;
    if(k & 1ll)
        res = res * a;
    return res;
}
ll ans;
ll k;
int main() {
    cin>>n>>k;
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            cin>>in[i][j];
        }
    }
    matrix a = matrix(n);
    a.make_matrix();
    matrix temp = bin_pow(a, k);
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            ans += temp.a[i][j];
            ans %= mod;
        }
    }
    cout<<ans;
}


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

int main(){
    int n;
    int k;
    cin >> n >> k;
    vector <int> h(n);
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    sort(h.begin(),h.end());
    int min = 2000000000;
    for(int i=0;i<=n-k;i++){
        if(min > (h[i+k-1] - h[i])){
            min = h[i+k-1] - h[i];
        }    
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		
		while (true) {
			int h = sc.nextInt(); int w = sc.nextInt();
			if (h==0 && w==0) return;
			
			for (int i=0; i<h; i++) {
				StringBuilder sb = new StringBuilder();
				for (int j=0; j<w; j++) {
					if ((i!=0&&i!=h-1) && (j!=0&&j!=w-1)) sb.append(".");
					else sb.append("#");
				}
				System.out.println(sb);
			}
			
			System.out.println();
		}
		
	}
}


Measured memory_bytes: 29028
N, M = map(int,input().split())

lst = [0] * N

flag = False
for i in range(M):
    a, b = map(int,input().split())
    if a == 1:
        if lst[b-1] == 1:
            flag = True
        else:
            lst[b-1] = 1
    if b == N:
        if lst[a-1] == 1:
            flag = True
        else:
            lst[a-1] = 1

if flag:
    print ('POSSIBLE')
else:
    print ('IMPOSSIBLE')
    




Measured memory_bytes: 4596
N = int(input())
remarks = []
for i in range(N):
    w = []
    for j in range(int(input())):
        w.append(list(map(int, input().split())))
    remarks.append(w)

def power2(n):
    if n == 1:
        return [[1], [0]]
    res = []
    for l in power2(n-1):
        res.append([1] + l)
        res.append([0] + l)
    return res

ans = 0
patterns = power2(N)
for p in patterns:
    flag = True
    for i, remark in enumerate(remarks):
        if p[i] == 0: #不親切者の発言を無視
            pass
        else:
            for w in remark:
                if p[w[0]-1] != w[1]: #発言の矛盾を判定:
                    flag = False 
                    break
                # print(w)
    if flag: #すべての発言で矛盾がなかった場合
        ans = max(ans, p.count(1))

print(ans)
    


Measured memory_bytes: 12660
#include<stdio.h>

int main(){
		int n,i,csf[500][3],j;
		scanf("%d",&n);
		for(i=0;i<n-1;i++)scanf("%d%d%d",&csf[i][0],&csf[i][1],&csf[i][2]); 
		for(j=0;j<n-1;j++){
				long t=0;
				for(i=j;i<n-1;i++){
						if(t<csf[i][1])t=csf[i][1];
						if(t%csf[i][2]!=0)t+=csf[i][2]-t%csf[i][2];
						t+=csf[i][0];
				}
				printf("%ld\n",t);
		}
		puts("0");
		return 0;
}


Measured memory_bytes: 128
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }


int main(){
    string S;

    cin>>S;
    int size = S.size();
    int r=0;

    rep(i, size){
        if(i%2){
            if (S[i]=='1') {
                ++r;
            }
        }else
        {
            if (S[i]=='0') {
                ++r;
            }
        }
        
    }


    cout<<min(r, size-r)<<endl;
    return 0;
    

}

Measured memory_bytes: 512
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    double s = 0;
    foreach (_; 0..N) {
        auto xu = readln.split;
        auto x = xu[0].to!double;
        if (xu[1] == "JPY") {
            s += x;
        } else {
            s += x * 380000.0;
        }
    }
    writefln("%0.8f", s);
}

Measured memory_bytes: 256
n = int(input())
from operator import itemgetter
sset = set()
sp = [list(input().split()) + [i+1] for i in range(n)]
for i in range(n):
    sp[i][1] = int(sp[i][1])
for i in range(n):
    sset.add(sp[i][0])
sp.sort(key = itemgetter(1),reverse = True)
slist = sorted(list(sset))
anslist = []
for i in range(len(sset)):
    for j in range(n):
        if sp[j][0] == slist[i]:
            anslist.append(sp[j][2])

for ans in anslist:
    print(ans)


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

vector<int> to[101010];
const int INF = 100000000;
int main(){
    int n, m;
    cin >> n >> m;
    int a, b;
    rep(i, m){
      cin >> a >> b;
      a--; b--;
      to[a].push_back(b);
      to[b].push_back(a);
    }

  queue<int> q;
  vector<int> d(n, INF);
  vector<int> par(n, -1);
  d[0] = 0;
  q.push(0);
  while(q.size()){
    int qq = q.front(); q.pop();
    for(int u : to[qq]){
      if(d[u] != INF){
        continue;
    }else{
      d[u] = d[qq] + 1;
      par[u] = qq;
      q.push(u);
    }
  }
  }
  cout << "Yes" << endl;
  rep(i, n){
    if(i == 0) continue;
    int ans = par[i];
    ans++;
    cout << ans << endl;
  }

}


Measured memory_bytes: 10748
//
// Created on 2020/03/28.
//

//#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int ans;
    int k,n;
    cin>>k>>n;


    int MAX = 0;
    int last ;
    int next ;
    cin>>last;
    int first = last;

    for (int i = 1; i < n; ++i) {
        cin>>next;
        MAX = max(abs(next-last),MAX);
        last = next;
    }

    MAX = max(abs((k-last)+first),MAX);
    ans = k-MAX;


    cout<<ans<<endl;
}


Measured memory_bytes: 256
/**
 * @Author: yujirotakahashi
 * @Date:   2020-05-17T20:21:41+09:00
 * @Last modified by:   yujirotakahashi
 * @Last modified time: 2020-05-18T01:04:41+09:00
 */

#include<bits/stdc++.h>
using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
//const ll INF = (1LL << 60);
//const double pi=acos(-1.0);
using ll = long long;
using PAIR = pair<int, int>;
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
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; }
/**************************************/

/******** User-defined Function *******/



/**************************************/

/********** Main()  function **********/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int q; cin >> q;
  vector<int> m(q);
  rep(i,q) cin >> m[i];

  map<ll,int> mp;
  for(int i=0; i<(1<<n); ++i){
      ll tmp = 0;
      rep(j,n){
          if(i & (1<<j)) tmp += a[j];
      }
      mp[tmp]++;
  }

  rep(i,q){
      if(mp[m[i]]) cout << "yes" << endl;
      else cout << "no" << endl;
  }

  return 0;
}
/********  Main() Ends Here *************/



Measured memory_bytes: 3184
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <math.h>
#include <stack>
#include <cmath>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for (int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    ios::sync_with_stdio(NULL);
    cin.tie(NULL); cout.tie(NULL);
    int n;  cin >> n;
    string A, B, ans;
    cin >> A >> B;
    Rep(i,0,n){
       ans += A[i];
       ans += B[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())


def solve(N):
    count = math.ceil(math.sqrt(N * 2))
    if count * (count - 1) != N * 2 or N == 2:
        return []

    ans = [[] for _ in range(count)]
    a = 1
    for i in range(count):
        for j in range(count - 1 - len(ans[i])):
            ans[i].append(a)
            ans[i + 1 + j].append(a)
            a += 1

    return ans


ans = solve(N)
if ans:
    print('Yes')
    cnt = len(ans)
    print(cnt)
    for r in ans:
        print(cnt - 1, *r)
else:
    print('No')


Measured memory_bytes: 9396