akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();
        int sum = 0;
    
    for(int i=0; i<K; i++) {
      if(A>0) {
        sum++;
        A--;
      } else if(B>0) {
        B--;
      } else if(C>0) {
        sum--;
        C--;
      }
    }
    System.out.println(sum);
    }
}

Measured memory_bytes: 36132
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
#include <iostream>
using namespace std;

/* 入力 */

int main() {
  int n; cin>>n;
  int l[11000];
  for(int i=0;i<n;i++)
  cin>>l[i];
  sort(l,l+n);
  int sum=0;
  for(int i=n-1;i>1;i--){
    for(int j=i-1;j>0;j--){
      int k=j-1;
      int count=0;
      while(l[i]<l[j]+l[k] &&k>=0){k--; count++;}

      sum+=count;
    }
  }
  cout<<sum<<endl;

}


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

int main() {
    int n;
    cin >> n;
    int d[n];
    for (int i = 0; i < n; i++) cin >> d[i];

    set<int> s;
    for (int i = 0; i < n; i++) {
        s.insert(d[i]);
    }

    cout << s.size() << endl;
}


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

long long weight[101], price[101], N, W, knapsack[101][100005]; 

long long solveKnapsack(long long N, long long W) {
	if (N <= 0 || W <= 0) {
		return 0;
	}
	if (knapsack[N][W] != -1) {
		return knapsack[N][W];
	}
	if (W < weight[N]) {
		knapsack[N][W] = solveKnapsack(N - 1, W);
		return knapsack[N][W];
	}
	else {
		knapsack[N][W] = max(solveKnapsack(N - 1, W), solveKnapsack(N - 1, W - weight[N]) + price[N]);
		return knapsack[N][W];
	}
}


int main() {
	memset(knapsack, -1, sizeof(knapsack));
	
	cin >> N >> W;
	for (int i = 1; i < N + 1; i++) {
		cin >> weight[i];
		cin >> price[i];
	}	

	for (int i = 0; i < W + 1; i++) {
		knapsack[0][i] = 0;
	}
	for (int i = 0; i < N + 1; i++) {
		knapsack[i][0] = 0;
	}
	solveKnapsack(N, W);
	cout << knapsack[N][W] << endl;


}	

Measured memory_bytes: 79104
N,M = map(int,input().split())
*A, = map(int,input().split())
BC=[list(map(int,input().split())) for _ in [0]*M]
A.sort()
BC.sort(key=lambda x:-x[1])
i = 0
for B,C in BC:
    for j in range(i,min(N,i+B)):
        if A[j]<C:A[j]=C
    i = i+B
print(sum(A))

Measured memory_bytes: 36076
import sys

def solve(a,b):
    return b+(b-a)

def readQuestion():
    a = sys.stdin.readline().strip()
    b = sys.stdin.readline().strip()
    
    return (int(a),int(b))

def main():
    a ,b  = readQuestion()
    answer = solve(a ,b)
    print(answer)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> p;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template <class T> bool chmax(T &a, const T &b) {
  if(a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if(b < a) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];
  vector<int> y(n);
  rep(i, n) y[i] = x[i];
  sort(y.begin(), y.end());

  int mid0 = y[n / 2 - 1];
  int mid1 = y[n / 2];

  rep(i, n) {
    if(mid1 > x[i])
      cout << mid1 << endl;
    else
      cout << mid0 << endl;
  }

  return 0;
}


Measured memory_bytes: 3712
import scala.io.StdIn._
object Main extends App {
  val ca = readLine.toCharArray
  val patterns = Seq("dream","dreamer","erase","eraser").map{_.toCharArray}

