akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int,int> pii;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=(int)(n);v>=0;v--)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":"\n");return os;}
//------------------------------------------------------------------------------

signed main() {
    string s;
    cin>>s;
    int n=s.size();
    int ans=0;
    for(int i=0; i<(1<<(n-1)); i++) {
        string t="";
        int sum=0;
        REP(j,n-1) {
            t.push_back(s[j]);
            if(((1<<j)&i)!=0) {
                int k=stol(t);
                sum+=k;
                t="";
            }
        }
        t.push_back(s[n-1]);
        sum+=stol(t);
        ans+=sum;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	int n,N,sum=0;
	string s;
	cin >> n;
	N = n;
	s = to_string(n);

	for (int i = 0; i < s.length(); i++) {
		sum += n % 10;
		n /= 10;
	}
	cout << (N % sum == 0 ? "Yes" :"No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#define mod 1000000007
using namespace std;

int main()
{
    int m,n,o,i,j,k;
    //long long int m,n,o,i,j,k,len=0;
    //vector <int> v;
    //float f,g,h;
    //char c,d;
    string a;
    cin>>n;
    if(n%2!=0)
    {
        cout<<0;
        return 0;
    }
    int *num=new int [n];
    //cin>>m>>c>>n>>d>>i;
    //cin>>f>>g;
    //cin>>c;
    for(i=0;i<n;i++) cin>>num[i];
    sort(num,num+n);
    cout<<num[n/2]-num[n/2-1];
    delete [] num;
    return 0;
}



Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

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

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

ll dp[1<<21];

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

  int n; cin >> n;
  bool mat[n][n];
  rep(i, n) rep(j, n) cin >> mat[i][j];
  int s = 1<<n;
  rep(i, s) dp[i] = 0;
  dp[0] = 1;
  for(int i=1; i<s; i++) {
    //debugln(i);
    int j = __builtin_popcount(i);
    rep(k, n) {
      int r = 1<<k;
      //debug(i); debug(r); debugln(j-1);
      if ((i & r) && mat[j-1][k]) {
        dp[i] += dp[i ^ r];
        dp[i] %= mod;
        //debug(i); debugln(dp[i]);
      }
    }
  }
  cout << dp[s-1] << endl;
}


Measured memory_bytes: 16640
import java.util.Scanner;

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

    if (s.equals("Sunny")) {
      System.out.println("Cloudy");
    } else if (s.equals("Cloudy")) {
      System.out.println("Rainy");
    } else if (s.equals("Rainy")) {
      System.out.println("Sunny");
    }
  }
}

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

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

    int num = 1;
    for(int i=0; i<n; i++){
        num = min(2*num, num+k);
    }
    cout << num << endl;
    
    return 0;
}


Measured memory_bytes: 256
//2019/3/12
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int M = sc.nextInt();

		long[][] AB = new long[N][2];

		long A,B;

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

				A = sc.nextLong();

				AB[i][0] = A;

				B = sc.nextLong();

				AB[i][1] = B;
		}

		Arrays.parallelSort(AB,(a,b) -> Long.compare(a[0],b[0]));

		long ans = 0;

		long x = 0;

		int index = 0;

		while(x<M) {

			if(x+AB[index][1]<=M) {

				ans += (AB[index][0]*AB[index][1]);

				x += AB[index][1];

			}else {

				for(int i=0;x<M;i++) {

					ans += AB[index][0];

					x++;

				}

			}

			index++;
		}

		System.out.println(ans);
	}

}


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

#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++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n;
    cin >> n;
    int a[n] = {};
    rep(i, n)
    {
        int t;
        cin >> t;
        a[t]++;
    }
    if (a[0] >= 2)
    {
        OP(0);
        return 0;
    }
    for (int i = 1; i < n; i++)
    {

        if (a[i] > 2)
        {
            OP(0);
            return 0;
        }
    }
    int sum = 1;
    for (int i = 1; i <= int(n / 2); i++)
    {
        sum = (sum * 2) % int(1e9 + 7);
    }
    OP(sum);

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

typedef struct {
	int start,end;
	int next;
} card_t;

int card_num;
card_t cards[10010];

