akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanInt() int {
	sc.Scan(); a,_ := strconv.Atoi(sc.Text()); return a
}

func scanInt64() int64 {
	sc.Scan(); a,_ := strconv.ParseInt(sc.Text(),10,64); return a
}

func scanFloat64() float64 {
	sc.Scan(); a,_ := strconv.ParseFloat(sc.Text(),64); return a
}

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanString() string {
	sc.Scan(); return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e); if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr); wr.Flush()
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	s := scanString()
	n := len(s)

	bc := 0
	ans := 0
	f := false

	for i := 0; i < n; i++ {
		switch s[n-1-i] {
		case 'C':
			if f {
				bc = 0
			}
			f = true
		case 'B':
			if f {
				bc++
			} else {
				bc = 0
			}
			f = false
		case 'A':
			if f {
				bc = 0
				f = false
			}
			ans += bc
		}
		// fmt.Println(ans,bc)
	}

	fmt.Println(ans)
}


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

int main()
{
   ll n,k;
   cin>>n>>k;
   set<ll> s;
   ll* a = new ll[n+1]();

   for(int i=0;i<n;i++)
   {
        ll temp;
        cin>>temp;
        a[temp]++;

        s.insert( temp);
   }

   if( s.size() <= k)
   {
       cout<<0;
   }
   else
   {

        sort( a , a+n+1);

       ll ans =0;
       ll total_types = s.size();

       int index =1;
       while( total_types > k && index<= n)
       {
           if(a[index]>0 )
           {
               ans += a[index];
               total_types --;
           }
           index++;
       }
       cout<<ans;
   }
}

Measured memory_bytes: 14388
#include <stdio.h>

#define MOD_BY 1000000007

int add(int a, int b) {
	return a + b - MOD_BY * (a + b >= MOD_BY);
}

int N;
char S1[64], S2[64];

int memo[64][4][4][4][4];

int sumipe(int pos, int ng1, int force1, int ng2, int force2) {
	int* m = &memo[pos][ng1][force1][ng2][force2];
	int i, j;
	int answer = 0;
	if (pos >= N) return 1;
	if (*m) return ~*m;
	if (S1[pos] == S2[pos]) {
		for (i = 1; i <= 3; i++) {
			if (i != ng1 && i != ng2) {
				answer = add(answer, sumipe(pos + 1, i, 0, i, 0));
			}
		}
	} else {
		for (i = 1; i <= 3; i++) {
			if (i != ng1 && (force1 == 0 || i == force1)) {
				for (j = 1; j <= 3; j++) {
					if (j != ng2 && i != j && (force2 == 0 || j == force2)) {
						int f1 = S1[pos] == S1[pos + 1], f2 = S2[pos] == S2[pos + 1];
						answer = add(answer, sumipe(pos + 1, f1 ? 0 : i, f1 ? i : 0, f2 ? 0 : j, f2 ? j : 0));
					}
				}
			}
		}
	}
	return ~(*m = ~answer);
}

int main(void) {
	if (scanf("%d", &N) != 1) return 1;
	if (scanf("%63s", S1) != 1) return 1;
	if (scanf("%63s", S2) != 1) return 1;
	printf("%d\n", sumipe(0, 0, 0, 0, 0));
	return 0;
}


Measured memory_bytes: 256
A=list(map(int,input().split()))
ans=int(0)
m=max(A)
for i in range(3):
    now=int((m-A[i])/2)
    ans+=now
    A[i]+=2*now

check=int(0)
for i in range(3):
    check+=m-A[i]
if check==0:
    print(ans)
elif check==2:
    print(ans+1)
else:
    print(ans+2)

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}


    
void go();

main(){
    ios
    int tc=1;
    // tc=in();
    while(tc--){
        go();
    }
    return 0;
}


void go(){
    int n=in(),k=in();
    ll ans=1;
    ans*=k;
    rep(i,n-1)ans*=(k-1);
    cout<<ans<<endl;
}





Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int k, n, a[200005] = {}, z = 0;
    cin >> k >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i < n; i++) z = max(z, a[i + 1] - a[i]);
    cout << min(k - z, a[n] - a[1]);
}


