akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <limits>

using namespace std;

#define ll long long

#define in(x) cin >> x
#define out(x) cout << x << endl

#define PI acos(-1)
#define pp push_back

#define Yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define No cout << "No" << endl
#define NO cout << "NO" << endl

#define vec2(type) vector<vector<type>>
#define vec3(type) vector<vector<vector<type>>>

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

template<typename T> void input(T *data, int n){
	For(i, n){
		cin >> data[i];
	}
}

template<typename T> void input(vector<T> &vec, int n){
	T temp;
	For(i, n){
		cin >> temp;
		vec.push_back(temp);
	}
}

template<typename T> void sort(vector<T> &ary){
	sort(ary.begin(), ary.end());
}

template<typename T> void rsort(vector<T> &ary){
	sort(ary.rbegin(), ary.rend());
}

void rstring(string &str){
	string temp = str;

	For(i, (int)str.size()){
		str[i] = temp[(str.size() - 1) - i];
	}
}

struct Vec{
	int x, y;
	Vec():
	x(0), y(0){}
	Vec(int _x, int _y):
	x(_x), y(_y){}
};

template<typename T> void print(T *x, int n){
	For(i, n){
		cout << x[i] << " ";
	}
	cout << endl;
}

template<typename T> void print(vector<T> &x){
	For(i, (int)x.size()){
		cout << x[i] << " ";
	}
	cout << endl;
}

int gcd(int n, int m){
	if(n % m == 0){
		return m;
	}
	else{
		return gcd(m, n % m);
	}
}

int main(){

	int H, W, h, w;

	cin >> H >> W >> h >> w;

	out(H * W - h * W - H * w + h * w);

	return 0;

}

Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int N;
    cin >> N;

    ll count_1 = 0;
    ll count_2 = 0;
    ll count_4 = 0;

    vector<ll> A(N);
    FOR(i, 0, N){
        ll a;
        cin >> a;
        if(a%4==0){
            count_4++;
        }
        else if(a%2==0){
            count_2++;
        }
        else{
            count_1++;
        }
    }

    if(count_2 > 0){
        // 2^1は先に全部並べて使ってしまう
        // その次に2^2から始める
        if(count_4 >= count_1){
            p_yes();
        }else{
            p_no();
        }
    }
    // 2^1がないとき、1, 4, 1, 4 .. と並べる
    else{
        if(count_4 >= count_1 - 1){
            p_yes();
        }else{
            p_no();
        }
    }
    
    return 0;
}

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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return result;
}

const ll M=1e9+7;

int32_t main()
{
    IOS

    ll n;
    cin>>n;
    bool mat[n][n];
    for(ll i=0;i<n;i++)
    	for(ll j=0;j<n;j++)
    		cin>>mat[i][j];
    
    vector<ll> dp((1LL<<n),0);
    dp[0]=1;
    
    for(ll mask=1;mask < (1<<n);mask++)
    {
        ll id=__builtin_popcountll(mask);

        for(ll i=0;i<n;i++)
        {
        	if(((mask>>i) & 1) && mat[id-1][i])
        		dp[mask]=(dp[mask] + dp[mask^(1LL<<i)])%M;
        }
    }

    ll ans=dp[(1LL<<n)-1];
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 19572
from fractions import gcd
n, m = map(int, input().split())
s = input()
t = input()
#一文字目が違うと無理
gcd_n_m = gcd(n,m)
if gcd_n_m == 1 and s[0] == t[0]:
    print(n*m)
else:
    step_s = n // gcd_n_m
    step_t = m // gcd_n_m
    index_s = 0
    index_t = 0
    while index_s < n and index_t < m:
        if s[index_s] != t[index_t]:
            print(-1)
            exit()
        index_s += step_s
        index_t += step_t
    print(n*m//gcd_n_m)


Measured memory_bytes: 65260
import java.util.Scanner;
import java.lang.Math;

public class Main {
    private static final int maxn = 111;
    private static int[][] a = new int[3][maxn], f = new int[3][maxn];
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for (int i = 1; i <= 2; ++i) for (int j = 1; j <= n; ++j) a[i][j] = in.nextInt();
        for (int i = 1; i <= 2; ++i) for (int j = 1; j <= n; ++j)
            f[i][j] = Math.max(f[i - 1][j], f[i][j - 1]) + a[i][j];
        System.out.println(f[2][n]);
    }
}

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

using namespace std;
typedef long long ll;

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

    if(a < k){
        ll diff = k - a;
        a = 0;
        b -= diff;   
    }else{
        a -= k;   
    }
    
    if(a < 0){
        a = 0;
    }
    if(b < 0){
        b = 0;
    }
    cout << a << " " << b << endl;

}

Measured memory_bytes: 256
import java.util.*;

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

		while(true){
			int n = sc.nextInt();
			if(n == 0) break;

			/* ツ妥ヲツ暗ェツ段ツ階ツづ個計ツ算 */
			HashSet<Integer> first = new HashSet<Integer>();
			for(int i=1;i<n;i++){
				first.add(i*i%n);
			}

			/* ツ妥ヲツ禿ア,ツ三ツ段ツ階ツづ個計ツ算 */
			int max = (n-1) / 2;
			int[] count = new int[max+1];
			for(int x : first){
				for(int y : first){
					if(x == y) continue;

					int diff = x - y;
					if(diff <= 0) diff += n;
					if(diff > max) diff = n - diff;
					count[diff]++;
				}
			}
			
			for(int i=1;i<=max;i++){
				System.out.println(count[i]);
			}
		}
	}
}