int main(void) {
	int n,m;
	int p,q,r;
	int x,y;
	int i,j,rest,status;
	int cut1,cut2,cut3,temp;
	int start,end,count;
	while(1) {
		scanf("%d",&n);
		if(n==0)break;
		scanf("%d",&m);
		scanf("%d%d%d",&p,&q,&r);
		cards[0].start=0;
		cards[0].end=-1;
		cards[0].next=1;
		cards[1].start=1;
		cards[1].end=n;
		cards[1].next=0;
		card_num=2;
		for(i=0;i<m;i++) {
			scanf("%d%d",&x,&y);
			for(j=cards[0].next,rest=x;j>0;j=cards[j].next) {
				rest-=cards[j].end-cards[j].start+1;
				if(rest==0) {
					cut1=j;
					break;
				} else if(rest<0) {
					cards[card_num].start=cards[j].end+rest+1;
					cards[card_num].end=cards[j].end;
					cards[card_num].next=cards[j].next;
					cards[j].end=cards[j].end+rest;
					cards[j].next=card_num;
					card_num++;
					cut1=j;
					break;
				}
			}
			if(j<=0)return 1;/* bug */
			for(j=cards[j].next,rest=y-x;j>0;j=cards[j].next) {
				rest-=cards[j].end-cards[j].start+1;
				if(rest==0) {
					cut2=j;
					break;
				} else if(rest<0) {
					cards[card_num].start=cards[j].end+rest+1;
					cards[card_num].end=cards[j].end;
					cards[card_num].next=cards[j].next;
					cards[j].end=cards[j].end+rest;
					cards[j].next=card_num;
					card_num++;
					cut2=j;
					break;
				}
			}
			if(j<=0)return 1;/* bug */
			for(j=cards[j].next;j>0;j=cards[j].next) {
				if(cards[j].next==0)cut3=j;
			}
			temp=cards[0].next;
			cards[0].next=cards[cut2].next;
			cards[cut3].next=cards[cut1].next;
			cards[cut2].next=temp;
			cards[cut1].next=0;
		}
		status=0;rest=p;count=0;
		for(j=cards[0].next;j>0;j=cards[j].next) {
			rest-=cards[j].end-cards[j].start+1;
			if(status==0) {
				if(rest==0) {
					status=1;
					if(cards[j].end<=r)count++;
					rest=q-p;
				} else if(rest<0) {
					status=1;
					start=cards[j].end+rest;
					end=cards[j].end;
					if(end>r)end=r;
					if(start<=end)count+=end-start+1;
					rest+=q-p;
				}
			} else if(status==1) {
				if(rest<=0) {
					status=2;
					start=cards[j].start;
					end=cards[j].end+rest;
					if(end>r)end=r;
					if(start<=end)count+=end-start+1;
				} else {
					start=cards[j].start;
					end=cards[j].end;
					if(end>r)end=r;
					if(start<=end)count+=end-start+1;
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll INF = 1e10;
ll MOD = 1e9 + 7;
void add(ll &a, ll b)
{
    a = (a+b)%MOD;
}
int main()
{
    string s;
    cin >> s;

    int n = s.size();
    vector<ll> one(n);
    one[0] = 1;
    for(int i = 1; i < n; i++)
    {
        one[i] = one[i-1] * 3 % MOD;
    }
    vector<ll> two(n+1);
    two[0] = 1;
    for(int i = 1; i <= n; i++)
    {
        two[i] = two[i-1] * 2 % MOD;
    }

    ll ans = 0;
    int count = 0;
    for(int i = 0; i < n; i++)
    {
        if(s[i] == '0') continue;
        add(ans, two[count] * one[n-1-i] % MOD);
        count++;
    }
    add(ans, two[count]);
    cout << (ans+MOD) % MOD << endl;
}


Measured memory_bytes: 2048
s = input()[::-1]
len_s = len(s)
start, end = 0,5
ans = "YES"
while end <= len_s:
  if s[start:end] == "maerd" or s[start:end] == "esare":
    start += 5
    end += 5
  elif s[start:end+1] == "resare":
    start += 6
    end += 6
  elif s[start:end+2] == "remaerd":
    start += 7
    end += 7
  else:
    ans = "NO"
    break
print(ans)
    

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

bool checkPrime(int );

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    cin>>x;
    while(!checkPrime(x)){
        x++;
    }
    cout<<x<<"\n";
    return 0;
}

bool checkPrime(int a)
{
    for(int i=2; i<sqrt(a); i++){
        if(a%i==0)
            return false;
    }
    return true;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
int n, x[200010], a[200010];
int main() {
	scanf("%d", &n);
	for(int i=1; i<=n; i++) {
		scanf("%d", x+i);
		a[i] = x[i];
	}
	sort(a+1, a+n+1);
	for(int i=1; i<=n; i++) {
		int idx = lower_bound(a+1, a+n+1, x[i]) - a;
		if(idx <= n / 2) printf("%d\n", a[n/2+1]);
		else printf("%d\n", a[n/2]);
	}
	return 0;
}

Measured memory_bytes: 3712
N = int(input())
x = []
y = []
for num in range(N):
  li = input()
  ubah = li.split(" ")
  x.append(int(ubah[0]))
  y.append(int(ubah[1]))

sum = 0
for i in range(N):
    for j in range(1+i,N):
        dist = ((x[i]-x[j])**2+(y[i]-y[j])**2)**0.5
        sum += dist*2/N
print(sum)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int intW = scan.nextInt();
		int intH = scan.nextInt();
		int intX = scan.nextInt();
		int intY = scan.nextInt();
		int intR = scan.nextInt();
		if(intX <= intW - intR && intR <= intX && intY <= intH - intR && intR <= intY){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17304
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int solve(int v) {
  if (v == 1)
    return 300000;
  else if (v == 2)
    return 200000;
  else if (v == 3)
    return 100000;
  else
    return 0;
}

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

  int x, y;
  cin >> x >> y;

  int ans = solve(x);
  ans += solve(y);
  if (x == 1 && y == 1)
    ans += 400000;
  cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
mone=1000
kabu=0
for i in range(n-1):
  if a[i]<=a[i+1]:
    kabu+=mone//a[i]
    mone%=a[i]
  else:
    mone+=kabu*a[i]
    kabu=0
mone+=kabu*a[-1]
print(mone)

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n, t;
  cin >> n >> t;
  int it = -1;
  int ans = 0;
  rep(i, 0, n) {
    int k;
    cin >> k;
    if(it <= k) ans += t;
    else ans += (k + t) - it;
    it = k + t;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#define w vector
#define z double
#define q int
#include<iostream>
#include<vector>
#include<algorithm>
#include<limits>
using namespace std;z inf=numeric_limits<z>::infinity();q main(){q n,m,r;cin>>n>>m>>r;w<w<z>>d=w<w<z>>(n,w<z>(n,inf));w<q>v;for(q i=0;i<r;i++){q l;cin>>l;v.push_back(l-1);}
sort(v.begin(),v.end());

for(q i=0;i<m;i++){
q a,b,c;
cin>>a>>b>>c;
d[a-1][b-1]=c;
d[b-1][a-1]=c;
}

for(q k=0;k<n;k++)for(q i=0;i<n;i++)for(q j=0;j<n;j++){d[i][j]=min(d[i][j],d[i][k]+d[k][j]);}
long min_dist=1e9;
do{long dist=0;
for(q i=0;i<v.size()-1;i++)dist+=d[v[i]][v[i+1]];
min_dist=min(min_dist,dist);}while(next_permutation(v.begin(),v.end()));cout<<min_dist<<endl;}


Measured memory_bytes: 512
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt(), M = cin.getInt();
    let A = cin.getIntArray(M);
    let P = new Array(M-1);
    A.sort((a, b) => a - b);
    let ans;
    if (N == 1) ans = A[M-1] - A[0];
    else if (N == M) ans = 0;
    else {
        for (let n = 0; n < M-1; n++) P[n] = A[n+1] - A[n];
        P.sort((a, b) => b - a);
        for (let n = 0; n < N-1; n++) P.shift();
        ans = P.reduce((ac, v) => ac + v, 0);
    }
    console.log(ans);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 27408
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray
    val N = sc.nextInt(); sc.nextLine()
    val S = sc.nextLine()
    val R = S.map(c => alphabets((alphabets.indexOf(c) + N) % 26)).mkString
    println(R)
  }

}

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

/** Problem0046 : Differential **/

int main()
{
	double max, min, input;
	cin >> max; min = max;
	
	while (cin >> input) {
		if (max < input)
			max = input;
		else if (min > input)
			min = input;
	}
	
	cout << max - min << endl;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int match_A,match_Z;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'Z'){
            match_Z = i;
        }
        if(s[s.length() - i - 1] == 'A'){
            match_A = s.length() - i - 1;
        }
    }
    cout << match_Z - match_A + 1 << endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int L = Integer.parseInt(S[1]);
    List<String> list = new ArrayList<>();
    for(int i = 0; i < N; i++){
      list.add(sc.nextLine());
    }
    Collections.sort(list);
    String ans = "";
    for(int i = 0; i < N; i++){
      ans = ans + list.get(i);
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 26324
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int N = 2100;

int n;
string s;

vector<int> eds[N];

const int INF = 1e9;

using tp = array<int, 3>;

tp dfs1(int v, int p) {
	vector<tp> vv;
	int sml = 0;
	int sm = 0;
	if (s[v] == '1')
		vv.push_back({0, 0, 1}), sm += 1;
	for (int u: eds[v]) {
		if (u == p)
			continue;
		tp go = dfs1(u, v);
		go[0] += go[2];
		go[1] += go[2];
		sml += go[0];
		sm += go[2];
		vv.push_back(go);
	}
	sort(ALL(vv));
	reverse(ALL(vv));
	if (vv.empty()) {
		return {0, 0, 0};
	}
	int cur = vv[0][1];
	for (int i = 1; i < vv.size(); ++i)
		cur -= vv[i][0];
	if (sml % 2 == 1)
		cur = max(cur, 1);
	else
		cur = max(cur, 0);
	return {sml, cur, sm};
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.precision(20);
	cin >> n;
	cin >> s;
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		eds[a].push_back(b);
		eds[b].push_back(a);
	}
	int ans = INF;
	for (int i = 0; i < n; ++i) {
		vector<pair<int, int>> vv;
		int sm = 0;
		for (int u: eds[i]) {
			tp go = dfs1(u, i);
			go[0] += go[2];
			go[1] += go[2];
			sm += go[0];
			vv.push_back({go[0], go[1]});
		}
		if (sm % 2 == 1)
			continue;
		sort(ALL(vv));
		reverse(ALL(vv));
		int cur = vv[0].second;
		for (int j = 1; j < vv.size(); ++j)
			cur -= vv[j].first;
		if (cur <= 0)
			ans = min(ans, sm / 2);
	}
	if (ans < INF)
		cout << ans << "\n";
	else
		cout << -1 << "\n";
	return 0;
}




Measured memory_bytes: 640
#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define endl "\n"
#define mod 1000000007
typedef map<ll, ll> mpll;
typedef map<vector<ll>, ll> mpvl;
int main()
{
  
 int a,b;
 cin>>a>>b;
 if(b>=a)
 {
     cout<<"unsafe";
 }
 else
 {
     cout<<"safe";
 }
 



}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  int c=b/2;
  if(a>=0&&a<=5){
    printf("0");
  }
  if(a>=6&&a<=12){
    printf("%d",c);
  }
  if(a>=13&&a<=100){
    printf("%d",b);
  }
  return 0;
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := nextInt()
	K := nextInt()
	S := nextString()
	prv := string(S[0])
	ch := 0
	sw := 0
	for i := 1; i < N; i++ {
		if prv == string(S[i]) {
			ch += 1
			continue
		} else {
			prv = string(S[i])
			sw += 1
		}
	}
	sw += 1
	fmt.Println(Min(ch+2*Min(sw, K), N-1))

}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

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

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

func MinA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Min(s, v)
	}
	return s
}

func MaxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Max(s, v)
	}
	return s
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1000000007;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mmax=1000009;