  @scala.annotation.tailrec
  def removeTail(size: Int): Int = {
    patterns.filter{_.size <= size}.find(p => (0 until p.size).forall{n => p(n) == ca(size - p.size + n)}) match {
      case None => size
      case Some(p) => removeTail(size - p.size)
    }
  }
  println(if (removeTail(ca.size) == 0) "YES" else "NO")
}

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

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

  long long int c = a / x + 1;
  long long int d = b / x;

  if(a % x == 0) {
    c = a / x;
  }

  cout << d - c + 1 << endl;
}

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

    using namespace std;
    typedef long long ll;
    # define M_PI  3.14159265358979323846

    const long long MOD=1e9+7;
    const long long maxN=2e6+5;
    ll k;
    string s;
    ll fact[maxN];
    ll inv_fact[maxN];

    ll pow_mod(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%MOD;
        long long res=1;
        while(b){
            if(b%2==1)
                res=(res*a)%MOD;
            a=(a*a)%MOD;
            b=b/2;
        }
        return res;
    }

    ll nCr(ll n , ll r){
        if(n<0 || r<0)
            return 0LL;
        if(n<r)
            return 0LL;
        return fact[n]*(inv_fact[r]*inv_fact[n-r]%MOD)%MOD;
    }

    void solve(){

        //calculating factorial
        fact[0]=1;
        for(ll i=1;i<maxN;i++){
            fact[i]=i*fact[i-1];
            fact[i]%=MOD;
        }
        inv_fact[maxN-1]=pow_mod(fact[maxN-1],MOD-2);

        // calculating modular inverse
        for(int i=maxN-2;i>=0;i--)
            inv_fact[i]=(inv_fact[i+1]*(i+1))%MOD;
        cin>>k>>s;
        ll n=s.size();
        ll ans=0;
        for(ll i=0;i<=k;i++){
            ll temp =((pow_mod(26,i))*(pow_mod(25,k-i)))%MOD;
            temp=(temp*nCr(n+k-i-1,n-1))%MOD;
            ans=(ans+temp)%MOD;
        }
        cout<<ans;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


Measured memory_bytes: 35468
# 2019-11-16 14:51:41(JST)
import sys
import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect_left as bi_l, bisect_right as bi_r, insort_left as in_l
# import itertools
from functools import reduce
import operator as op
# from scipy.misc import comb # float
# import numpy as np
# import heapq
# import array


def nCr(n, r):
    r = min(r, n - r)
    upper = reduce(op.mul, range(n, n-r, -1), 1)
    lower = reduce(op.mul, range(r, 0, -1), 1)
    return upper // lower

def main():
    n = int(sys.stdin.readline().rstrip())

    sorted_letters = [''.join(sorted(sys.stdin.readline().rstrip())) for _ in range(n)]
  
    count = 0
    for c in collections.Counter(sorted_letters).values():
        if c >= 2:
            count += nCr(c, 2)
            
    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 20040
#include <bits/stdc++.h>
using namespace std;
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; }

string s, t;

int main() {
    cin >> s >> t;
    int slen = s.length();
    bool flg = true;
    for(int i = 0; i < slen; ++i) {
        if(s.at(i) != t.at(i)) {
            flg = false;
            break;
        }
    }

    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;	
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;	i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		fn{
			cin >> ar[i];
		}
		sort(ar,ar+n,greater<int>());
		int ans =0;
		int cnt = n/2;
		for(int i =0 ;i < cnt;i++)ans+=ar[i];
		n-=cnt;
		for(int i =1 ;i < n;i++)ans+=ar[i];
		cout<<ans;
	
	}
	return 0;
}

Measured memory_bytes: 5204
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

signed main(signed argc, char *argv[]) {
    int N;
    cin >> N;

    int D[N];
    for(int i=0; i < N; i++) {
        cin >> D[i];
    }

    sort(D, D + N);

    if(N % 2 == 1) {
        cout << 0 << endl;
    } else {
        cout << D[N / 2] - D[N / 2 - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 640
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        a: usize,
        b: usize,
    }
    if a%3==0 || b%3==0 || (a+b)%3==0 {
        println!("Possible");
    } else {
        println!("Impossible");
    }
}


Measured memory_bytes: 2200
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K, S;
  cin >> N >> K >> S;
  for(int i = 0; i < N; ++i){
    if(i < K) cout << S;
    else{
      if(S==1000000000){
      	cout << S-1;
      }
      else{
        cout << S+1;
      }
    }
    
    if(i < N-1) cout << " ";
    else cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long 
    #define mp make_pair
    #define pb push_back
    #define pii pair<int,int>
    #define F first
    #define S second
    int const M=2e5+10,inf=1e9+10;
    int a[M],n;
    void print(int x,int y)
    {
    	y=y xor x;
    	if(y==1)cout<<"Second";
    	else cout<<"First";
    	exit(0);
    }
    void bt(int now)
    {
    	int cnt=0;
    	for(int i=1;i<=n;i++)
    	{
    		cnt+=a[i]%2;
    	}
    	if(cnt>=2)
    	{
    		if(cnt%2==n%2)
    		{
    			print(1,now);
    		}
    		else print(0,now);
    	}
    	bool flag=0;
    	if(cnt==1)
    	{
    		if(cnt%2!=n%2)
    		{
    			print(0,now);
    		}
    		else
    		{
    			flag=1;
    			for(int i=1;i<=n;i++)
    			{
    				if(a[i]%2){
    					if(a[i]==1)
    					{
    						print(1,now);
    					}
    					a[i]--;
    				}
    			}
    			int tmp=0;
    			for(int i=1;i<=n;i++)tmp=__gcd(tmp,a[i]);
    			for(int i=1;i<=n;i++)a[i]/=tmp;
    			bt(1-now);
    		}
    	}
    }
    int main()
    {
    	cin>>n;
    	for(int i=1;i<=n;i++)cin>>a[i];
    	if(n==1)
    	{
    		if(a[1]%2==1)cout<<"Second";
    		else cout<<"First";
    		return 0;
    	}
    	bt(0);
    }

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n, m;
vector<int> s, f;

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

	for (int i = 0;i < m;i++) {
		int a, b;
		cin >> a >> b;

		if (a == 1) {
			s.push_back(b);
		}

		if (b == n) {
			f.push_back(a);
		}
	}

	set<int> stk;

	for (int i = 0;i < s.size();i++) {
		stk.insert(s[i]);
	}

	for (int i = 0;i < f.size();i++) {
		stk.insert(f[i]);
	}

	if (s.size() + f.size() == stk.size()) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		cout << "POSSIBLE" << endl;
	}

	return 0;
}