Measured memory_bytes: 13000
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	int p[1010] = {};
	for (int n, m; cin >> n >> m&&n;) {
		memset(p, 0, sizeof(p));
		int ans = 0;
		rep(i, 0, n) { cin >> p[i]; ans += p[i]; }
		sort(p, p + n);
		for (int i = n%m; i < n; i += m) {
			ans -= p[i];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define lc tree[pos].ch[0]
#define rc tree[pos].ch[1]
using namespace std;

inline int read()
{
    char ch=getchar();
    int x=0;bool f=1;
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
        f=false;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return f?x:-x;
}
pair<int,int> a[100005];
int n,b[100005],ans1,ans2;
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	a[i].first=read(),a[i].second=i;
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		if(i&1)
		ans1+=a[i].second%2!=i%2;
		else
		ans2+=a[i].second%2!=i%2;
	}
	printf("%d\n",max(ans1,ans2));
}

Measured memory_bytes: 1024
n = input()
length = len(n) - 1
for i in range(2 ** length):
    op = ["-"] * length
    for j in range(length):
        if ((i >> j) & 1):
            op[length - 1 - j] = "+"
    ans = ""
    for p_n, p_o in zip(n, op + [""]):
        ans += (p_n + p_o)
    if eval(ans) == 7:
        print(ans + "=7")
        break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define rep(i, n) for (int (i) = 0; (i) < n; (i)++)
#define until(x) while (!x)
#define fail(s) assert(!s)
#define ULL unsigned long long
const int INF = 0x3f3f3f3f;
const int EPS = 1e-6;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	cout << max(c - (a - b), 0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 1234567890123456
typedef pair<lb, int> P;
typedef pair<int, P> PP;

const int maxn =1e3 + 10;

//initialization here
//

//
//initialization finish


// your function is here
//

//
// your function finished



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here
	//
	int n; cin >> n;
	Print(n / 3);
	//
	// your code finished


	return 0;
}

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

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

#define NMAX (100001)
vector<pair<int, int> > T[NMAX];
bool colored[NMAX] = { false };
int ans[NMAX];

void BFS(int node)
{
	int current, next, w;
	queue<int> Q;

	Q.push(node);
	ans[node] = 0;
	colored[node] = true;

	while (!Q.empty())
	{
		current = Q.front(); Q.pop();
		
		rep(i, (int)T[current].size()) {
			next = T[current][i].first;
			w = T[current][i].second;
			if (colored[next]) continue;

			Q.push(next);
			if (w % 2 == 0) ans[next] = ans[current];
			else ans[next] = 1 - ans[current];
			colored[next] = true;
		}
	}
}

int main()
{
	int N, u, v, w;

	cin >> N;
	rep(i, N - 1) {
		cin >> u >> v >> w;
		T[u].push_back(make_pair(v, w));
		T[v].push_back(make_pair(u, w));
	}

	BFS(1);

	repc(i, 1, N) cout << ans[i] << endl;

	return 0;
}

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


int main() {
  char S[21];
  rep(i,20)cin >> S[i];
  rep(i,3)cout << S[i];
  cout << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void) {
  int n;
  cin >> n;
  vector<LL> a(n);
  for(auto &x: a) cin >> x;
  bool flag = false;
  for(auto x: a) if(x<0) flag = !flag;
  for(auto &x: a) x = abs(x);
  sort(a.begin(),a.end());
  if(flag) a[0]*=-1;
  LL answer = 0;
  for(auto x: a) answer+=x;
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
int a[1000123];
int n;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    int mx=-1;
    int mn=10000000000;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        mx = max(mx, a[i]);
        mn = min(mn, a[i]);
    }
    if(mx - mn >= 2){
        cout << "No";
        return 0;
    }
    if(mx == mn){
        bool good = 1, good2 = 1;
        for(int i = 1; i <= n; i++){
            if(2 * a[i] > n){
                good = 0;
            }
            if(n - 1 != a[i]){
                good2 = 0;
            }
        }
        if(!good&&!good2){
            cout << "No";
            return 0;
        }
        cout << "Yes";
        return 0;
    }
    int x = 0;
    int y = 0;
    for(int i = 1; i <= n; i++){
        if(a[i] == mn){
            x++;
        }
        else{
            y++;
        }
    }
    if(x + 1 <= mx && mx <= x + y / 2){
        cout << "Yes";
        return 0;
    }
    cout << "No";
    return 0;
    }


Measured memory_bytes: 640
N, C = list(map(int, input().split()))

D = []

for i in range(N):
    D.append(list(map(int, input().split())))

R = [[0, 0] for i in range(N + 1)]
cnt = 0
ma = 0
rma = 0
R[0][0] = -1
for i in range(N):
    cnt += D[i][1]
    if cnt - D[i][0] > ma:
        ma = cnt - D[i][0]
    if cnt - D[i][0] * 2 > rma:
        rma = cnt - D[i][0] * 2
    R[i + 1] = [ma, rma]