//解説
int main(void){
    int n;
    cin>>n;
    long long takahashi=1,aoki=1;
    rep(i,n){
        long long t,a;
        cin>>t>>a;
        long long nt=(takahashi+t-1)/t;
        long long na=(aoki+a-1)/a;
        long long n=max(nt,na);
        takahashi=n*t;
        aoki=n*a;
        //cout<<takahashi<<" "<<aoki<<endl;
    }
    cout<<takahashi+aoki<<endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int n,a[100][100];

int suit(char h)
{
    if (h=='S') return 1;
    else
        if (h=='H') return 2;
        else
            if(h=='C') return 3;
            else return 4;
}

int suitch(int k)
{
    if (k==1) return 'S';
    else
        if(k==2) return 'H';
        else
            if (k==3) return 'C';
            else return 'D';
}

int main()
{
    
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        char h;
        int x;
        cin>>h>>x;
        int k=suit(h);
        a[k][x]=1;
    }
    for(int i=1;i<=4;i++)
        for(int j=1;j<=13;j++)
            if (a[i][j]==0)
            {
                char ch=suitch(i);
                cout<<ch<<" "<<j<<endl;
            }
}



Measured memory_bytes: 3092
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7


def main():
    x = int(input())
    c = x //100
    v = x % 100
    #print(c, v)
    if v <= c * 5 and v >= 0:
        print(1)
    else:
        print(0)



    