Measured memory_bytes: 4436
#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>;

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

  int n, m;
  cin >> n >> m;

  vector<vector<int>> v(m);
  rep(i, 0, m) {
    int k;
    cin >> k;
    rep(j, 0, k) {
      int s;
      cin >> s;
      s--;
      v[i].push_back(s);
    }
  }

  vector<int> p(m);
  rep(i, 0, m) cin >> p[i];

  int ans = 0;
  rep(i, 0, 1 << n) {
    vector<int> swi(n, 0);
    rep(j, 0, n) {
      if (i >> j & 1) {
        swi[j] = 1;
      }
    }

    bool b = true;
    rep(j, 0, m) {
      int c = 0;
      rep(k, 0, v[j].size()) { c += swi[v[j][k]]; }
      if (c % 2 != p[j]) {
        b = false;
        break;
      }
    }

    if (b)
      ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vint;
typedef vector<uint> vuint;
typedef vector<ull> vull;
typedef vector<ll> vll;

#define init(type,var) type var;cin>>var;
#define vinit(type,var,n) vector<type> var((uint)n);loop(i,0,n)cin>>var[i];
#define linit(type,var,n) list<type> var;loop(i,0,n){type _v;cin>>_v;var.push_back(_v);}
#define range(container) container.begin(),container.end()
#define loop(i,first,end) for(ull i=(first);i<(end);i++)
#define outl(out) cout<<(out)<<endl;

const ull INF = (ull)(-1LL);

typedef ull aint;

typedef vector<aint> vaint;
typedef list<aint> laint;

int main(void){
	init(aint, n);

	vector<string> s(n);
	vaint t(n);

	for (uint i = 0; i < n; i++){
		cin >> s[i] >> t[i];
	}

	init(string, x);

	aint index;
	for (index = 0; s[index] != x; index++);
	aint ans = 0;
	for (index++; index < n; index++)ans += t[index];

	outl(ans);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=100010;
const int inf=0x3f3f3f3f;
int dp[maxn];
int a[maxn];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=2;i<=n;i++)dp[i]=inf;
	for(int i=2;i<=n;i++){
		for(int j=1;j<=k;j++) {
			if(i-j<1)break;
			dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
		}
	}
	cout<<dp[n];
} 

Measured memory_bytes: 4388
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007
#define INF 2000000000000
#define int long long
#define double long double
#define floot10 cout<<fixed<<setprecision(10)
#define Int long long
#define ALL(n) n.begin(),n.end()
#define hogea pair<pair<int,int>,int>

struct field{
  string s[4];
  field(){};
  field(string s1,string s2,string s3,string s4){
    s[0]=s1;
    s[1]=s2;
    s[2]=s3;
    s[3]=s4;
  };
};

string ms(field f){
  string s=f.s[0]+f.s[1]+f.s[2]+f.s[3];
  return s;
}

struct teto{
  string s[4];
  int h,w;
};

teto t[4];
set<string> lis;

void revs(int n){
  teto x;
  x.h=t[n].w;
  x.w=t[n].h;
  lp(i,x.h){
    string s="";
    lp(j,t[n].h){
      s=s+t[n].s[j].substr(i,1);
    }
    x.s[i]=s;
  }
  t[n]=x;
}

field br(field f,int n,int x,int y){
  for(int i=x;i<x+t[n].h;i++){
    for(int j=y;j<y+t[n].w;j++){
      if(t[n].s[i-x][j-y]=='#'){
	f.s[i][j]='.';
      }
    }
  }
  return f;
}

bool brcheck(field f,int n,int x,int y){
  for(int i=x;i<x+t[n].h;i++){
    if(i>=4)return false;
    for(int j=y;j<y+t[n].w;j++){
      if(j>=10)return false;
      if(t[n].s[i-x][j-y]=='#'){
	if(f.s[i][j]=='.')return false;
      }
    }
  }
  return true;
}

int popcount(int n){
  int cnt=0;
  lp(i,64){
    if(n&(1<<1))cnt++;
  }
  return cnt;
}

void DBD(field f){
  lp(i,4){
    cout<<f.s[i]<<endl;
  }
  return;
}

void hoge(field f,int b){
  if(__builtin_popcount(b)==3){
    lis.insert(ms(f));
    /*DBD(f);
    int hoge;
    cin>>hoge;*/
    return;
  }
  lp(z,4){
    if(b&(1<<z))continue;
    lp(i,10){
      lp(j,10){
	if(brcheck(f,z,i,j)){
	  hoge(br(f,z,i,j),b|(1<<z));
	}
      }
    }
  }
}

void make(){
  field f("##########","##########","##########","##########");
  hoge(f,0);
}