cnt = 0
Ans = R[N][0]
tmp = 0
for i in range(N - 1, -1, -1):
    cnt += D[i][1]
    tmp = C - D[i][0]
    tmp2 = cnt - tmp * 2 + R[i][0]
    tmp2 = max(tmp2, cnt - tmp + R[i][1])
    if tmp2 > Ans:
        Ans = tmp2

print(Ans)


Measured memory_bytes: 79960
# -*- coding: utf-8 -*-
# input
#a = int(input())
#a = input()
a, b, c, d = map(int, input().split())
#a, b, c = input().split()
o = 0
for i in range((d//a)+1):
    for j in range(((d-a*i)//b)+1):
        if (d-a*i-b*j) % c == 0:
            o += 1
# output
print(o)

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

using namespace std;

int main()
{
    long long int n,ar[100000],i,j,br[3],c=0;
    cin>>n;
    for (i=0;i<n;++i){

        cin>>ar[i];

    }
    for (i=0;i<=(n-3);++i){

        br[0]=ar[i];
        br[1]=ar[i+1];
        br[2]=ar[i+2];
        sort(br,br+3);
        if(br[1]==ar[i+1])++c;

    }

    cout<<c<<endl;

    return 0;


}


Measured memory_bytes: 256
#include <stdio.h>

int main() {

  int n,m,i,j;
  int a,b;
  int A[100][100] = {0};
  int B[100] = {0};
  int c[100] = {0};

  scanf("%d %d " ,&n,&m);

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

  for(j=0; j<m; j++) {
    scanf("%d",&b);
    B[j] = b;
  }

  for(j=0;j<n ; j++){ 
  for(i = 0; i<m; i++){
     c[j] = c[j] + A[j][i]*B[i];
    }
  }

  for(i=0;i<n;i++) {
    printf("%d\n",c[i]);
  }
  return 0;
}




Measured memory_bytes: 2804
n,m=map(int,input().split())
x=list(map(int,input().split()))
ans=0
x.sort()
y=[0]*(m-1)
for i in range(m-1):
  y[i]=x[i+1]-x[i]
y.sort()
y=y[:max(0,m-n)]
print(sum(y))

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

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end(), greater<long long>());
	long long ans = a[0];
	multiset<long long> s;
	s.insert(-a[1]);
	s.insert(-a[1]);
	for (int i = 2; i < n; i++) {
		ans += -*s.begin();
		s.erase(s.begin());
		s.insert(-a[i]);
		s.insert(-a[i]);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 14280
n = gets.chomp.to_i
 a = gets.chomp.split(' ').map(&:to_i)
 sum = 1
 
 for i in 1..n do
  if(a[i-1] == 0)
   sum = 0
  end
 end
 
 a.each{|num|
   sum *= num
   if(sum > 10 ** 18)
     sum = -1
     break
   end
 }
 
 puts sum


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

using namespace std;

const int P = 1000000007;

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

	vector<bool> mark;
	mark.assign(n + 1, false);

	vector<int> pri;

	for(int i = 2; i <= n; ++i) {
		if(!mark[i]) {
			pri.emplace_back(i);
		}	

		for(int j = i; j <= n; j += i) {
			mark[j] = true;
		}

	}

	vector<int> cnt;
	cnt.resize(pri.size());

	for(int i = 1; i <= n; ++i) {
		int t = i;
		
		for(int j = 0; j < pri.size(); ++j) {
			while(t % pri[j] == 0) {
				t /= pri[j];
				++cnt[j];
			}
		}

	}

	long long ans = 1;

	for(auto x : cnt) {
		ans = ans * (x + 1) % P; 
	}

	cout << ans << '\n';

	return 0;

}


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

#define int long long

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

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; }


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    while(true)
    {
        int m, f, r; cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) break;
        else if(m == -1 || f == -1) cout << 'F' << endl;
        else if(m+f >= 80) cout << 'A' << endl;
        else if(65 <= m+f) cout << 'B' << endl;
        else if(50 <= m+f) cout << 'C' << endl;
        else if(30 <= m+f && 50 <= r) cout << 'C' << endl;
        else if(30 <= m+f) cout << 'D' << endl;
        else cout << 'F' << endl;
    }
}


Measured memory_bytes: 3120
/*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2006&lang=jp
Keitai Message
*/

package main

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

// 標準入力を取得するScannerのインスタンスを作成
var scanner = bufio.NewScanner(os.Stdin)

// 標準入力で各行を読み込みstringとして返す
func readLine() string {
	if scanner.Scan() {
		return scanner.Text()
	}
	return ""
}