if __name__ == '__main__':
    main()


Measured memory_bytes: 5600
#include<stdio.h>
int main()
{
    int a,b,ca=0,cb=0,i,sum=0,j;
    while(scanf("%d %d",&a,&b)!=EOF)
    {
        j=b-a-1;
        for(i=1;i<=j ; i++)
        {
            sum+=i;
        }
        sum=sum-a;
        printf("%d\n",sum);
        sum=0;
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

struct mint {
    LL x; // typedef long long LL;
    mint(LL x=0):x(x%mod){}
    mint& operator+=(const mint a) {
      if ((x += a.x) >= mod) x -= mod;
      return *this;
    }
    mint& operator-=(const mint a) {
      if ((x += mod-a.x) >= mod) x -= mod;
      return *this;
    }
    mint& operator*=(const mint a) {
      (x *= a.x) %= mod;
      return *this;
    }
    mint operator+(const mint a) const {
      mint res(*this);
      return res+=a;
    }
    mint operator-(const mint a) const {
      mint res(*this);
      return res-=a;
    }
    mint operator*(const mint a) const {
      mint res(*this);
      return res*=a;
    }
    mint pow(LL t) const {
      if (!t) return 1;
      mint a = pow(t>>1);
      a *= a;
      if (t&1) a *= *this;
      return a;
    }

    // for prime mod
    mint inv() const {
      return pow(mod-2);
    }
    mint& operator/=(const mint a) {
      return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
      mint res(*this);
      return res/=a;
    }
  };

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<PII> ar;
    REP(i,N){
        int a; cin >> a;
        ar.eb(a,0);
    }
    REP(i,N){
        int b; cin >> b;
        ar.eb(b,1);
    }
    sort(ar.begin(),ar.end());
    int cnt[2] = {};

    mint ans = 1;
    for(auto p : ar){
        if(p.second == 0){
            if(cnt[1] > 0){
                ans *= cnt[1];
                cnt[1]--;
            }else{
                cnt[0]++;
            }
        }else{
            if(cnt[0] > 0){
                ans *= cnt[0];
                cnt[0]--;
            }else{
                cnt[1]++;
            }
        }
        dump(ans.x)
    }
    cout << ans.x << endl;

}


Measured memory_bytes: 2420
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <sstream> //C++
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
#include <map> //C++

using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)



/*
int N, i;
int H[100];
scanf("%d", &N);
for (i = 0; i < N; i++) scanf("%s", &H[i]);
*/