Measured memory_bytes: 10356
#include <iostream>
#define ll long long
using namespace std;

int main()
{
    ll h, n;
    while(cin >> h >> n )
    {
        ll sum  = 0;
        ll t = 0;
        for(ll i = 0 ; i < n;++i)
        {
            cin >> t;
            sum += t;
        }
        if(sum >= h)
        {
            cout  << "Yes"<<endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define hina cout << ‘ ‘
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, k, g;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n)
    cin >> a[i];
  sort(all(a));
  g = n;
  while(true){
    if(a[n - g] < k)
      g--;
    else{
      cout << g;
      memi;
      return 0;
    }
    if(g == 0){
      cout << 0;
      memi;
      return 0;
    }
  }
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
#define Max 1000000000000000000
/*long long gcd(long long a,long long b)
{
	if(b==0) return a;
	return gcd(b,a%b);
}*/
int main()
{
	unsigned long long x,y,i,f;
	scanf("%llu%llu",&x,&y);
	if(x%y)
	{
		f=0;
		for(i=2;i<=Max/x;i++)
		{
			if(i*x%y!=0)
			{
				f=1;
				printf("%llu\n",i*x);
				break;
			}			
		}
		if(f==0)
			printf("-1\n");
	}
	else
	{
		printf("-1\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define N 1000005
using namespace std;
const int d = 2005;
int n;
int a[N],b[N],jie[N],ni[N];
int f[5005][5005];
const int p = 1000000007;
int c(int n,int m)
{
    return 1LL*jie[n]*ni[m]%p*ni[n-m]%p;
}
int main()
{
    scanf("%d",&n);
    jie[0]=ni[0]=ni[1]=1;
    for(int i=1;i<=10000;i++)jie[i]=1LL*jie[i-1]*i%p;
    for(int j=2;j<=10000;j++)ni[j]=1LL*ni[p%j]*(p-p/j)%p;
    for(int j=2;j<=10000;j++)ni[j]=1LL*ni[j-1]*ni[j]%p;
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&a[i],&b[i]);
        f[a[i]+d][b[i]+d]++;
    }
    for(int i=5000;i>=0;i--)
    {
        for(int j=5000;j>=0;j--)
        {
            (f[i][j]+=f[i][j+1])%=p;
            (f[i][j]+=f[i+1][j])%=p;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans+=f[-a[i]+d][-b[i]+d]-c(2*a[i]+2*b[i],a[i]+a[i]);
        ans%=p;
    }
    ans=(ans+p)%p;
    ans=1LL*ans*500000004%p;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 104704
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define endl '\n'
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
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);
	string s1, s2;
	cin >> s1 >> s2;
	int ans = 1e9;
	for (int i = 0; i <= int(s1.size() - s2.size()); i++) {
		int cnt = 0;
		for (int j = 0; j < int(s2.size()); j++) {
			if (s1[i + j] == s2[j]) {
				cnt++;
			}
		}
		ans = min(ans, int(s2.size()) - cnt);
	}
	if (ans == 1e9)ans = 0;
	cout << ans << endl;
}


Measured memory_bytes: 3664
(defn LucasNumber [N]
  (case N
    0 (bigint 2)
    1 (bigint 1)
    (+ (LucasNumber (dec N)) (LucasNumber (dec (dec N))))))

(def LucasNumber (memoize LucasNumber))

(->> (read)
  int
  LucasNumber
  (printf "%s\n"))

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if ((A <= C && C <= B) || (B <= C && C <= A)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main(void){
   char st[27],alp[26];
   int i,n;

   scanf("%s",st);
   n=strlen(st);

   for(i=0;i<26;i++)
      alp[i]=0;

   for(i=0;i<n;i++){
      alp[st[i]-'a']++;
      if(alp[st[i]-'a'] >= 2){printf("no\n");return 0;}
   }


   printf("yes\n");
   return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,p[SZ],a[SZ];
bool cyc[SZ];
vector<int> cy,ed[SZ];
bool ss[SZ];
void tryy(int x,int f=0)
{
	for(auto b:ed[x]) if(!cyc[b]) tryy(b);
	if(!f)
	{
		for(auto b:ed[x]) ss[a[b]]=1;
		int g=0; while(ss[g]) ++g;
		a[x]=g;
		for(auto b:ed[x]) ss[a[b]]=0;
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",p+i),ed[p[i]].pb(i);
	int g=1; for(int i=1;i<=n+5;++i) g=p[g];
	int x=g;
	do{cy.pb(x); cyc[x]=1; x=p[x];}while(x!=g);
//	for(int i=1;i<=n;++i) cout<<cyc[i]<<",";
//	cout<<"\n";
	for(auto s:cy) tryy(s,1);
	for(auto b:ed[g]) if(!cyc[b]) ss[a[b]]=1;
	int xx=0; while(ss[xx]) ++xx;
	int x1=(xx++); while(ss[xx]) ++xx;
	int x2=xx;
	for(auto b:ed[g])
		if(!cyc[b]) ss[a[b]]=0;
	a[g]=x1; x=p[g];
	while(x!=g)
	{
		for(auto b:ed[x]) ss[a[b]]=1;
		int g=0; while(ss[g]) ++g;
		a[x]=g; for(auto b:ed[x]) ss[a[b]]=0;
		x=p[x];
	}
	bool GG=0;
	for(int x=1;x<=n;++x)
	{
		for(auto b:ed[x]) ss[a[b]]=1;
		int g=0; while(ss[g]) ++g;
		if(a[x]!=g) GG=1;
		for(auto b:ed[x]) ss[a[b]]=0;
	}
	if(!GG)
	{
		puts("POSSIBLE");
		return 0;
	}
	GG=0;
	a[g]=x2; x=p[g];
	while(x!=g)
	{
		for(auto b:ed[x]) ss[a[b]]=1;
		int g=0; while(ss[g]) ++g;
		a[x]=g; for(auto b:ed[x]) ss[a[b]]=0;
		x=p[x];
	}
	for(int x=1;x<=n;++x)
	{
		for(auto b:ed[x]) ss[a[b]]=1;
		int g=0; while(ss[g]) ++g;
		if(a[x]!=g) GG=1;
		for(auto b:ed[x]) ss[a[b]]=0;
	}
	if(!GG)
	{
		puts("POSSIBLE");
		return 0;
	}
	puts("IMPOSSIBLE");
}


Measured memory_bytes: 26488
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s: Vec<char> = iterator.next().unwrap().chars().collect();
    let w: usize = iterator.next().unwrap().parse().unwrap();

    let mut result = String::new();
    for i in 0..s.len() {
        if i % w == 0 {
            result.push(s[i]);
        }
    }
    result
}


Measured memory_bytes: 2116
#include <stdio.h>
 
int main(void){
  int r,c,i,j;
  static int s[101][101];
 
  scanf("%d%d",&r,&c);
 
  for(i=0;i<=r;i++){
    for(j=0;j<c;j++){
      scanf("%d", &s[i][j]);
      printf("%d ", s[i][j]);
      s[i][c] += s[i][j];
      s[r][j] += s[i][j];
    }
    printf("%d\n",s[i][c]);
  }
 
  return 0;
}


Measured memory_bytes: 2048
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
//fixed<<setprecision(10)<<ans<<endl;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M,K;
    cin >> N >> M >> K;

    REP(i,N+1){
        REP(j,M+1){
            if((i*(M-j)) + (j*(N-i)) == K){
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    ll ans=0;
    ll a[n],b[n];
    rep(i,n)cin>>a[i]>>b[i];
    reverse(a,a+n);
    reverse(b,b+n);
    rep(i,n){
        (a[i]+=ans)%=b[i];
        if(a[i]){
            ans+=i[b]-*(i+a);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
/**********************************************************
* @Author: 			   Maple
* @Date:   			   2020-03-01 20:08:34
* @Last Modified by:   Maple
* @Last Modified time: 2020-03-01 20:15:37
* @Remark: 
**********************************************************/
#include <bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define CSE(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define Abs(x) (x>=0?x:(-x))
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll , ll> pll;

const int maxn=1000;
int bingo[5][5],b[22];

int main()
{
/*	#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	#endif*/
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>bingo[i][j];
		}
	}
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>b[i];
		bool fl=true;
		for(int r=0;r<3&&fl;r++){
			for(int c=0;c<3&&fl;c++){
				if(bingo[r][c]==b[i]){
					bingo[r][c]=0;
					fl=false;
				}
			}
		}
	}
	bool ans=false;
	for(int i=0;i<3;i++){
		if(bingo[i][0]==0&&bingo[i][1]==0&&bingo[i][2]==0)
			ans=true;
		if(bingo[0][i]==0&&bingo[1][i]==0&&bingo[2][i]==0)
			ans=true;
	}
	if(bingo[0][0]==0&&bingo[1][1]==0&&bingo[2][2]==0)
		ans=true;
	if(bingo[0][2]==0&&bingo[1][1]==0&&bingo[2][0]==0)
		ans=true;
	ans?cout<<"Yes"<<endl:cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
vector<int> input(int N) {
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}

int main() {
  int k,x;
  cin >> k >> x;
  for(int i=1;i<=k;i++){
    cout << x-k+i << " ";
  }
  for(int i=1;i<k;i++){
    cout << x+i << " ";
  }
  cout << endl;
}

Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val bList = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
    val aList = mutableListOf<Int>()
    bList.add(0, bList.first())
    bList.add(bList.last())
    for(i in (1 until bList.size)) {
        aList.add(Math.min(bList[i-1], bList[i]))
    }
    println(aList.sum())
}



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

string s;

bool ok(int len) {
	if(2 * len <= s.length())
		return true;
	return *min_element(s.begin() + s.size() - len, s.begin() + len) == *max_element(s.begin() + s.size() - len, s.begin() + len);
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> s;
	int l = 0, r = s.length() + 1;
	while(r - l > 1) {
		int c = (l + r) >> 1;
		if(ok(c))
			l = c;
		else
			r = c;
	}
	cout << l;
	return 0;
}

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

using namespace std;

class Area {
public:
    Area() {}
    Area(int _h, int _w) {
        h = _h;
        w = _w;
    }

    bool operator<(const Area& area) const {
        if (h == area.h) {
            return w < area.w;
        }
        return h < area.h;
    }

    bool area_equal(Area area) {
        return h == area.h && w == area.w;
    }

    int h, w;
};

bool check(Area a1, Area a2, Area a3)
{
    if (a1.h == a2.h && a2.w == a3.h && a3.w == a1.w) {
        return true;
    }
    if (a1.w == a2.h && a2.w == a3.h && a3.w == a1.h) {
        return true;
    }
    if (a1.h == a2.w && a2.h == a3.h && a3.w == a1.w) {
        return true;
    }
    if (a1.w == a2.w && a2.h == a3.h && a3.w == a1.h) {
        return true;
    }
    if (a1.h == a2.h && a2.w == a3.w && a3.h == a1.w) {
        return true;
    }
    if (a1.w == a2.h && a2.w == a3.w && a3.h == a1.h) {
        return true;
    }
    if (a1.h == a2.w && a2.h == a3.w && a3.h == a1.w) {
        return true;
    }
    if (a1.w == a2.w && a2.h == a3.w && a3.h == a1.h) {
        return true;
    }
    return false;
}

string solve(vector<Area> vec)
{
    bool flag = vec[0].area_equal(vec[1]) & vec[2].area_equal(vec[3]) & vec[4].area_equal(vec[5]);
    if (!flag) {
        return "no";
    }

    if (check(vec[0], vec[2], vec[4])){
        return "yes";
    }

    return "no";
}

int main()
{
    int h, w;
    vector<Area> vec;
    for (int i = 0; i < 6; ++i) {
        cin >> h >> w;
        if (h > w) {
            swap(h, w);
        }
        vec.push_back(Area(h, w));
    }
    sort(vec.begin(), vec.end());

    cout << solve(vec) << endl;

    return 0;
}

Measured memory_bytes: 3184
/* 
 * Project: AtCoder Beginners Contest 143 C - Slimes
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/08/18
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstdint>
using namespace std;

uint32_t n;
char s[100000];

void solve() {

    uint32_t cnt = n;
    for (int i=0;i<n-1;i++) {
        if (s[i] == s[i+1])
            cnt--;
    }
    printf("%d\n", cnt);
}

int main() {

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

    solve();
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<string> s(N);
    rep (i, N) {
        cin >> s[i];
    }

    map<string, ll> m;
    rep (i, N) {
        sort(s[i].begin(), s[i].end());
        m[s[i]]++;
    }

    ll ans = 0;
    for (auto it : m) {
        ans += (it.second)*(it.second-1)/2;
    }

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

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	int a,b; cin>>a>>b;
	int ans=0;
	if(a==b)ans=0;
	else if(b==0){
		if(a<0)ans=abs(a);
		else ans=a+1;
	}
	else if(abs(a)>abs(b)){
		if(a>=0 && b>=0)ans=a-b+2;
		else if(a<0 && b<0)ans=b-a;
		else if(a>=0 && b<0)ans=a+b+1;
		else ans=abs(a+b)+1;
	}
	else{
		if(a>=0 && b>=0)ans=b-a;
		else if(a<0 && b<0)ans=a-b+2;
		else if(a<0 && b>=a)ans=a+b+1;
		else ans=abs(a+b)+1;
	}
	cout<<ans<<endl;
	
	return 0;
}

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

int main () {
  
vector<vector<int>> bingo(3, vector<int>(3));  
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++){
cin >> bingo.at(i).at(j);
}
}
  int N;
  cin >> N;
  vector<int> B(N);
  for (int k = 0; k < N; k++) {
  cin >> B[k];
  }
  for (int l = 0; l < N;l++) {
  for (int m = 0; m < 3;m++) {
  for (int n = 0; n < 3;n++) {
  if (B[l] == bingo.at(m).at(n)) {
  bingo.at(m).at(n) = -1;
  }
  }
  }
  }
  if (bingo[0][0] == -1 && bingo[0][1] == -1 && bingo[0][2] == -1) {
  cout << "Yes" << endl;
  }
  else if (bingo[1][0] == -1 && bingo[1][1] == -1 && bingo[1][2] == -1) {
  cout << "Yes" << endl;
  }
  else if (bingo[2][0] == -1 && bingo[2][1] == -1 && bingo[2][2] == -1) {
  cout << "Yes" << endl;
  }
  else if (bingo[0][0] == -1 && bingo[1][0] == -1 && bingo[2][0] == -1) {
  cout << "Yes" << endl;
  }
  else if (bingo[0][1] == -1 && bingo[1][1] == -1 && bingo[2][1] == -1) {
  cout << "Yes" << endl;
  }
  else if (bingo[0][2] == -1 && bingo[1][2] == -1 && bingo[2][2] == -1) {
  cout << "Yes" << endl;
  }
  else if (bingo[0][0] == -1 && bingo[1][1] == -1 && bingo[2][2] == -1) {
  cout << "Yes" << endl;
  }
  else if (bingo[0][2] == -1 && bingo[1][1] == -1 && bingo[2][0] == -1) {
  cout << "Yes" << endl;
  }
  else {
  cout << "No" << endl;
  }
}




Measured memory_bytes: 256
#include<iostream>
#include<stack>
using namespace std;
int main(){
    stack<int>  s;
    int x;
    cin >> x;
    s.push(x);
    while(cin>>x){
        if(x==0){
            cout << s.top() << endl;
            s.pop();
        }
        else{
            s.push(x);
        }
    }
}


Measured memory_bytes: 3072
#ユークリッド互除法
def gcd(a,b):
  if(a<b):
    a,b=b,a
  if(b==0):
    return a
  c= a%b
  return gcd(b,c)

n,x=map(int,input().split())
hoge=list(map(int,input().split()))
ans=abs(x-hoge[0])
for i in range(n):
  ans=gcd(ans,abs(hoge[i]-x))
print(ans)

Measured memory_bytes: 14252
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	fastio;
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	int ok=0;
	if(a[0]==a[1]&&a[1]!=a[2]) ok=1;
	if(a[1]==a[2]&&a[0]!=a[1]) ok=1;
	if(ok){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 256
//by xxj
#include<bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define lowbit(x) x&-x
const int inf=1e9+7;
const double eps=1e-10;
const ll linf=1e18+7;
const ll hh=523;
//const int mod=;
int q[200007];
int cnt=0;
ll ans=0;
void deal(){
	int tot=0;
	for (int i=0;i<cnt;i++){
		if (q[i]==1){
			tot++;
		}
		else{
			ans+=tot;
		}
	}
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	string s;
	cin>>s;
	for (int i=0;i<s.size();i++){
		while ((i<s.size() && s[i]=='A') || (i<=s.size()-2 && s[i]=='B' && s[i+1]=='C')){
			if (s[i]=='A'){
				q[cnt++]=1;
				i++;
			}
			else{
				q[cnt++]=2;
				i+=2;
			}
		}
		deal();
		cnt=0;
	}
	printf("%lld\n",ans);
	return 0;
}
/*
input:
*/


Measured memory_bytes: 1284
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>
#include <map>
#include <string>
#include <climits>
#include <set>
#include <sstream>
#include <utility>
#include <ctime>
#include <cassert>
#include <fstream>
using namespace std;
typedef long long LL;
#define MS(A) memset(A, 0, sizeof(A))
#define MSV(A,a) memset(A, a, sizeof(A))
#define MAX(a,b) ((a >= b) ? (a) : (b))
#define MIN(a,b) ((a >= b) ? (b) : (a))
#define ABS(a) (((a) > 0) ? (a) : (-a))
#define MP make_pair
#define PB push_back
#define getcx getchar_unlocked
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define clrbit(s, b) (s &= ~(1<<b))


double pi = std::acos(-1);

int main() {

	int a,b,h,m;
	cin>>a>>b>>h>>m;

	double hangle = 0.5 * (h * 60 + m);  
    double mangle = 6 * m;  
    double angle = ABS((hangle - mangle));  

	angle = min(360 - angle, angle);  

	double cosine = cos(angle*pi/180);
	
 	double l = a*a + b*b - 2*a*b*cosine;
 	double ans = sqrt(l);
 	printf("%0.9lf\n", ans);

 	return 0;

}

Measured memory_bytes: 4188
#include<stdio.h>
int main(){
	char a,b,c,d;
	scanf("%c %c %c %c",&a,&b,&c,&d);
	if (a == b || b == c || c == d){
		printf("Bad\n");
	}
	else{
		printf("Good\n");
	}
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
//#define local
#ifdef local
#include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
#include <boost/multiprecision/cpp_int.hpp>
#endif

#define p std::pair
#define ll long long
#define ull unsigned long long
#define pi (acos(-1))
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
constexpr ll mod = 1000000000 + 7;

int main()
{
    int n, d;
    cin >> n >> d;
    vec<vec<int>> r(n, vector<int>(d));

    rep(i, n)
    {
        rep(j, d) { cin >> r[i][j]; }
    }

    ll ans = 0;
    rep(i, n)
    {
        for (int j = i + 1; j < n; ++j)
        {
            int sq = 0;
            rep(k, d)
            {
                int sub = r[i][k] - r[j][k];
                sq += sub * sub;
            }
	    double dist=sqrt(sq);
	    if(dist==floor(dist)){++ans;}
        }
    }
cout<<ans<<endl;
    return 0;
}
ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}



Measured memory_bytes: 3688
#include<iostream>
using namespace std;
int main(){
  string c;
  cin>>c;
  if(c=="a"){
    cout<<"vowel"<<endl;
  }
   else if(c=="i"){
     cout<<"vowel"<<endl;
  }
   else if(c=="u"){
     cout<<"vowel"<<endl;
  }
  else if(c=="e"){
    cout<<"vowel"<<endl; 
  }
   else if(c=="o"){
     cout<<"vowel"<<endl; 
  }
   else{
    cout<<"consonant"<<endl; 
  }   
}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int main() {

entry:;
  int n; cin >> n;
  if (n == 0) return 0;

  int d[10][10];
  rep (i, 10) rep(j, 10) d[i][j] = i == j ? 0 : INF;

  int m = 0;
  rep (i, n) {
    int a, b, c; cin >> a >> b >> c;
    d[a][b] = d[b][a] = c;
    m = max(m, max(a, b));
  }
  ++m;

  rep(k,m)rep(i,m)rep(j,m) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

  long mx = INF;
  int mi = -1;
  rep (i, m) {
    long a = 0;
    rep (j, m) {
      a += d[i][j];
    }
    if (mx > a) {
      mx = a;
      mi = i;
    }
  }

  cout << mi << ' ' << mx << endl;

  goto entry;

  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

int main(){
  int n;
  cin >> n;
  if(n==1){
    cout << 0;
    return 0;
  }
  vector<set<int>>tree(n);
  for(int i=0; i<n-1; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    tree[a].insert(b);
    tree[b].insert(a);
  }
  priority_queue<int>c;
  for(int i=0; i<n; i++){
    int tmp;
    cin >> tmp;
    c.push(-tmp);
  }
  queue<int>Q;
  for(int i=0; i<n; i++){
    if(tree[i].size()==1)Q.push(i);
  }
  int sum=0;
  vector<int>ret(n, 0);
  while(Q.size()>1){
    int l=Q.front();
    Q.pop();
    ret[l]=-c.top();
    c.pop();
    sum+=ret[l];
   	int p=*tree[l].begin();
    tree[l].erase(p);
    tree[p].erase(l);
    if(tree[p].size()==1)Q.push(p);
  }
  ret[Q.front()]=-c.top();
  cout << sum << endl;
  for(int i: ret)cout << i << ' ';
  return 0;
}

Measured memory_bytes: 1664
<?php
  $ary = array();
  while (true) {
    $str = trim(fgets(STDIN));
    if ($str === '') {
      $alpha = range('a','z');
      $join = strtolower(join('', $ary));
      foreach ($alpha as $a) {
        print($a . " : " . substr_count($join, $a) . "\n");
      }
      return;
    }
    $ary[] = $str;
  }
?>

Measured memory_bytes: 6600
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  ll int k, n, sm = 0;
  cin >> n >> k;
  do{
    sm++;
    //int a = n % k;
    n = n / k;
    if(n == 1){
      sm++;
      break;
    }
  }while(n != 0);
    
    cout << sm << "\n";
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


int main() {
	int n;
	cin >> n;
	unordered_map<int, int> counter;
	rep(i,n){
        int a;
        cin >> a;
        counter[a]++;
	}

	int ans = 0;
	for(auto p : counter){
        if(p.second) ans++;
	}
	cout << (ans&1 ? ans : ans - 1) << endl;
}


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

int main() {
  int N;
  cin >>N;
  int A[N],B[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
    B[i]=A[i];
  }
  sort(B,B+N,greater<int>());
  for(int i=0;i<N;i++){
    if(A[i]==B[0]) cout << B[1]<<endl;
    else cout << B[0]<<endl;
  }
}

Measured memory_bytes: 3200
class SWAG():
    __slots__='unit','f','fold_r','fold_l','data_r','data_l'
    def __init__(self,unit,f,data):
        self.unit=unit
        self.f=f
        self.construct(data)
    def construct(self,data):
        self.fold_r=[self.unit]
        self.fold_l=[self.unit]
        self.data_r=[]
        self.data_l=[]
        sep=len(data)//2
        for t in data[sep+1:]:
            self.append(t)
        for t in data[sep::-1]:
            self.appendleft(t)
    def append(self,x):
        self.fold_r.append(self.f(self.fold_r[-1],x))
        self.data_r.append(x)
    def appendleft(self,x):
        self.fold_l.append(self.f(self.fold_l[-1],x))
        self.data_l.append(x)
    def pop(self):
        if not self.data_r:
            self.construct(self.data_l[::-1])
        self.fold_r.pop()
        return self.data_r.pop()
    def popleft(self):
        if not self.data_l:
            self.construct(self.data_r)
        self.fold_l.pop()
        return self.data_l.pop()
    def fold_all(self):
        return self.f(self.fold_r[-1],self.fold_l[-1])
n,k,*p=map(int,open(0).read().split())
c=[0]
for a,b in zip(p,p[1:]):c+=c[-1]+(a<b),
*c,f=[b-a==k-1for a,b in zip(c,c[k-1:])]
x=not f
s_min=SWAG(10**18,min,p[:k-1])
s_max=SWAG(0,max,p[1:k])
for i,(a,b,c)in enumerate(zip(p,p[k:],c)):
    f|=c
    s_min.append(p[i+k-1])
    s_max.append(b)
    if not c and(a!=s_min.fold_all()or b!=s_max.fold_all()):x+=1
    s_min.popleft()
    s_max.popleft()
print(x+f)

Measured memory_bytes: 120764
n, m = map(int, input().split())
a = [[] for i in range(m)]
for i in range(m):
    t = list(map(int, input().split()))
    a[i] = t[1:]

p = list(map(int, input().split()))
ans = 0
for i in range(1<<n):
    p_ = p[:]
    for j in range(n):
        if not (i & (1<<j)):
            continue
        for k in range(m):
            if j+1 in a[k]:
                p_[k] ^= 1
    ans += (max(p_) == 0)
print(ans)



Measured memory_bytes: 3188
#include <iostream>
#include <vector>
using namespace std;
const int N_MAX = 100;

bool P[N_MAX+1] = {false, false};

void sieve(int n) {
	fill(P+2, P+n+1, true);
	for (int i = 2; (long long)i*i <= n; ++i) {
		if (P[i]){
			for (int j = i*i; j <= n; j += i) {
				P[j] = false;
			}
		}
	}
}

vector<pair<int,int>> prime_factorization_factorial(int n) {
	vector<pair<int, int>> v;
	for (int i = 2; i <= n; i++) {
		if (!P[i]) continue;
		int p = i, e = 0;
		while (p <= n) {
			e += n / p;
			p *= i;
		}
		v.emplace_back(i, e);
	}
	return v;
}

int main() {
	sieve(100);
	int n;
	cin >> n;
	int s[150] = {0};
	auto v = prime_factorization_factorial(n);
	for (auto e : v) {
		s[e.second]++;
	}
	for (int i = 148; i >= 1; i--) {
		s[i] += s[i+1];
	}
	int ans = 0;
	ans += s[4] * (s[4] - 1) / 2 * (s[2] - 2);
	ans += s[14] * (s[4] - 1);
	ans += s[24] * (s[2] - 1);
	ans += s[74];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;
const ll mod = 998244353;

struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
  mint operator+(const mint a) const { return mint(*this)+=a; }
  mint operator-(const mint a) const { return mint(*this)-=a; }
  mint operator*(const mint a) const { return mint(*this)*=a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod-2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this)/=a; }
  bool operator==(const mint a) const { return x == a.x; }
  bool operator!=(const mint a) const { return x != a.x; }
  friend ostream &operator<<(ostream &os, const mint &p) { return os << p.x; }
  friend istream &operator>>(istream &is, mint &a) {
    ll t;
    is >> t;
    a = mint(t);
    return (is);
  }
};

template<typename T>
struct Comb {
  vector<T> fact, finv, inv;
  Comb(int n) : fact(n, 1), finv(n, 1), inv(n, 1) { init(n); }
  void init(int n) {
    fact.assign(n, 1), finv.assign(n, 1), inv.assign(n, 1);
    for (ll i=2; i<n; i++) {
      fact[i] = fact[i-1] * i % mod;
      inv[i] = mod - inv[mod%i] * (mod/i) % mod;
      finv[i] = finv[i-1] * inv[i] % mod;
    }
  }
  T nck(int n, int k) {
    if (n<k || n<0 || k<0) return 0;
    return fact[n] * (finv[k] * finv[n-k] % mod) % mod;
  }
  T nhk(int n, int k) { return nck(n+k-1, k); }
  T npk(int n, int k) {
    if (n<k || n<0 || k<0) return 0;
    return fact[n] * finv[n-k] % mod;
  }
};

int main()
{
  ll n; cin>>n;
  vector<ll> d(n);
  rep(i, n) cin>>d[i];

  ll ma = 0;
  vector<ll> a(n);
  rep(i, n) {
    if (i == 0) {
      if (d[i] != 0) {
        cout << 0 << endl;
        return 0;
      }
    } else {
      if (d[i] == 0) {
        cout << 0 << endl;
        return 0;
      }
    }
    ma = max(ma, d[i]);
    a[d[i]]++;
  }

  mint ans = 1;
  for (int i=1; i<ma; i++) {
    ans *= mint(a[i]).pow(a[i+1]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4784
import java.io.*;
public class Main{
  public static void main(String[] args){
    try{
      BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	  int N = Integer.parseInt(bf.readLine());
      long a = 2;
      long b = 1;
      long c = N == 0 ? a : N == 1 ? b : 0;
      for(int i = 2; i <= N; i++){
      	c = a+b;
        a = b;
        b = c;        
      }
      System.out.println(c);
    } catch(IOException e){}
  }
}
    

Measured memory_bytes: 21204
#include<stdio.h>
int main(void){
long A,B,K;
  scanf("%ld %ld %ld",&A,&B,&K);
  if(A>=K)
  printf("%ld %ld\n",A-K,B);
  else if(B-K+A>=0)printf("0 %ld\n",B-K+A);
  else printf("0 0\n");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n;
long long k;
long long a[N] = {0};

int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        int x, y; cin >> x >> y;
        a[x] += y;
    }
    for (int i = 1; i < N; i++) a[i] += a[i - 1];
    for (int i = 1; i < N; i++) {
        if (a[i] >= k) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1024