func main() {
	// 1: . , ! ? (スペース)
	// 2: a b c
	// 3: d e f
	// 4: g h i
	// 5: j k l
	// 6: m n o
	// 7: p q r s
	// 8: t u v
	// 9: w x y z
	// 0: 確定ボタン

	// 改行から空白区切りに変更
	scanner.Split(bufio.ScanWords)
	line, _ := strconv.Atoi(readLine()) // 5行標準入力が続く

	table := []string{
		"",      // 0 index調整ためダミーデータ
		".,!? ", // 1
		"abc",   // 2
		"def",   // 3
		"ghi",   // 4
		"jkl",   // 5
		"mno",   // 6
		"pqrs",  // 7
		"tuv",   // 8
		"wxyz"}  // 9

	// 5行分の標準入力を格納するsliceを作成する
	messages := make([]string, 0, line)

	// sliceに標準入力の内容を格納する
	for i := 0; i < line; i++ {
		messages = append(messages, readLine()) // messages=[20 220 222220 44033055505550666011011111090666077705550301110 000555555550000330000444000080000200004440000]
	}

	// 各行毎に解析する
	for _, message := range messages { // message=000555555550000330000444000080000200004440000
		// 0で分割する
		messageSlice := strings.Split(message, "0") // messageSlice=[   55555555    33    444    8    2    444    ]
		for _, word := range messageSlice {
			if word == "" {
				// NOP.
				// 0をセパレーターにしているので空文字がsliceに格納されてい箇所がある
				// 何もしない
			} else { // word=55555555
				// 一文字取り出しコード値をASCII文字に変換する
				ascii := string((word[0])) // word[0]=5

				// ASCII文字からintへ変換する(tableのindexになる)
				number, _ := strconv.Atoi(ascii)

				// 入力回数をカウントする
				count := len(word) // 5

				// 同じ数字を続けて入力すると変化する文字はループすることを考慮する
				for count > len(table[number]) { // 5 > 3
					count -= len(table[number]) // 2
				}

				// キー配列
				keys := table[number]                   //jkl
				fmt.Printf("%s", string(keys[count-1])) //k
			}
		}
		fmt.Println() // 改行
	}
}



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

int main() {
    std::vector<int> v(3);
    int k;
    cin >> v.at(0) >> v.at(1) >> v.at(2) >> k;
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    while(k > 0) {
        v.at(0) *= 2;
        k--;
    }
    cout << v.at(0) + v.at(1) + v.at(2) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int N=2e5+4;
const ll MOD=1000000007;
int n;
map<pair<ll,ll>,int> mp;
int cnt[N];
bool vis[N];
int tot;
pair<ll,ll> p[N];
ll ans=1;
inline ll gcd(ll a,ll b) {
	return !b?a:gcd(b,a%b);
}
inline ll fpow(ll a,ll b) {
	ll ret=1;
	while (b) {
		if (b&1) ret=ret*a%MOD;
		b>>=1,a=a*a%MOD;
	}
	return ret;
}
int main() {
//	freopen("in1.txt","r",stdin);
	scanf("%d",&n);
	for (register int i=1;i<=n;++i) {
		ll x,y;
		scanf("%lld%lld",&x,&y);
		if (x==0&&y) y=1;
		else if (y==0&&x) x=1;
		else if (x&&y) {
			ll d=gcd(x,y);
			x/=d,y/=d;
			if (x<0&&y>0) x=-x,y=-y;
		}
		pair<ll,ll> cur=make_pair(x,y);
		if (!mp.count(cur)) {
			p[++tot]=cur;
			mp[cur]=tot;
			cnt[tot]=1;
		} else ++cnt[mp[cur]];
	}
	for (register int i=1;i<=tot;++i) {
		if (vis[i]||(!p[i].first&&!p[i].second)) continue;
		pair<ll,ll> cur=p[i];
		ll x=cur.first,y=cur.second,fac=fpow(2,cnt[i]);
		ll x1=-y,y1=x;
		if (x1==0) y1=1;
		else if (y1==0) x1=1;
		else if (x1<0&&y1>0) x1=-x1,y1=-y1;
		pair<ll,ll> rev=make_pair(x1,y1);
		if (mp.count(rev)) {
			vis[mp[rev]]=true;
			fac=(fpow(2,cnt[i])+fpow(2,cnt[mp[rev]])-1)%MOD;
		} else {
			fac=fpow(2,cnt[i]);
		}
		(ans*=fac)%=MOD;
	}
	pair<ll,ll> nul=make_pair(0,0);
	if (mp.count(nul)) (ans+=cnt[mp[nul]])%=MOD;
	printf("%lld\n",(ans-1+MOD)%MOD);
	return 0;
}

Measured memory_bytes: 20012
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

bool getans(vector<int>&used, vector<int>&vs, int rest) {
	if (rest) {
		bool flag = false;
		for (int i = 0; i < used.size(); ++i) {
			if (used[i] == 0) {
				used[i] = 2;
				if (rest >= vs[i]) {

					if (getans(used, vs, rest - vs[i])) {
						used[i] = 0;
						return true;
					}
				}
				used[i] = 0;
				if (!flag)return false;
			}
			else if(used[i]==2){
				flag = true;
			}
		}
		return false;
	}
	else {
		if (all_of(used.begin(), used.end(), [](const int n) {return n; })) {
			return true;
		}
		bool flag = false;
		for (int i = 0; i < used.size(); ++i) {
			if (used[i] == 2) {
				used[i] = 1;
				bool ok=getans(used, vs, vs[i]);
				used[i] = 2;
				if (ok)return true;
			}
			else if (used[i] == 0) {
				return false;
			}
		}
		return false;
	}
}
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<int>vs(N),used(N);
		for (int i = 0; i < N; ++i) {
			cin >> vs[i];
		}
		sort(vs.begin(), vs.end(), greater<int>());
		used[0] = 2;
		bool ans = getans(used,vs, 0);
		if (ans)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3120
#include <stdio.h>
#include <string.h>

int main() {
  char s[10];
  scanf("%s", s);
  for(int i = 1; i < 4; i++)
    if(s[i] == s[i-1]){
      printf("Bad\n");
      return 0;
    }
  printf("Good\n");
}

Measured memory_bytes: 128
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val H = input.nextLong()
    val W = input.nextLong()
    
    if (H == 1L || W == 1L) {
      println(1)
    } else {
      val area = H * W
      var reachable = (area / 2) + if (area % 2 == 1L) 1 else 0
    
      println(reachable)
    }
  }
}