int main()
{
	
    long long int  x;

	cin >> x;

	long long int i=1;
	
	double count = 100;

	while (count < x) {
		
		count = (long long int)(count*1.01);
		
		i++;

		
	}


	cout << i-1;
	return 0;





	




	

}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<ll, ll> > vp;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define vin(n, d) rep(i, 0, n) cin >> d[i];
#define out(n) cout << (n) << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


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

  if(n == 1 || a > b) {
    out(a == b ? 1 : 0)
    return 0;
  }

  if(n == 2) {
    out(1)
    return 0;
  }

  out((b - a) * (n - 2) + 1)
}


Measured memory_bytes: 256
def numeric_naming(N,M):
    result = []
    added_number = 1

    while N > 0 :
        result.append(0)
        if added_number == 0:
            result[-1] -= 1

        added_number = N % M

        result[-1] += added_number
        
        if result[-1] < 0:
            result[-1] = M -1 
        if result[-1] == 0:
            result[-1] = M
            added_number = 0

        N = N // M

    if result[-1] == M:
        del result[-1]

    result.reverse()
    print(''.join([chr(i + 96) for i in result]))


M = 26
numeric_naming(int(input()),M)


Measured memory_bytes: 9084
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 100005
using namespace std;
int n,m,cnt[M];
int ex[M],ey[M],rev[M];
int fa[M],c[M];
bool vis[M];
vector<pair<int,int>> e[M];

vector<int> dfs(int cur) {
    vis[cur] = true;
    
    vector<int> res;
    if (cnt[cur]%2) res.push_back(cur);
    for (auto i:e[cur]) if (!vis[i.first]) {
        fa[i.first] = i.second;
        auto tmp = dfs(i.first);
        res.insert(res.end(), tmp.begin(), tmp.end());
    }

    while ((int)res.size() >= 2) {
        int x = res.back(); res.pop_back();
        int y = res.back(); res.pop_back();
        c[x]++;
        c[y]++;
    }
    return res;
}
int dfs2(int cur) {
    int res = c[cur];
    for (auto i:e[cur]) if (i.second == fa[i.first]) {
        res += dfs2(i.first);
    }
    if (res%2) rev[fa[cur]] = 1;
    return res;
}

int main()
{
    while (~scanf("%d %d", &n, &m)) {
        MSET(cnt, 0);
        MSET(c, 0);
        MSET(rev, 0);
        MSET(vis, false);
        REP(i,0,n) e[i].clear();

        REP(i,1,m) {
            int x,y;
            scanf("%d %d",&x,&y);
            e[x].push_back({y, i});
            e[y].push_back({x, i});
            ex[i] = x;
            ey[i] = y;
            rev[i] = 0;
            cnt[x]++;
        }

        if (m%2 == 1) {
            puts("-1");
            continue;
        }

        dfs(1);
        dfs2(1);
        REP(i,1,m) {
            if (rev[i]) printf("%d %d\n",ey[i],ex[i]);
            else printf("%d %d\n",ex[i],ey[i]);
        }

    }
    return 0;
}


Measured memory_bytes: 20224
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
       Scanner scan= new Scanner(System.in);
       int a[][][] = new int[4][3][10];
       int n=scan.nextInt();
       for(int i=0;i<n;i++){
           int b=scan.nextInt();
           int f=scan.nextInt();
           int r=scan.nextInt();
           int v=scan.nextInt();

           a[b-1][f-1][r-1]+=v;
       }

       for(int i=0;i<4;i++){
           for(int j=0;j<3;j++){
               for(int k=0;k<10;k++){
                   System.out.print(" "+a[i][j][k]);
               }
               System.out.println();
           }
           if(i<3){
               System.out.println("####################");
           }
       }
    }
}