signed main(){
  lp(i,4){
    int h,w;
    cin>>h>>w;
    t[i].h=h;
    t[i].w=w;
    lp(j,h){
      string s;
      cin>>s;
      t[i].s[j]=s;
    }
  }
  make();
  int n;
  cin>>n;
  lp(i,n){
    string s[4];
    lp(j,4){
      cin>>s[j];
    }
    field f(s[0],s[1],s[2],s[3]);
    if(lis.find(ms(f))==lis.end()){
      cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;
  }
  return 0;
}



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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end(), greater<int>());
    int ans = 0;
    rep(i, k) ans += l[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
using namespace std;

int main(){
    int N;
    scanf("%d",&N);
    int A[N+2];
    int s=0;
    A[0]=0;A[N+1]=0;
    for(int i=1;i<N+1;i++){scanf("%d",A+i);}
    for(int i=0;i<N+1;i++){
        s+=abs(A[i+1]-A[i]);
    }
    for(int i=1;i<N+1;i++){
        printf("%d\n",s+abs(A[i-1]-A[i+1])-(abs(A[i-1]-A[i])+abs(A[i]-A[i+1])));
    }
    return 0;
}


Measured memory_bytes: 1536
defmodule Main do
  def main() do
    _n =
      IO.gets("")
      |> String.trim()
      |> String.to_integer()
    a =
      IO.gets("")
      |> String.trim()
      |> String.split()
      |> Enum.map(&String.to_integer/1)
      |> Enum.sort(:desc)
    take(a, 0)
    |> IO.puts()
  end

  def take(a, n), do: _take(a, n, 0, 0)

  defp _take([], _, a_acc, b_acc), do: a_acc - b_acc

  defp _take([h|t], n, a_acc, b_acc) do
    case rem(n, 2) do
      0 -> _take(t, n + 1, a_acc + h, b_acc)
      1 -> _take(t, n + 1, a_acc, b_acc + h)
    end
  end
end


Measured memory_bytes: 30692
import math

def make_3_points(p1, p2):
    """p1, p2 を分割する３点を作成する。
    
    p1, p2 を両端の点とする線分を３等分する２点 s, t を
    頂点とする正三角形の頂点 (s, u, t) のタプルを返す。
    """
    s = ((2 * p1[0] + p2[0]) / 3, (2 * p1[1] + p2[1]) / 3)
    t = ((p1[0] + 2 * p2[0]) / 3, (p1[1] + 2 * p2[1]) / 3)

    theta = math.radians(60)

    x = t[0] - s[0]
    y = t[1] - s[1]

    u = (math.cos(theta) * x - math.sin(theta) * y, math.sin(theta) * x + math.cos(theta) * y)
    u = (u[0] + s[0], u[1] + s[1])

    return (s, u, t)

def make_koch(n, pl):
    if n == 0:
        return pl
    next_pl = [pl[0]]
    for i in range(1, len(pl)):
        s, u, t = make_3_points(next_pl[-1], pl[i])
        next_pl += [s, u, t, pl[i]]
    
    pl = None
    return make_koch(n - 1, next_pl)

n = int(input())
rl = make_koch(n, [(0, 0), (100, 0)])
for p1, p2 in rl:
    print(p1, p2)



Measured memory_bytes: 6280
s = list(input())
t = list(input())

for _ in range(2):

    n = len(s)
    l = [set() for _ in range(26)]

    def f(c):
        return ord(c) - ord('a')

    for i, j in enumerate(s):
        l[f(j)].add(t[i])

    for i in l:
        if len(list(i)) > 1:
            print('No')
            exit(0)
        
    s,t = t,s

print('Yes')


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

int main(){
    int b1,b2,b3;
    bool open=false;
    cin>>b1>>b2>>b3;

    if(b1==1 && b2==1 && b3==0){
        open=true;
    }else if(b1==0 && b2==0 && b3==1){
        open=true;
    }

    if(open==true){
        cout<<"Open"<<endl;
    }else{
        cout<<"Close"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3108
n, m = map(int, input().split())
x = list(map(int, input().split()))

x.sort()

y = []
for i in range(0, m - 1):
    y.append(x[i + 1] - x[i])

y.sort()

s = 0
if m > n:
    s = sum(y[0:m - n])
print(s)

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

int main() {
  
  int N,M;
  cin >> N >> M;
  int sum =0;
  
  vector<int> A(N);
  for(int i = 0;i<N;i++) {
    cin >> A.at(i);
    sum += A.at(i);
  }
  
  sort(A.begin(),A.end(),greater<int>());
  
  if(sum*1.0/(4*M) > A.at(M-1)) {
    cout << "No" <<endl;
  }
  
  else {
    cout << "Yes" <<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import Control.Applicative

main = do
    [n,k] <- map read . words <$> getLine
    print $ solve n k

solve n k = if mod k 2 == 0 then (div n k) ^ 3 + (f n k) ^ 3 else (div n k) ^ 3

f n k = div n k + if mod n k >= div k 2 then 1 else 0

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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int A, B, C;
	cin >> A >> B >> C;
	for(int d=2; d<=B; d++){
		if(A%d==0 and B%d==0 and C%d!=0){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 256
//abc147D
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define deb 60
int main(void) {
  int i, j;
  long long n, mod=1000000007, sum=0,bin=1, x[deb];
  scanf("%lld", &n);
  long long a[n];

  for(i=0; i < n; i++) scanf("%lld", &a[i]);
  for(i=0; i < deb; i++) x[i]=0;

  for(i=0; i < n; i++){
    for(j=0; j < deb; j++){
      if(a[i] & 2 != 0) x[j]++;
      else if(a[i]==0)break;
      a[i]/=2;
    }
  }

  for(i=0; i < deb; i++){
    sum=(sum+x[i]*(n-x[i])%mod*bin)%mod;
    bin=bin*2%mod;
  }
  printf("%lld", sum);
}

Measured memory_bytes: 2560
//#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

struct dat {
	int y1;
	int x1;
	int y2;
	int x2;
};
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	vector<dat> out;
	int i, j, h, w, x = -1, y = -1;
	cin >> h >> w;
	vector2d(a, int, h, w, 0);
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}
	for (i = 0; i < h; i++) {
		if (i % 2 == 0) {
			for (j = 0; j < w; j++) {
				if (a[i][j] % 2 == 1) {
					if (x == -1 && y == -1) {
						y = i + 1;
						x = j + 1;
					}
					else {
						out.push_back({ y, x, i + 1, j + 1 });
						y = i + 1;
						x = j + 1;
						x = -1;
						y = -1;
					}
				}
				else {
					if (x != -1 && y != -1) {
						out.push_back({ y, x, i + 1, j + 1 });
						y = i + 1;
						x = j + 1;
					}
				}
			}
		}
		else {
			for (j = w - 1; j >= 0; j--) {
				if (a[i][j] % 2 == 1) {
					if (x == -1 && y == -1) {
						y = i + 1;
						x = j + 1;
					}
					else {
						out.push_back({ y, x, i + 1, j + 1 });
						y = i + 1;
						x = j + 1;
						x = -1;
						y = -1;
					}
				}
				else {
					if (x != -1 && y != -1) {
						out.push_back({ y, x, i + 1, j + 1 });
						y = i + 1;
						x = j + 1;
					}
				}
			}
		}
	}
	cout << out.size() << endl;
	for (i = 0; i < out.size(); i++) {
		cout << out[i].y1 << " " << out[i].x1 << " " << out[i].y2 << " " << out[i].x2 << endl;
	}
	return 0;
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long MOD = 1000000007;

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void solve(long long N, long long K, std::vector<long long> A){
    COMinit();
    ll ans =0;
    sort(A.begin(),A.end());
    for(int i=K-1;i<N;i++){
        ans += COM(i,K-1) *A[i];
        ans %= MOD;
        ans -= (COM(i,K-1) *A[N-1-i]) %MOD;
        ans = (ans + MOD)%MOD;
    }
    cout << ans << endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 12928
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;
int main(){

int N,c=0,i,X;

cin >> N;

for(i=0;i<=N;i++){
  X=i*1.08;
  if(N==X){
    c=1;
    break;
  }

}

if(c){
  cout << i << endl;
}
else{
  cout << ":(" << endl;
}

}


Measured memory_bytes: 3556
n,m=map(int,input().split())
par=[-1 for i in range(n+1)]
def root(a):
    if par[a]<0:
        return a
    else:
        return root(par[a])

def size(a):
    return -par[root(a)]

def connect(a,b):
    a=root(a)
    b=root(b)
    if a==b:
        return False
    if size(a)<size(b):
        a,b=b,a
    par[a]+=par[b]
    par[b]=a
    return True

for i in range(m):
    a,b=map(int,input().split())
    connect(a-1,b-1)
ans=0
for i in par:
    if i<0:
        ans=max(ans,-i)
print(ans)

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

using namespace std;


int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

	int n;
	cin >> n;
	while(n >= 1000){
		n -= 1000;
	}

	cout << (1000 - n) % 1000;
    return 0;
}


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

int main() {
  int A,B,C,D; cin >> A >> B >> C >> D;
  int cnt = 0;
  for ( int i = 0; i <= 100; i++ ) {
    if ( i >= A && i >= C && i <= B && i <= D ) cnt++;
  }
  if ( cnt == 0 ) cout << 0 << endl;
  else cout << cnt-1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(string, s);
  	if(s == "SUN") Return(7);
  	if(s == "MON") Return(6);
  	if(s == "TUE") Return(5);
  	if(s == "WED") Return(4);
  	if(s == "THU") Return(3);
  	if(s == "FRI") Return(2);
  	if(s == "SAT") Return(1);
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# K個の連番の単色があればよい。単色の場所を決め打って貪欲

import numpy as np

N,K = map(int,readline().split())
A = np.array(read().split(),np.int64)

Aplus = np.maximum(A,0)

# K個の連番の左端のインデックスに合わせる
left = np.zeros(N-K+1,np.int64)
left[1:N-K+1] = Aplus[:N-K].cumsum()
right = np.zeros(N-K+1,np.int64)
right[0:N-K] = Aplus[::-1][:N-K].cumsum()[::-1]

Acum = np.cumsum(A)
mid = Acum[K-1:N] - Acum[0:N-K+1] + A[0:N-K+1]
mid = np.maximum(mid,0)

x = left + mid + right
answer = x.max()
print(answer)

Measured memory_bytes: 18740
#include <bits/stdc++.h>
using namespace std;
int f(int x)
{
  int flag=0;
  for(int i=2;i<x;i++)
  {
    if(x%i==0){flag=1;break;}
  }
  return flag;
}
int main()
{
  int X;
  cin>>X;
  while(f(X)!=0){X++;f(X);}
  cout<<X<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
#define maxn 201000

const LL mod=1e9+7;
LL jc[maxn],ny[maxn];
LL qpow(LL x,LL t)
{
	LL ret=1;
	while (t)
	{
		if (t&1) ret=ret*x%mod;
		x=x*x%mod;t>>=1;
	}
	return ret;
}
void pre()
{
	jc[0]=ny[0]=jc[1]=ny[1]=1LL;
	for (LL i=2;i<maxn;i++)
	{
		jc[i]=jc[i-1]*i%mod;
		ny[i]=qpow(jc[i],mod-2);
		//if (i<=10) printf("%lld %lld %lld\n",i,jc[i],ny[i]);
	}
}
LL C(int n,int m)//C(n,m)
{
	//printf("%d %d\n",n,m);
	return jc[n]*ny[m]%mod*ny[n-m]%mod;
}
//10,4 10!/4!*6!
int mymin(int x,int y){return (x<y)?x:y;}
LL ct(int sx,int sy,int tx,int ty)
{
	//printf("%d %d %d %d\n",sx,sy,tx,ty);
	return C((tx-sx)+(ty-sy),mymin(tx-sx,ty-sy));
}
int main()
{
	int n,m,a,b,i;
	pre();LL ret=0;
	scanf("%d%d%d%d",&n,&m,&a,&b);
	for (i=b+1;i<=m;i++)
		ret=(ret+ct(1,1,n-a,i)*ct(n-a+1,i,n,m)%mod)%mod;
	printf("%lld\n",ret);
	return 0;
}
//n-a b+1 m


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    string s,t;

    cin>>s>>t;

    li n=s.length();
    li m=t.length();

    li ans=1e18;

    f(i,0,n-1)
    {
        if(i+m-1>=n)
            break;

        li cnt=0;

        f(j,i,i+m-1)
        {
            if(s[j]!=t[j-i])
                cnt++;
        }
        // debug(cnt);
        ans=min(ans,cnt);
    }

    cout<<ans;
}

int main()
{    
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

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

int main(){
  int n;
  while(cin >> n,n){
    int y=0;
    for(int i=2;i<=n;i++){
      for(int j=1;j<=n-i+1;j++){
        int x=0;
        for(int k=j;k<=j+i-1;k++)x+=k;
        if(x==n)y++;
      }
    }
  cout << y << endl;
  }
}
  
  

Measured memory_bytes: 2964
#include <cstdio>
#include <algorithm>
int N, a[100001], sign[100001], L;
long long f[100001];
int main()
{
	scanf("%d%d", &N, a + 1);
	sign[1] = 1;
	for (int i = 2; i <= N; i++)
	{
		static char in[3];
		scanf("%s", in);
		sign[i] = in[0] == '+' ? 1 : -1;
		scanf("%d", a + i);
		a[i] *= sign[i];
	}
	int L = 0;
	f[0] = 0;
	for (int i = 1; i <= N; i++)
	{
		if (sign[i] == 1)
		{
			for (int j = 0; j <= L; j++)
				f[j] += j & 1 ? -a[i] : a[i];
			for (int j = L - 1; j >= 0; j--)
				f[j] = std::max(f[j], f[j + 1]);
		}
		else
		{
			for (int j = 0; j <= L; j++)
				f[j] += j & 1 ? -a[i] : a[i];
			f[++L] = -1LL << 60;
			for (int j = L; j; j--)
				f[j] = std::max(f[j], f[j - 1]);
			for (int j = L - 1; j >= 0; j--)
				f[j] = std::max(f[j], f[j + 1]);
		}
		while (L > 10)
			L -= 2;
	}
	printf("%lld\n", *std::max_element(f, f + L + 1));
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;
const int MOD = 1000000007;
typedef pair<int,int> P;
struct edge{
    int to;
    int yen;
    int snuuk;
};
signed main(void){
    cin.tie(0);
ios::sync_with_stdio(false);
    int n,m,s,t; cin>>n>>m>>s>>t; s--; t--;
    vector <vector<edge>> g(100010,vector <edge>());
    rep(i,m){
        int a,b,c,d; cin>>a>>b>>c>>d; a--; b--; edge e = {b,c,d};
        g[a].push_back(e);
        edge ee = {a,c,d};
        g[b].push_back(ee);
    }
    ////sから円のダイクストラ
    vector <int> dy(100010,INF); 
    dy[s]=0;
    priority_queue <P, vector <P>, greater<P>> q;
    q.push({0, s});
    while(!q.empty()){
        //cout<<"*"<<endl;
        P tmp = q.top(); q.pop();
        int cost = tmp.first, now = tmp.second;
        //cout<<cost<<' '<<now<<endl;
        if(dy[now] < tmp.first) continue;
        else dy[now] = tmp.first;
        int x = g[now].size();
        for(int i = 0;i<x; i++){
            //cout<<"*"<<endl;
            if(dy[g[now][i].to] > cost + g[now][i].yen) {dy[g[now][i].to]= cost + g[now][i].yen; 
            q.push({cost + g[now][i].yen, g[now][i].to}); }
        }
    }

    ///tからスヌークの
    vector <int> ts(100010, INF); 
    ts[t] = 0;
    priority_queue <P, vector <P>, greater<P>> q4;
    q4.push({0, t});
    while(!q4.empty()){
        P tmp = q4.top(); q4.pop();
        int cost = tmp.first, now = tmp.second;
        if(ts[now]< tmp.first) continue;
        int x = g[now].size();
        for(int i = 0;i<x; i++){
            if(ts[g[now][i].to] > cost + g[now][i].snuuk) {ts[g[now][i].to]= cost + g[now][i].snuuk;
            q4.push({cost + g[now][i].snuuk, g[now][i].to});}
        }
    }
    int ans[n];
    int mi = INF;
    rrep(i,n){
        //cout<<dy[i]<<"円"<<ts[i]<<"スヌーク"<<endl;
        chmin(mi, dy[i] + ts[i]);
        if(t>i) chmin(mi, dy[t]);
        if(s>i) chmin(mi, ts[s]); 
        ans[i] = mi;
    }
    rep(i,n) printf("%lld\n" ,1000000000000000 - ans[i]);
}


Measured memory_bytes: 14200
import scala.io.StdIn.{readInt, readLine}

object Main extends App {
  val n = readInt()
  val values = readLine().split(' ').map(_.toInt)
  val costs = readLine().split(' ').map(_.toInt)
  
  val result = values.zipWithIndex.foldLeft(0) { case (sum, (value, index)) =>
    val gain = value - costs(index)
    if (gain > 0)
      sum + gain
    else
      sum
  }
  println(result)
}

Measured memory_bytes: 54608
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = || -> String {
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let n: i32 = read_line().parse().unwrap();
    if n == 1 {
        println!("Hello World");
    } else {
        let a: i32 = read_line().parse().unwrap();
        let b: i32 = read_line().parse().unwrap();
        println!("{}",a+b);
    }
}

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

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> F(h);
    rep(i, h) cin >> F[i];

    //bit全探索
    int ans = 0;
    for (int i = 0; i < (1 << h); i++)
    {
        for (int j = 0; j < (1 << w); j++)
        {
            vector<string> G = F;
            //横方向
            rep(p, h)
            {
                if (i & (1 << p))
                {
                    G[p] = "";
                    rep(a, w) G[p] += '@';
                }
            }
            //縦方向塗りつぶし
            rep(q, w)
            {
                if (j & (1 << q))
                {
                    rep(b, h)
                    {
                        G[b][q] = '@';
                    }
                }
            }
            //Gを検証
            int cnt = 0;
            rep(e, h)
            {
                rep(f, w)
                {
                    if (G[e][f] == '#')
                    {
                        cnt++;
                    }
                }
            }
            if (cnt == k)
                ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <queue>

using namespace std;

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

int main(){
    int K, T;
    cin >> K >> T;
    vector<int> a(T);
    priority_queue<int> que;
    for(int i = 0; i < T; ++i){
        cin >> a[i];
        que.push(a[i]);
    }

    int res = 0;
    bool flag = true;
    while(!que.empty()){
        int n1, n2;
        n1 = que.top();
        que.pop();
        
        if(!que.empty()){
            n2 = que.top();
            que.pop();
            
            n1--;
            n2--;
            
            if(n1 > 0){
                que.push(n1);
            }
            if(n2 > 0){
                que.push(n2);
            }
        }
        else{
            if(flag){
                flag = false;
            }
            else{
                res++;
            }
            n1--;
            if(n1 > 0){
                que.push(n1);
            }
        }
    }
    
    cout << res << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.ArrayDeque;
import java.util.Deque;


public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        
        long sum = 0;
        for (int i = 0; i < (1<<s.length()-1); i++) {
            String shiki = s.substring(0, 1);
            for (int j = 0; j < s.length()-1; j++) {
                if ((1 & (i>>j)) == 1) {
                    //shiki += "+" + s.substring(j+1, j+2);
                    sum += Long.parseLong(shiki);
                    shiki = s.substring(j+1, j+2);
                }
                else {
                    shiki += s.substring(j+1, j+2);
                }
            }
            sum += Long.parseLong(shiki);
        }
        
        System.out.println(sum);
        
    }
}


Measured memory_bytes: 21204
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

alice = 0
bob = 0
a.sort{|a,b| b <=> a}
 .each_with_index{|n, idx|
     if idx % 2 == 0
         alice += n
     else
         bob += n
     end
 }

puts alice - bob

Measured memory_bytes: 1788
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll       long long
#define PR       pair<ll, ll>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    ll x, y;
    cin >> x >> y;
    ll d = abs(x - y);
    ll t = d / y;
    if (d % y) {
        t++;
    }
    ll f = t * y;
    x = abs(x - f);
    y = abs(x - y);
    cout << min(x, y) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

ii ma[1 << 18];

void Update(ii& a, int x) {
  if (x > a.first) {
    a.second = a.first;
    a.first = x;
  } else if (x > a.second) {
    a.second = x;
  }
}

ii Join(ii a, ii b) {
  Update(a, b.first);
  Update(a, b.second);
  return a;
}

int GetValue(ii a) {
  return a.first + a.second;
}

int main()
{
  int n;
  cin >> n;
  vector<int> a(1 << n);
  for (int i = 0; i < a.size(); ++i) cin >> a[i];

  for (int i = 0; i < (1 << n); ++i) ma[i].first = a[i];  

  for (int i = 0; i < n; ++i) for (int mask = 0; mask < (1 << n); ++mask) {
    if (mask & (1 << i)) {
      ma[mask] = Join(ma[mask], ma[mask ^ (1 << i)]);
    }
  }          

  int result = 0;
  for (int k = 1; k < (1 << n); ++k) {
    result = max(result, GetValue(ma[k]));
    cout << result << endl;
  }

  return 0;
}


Measured memory_bytes: 6144
A, B, C, D = gets.split('').map &:to_i
plus_list = []
minus_list = []
ret = [A.to_s]
[0, 1].each do |b|
    if b == 0 
        ret << '-' << B.to_s 
        minus_list << B
    else
        ret << '+' << B.to_s 
        plus_list << B
    end
    [0, 1].each do |c|
        if c == 0 
            ret << '-' << C.to_s 
            minus_list << C
        else
            ret << '+' << C.to_s 
            plus_list << C
        end
        [0, 1].each do |d|
            if d == 0
                ret << '-' << D.to_s 
                minus_list << D
            else
                ret << '+' << D.to_s 
                plus_list << D
            end
            if A + plus_list.inject(0, :+) - minus_list.inject(0, :+) == 7
                puts ret.join + "=7"
                exit
            else
                ret.delete_at(-1)
                if ret[-1] == '-'
                    minus_list.delete_at(-1)
                else
                    plus_list.delete_at(-1)
                end
                ret.delete_at(-1)
            end
        end
        ret.delete_at(-1)
        if ret[-1] == '-'
            minus_list.delete_at(-1)
        else
            plus_list.delete_at(-1)
        end
        ret.delete_at(-1)
    end
    ret.delete_at(-1)
    if ret[-1] == '-'
        minus_list.delete_at(-1)
    else
        plus_list.delete_at(-1)
    end
    ret.delete_at(-1)
end
puts 'error!'

Measured memory_bytes: 1788
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read();
    let mut v: Vec<(i32, i32, i32)> =
        (0..n).map(|_| (read(), read(), read())).collect();
    v.insert(0, (0, 0, 0));
    let yes = v[..].windows(2).all(|w| {
        let (t, x, y) = w[0];
        let (nt, nx, ny) = w[1];
        let time = nt - t;
        let dist = (nx - x).abs() + (ny - y).abs();
        dist <= time && time % 2 == dist % 2
    });
    println!("{}", if yes { "Yes" } else { "No" });
}


Measured memory_bytes: 6396
#include <stdio.h>

int main(void) {
	int sum = 0;

	char c;
	while ((c = getchar()) != EOF) {
		if (c >= '0' && c <= '9') {
			sum += c-'0';
			sum %= 9;
		}
	}

	if (sum == 0)
		puts("Yes");
	else
		puts("No");
}


Measured memory_bytes: 1464
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int K;cin >> K;
    int s[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << s[K-1] << endl;
}


Measured memory_bytes: 256
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = (int)1e5 + 3;
const int MOD = (int)1e9 + 7;

int n, k;
VI child[N];
bool vis[N];

int dfs(int v, int hm) {
  vis[v] = true;
  int res = hm;
  int cn = 1;
  if (v == 1)
    cn = 0;
  int qwe = 0;
  for (int i = 0; i < child[v].size(); ++i) {
    int cnt = max(0LL, k-1-cn-qwe);
    if (!vis[child[v][i]]) {
      ++qwe;
      res = (res*dfs(child[v][i], cnt))%MOD;
    }
  }
  return res;
}

signed main() {
  init_ios();
  cin >> n >> k;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    child[x].PB(y);
    child[y].PB(x);
  }
  cout<<dfs(1, k)<<"\n";
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;
typedef long long ll;
int main(){
    ll a;
    double b;
    cin >> a >> b;
    ll ib = b * 100 + 0.1;
    a *= ib;
    a /= 100;
    printf("%lld\n", a);
    return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define x_ real()
#define y_ imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define F first
#define S second
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
pair<int, int> dirs[] = { {1, 2}, {-1, 2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2} };
const ll mod = 1e9 + 7;
const ll N = 2e6 + 7;
ll fact[N];



int main() {
	fastIO;
	int n, r;
	cin >> n >> r;
	cout << r + max(0, 100*(10-n));

}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << "\n"; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(int, n, k);
    ll ans = k;
    Rep(n-1) ans *= (k-1);
    Cout(ans);
}


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

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

Measured memory_bytes: 1160
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<ctime>
#include<list>
#define ull unsigned long long 
#define ll long long 
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define MAXN 300000
using namespace std;

char s[MAXN];
ll v[40];

bool isP(int l,int r)
{	
	
	while (r-l>=1)
	{
		if(s[l]!=s[r])return false;
		l++;r--;
	}
	return true;
}



int main()
{
	scanf("%s",s);
	
	for(int i=0;s[i];i++)
		v[s[i]-'a']++;
		
		
	ll res=0,n=strlen(s);
	
	for(int i=0;i<26;i++)
		res+=(v[i]-1)*v[i]/2;
		
	cout<<n*(n+1)/2-n+1-res<<endl;
	
	return 0;	
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n,a[52],b[52];
bool f[52][52];
main () {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	cin>>n;
	
	for (int i=1; i<=n; i++) 
		cin>>a[i];
		
	for (int i=1; i<=n; i++) 
		cin>>b[i];

	vector < int > ans,h; 
	for (int i=50; i>=1; i--) {
		h.clear();
		
		for (int j=0; j<=50; j++)
			for (int k=0; k<=50; k++)
				f[j][k]=0;
		
		for (int j=0; j<ans.size(); j++) 
			h.push_back(ans[j]);
		for (int j=1; j<i; j++)
			h.push_back(j);
		
		for (int j=0; j<=50; j++)
			f[j][j]=1;
			
		for (int k=1; k<=50; k++) 
			for (int j=0; j<h.size(); j++) 
				f[k][k%h[j]]=1;
		
		for (int K=0; K<=50; K++)
			for (int I=0; I<=50; I++)
				for (int J=0; J<=50; J++)
					if (f[I][K] && f[K][J]) f[I][J]=1;
					
		for (int j=1; j<=n; j++)
			if (!f[a[j]][b[j]]) { ans.push_back(i); break; }
	}
	
	if (ans.size()==50) {
		cout<<-1<<endl;
		return 0;
	}
	
	ll ANS=0;
	for (int i=0; i<ans.size(); i++) 
		ANS+=(1LL<<(ans[i]));
		
	cout<<ANS<<endl;
}

Measured memory_bytes: 256
d = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(d)]
ld = [0]*26
score = 0
def dec(day):
    ans = 0
    for i in range(26):
        ans += c[i]*(day-ld[i])
    return ans

for i in range(d):
    ma=0
    t2=1
    score2=score
    for t in range(26):
        ld2=ld.copy()
        score2+=s[i][t]
        ld2[t]=i+1
        score2-=dec(i+1)
        ma = max(score2,ma)
        if score2==ma:
            t2=t
            t3=i+1
    score=ma
    ld[t2]=t3
    print(t2+1)

Measured memory_bytes: 9400
#include<bits/stdc++.h>
using namespace std;
int k;
int sum=9;
int a[11];
void sxqn(int n,int m,int p)
{
	if(m<0)return;
	if(m>9)return;
	a[p]=m;
	if(p==n)
	{
	  sum++;
	  if(sum==k)
	  {
	  	for(int i=1;i<=p;i++)
	  	  cout<<a[i];
	  	exit(0);
	  }
	  return;
	}
	sxqn(n,m-1,p+1);
	sxqn(n,m,p+1);
	sxqn(n,m+1,p+1);
}
int main()
{
	cin>>k;
	if(k<10)
	{
	  cout<<k;
	  return 0;
	}
	for(int i=2;i<=10;i++)
	  for(int j=1;j<=9;j++)
	    sxqn(i,j,1);
	return 0;
}

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

class Main {
    final Scanner sc = new Scanner(System.in);

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

    private void run() {
        int a = sc.nextInt();
        System.out.println(a + a*a + a*a*a);
    }
}


Measured memory_bytes: 35676