Measured memory_bytes: 36328
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

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

	int n, k;
	scanf("%d%d\n", &n, &k);
	double prob = 0;
	for (int i = 1; i <= n; i++) {
		double p = (double)1 / n;
		for (int x = i; x < k; x *= 2) p /= 2;
		prob += p;
		//printf("%d %f\n", i, p);
	}
	printf("%.12f\n", prob);
}


Measured memory_bytes: 256
import sys
from scipy.sparse.csgraph import floyd_warshall as f
def main():
  n,m,l,*t=map(int,sys.stdin.buffer.read().split())
  d=[[0]*(n+1)for _ in range(n+1)]
  for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=c
  d=f(f(d,0)<=l)-1
  d[d>n]=-1
  d=d.astype('i2')
  print('\n'.join(map(str,map(d.__getitem__,zip(*[iter(t[m*3+1:])]*2)))))
main()

Measured memory_bytes: 36280
#include<stdio.h>
int partition(int *,int,int);
int main(){
  int i,norm,n,A[100000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  norm=partition(A,0,n-1);
  for(i=0;i<n;i++){
    if(i==norm){
      printf("[%d] ",A[i]);
      continue;
    }
    printf("%d",A[i]);
    if(i!=n-1){
      printf(" ");
    }
  }
  printf("\n");
  return 0;
}

int partition(int *A,int p,int r){
  int i,j,x,temp;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      temp=A[i];
      A[i]=A[j];
      A[j]=temp;
        }
   }
  temp=A[i+1];
  A[i+1]=A[r];
  A[r]=temp;
  return i+1;
}



Measured memory_bytes: 2104
# from sys import exit
H, W = [int(n) for n in input().split()]
c = [[0 for _ in range(W)] for __ in range(H)]
Bs = []

for i in range(H):
    c[i] = list(str(input()))
    for j in range(W):
        if c[i][j] == "B":
            Bs.append((i, j))

INF = 10e10
a, c = -INF, -INF
b, d = INF, INF
for e in Bs:
    a = max(e[0] - e[1], a)
    b = min(e[0] - e[1], b)
    c = max(e[0] + e[1], c)
    d = min(e[0] + e[1], d)
print(max(a-b, c-d))



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

MOD = 10**9+7
dp = [0 for _ in range(10**5+2)]

dp[0] = 1
dp[1] = 1

for i in range(2, 10**5+2):
    dp[i] = i*dp[i-1] % MOD

if abs(N-M) > 1:
    print(0)
elif abs(N-M) == 1:
    print(dp[N]*dp[M]%MOD)
else:
    print(2*dp[N]*dp[M]%MOD)

Measured memory_bytes: 7064
package main

import "fmt"

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

	h := make([]int, n)
	for i := range h {
		fmt.Scan(&h[i])
	}

	good := make([]bool, n)
	for i := range good {
		good[i] = true
	}

	var a, b int
	for i := 0; i < m; i++ {
		fmt.Scan(&a, &b)
		if h[a-1] < h[b-1] {
			good[a-1] = false
		} else if h[a-1] > h[b-1] {
			good[b-1] = false
		} else {
			good[a-1] = false
			good[b-1] = false
		}
	}

	count := 0
	for _, v := range good {
		if v {
			count++
		}
	}
	fmt.Println(count)
}


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

#define VIC ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
#define wtf(s) freopen((s), "w", stdout)
#define rff(s) freopen((s), "r", stdin)
#define pi (2 * acos(0))
typedef long double ld;
typedef long long ll;
typedef complex<ld> point;
#define endl '\n'
#define matrix vector<vector<ll>>
#define EPS 1e-9
#define X real()
#define Y imag()
#define vec(a, b) ((b) - (a))
#define dot(a, b) ((conj(a) * (b)).real())
#define cross(a, b) ((conj(a) *(b)).imag())
#define lengthsqr(v) (dot(v, v))
#define length(v) ((ld)hypot((v).Y, (v).X))
#define same(a, b) (lengthsqr(vec(a, b)) < EPS)

const int N = 15 + 5, inf = 2e9, mod = 1e9 + 7;