Measured memory_bytes: 29556
#include<bits/stdc++.h>
using namespace std;
const int M=100017;
bool book[510][510];
int n,m,a[M],b[M];
bool vis[510];
int main(){
    cin>>n>>m; 
    for(int i=1;i<=m;i++){
    	cin>>a[i]>>b[i];
	}
    for(int i=1;i<=n;i++){
        book[i][i]=1;
        for(int j=m;j>=1;j--){
            bool x=book[i][a[j]],y=book[i][b[j]];
            if(x&&y){
				vis[i]=1;
				break;
			}
            else if(x){
            	book[i][b[j]]=1;
			}
            else if(y){
            	book[i][a[j]]=1;
			}
        }
    }
    int ans=0;
    for(int i=1;i<n;i++){
        if(vis[i]){
        	continue;
		}
        for(int j=i+1;j<=n;j++){
            if(vis[j]){
            	continue;
			}
            bool flag=1;
            for(int k=1;k<=n;k++){
            	if(book[i][k]&&book[j][k]){
            		flag=0;
				}
			}
            ans+=flag;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1280
n, m = map(int, input().split())
k = []
a = []
ans = [0] * m
for i in range(n):
    ka = list(map(int, input().split()))
    k += [ka[0]]
    del ka[0]
    a += [ka]
for i in range(n):
    for j in range(k[i]):
        ans[int(a[i][j]) - 1] += 1
count = 0
for i in range(m):
    if ans[i] == n:
        count += 1
print(count)

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

const ll INF = 1LL << 60;

// i: 何桁目か
// j: 繰り下がりがあるかどうか
ll dp[10100100 + 10][2];

string S;
ll N;
int main() {
    cin >> S;

    reverse(S.begin(), S.end());
    S += '0';

    N = S.size();

    rep(i, N + 1)rep(j, 2) dp[i][j] = INF;
    dp[0][0] = 0;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 2; j++) {
            int x = S[i] - '0';

            // 遷移
            for (int a = 0; a <= 9; a++) {
                int ni = i + 1, nj = 0;
                int b = (a - j) - x;
                if (b < 0) {
                    nj = 1;
                    b += 10;
                }

                dp[ni][nj] = min(dp[ni][nj], dp[i][j] + a + b);
            }
        }
    }

    cout << dp[N][0] << endl;
}

Measured memory_bytes: 20024
#define NDEBUG

#include <cstdio>

#include <vector>
#include <queue>
#include <cstdint>
#include <cassert>
#include <tuple>

template<typename t> t inf() { assert(0); return t(); }
template<> double inf() { return (1LL << 50); }
template<> long inf() { return (1LL << 50); }
template<> int inf() { return (1LL << 31)-1; }

namespace Graph {
  template<typename tEdge>
  struct Graph {
    Graph() : v(0) {}
    std::vector<tEdge> edges;
    uint32_t v;
  };
  template<typename tEdge>
  void addEdge(Graph<tEdge>& graph, tEdge edge) {
    assert( edge.from < graph.v );
    assert( edge.to   < graph.v );
    graph.edges.push_back(edge);
  }
  template<typename tEdge>
  void setV(Graph<tEdge>& graph, uint32_t v) {
    graph.v = v;
  }
};

namespace Graph {
  namespace Dijkstra {
    template<typename tEdge>
    struct DijkstraInfo {
      std::vector<typename tEdge::wType> dists;
    };
    template<typename tEdge>
    static DijkstraInfo<tEdge> dijkstra(const Graph<tEdge>& graph, uint32_t start) {
      std::vector< std::pair<uint32_t, typename tEdge::wType> > *adj = new std::vector< std::pair<uint32_t, typename tEdge::wType> >[graph.v];
      int n = graph.edges.size();
      for(uint32_t i = 0; i < graph.v; ++i) adj[i].reserve(16);
      for(int i = 0; i < n; ++i) {
        adj[graph.edges[i].from].push_back(std::make_pair(graph.edges[i].to, graph.edges[i].w));
      }
      DijkstraInfo<tEdge> info;
      info.dists.resize(graph.v);
      for(auto &x : info.dists) x = inf<typename tEdge::wType>();
      info.dists[start] = 0;
      std::priority_queue< std::pair<typename tEdge::wType, uint32_t> > q;
      q.push(std::make_pair(0, start));
      while( not q.empty() ) {
        typename tEdge::wType w;
        uint32_t id;
        std::tie(w, id) = q.top(); q.pop(); w = -w;
        for(auto I : adj[id]) {
          uint32_t next;
          typename tEdge::wType nw;
          std::tie(next, nw) = I; nw += w;
          if( info.dists[next] <= nw ) continue;
          info.dists[next] = nw;
          q.push(std::make_pair(-nw, next));
        }
      }
      delete [] adj;
      return info;
    }
  };
};


struct Edge {
  uint32_t from;
  uint32_t to;
  typedef int wType;
  wType w;
};

int main() {
  Graph::Graph<Edge> graph;
  int v, e, r;
  scanf("%d %d %d", &v, &e, &r);
  setV(graph, v);
  for(int i = 0; i < e; ++i) {
    Edge edge;
    scanf("%u %u %d", &edge.from, &edge.to, &edge.w);
    addEdge(graph, edge);
  }
  auto res = Graph::Dijkstra::dijkstra(graph, r);
  int n = res.dists.size();
  for(int i = 0; i < n; ++i) {
    printf("%s\n", res.dists[i] == inf<int>() ? "INF" : std::to_string(res.dists[i]).c_str());
  }
  
  return 0;
}

Measured memory_bytes: 25928
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

//ここから編集 
ll N, K; 
vector<ll> a(200010);
using  ld = long double;
bool C(ll x){

  ll cnt = 0;
  for(int i=0; i<N; i++){
    if(a[i]%x == 0){
      cnt += a[i]/x-1;
    }else{
      cnt += a[i]/x;
    }
  }

  if(cnt <= K) return true;
  return false;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  
  cin >> N >> K;
  
  REP(i,N) cin >> a[i];

  int lb = 0, ub = 1e9;
  for(int i=0; i<100; i++){
    int mid = (lb+ub)/2;
    if(mid != 0 && C(mid)){
      ub = mid;
    }else{
      lb = mid;
    }
  }
  cout << ub << endl;
  return 0;
}


Measured memory_bytes: 4700
#include<bits/stdc++.h>
using namespace std;
#define int long long
string s[8];
int ng[8][8];
bool flg;
void dfs(int r){
  if(r==8){
    flg=true;
    return;
  }
  for(int c=0;c<8;c++){
    if(s[r][c]=='Q'){
      dfs(r+1);
      return;
    }
  }
  for(int c=0;c<8;c++){
    if(ng[r][c]) continue;
    s[r][c]='Q';
    for(int j=0;j<8;j++){
      if(r+j<8 ) ng[r+j][c]++;
      if(r-j>=0) ng[r-j][c]++;
      if(c+j<8 ) ng[r][c+j]++;
      if(c-j>=0) ng[r][c-j]++;
      if(r+j<8 &&c+j<8 ) ng[r+j][c+j]++;
      if(r-j>=0&&c+j<8 ) ng[r-j][c+j]++;
      if(r-j>=0&&c-j>=0) ng[r-j][c-j]++;
      if(r+j<8 &&c-j>=0) ng[r+j][c-j]++;
    }
    dfs(r+1);
    if(flg) return;
    s[r][c]='.';
    for(int j=0;j<8;j++){
      if(r+j<8 ) ng[r+j][c]--;
      if(r-j>=0) ng[r-j][c]--;
      if(c+j<8 ) ng[r][c+j]--;
      if(c-j>=0) ng[r][c-j]--;
      if(r+j<8 &&c+j<8 ) ng[r+j][c+j]--;
      if(r-j>=0&&c+j<8 ) ng[r-j][c+j]--;
      if(r-j>=0&&c-j>=0) ng[r-j][c-j]--;
      if(r+j<8 &&c-j>=0) ng[r+j][c-j]--;
    }
  }
}
signed main(){
  for(int i=0;i<8;i++) s[i]=string(8,'.');
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int r,c;
    cin>>r>>c;
    s[r][c]='Q';
    for(int j=0;j<8;j++){
      if(r+j<8 ) ng[r+j][c]++;
      if(r-j>=0) ng[r-j][c]++;
      if(c+j<8 ) ng[r][c+j]++;
      if(c-j>=0) ng[r][c-j]++;
      if(r+j<8 &&c+j<8 ) ng[r+j][c+j]++;
      if(r-j>=0&&c+j<8 ) ng[r-j][c+j]++;
      if(r-j>=0&&c-j>=0) ng[r-j][c-j]++;
      if(r+j<8 &&c-j>=0) ng[r+j][c-j]++;
    }
  }
  dfs(0);
  for(int i=0;i<8;i++) cout<<s[i]<<endl;
  return 0;
}