int main()
{
    int n, x, ans = INT_MAX;
    cin >> n;
    while (n--)
    {
        int c = 0;
        cin >> x;
        while (x >= 2 && x % 2 == 0)
            c++,
            x /= 2;
        ans = min(ans, c);
    }
    cout << ans;
    return 0;
}


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

const int N = 1e5 + 10;

struct Edge {
	int dest, weight;
	Edge() {}
	Edge(int _dest, int _weight) : dest(_dest), weight(_weight) {}
};
vector<Edge> edges[N];
long long dist[N];
int n, size[N], mx[N];

void dfs(int x, int pre) {
	size[x] = 1;
	for (int i = 0; i < edges[x].size(); ++i) {
		int y = edges[x][i].dest, w = edges[x][i].weight;
		if (y != pre) {
			dist[y] = w;
			dfs(y, x);
			size[x] += size[y];
			mx[x] = max(mx[x], size[y]);
		}
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		int x, y, w;
		scanf("%d%d%d", &x, &y, &w);
		edges[x].push_back(Edge(y, w));
		edges[y].push_back(Edge(x, w));
	}
	dfs(1, 0);
	long long ans = 0LL;
	for (int i = 1; i <= n; ++i) {
		ans += min(size[i], n - size[i]) * dist[i];
		mx[i] = max(mx[i], n - size[i]);
	}
	ans <<= 1;
	vector<int> root;
	root.push_back(1);
	for (int i = 2; i <= n; ++i)
		if (mx[i] < mx[root[0]]) {
			root.clear();
			root.push_back(i);
		} else if (mx[i] == mx[root[0]])
			root.push_back(i);
	assert(root.size() <= 2);
	if (root.size() == 2) {
		int x = root[0];
		for (int i = 0; i < edges[x].size(); ++i) {
			int y = edges[x][i].dest, w = edges[x][i].weight;
			if (y == root[1]) ans -= w;
		}
	} else {
		int x = root[0], min_weight = INT_MAX;
		for (int i = 0; i < edges[x].size(); ++i)
			min_weight = min(min_weight, edges[x][i].weight);
		ans -= min_weight;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 13952
n = int(input())
values = [int(input()) for i in range(n)]

maxv = -999999999
minimum = values[0]

for i in range(1, n):
    if values[i] - minimum > maxv:
        maxv = values[i] - minimum
    if values[i] < minimum:
        minimum = values[i]

print(maxv)

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

int main(){
  vector<int> vec = {1,2,4,8,16,32,64};
  int n;
  cin >> n;
  
  if(n == 1)cout << vec.at(0) << endl;
  else if(2 <= n && n < 4)cout << vec.at(1) << endl;
  else if(4 <= n && n < 8)cout << vec.at(2) << endl;
  else if(8 <= n && n < 16)cout << vec.at(3) << endl;
  else if(16 <= n && n < 32)cout << vec.at(4) << endl;
  else if(32 <= n && n < 64)cout << vec.at(5) << endl;
  else if(64 <= n && n <= 100)cout << vec.at(6) << endl;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
const int N=505;
int n,k,sum,mx,a[N],b[N];
set<int> st;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	for(int i=1;i*i<=sum;i++){
		if(sum%i==0){
			st.insert(i);
			st.insert(sum/i);
		}
	}
	for(set<int>::iterator it=st.begin();it!=st.end();it++){
		int x=*it;
		long long ans=0;
		for(int i=1;i<=n;i++){
			b[i]=a[i]%x;
		}
		sort(b+1,b+n+1);
		for(int i=1,j=n;i<j;i++){
			while(b[i]){
				int tmp=min(b[i],x-b[j]);
				ans+=tmp;
				b[i]-=tmp;
				b[j]+=tmp;
				if(b[j]==x){
					j--;
				}
			}
		}
		if(ans<=k){
			mx=max(mx,x);
		}
	}
	printf("%d\n",mx);
}

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

int main(){
  
  int N,M,e[10000];
  scanf("%d%d", &N, &M);
  
  for(int i = 0; i < M; i++){
    scanf("%d", &e[i]);
  }
  
  int s=0;

  for(int i = 0; i < M; i++){
    s+=e[i];
  }
  
  N = N - s;
  
  if(N >= 0){
    cout << N << endl;
  }else{
    printf("-1");
  }
}

  

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n, l;
    cin >> n >> l;
    vector<ll> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    bool flag = false;
    int pos = 0;
    for(int i = 1; i < n; i++)
    {
        if(a[i] + a[i-1] >= l)
        {
            flag = true;
            pos = i;
        }
    }
    if(!flag)
    {
        cout << "Impossible" << endl;
    }
    else
    {
        cout << "Possible" << endl;
        for(int i = 1; i < pos; i++)
        {
            cout << i << endl;
        }
        for(int i = n-1; i > pos; i--)
        {
            cout << i << endl;
        }
        cout << pos << endl;
    }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5;
int n, m;
ll a[maxn + 10], b[maxn + 10];
vector<int> g[maxn + 10];
int fa[maxn + 10];
ll sum[maxn + 10], f[maxn + 10];
int id[maxn + 10];
bool vis[maxn + 10];

bool cmp(int x, int y) {
	return a[x] < a[y];
}

int getf(int p) {
	return fa[p] == p ? p : fa[p] = getf(fa[p]);
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) {
		scanf("%lld%lld", &a[i], &b[i]);
		a[i] = max(a[i] - b[i], 0ll);
		sum[i] = b[i]; id[i] = fa[i] = i;
	}
	sort(id + 1, id + n + 1, cmp);
	for (int i = 1; i <= m; ++i) {
		int l, r; scanf("%d%d", &l, &r);
		g[l].push_back(r); g[r].push_back(l);
	}
	for (int i = 1; i <= n; ++i) {
		int p = id[i]; vis[p] = 1;
		bool fd = 1;
		f[p] = 1e18;
		for (int j = 0; j < (int)g[p].size(); ++j) {
			int e = g[p][j];
			if (vis[e]) {
				e = getf(e);
				if (e != p) {
					fa[e] = p; sum[p] += sum[e];
					f[p] = min(f[p], max(a[p], f[e]) - sum[e]);
					fd = 0;
				}
			}
		}
		if (fd) f[p] = a[p];
		f[p] += sum[p];
	}
	printf("%lld", f[id[n]]);
}


Measured memory_bytes: 9980
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#define fo(i,n) for(long long i=0;i<n;i++)
#define ll long long int
#define inf 999999999999999999
#define pb push_back
#define fi first
#define se second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define pi pair<ll,ll>
#define mp make_pair
#define MOD 1000000007
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); ++it)
#define fio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
//cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
//freopen("explicit.in", "r", stdin);
//freopen("explicit.out", "w", stdout);
 