Measured memory_bytes: 3160
# https://atcoder.jp/contests/abc060/tasks/arc073_b
# 典型的なナップサック。だけど配列が大きいので素直に実装するとTLEになる
# 成約により、w1以上は必ず前のjを見ることに注意するとテーブルのサイズがぐっと減ることに気がつくがこれを実装するのはなかなかめんどくさそう。
# defaltdictを利用した再帰メモ化なら比較的実装可能では？

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret


N, W = read_ints()
w, v = read_col(N, 2)

from collections import defaultdict
dp = defaultdict(lambda: -1)


def f(i, j):  # i番目を含んで考慮したとき重さjまでで達成できる価値の最大値
    if dp[i, j] != -1:
        return dp[i, j]
    if i == -1:
        return 0
    if j - w[i] < 0:
        return f(i - 1, j)

    ret = max(f(i - 1, j - w[i]) + v[i], f(i - 1, j))
    dp[i, j] = ret
    return ret


print(f(N - 1, W))


Measured memory_bytes: 20884
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint(), M = getint();
	bool A[100001] = {};
	rep(i, M + M) A[getint()] ^= true;
	bool ikeru = true;
	rep1(i, N) if (A[i]) ikeru = false;
	
	if (ikeru) co("YES");
	else co("NO");

	Would you please return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
  long long n,k;
  cin>>n>>k;
  vector<int>vec(n,10000000);
  for(int i=0;i<n;i++)
  {
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  long long ans=0;
  for(int i=0;i<k;i++)
  {
    ans+=vec.at(i);
  }
  cout<<ans<<endl;
}

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

int main(){
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[0] << " " << a[1] << " " << a[2] << endl;

	return 0;
}

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

int main(){
	int h,w;
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0 && w==0) break;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(i==0||i==h-1||j==0||j==w-1) printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

struct Point {
    double x, y;
};

void koch(int n, Point a, Point b) {
    if (n == 0) return;

    Point s, t, u;
    double th = M_PI * 60.0 / 180.0;

    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n - 1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n - 1, t, b);
}

int main() {
    Point a, b;
    int n;

    cin >> n;

    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);
}



Measured memory_bytes: 3160
#include <stdio.h>
#include <string.h>
 char x[1000];
 char *q;
    int y[1000];
    int n,i,j;
  int main(void){
   scanf("%d\n",&n);
   for(i=0;i<n;i++){
        gets(x);
        while(strstr(x,"Hoshino") != NULL){
		q=strstr(x,"Hoshino");
		q[6]='a';
		}
		puts(x);
   }
return 0;
}      

Measured memory_bytes: 1020
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int K;
    int S;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        K = sc.nextInt();
        S = sc.nextInt();
    }
    
    //解答処理
    private int solve() {
        int count = 0;
        
        for (int x=0; x<=K; x++){
        	for (int y=0; y<=K; y++) {
        		int z = S - x - y;
        		if (0<=z && z<=K && x+y+z == S) {
        			count++;
        		}
        	}
        }
        
        return count;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }
}


Measured memory_bytes: 35320
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin >>N;
	vector<int> h(N);
	vector<int> dp(N);
	for(int i = 0; i<N; i++){
		cin >> h[i];
	} 
	
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	for(int i = 2; i<N; i++){
		dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
	}
	cout << dp[N-1];
}

Measured memory_bytes: 1024
import Data.IORef
import Control.Monad
 
main :: IO()
main = getLine >> getContents >>= solve.map read.lines >>= print
 
solve :: [Int] -> IO Int
solve (x:y:xs) = do
                   a <- newIORef (y - x)
                   b <- newIORef (min x y)
                   forM_ xs $ \z -> do
                     a' <- readIORef a
                     b' <- readIORef b
                     when (z - b' > a') $ writeIORef a (z - b')
                     when (z < b')      $ writeIORef b z
                   readIORef a

Measured memory_bytes: 5528
fun main(args: Array<String>) {
    apc001a()
}

fun apc001a() {
    val (x, y) = readLine()!!.split(' ').map { it.toLong() }

    if (x % y == 0L) return println(-1)

    for (i in x..(1e18).toLong() step x) if (i%y!=0L) return println(i)

    println(-1)
}


Measured memory_bytes: 38168
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int x,y;
  cin>>x>>y;
  for(int crane=0;crane<=100;crane++){
    for(int turtle=0;turtle<=100;turtle++){
      int sum=crane+turtle;
      int legs=2*crane+4*turtle;
      if(x==sum && y==legs){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3632
from itertools import combinations

input = open(0).read

Sn = [i[0] for i in input().split() if i[0] in "MARCH"]
st = set(Sn)


def main():

    print(
        sum(x * y * z for x, y, z
            in combinations([Sn.count(s) for s in st], 3)))

    return


main()


Measured memory_bytes: 10864
#include<stdio.h>
#include<string.h>
int main()
{
	int N, M;
	char s[100][11] = {}, t[100][11] = {};
	int i, j;

	//	input
	scanf("%d", &N);
	for ( i = 0; i < N; i++)
	{
		scanf("%s", &s[i]);
	}
	scanf("%d", &M);
	for ( i = 0; i < M; i++)
	{
		scanf("%s",&t[i]);
	}

	int counter;
	int point = 0;
	for ( i = 0; i < N; i++)
	{
		counter = 1;
		for ( j = i+1; j < N; j++)
		{
			if (strcmp(s[i],s[j])==0)
			{
				counter++;
			}
		}
		for ( j = 0; j < M; j++)
		{
			if (strcmp(s[i],t[j])==0)
			{
				counter--;
			}
		}
		if (counter > point)
		{
			point = counter;
		}
	}
	printf("%d", point);
	return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <map>
#include <stack>
using namespace std;

#define null -1

void DFS(vector<int> rVal[], map<int, int> &uColor_m, int idOrSs) {
	stack<int> stack;
	stack.push(idOrSs);
	uColor_m[idOrSs] = idOrSs;

	while (!stack.empty()) {
		int curUVal = stack.top();
		stack.pop();
		for (int i = 0; i < (signed)rVal[curUVal].size(); i++) {
			int curV = rVal[curUVal][i];
			if (uColor_m[curV] != null) continue;
			uColor_m[curV] = idOrSs;
			stack.push(curV);
		}
	}
}

void assignColor(int uNum, vector<int> rVal[], map<int, int> &uColor_m) {
	for (int i = 0; i < uNum; i++)
		uColor_m[i] = null;
	for (int i = 0; i < uNum; i++) {
		if (uColor_m[i] == null) DFS(rVal, uColor_m, i);
	}
}

int main() {
	int userNum;
	int relationNum;
//	int uColor_map[100000]; //<?????????, ??°??????????????????>
//	map<int, int> uColor_m;
	map<int, int> uColor_m;
	//??????????????¨????????????
	vector<int> relationVal[100000];
	//int userColor[100000];

	cin >> userNum >> relationNum;
	for (int i = 0; i < relationNum; i++) {
		int userVal1, userVal2;
		cin >> userVal1 >> userVal2;
		relationVal[userVal1].push_back(userVal2);
		relationVal[userVal2].push_back(userVal1);
		uColor_m[i] = null;
	}

	assignColor(userNum, relationVal, uColor_m);

	int qNum;
	cin >> qNum;
	for (int i = 0; i < qNum; i++) {
		int uV1, uV2;
		cin >> uV1 >> uV2;
		if (uColor_m[uV1] == uColor_m[uV2])
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 13296