void SieveOfEratosthenes() 
{ 
    bool prime[10000001];
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=10000000; p++) 
    { 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (ll i=p*p; i<=10000000; i += p) {
                prime[i] = false; 
            }
        } 
    }  
} 
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
	if(b%a==0)
	   return a;
	return gcd(b%a,a);
}
ll nCrModpDP(ll n, ll r, ll p) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C));   
    C[0] = 1;
    for (ll i = 1; i <= n; i++) 
    {
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
} 
ll nCrModp(ll n, ll r, ll p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
   ll ni = n%p, ri = r%p; 
  
   return (nCrModp(n/p, r/p, p) * 
           nCrModpDP(ni, ri, p)) % p; 
} 
int32_t main() 
{
    fio
	ll j,i,n,t,l,r,c,h,k,m,maxi,d,x;
	cin>>n>>x>>t;
	if(n%x==0)
		c=n/x;
	else
		c=n/x+1;
	cout<<c*t;
}





	

		

Measured memory_bytes: 3632
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, n);
	VEC(int, a, n);
  sort(ALL(a));

	PAIR p = make_pair(a[0], a.back());
	deque< int > dq;
	FOR(i, 1, n - 1) {
		dq.push_back(a[i]);
	}

	int ans = abs(a.back() - a[0]);
	while (!dq.empty()) {
		int f = dq.front(), l = dq.back();
		int one = abs(p.first - l), two = abs(p.second - f);
		//	debug(f);
		// debug(l);
		if (one > two) {
			p.first = l;
			dq.pop_back();
			ans += one;
		} else {
			p.second = f;
			dq.pop_front();
			ans += two;
		}
		f = p.first; l = p.second;
		p = make_pair(min(f, l), max(f, l));
		//debug(f);
		//debug(l);
		//debug(ans);
	}

	OUT(ans)BR;
  return 0;
}


Measured memory_bytes: 1920
import java.util.Scanner
import java.io.PrintWriter

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val pw = new PrintWriter(System.out)

    val n: Long = sc.nextLong()
    for (i <- math.sqrt(n).toInt to 1 by -1) {
      if (n % i == 0) {
        pw.println(i - 1 + n / i - 1)
        pw.flush()
        return
      }
    }

    pw.flush()
  }
}

Measured memory_bytes: 27336
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int x, a;
	cin >> x >> a;
	cout << 10 * (x >= a) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int N;
  cin >> N;
  int i=1;
  while((i+1)*(i+1)<=N){
    i++;
  }

  cout << i*i << endl;
  return 0;
}


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

using namespace std;

const int maxn = 60;
int n, m;
vector <int> city[maxn];

int main(){
	cin >> n >> m;
	for(int i=0; i<m; i++){
		int a, b;
		cin >> a >> b;
		city[--a].push_back(i);
		city[--b].push_back(i);
	}
	for(int i=0; i<n; i++){
		int a = city[i].size();
		cout << a << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, x;
int a[1000];

signed main(){
    cin >> N >> x;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    sort(a,a + N);
    int cnt = 0;
    for(int i = 0; i < N; i++){
        if(x >= a[i]){
            cnt++;
            x -= a[i];
        }
    }
    if(x > 0 && cnt == N)cnt--;
    cout << cnt << endl;


    return 0;
}

/*


*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b;
    cin >> a >> b;
    
    cout << (a-1) * (b-1) << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	
  string s, t;
  cin >> s >> t;
  if(s == t.substr(0, s.size()) and (s.size() + 1 == t.size())) {
    cout << "Yes" << endl;
  }
   else cout << "No" << endl;
       
  return 0;
}


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

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

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

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

int main() {
    lli n;
    cin >> n;
    lli a[n];
    REP(i, 0, n) {
        cin >> a[i];
    }
    sort(a, a+n);
    lli dup = 0;
    REP(i, 0, n-1) {
        if (a[i] == a[i+1])
            dup++;
    }
    if (dup % 2 == 1)
        cout << n - (dup/2+1)*2 << endl;
    else
        cout << n - (dup/2)*2 << endl;

}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] AN = new int[N];
        int[] AN2 = new int[N];
        int changeCount = 0;
        int min = 2147483647;
        long S = 0;

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

            AN[i] = sc.nextInt();

            if(AN[i] < 0) {

                AN2[i] = -AN[i];
                changeCount++;
            } else {

                AN2[i] = AN[i];
            }

            min = (AN2[i] < min) ? AN2[i] : min;
        }

        if (changeCount % 2 == 0) {

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

                S += AN2[i];
            }
            System.out.println(S);
        } else {

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

                S += AN2[i];
            }
            System.out.println(S-min*2);
        }
        sc.close();
    }

}

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

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

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

	
	int even_counter = 0;
	int counter = 0;
	for(int i = 0; i < n; ++i) {
	 	if(vec[i] % 2 == 0) {
	 		++even_counter;
	 		if(vec[i] % 3 == 0 || vec[i] % 5 == 0) ++counter;;
	 	}
	}

	//cout << even_counter << "\n";
	//cout << counter << "\n";
	if(counter == even_counter) cout << "APPROVED" << "\n";
	else cout << "DENIED" << "\n";

}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main(){
  int n,a,b,c,X;
  while(readf("%d %d %d %d %d\n",&n,&a,&b,&c,&X),n||a||b||c||X){
    auto ran = map!("to!int(a)")(split(chomp(readln())));
    int x=X,j=0,i;
    for(i=0;i<=10000;++i){
      if(ran[j]==x) ++j;
      x=(a*x+b)%c;
      if(j==ran.length) break;
    }
    writeln((i==10001)?-1:i);
  }
}

Measured memory_bytes: 1508
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    ll a, v, b, w, t;
    cin >> a >>v >> b >> w >> t;
    ll d = abs(a - b);
    ll x = v - w;
    ll y = v+w;
    if(x > 0 && (d+x-1)/x <= t) cout << "YES" << '\n';
    else cout << "NO" <<'\n';
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 100;

struct Card
{
    char suit;
    int value;
};

void trace( struct Card A[], int N )
{
    for ( int i = 0; i < N; i++ )
    {
        if ( i > 0 ) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

void bubbleSort( struct Card A[], int N )
{
    bool flag = true;
    for ( int i = 0; flag; i++ )
    {
        flag = false;
        for ( int j = N-1; j > i; j-- )
        {
            if ( A[j].value < A[j-1].value )
            {
                swap( A[j], A[j-1] );
                flag = true;
            }
        }
    }
}

void selectionSort( struct Card A[], int N )
{
    int count = 0;
    for ( int i = 0; i < N-1; i++ )
    {
        int minj = i;

        for ( int j = i+1; j < N; j++ )
        {
            if ( A[j].value < A[minj].value )
                minj = j;
        }

        if ( i != minj )
        {
            swap( A[i], A[minj] );
        }
    }
}

int main(void)
{
    struct Card A[MAX], B[MAX];
    int N;

    cin >> N;
    for ( int i = 0; i < N; i++ )
    {
        cin >> A[i].suit >> A[i].value;
        B[i] = A[i];
    }


    bubbleSort( A, N );
    selectionSort( B, N );

    trace( A, N );
    cout << "Stable" << endl;
    trace( B, N );

    bool flag = true;
    for ( int i = 0; i < N; i++ )
    {
        if ( A[i].suit != B[i].suit ) flag = false;
    }

    cout << ( ( flag ) ? "Stable" : "Not stable" ) << endl;

    return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;
ll N;

int main(){

    ll N, T;
    cin >> N >> T;

    vector<pair<ll, ll > > ct;

    for(ll i = 0; i < N; i++){
        ll c, t;
        cin >> c >> t;
        ct.push_back(make_pair(t, c));
    }

    sort(ct.begin(), ct.end());

    ll ans = 1145141919;

    for(ll i = 0; i < N; i++){
        if(ct[i].first > T){
            break;
        }
        if(ans > ct[i].second){
            ans = ct[i].second;
        }
    }

    if(ans == 1145141919){
        cout << "TLE" << endl;
    }else{
        cout << ans << endl;
    }



} 

Measured memory_bytes: 256
##B - Substring
S = str(input())
T = str(input())
L = len(S) - len(T) + 1
##print(L)
ansL = []
for i in range(L):
    ans = 0
    for j in range(len(T)):
        if S[j] != T[j]:
            ans += 1
    ##print(ans)
    ansL.append(ans)
    S = S[1:]
print(min(ansL))

Measured memory_bytes: 9000
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	static int[] S ;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		long N = Long.parseLong(W);

		long ans = N-1;
		double sq = Math.sqrt(N);
		long i = (long)sq;

		for(;i>0;i--){
			if(N%i==0){
				ans = Math.min(ans, i+N/i-2);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22100