akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

// C
#define MAX 100005
int a[MAX];
vector<int> ve1,ve2;
map<int,int> mp1,mp2;
vector<P> ve;
signed main(){
  int n; cin>>n;
  for(int i=1; i<=n; i++) cin>>a[i];

  for(int i=1; i<=n; i+=2){
    if(mp1[a[i]]++==0) ve1.push_back(a[i]);
  }
  for(int i=2; i<=n; i+=2){
    if(mp2[a[i]]++==0) ve2.push_back(a[i]);
  }

  for(int i=0; i<ve1.size(); i++){
    ve.push_back(mk(mp1[ve1[i]],ve1[i]));
  }
  sort(ve.begin(), ve.end(),greater<P>());
  P one=ve[0],sec=ve[1];
  ve.clear();
  for(int i=0; i<ve2.size(); i++){
    ve.push_back(mk(mp2[ve2[i]],ve2[i]));
  }
  sort(ve.begin(), ve.end(),greater<P>());
  int m=0;
  if(one.second==ve[0].second){
    m=max(one.first+ve[1].first,sec.first+ve[0].first);
  }else{
    m=ve[0].first+one.first;
  }
  cout<<n-m<<en;
}


Measured memory_bytes: 9208
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		int[] A=new int[N];
		int x=(int)(Math.log(Math.pow(10, 9))/Math.log(2));
		//System.out.println(x);
		//System.out.println(Math.pow(2,x));
		int a[]=new int[x+1];
		for(int i=0;i<x+1;i++) {
			a[i]=0;
		}
		//System.out.println(x);
		for(int i=0;i<N;i++) {
			A[i]=sc.nextInt();
			int b=(int)(Math.log(A[i])/Math.log(2));
			a[b]++;
			//System.out.println(b);
		}
		Arrays.sort(A);
		int count=0;
		for(int i=x+1;i>0;i--) {
			int m=0;
			for(int j=x+1;j>=i;j--) {
				m+=a[j-1];
			}
			for(int j=0;j<m;j++) {
				A[N-1-j]=A[N-1-j]/2;
				count++;
				if(count==M) {
					break;
				}
			}
			if(count==M) {
				break;
			}
			Arrays.sort(A);
		}
		long sum=0;
		for(int i=0;i<N;i++) {
			sum+=(long)A[i];
			//System.out.println(A[i]);
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 52336
#include <cstdio>
#include <cmath>

#define s(a) sin(a*M_PI/180)
#define S(a) (float)a

int main(){
  int n;

  while(scanf("%d" ,&n),n){
    double a1 = 0.0,a2 = 0.0,in,rem = 360;
    for(int i = 0 ; i < n-1 ; i++){
      scanf("%lf" ,&in);
      rem -= in;
      a1 += s(in);
    }
    a1 += s(rem);

    scanf("%d" ,&n);
    rem = 360;
    for(int i = 0 ; i < n-1 ; i++){
      scanf("%lf" ,&in);
      rem -= in;
      a2 += s(in);
    }    
    a2 += s(rem);

    if(S(a1) > S(a2)){
      puts("1");
    }else if(S(a1) < S(a2)){
      puts("2");
    }else{
      puts("0");
    }
  }

  return 0;
}

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


ll minK(ll a,ll b){
  ll c;
  c = max(a,b)%min(a,b);
  if(c==0){
    return min(a,b);
  }
  return minK(min(a,b),c);
}

int main(){

  int n;
  cin>>n;
  ll t[n];
  REP(i,n){
    cin>>t[i];
  }
  ll ans = t[0];
  for(int i=1;i<n;i++){
    ans = ans /minK(ans,t[i]) * t[i];
  }
  cout<<ans<<endl;
    
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int answer = -1;

		for (int i = 1; i <= 9; i++) {
			if (N <= i * 1 + i * 10 + i * 100) {
				answer = i * 1 + i * 10 + i * 100;
				break;
			}
		}

		System.out.println(answer);
	}
}


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

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


int main() {
  int N = 0;
  int H = 0;
  std::cin >> N >> H;
  std::vector<int> a;
  std::vector<int> b;
  repeat(i, N) {
    int aBuffer = 0;
    int bBuffer = 0;
    std::cin >> aBuffer >> bBuffer;
    a.push_back(aBuffer);
    b.push_back(bBuffer);
  }
  std::sort(a.begin(), a.end());
  std::sort(b.begin(), b.end());
  int iCount = 0;
  int cnt = 0;
  repeat(i, N) {
    if(b[N - 1 - i] <= a[N - 1]) {
      break;
    }
    iCount += b[N - 1 - i];
    cnt++;
    if(iCount >= H) {
      std::cout << cnt << std::endl;
      return 0;
    }
  }
  while(true) {
    iCount += a[N - 1];
    cnt++;
    if(iCount >= H) {
      std::cout << cnt << std::endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 1276
#include <stdio.h>
int main ()
{
	int n,i;
	int a, b, c, d;
	scanf("%d",&n);
	{
		d = n / 1000;
		a = n % 10;
		c = (n - d * 1000) / 100;
		b = n % 100 / 10;
		if((a == b && b == c) || (b == c && c == d))
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	return 0;
}

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

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

    ll a, b, n; cin >> n >> a >> b;

    ll p = (n / (a + b));
    ll q = (n % (a + b));

    ll ans = p * a;

    if(q <= a) {
        ans += q;
    } else {
        ans += a;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>
using namespace std;
typedef long long ll ;
typedef double db;
typedef long double ldb;
typedef unsigned long long ull ;
//const double PI = acos(-1) ;
db PI=3.1415926;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define for0(i,n)          for(int i=0;i<n;i++)
#define for1(i,n)          for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define gcd(a, b)     __gcd(a, b)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
//#define abs(x)		fabs(x)
#define pcase(z,x)     pf("Case %d: %lld\n",z,x)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)


using namespace std;
ll n,m,y,x,h,e,l,o,z;
//int p,n,arr[2100000],ans;

//ll function_(ll p,ll q,ll r);
int main(void)
{
	CIN;

	cin>>n;
	m=ceil(n*1.0/1000);
	m*=1000;
	pf("%lld\n",m-n);
	
}
	


Measured memory_bytes: 3820
import java.util.*;

class Main {
	public static void main(String args[]){
		
		Scanner sc = new Scanner(System.in);
		
		//表の行数rと列数cを読み取る
		String s1 = sc.next();
		int r = Integer.parseInt(s1);
		String s2 = sc.next();
		int c = Integer.parseInt(s2);
		//表を値を配列に受け取る
		int a[][] = new int[r][c];
		
		//cとrが条件範囲内か確認
		if(1 <= r && r <= 100){
			if(1 <= c && c <= 100){
				
				//配列に格納していく
				for(int i = 0; i < r; i++ ){
					for(int j = 0; j < c; j++){
						String s3 = sc.next();
						int k = Integer.parseInt(s3);
						a[i][j] = k;
					}
				}
				
				int total = 0;
				//入力された表の値と行ごとの合計値の表示
				for(int i = 0; i < r; i++ ){
					int sum = 0;
					for(int j = 0; j < c; j++){
						System.out.print(a[i][j] + " ");
						sum += a[i][j];
					}
					total += sum;
					System.out.println( sum );
				}
				
				//入力された表の値の列ごとの合計値の表示
				for(int j = 0; j < c; j++ ){
					int sum = 0;
					for(int i = 0; i < r; i++){
						sum += a[i][j];
					}
					System.out.print( sum + " ");
				}
				System.out.println( total );
			}
		}
	}

}

Measured memory_bytes: 41884
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ac = a*c;
  ll ad = a*d;
  ll bc = b*c;
  ll bd = b*d;
  ll ans = max(ac, ad);
  ans = max(ans, bc);
  ans = max(ans, bd);
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int r,g, b;cin>>r>>g>>b;
    int sum = r*100+g*10+b;
    if(sum%4==0){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int main()
{
    int m;
    long int n;
    while(1==1)
    {
        scanf("%d %ld\n",&m,&n);
        if(m==0 && n==0)break;
        int mat[7368795]={};
        long int poi=m;
        while(n>0)
        {
            for(int i=poi;i<7368795;i+=poi)mat[i]=1;
            n--;
            while(mat[poi]==1)poi++;
        }
        printf("%ld\n",poi);
    }
    return 0;
}


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

using namespace std;

int main(){
	string S;
	int K;
	cin >> S >> K;

	for (int i = 0; i < S.length(); i++){
		if (i == S.length() - 1){
			char last = (S[i] - 'a' + K) % 26 + 'a';
			cout << last << endl;
			break;
		}
		if (S[i] != 'a' && 'z' - S[i] + 1 <= K){
			cout << 'a';
			K -= 'z' - S[i] + 1;
		}
		else{
			cout << S[i];
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <algorithm>
using namespace std;
int input;
string toString(int n){stringstream ss; ss << n; return ss.str();}
bool isPalindromicNum(int x){
  string s = toString(x);
  string _s = s;
  reverse(s.begin(), s.end());
  return s == _s;
}
void solve(){
  int margin = input;
  int ans;
  for(int i = 0 ; i < input + margin; i++){
    if(isPalindromicNum(i)){
      margin = abs(input - i);
      ans = i;
    }
  }
  cout << ans << endl;
}
int main(){
  while(cin >> input){
    solve();
  }
  return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int n,m;int dp[110000];vector<int> g[110000];
int rec(int v){
  if(dp[v] != -1)return dp[v];
  int res = 0;
  for(int nv : g[v]){
    res = max(res, rec(nv)+1);
  }
  return dp[v] = res;
}
signed main() {
  cin>>n>>m;
  rep(i,m){
    int x,y;cin>>x>>y;g[x].push_back(y);
  }
  repd(i,1,n+1)g[n+1].push_back(i);
  rep(i,110000)dp[i] = -1;
  cout << rec(n+1) - 1 << endl;
}

Measured memory_bytes: 9716
import itertools
n = int(input())
l = list(map(int,input().split()))
count = 0
for item in itertools.combinations(l, 3):
    if len(set(item)) == 3:
        if item[0] + item[1] > item[2] and item[1] + item[2] > item[0] and item[2] + item[0] > item[1]:
            count += 1
print(count)

Measured memory_bytes: 68172
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

template<long long mod>
struct modint{
    long long num;

    constexpr modint(long long x = 0) : num((x + mod) % mod) {}

    constexpr modint &operator += (const modint& rhs){
        num = (num + rhs.num) % mod;
        return *this;
    }
    constexpr modint &operator -= (const modint& rhs){
        num  -= rhs.num;
        while(num < 0) num += mod;
        num %= mod;
        return *this;
    }
    constexpr modint &operator *= (const modint& rhs){
        num = num * rhs.num % mod;
        return *this;
    }
    constexpr modint &operator /= (modint rhs){
        int exp = mod - 2;
        while(exp > 0){
            if(exp % 2){
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }

    constexpr modint operator ++ (){
        ++num;
        return *this;
    }
    constexpr modint operator ++ (int n){
        modint tmp = *this;
        ++(*this);
        return tmp;
    }
    constexpr modint operator -- (){
        --num;
        return *this;
    }
    constexpr modint operator -- (int n){
        const modint tmp = *this;
        --(*this);
        return tmp;
    }

    void modpow(ll y){
        modint tmp = (*this);
        (*this) = 1;
        while(y > 0){
            if(y % 2){
                (*this) *= tmp;
            }
            tmp *= tmp;
            y /= 2;
        }
    }

    constexpr modint operator + (const modint& rhs) const {
        return modint(*this) += rhs;
    }
    constexpr modint operator - (const modint& rhs) const {
        return modint(*this) -= rhs;
    }
    constexpr modint operator * (const modint& rhs) const {
        return modint(*this) *= rhs;
    }
    constexpr modint operator / (const modint& rhs) const {
        return modint(*this) /= rhs;
    }

    
    friend ostream &operator << (ostream& lhs, const modint& rhs){
        return lhs << rhs.num;
    }

    friend istream &operator >> (istream& lhs, modint& rhs){
        long long tmp;
        lhs >> rhs.num;
        return lhs;
    }
};

#define mint modint<1000000007>

int n;
mint dp[1000010];
mint ans = 0;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    dp[0] = 1;
    for(int i = 0; i <= n; i++){
        //伝播
        if(i != 0) dp[i + 1] += dp[i];
        if(i + 1 <= n) dp[i + 1] += dp[i];
        if(i + 2 <= n) dp[i + 2] -= dp[i];
        if(i + 3 <= n) dp[i + 3] += dp[i];
        //計算
        if(i + 2 <= n) ans += dp[i] * (i + 1);
        
        if(i == n) ans += dp[i];
        else if(i + 1 == n) ans += dp[i] * (n - 1);
        else ans += dp[i] * (n - 1) * (n - 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int branch(char c, int pre)
{
    switch (c) {
        case 'a' : return 0;
        case 'b' : return 1;
        case 'c' : return 2;
        default : return pre+3;
    }
}
int main()
{
    string sa, sb, sc;
    cin >> sa >> sb >> sc;

    int aa=0, ab=0, ac=0;
    int len = sa.length() + sb.length() + sc.length();

    int ans, next = 0;
    for(int i=0; i<len; i++){
        if(next == 0) {
            next = branch(sa[aa], next);
            aa++;
        } else if (next == 1) {
            next = branch(sb[ab], next);
            ab++;
        } else if (next == 2) {
            next = branch(sc[ac], next);
            ac++;
        } else {
            ans = next-3;
            break;
        }
    }

    cout << (ans==0 ? "A" : (ans==1 ? "B" : "C" )) << endl;

    return 0;
}


Measured memory_bytes: 256
n=int(raw_input())

def comb(tr):
    l=len(tr)
    res=[]
    for i in range(l):
        head,tail=tr[i:],tr[:i]
        headrev=head[::-1]
        tailrev=tail[::-1]
        res.append(head+tail)
        res.append(headrev+tail)
        res.append(head+tailrev)
        res.append(headrev+tailrev)
        res.append(tail+head)
        res.append(tailrev+head)
        res.append(tail+headrev)
        res.append(tailrev+headrev)
    return len(set(res))
    #return res
for i in range(n):
    tr = raw_input()
    print comb(tr)

Measured memory_bytes: 6348
K = 3             # 単一整数
H,W,N = K.times.map{gets.to_i}  # 縦に並んだ複数の整数。たまにある

#判定
wk = 0

if H >= W then
  wk = H
else
  wk = W
end
  
ans = 0
i = 0
while i < N do
  i = i + wk
  ans = ans + 1
end

  puts ans

Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;

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

const int INF = 1000000007;

int main(void){
	string S; cin>>S;
	vector<char> vec;

	for(int i=0;i<S.size();i++){
		if(S[i]=='0' || S[i]=='1') vec.push_back(S[i]);
		if(S[i] == 'B' && (!vec.empty())) vec.pop_back();
	}

	for(int i=0;i<vec.size();i++) cout<<vec[i];
	cout<<endl;
	//printf("%s\n", vec);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <climits>
using namespace std;

int main()
{
    int A, B, M;
    int x;
    scanf("%d%d%d", &A, &B, &M);
    vector<int>AS, BS;
    int mina = INT_MAX;
    int minb = INT_MAX;
    for(int i = 0; i < A; i++)
    {
        scanf("%d", &x);
        AS.push_back(x);
        mina = min(mina, x);
    }
    for(int i = 0; i < B; i++)
    {
        scanf("%d", &x);
        BS.push_back(x);
        minb = min(minb, x);
    }
    int result = mina + minb;
    for(int i = 0; i < M; i++)
    {
        int xi, yi, ci;
        scanf("%d%d%d", &xi, &yi, &ci);
        result = min(result, AS[xi - 1] + BS[yi - 1] - ci);
    }
    printf("%d\n", result);
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        
        int[] bs = new int[n - 1];
        bs[0] = s.nextInt();
        
        int sum = bs[0];
        
        for (int i = 1; i < n - 1; i ++) {
            bs[i] = s.nextInt();
            if (bs[i] > bs[i - 1])
                sum += bs[i - 1];
            else
                sum += bs[i];
        }
        
        sum += bs[n - 2];
        
        System.out.println(sum);
    }
    
}


Measured memory_bytes: 23632
using System;
using System.Linq;
using System.Text.RegularExpressions;

namespace algorithm
{
	class Program
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine();

			int z = s.Where(x => x == '0').Count();
			int i = s.Where(x => x == '1').Count();
			if (z < i)
			{
				
			}
			else
			{
				z = i;
			}
			Console.WriteLine(z*2);
		}
	}
}


Measured memory_bytes: 11360
k, n = map(int, input().split())
a = list(map(int, input().split()))

sa = []

for i in range(n-1):
    sa.append(a[i+1]-a[i])

sa.append(k+a[0]-a[n-1])

ma = max(sa)
sa.remove(ma)

print(sum(sa))

Measured memory_bytes: 26436
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <tuple>
#include <unordered_set>
#include <unordered_map>

typedef long long ll;
using namespace std;

int main(void) {
  int N; cin >> N;
  vector<int> A(N), B(N), C(N);
  for (int i = 0; i < N; i++) { cin >> A[i]; }
  for (int i = 0; i < N; i++) { cin >> B[i]; }
  for (int i = 0; i < N; i++) { cin >> C[i]; }
  sort(A.begin(), A.end());
  // sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  ll count = 0;
  // for (int b : B) {
  for (int i = 0; i < N; i++) {
    ll countL = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
    ll countR = upper_bound(C.begin(), C.end(), B[i]) - C.begin();
    count += countL * (N - countR);
  }
  cout << count << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> list(n);
  cin >> list.at(0);
  char a = list.at(0).back();
  for(int i=1; i<n; i++) {
    cin >> list.at(i);
    if(list.at(i).at(0) != a) {
      cout << "No" << endl;
      return 0;
    }
    a = list.at(i).back();
  }
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      if(list.at(i) == list.at(j) && i != j) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main  {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long result = 1;
        for (int i = 1; i <= n; i++) {
            result *= i;
            result %= (1e9 + 7);
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}




int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<ll>v,s;
    for(int i=0;i<pow(2,n);i++){
        ll a;
        cin>>a;
        v.push_back(a);
        s.push_back(a);
    }
    sort(v.rbegin(),v.rend());
    map<ll,ll>m;
    m[0]=1;
    int cnt=0;
    vector<ll>res;
    res.push_back(v[0]);
    while(n>0){
        ll puis=pow(2,cnt);
        ll cnt1=0;
        vector<ll>ans;
        for(int i=0;i<v.size();i++){
            if(m[i]==0){
                if(res[cnt1]>v[i]){
                    m[i]=1;
                    ans.push_back(v[i]);
                    cnt1++;
                }
            }
            if(cnt1==puis)break;
        }
        if(cnt1<puis){cout<<"No"<<endl;return 0;}
        for(int i=0;i<ans.size();i++){
            res.push_back(ans[i]);
        }
        sort(res.rbegin(),res.rend());



        n--;
        cnt++;
    }
    if(res==v){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}

    return 0;
    }


Measured memory_bytes: 26596
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[5];
    for(int i = 0; i < 3; i++)
        cin >> a[i];
    sort(a, a+3);
    if(a[0] + a[1] == a[2])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> V(N), C(N);
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> V[i];
	}
	for (int i = 0; i < N; i++)
	{
		cin >> C[i];
		if (V[i] > C[i])
		{
			ans += V[i] - C[i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace CompetitiveProgramming
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            var charList = new List<char>();
            foreach(char c in s)
            {
                charList.Add(c);
            }
            int min = 1000;

            for (var i = 0; i < charList.Count - 2;i++)
            {
                int first = int.Parse(charList[i].ToString());
                int second = int.Parse(charList[i+1].ToString());
                int third = int.Parse(charList[i+2].ToString());
                int number = first * 100 + second * 10 + third;
                int ans = Math.Abs(number - 753);
                if (ans < min)
                {
                    min = ans;
                }
            }
            Console.WriteLine(min);
        }

    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int x;
    cin >> x;
    cout << -((x-400)/200)+8 << endl;
    
}

Measured memory_bytes: 3632
def Mcheck(n):
    if(0<n<13):
        return 0
    else:
        return 1
    

S=input()
f=int(S[0])*10+int(S[1])
s=int(S[2])*10+int(S[3])

if(Mcheck(f)==0):
    if(Mcheck(s)==0):
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if(Mcheck(s)==0):
        print("YYMM")
    else:
        print("NA")
        

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
using namespace std;

const int MX = 1<<16;
bool sieve[MX];

void prepare() {
    memset(sieve, false, sizeof sieve);
    sieve[0] = sieve[1] = true;
    for (int i=2; i*i<MX; ++i) {
        if ( ! sieve[i]) {
            for (int j=i*i; j<MX; j+=i) {
                sieve[j] = true;
            }
        }
    }
}

int main() {
    prepare();
    int n;
    while (cin >> n, n) {
        int cnt = 0;
        for (int i=2; i<=n-i; ++i) {
            if ( ! sieve[i] && ! sieve[n-i]) {
                cnt ++;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
ll n;
map<ll,ll>mp;
map<ll,ll>::iterator it;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll i,j,k,ans=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>j;
        mp[j]++;
    }
    for(it=mp.begin();it!=mp.end();it++)
    {
        j=it->first;
        k=it->second;
        if(k>=j)
        ans+=(k-j);
        else
        {
            ans+=k;
        }
    }
    cout<<ans<<"\n";
    return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    int n,t,a;
    vi h;
    cin>>n;
    cin>>t>>a;
    h.resize(n);
    REP(i,n) cin>>h[i];

    double closesttemp = 100000;
    int ans;

    REP(i,n){
        double tt = t-h[i]*0.006;
        tt = abs(tt-a);

        if(closesttemp > tt ){
            closesttemp = tt;
            ans = i+1;
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++){
    string S;
    cin >> S;
    if(S == "Y"){
      cout << "Four" << endl;
      return 0;
    }
  } 
      cout << "Three" << endl;
      return 0; 
}

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

int main()
{
    char a, b;
    
    cin >> a >> b;
    
    if(a == 'H' && b == 'H')
    {
        cout << 'H';
    }
    else if(a == 'H' && b == 'D')
    {
        cout << 'D';
    }
    else if(a == 'D' && b == 'H')
    {
        cout << 'D';
    }
    else if(a == 'D' && b == 'D')
    {
        cout << 'H';
    }
    
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define All(x) (x).begin(),(x).end()
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>inline void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);	
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
const int maxn=2e5+5,maxm=1e6+5;
int n,tot=1;
int head[maxn],des[maxm],nxt[maxm],vis[maxm],ans[maxn],d[maxn];
void adde(int x,int y){
	des[++tot]=y;nxt[tot]=head[x];head[x]=tot;
	des[++tot]=x;nxt[tot]=head[y];head[y]=tot;
}
void dfs(int x){
	for(int &p=head[x];p;p=nxt[p])if(!vis[p>>1]){
		vis[p>>1]=1;
		int now=des[p];
		dfs(now);
		if(now==x+n)ans[x]=1;
		if(x==now+n)ans[now]=-1;
	}
}
int main(){
	read(n);
	rep(i,1,n){
		int x;read(x);
		if(x!=-1)d[x]^=1,adde(x,i);
		else adde(2*n+1,i);
	}
	rep(i,1,n){
		int x;read(x);
		if(x!=-1)d[x+n]^=1,adde(x+n,i+n);
		else adde(2*n+1,i+n);
	}
	rep(i,1,n)if(d[i]!=d[i+n])return puts("IMPOSSIBLE"),0;
	puts("POSSIBLE");
	rep(i,1,n)if(!d[i])adde(i,i+n);
	dfs(2*n+1);
	rep(i,1,n)printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 22016
#include <cstdio>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

// backslash: \
// \\\\////
// \ = -1
// / = +1
// _ =  0
// height の累積和
// 横軸の位置に対する
// 陸地のheight
// 水深のdepth 
//

#define MAX_LEN 20000

int main() {
	string s;
	cin >> s;

	int max_width = s.length() + 1;
	// ground height
	vector<int> gh(max_width);
	// left max, right max
	vector<int> ghmaxl(max_width, -MAX_LEN);
	vector<int> ghmaxr(max_width, -MAX_LEN); 
	// water depth
	vector<int> wd(max_width,0);

	// base level = 0
	gh[0] = 0;
	ghmaxl[0] = gh[0];
	for (int i=1; i<max_width; ++i) {
		int iprev = i-1;
		int inc = 0;
		if (s[iprev] == '\\') {
			inc = -1;
		} else if (s[iprev] == '/') {
			inc = +1;
		} else if (s[iprev] == '_') {
			inc =  0;
		}
		gh[i] = gh[iprev] + inc;
		ghmaxl[i] = max(ghmaxl[iprev], gh[i]);
		//cout << "gh[" << i << "] = " << gh[i] << ", ghmaxl = " << ghmaxl[i] << endl;
	}
	ghmaxr[max_width-1] = gh[max_width-1];
	for (int i=max_width-2; i>=0; --i) {
		ghmaxr[i] = max(ghmaxr[i+1], gh[i]);
		//cout << "gh[" << i << "] = " << gh[i] << ", ghmaxr = " << ghmaxr[i] << endl;
	}
	// water depth and area
	vector<int> area;
	int current_area = 0;
	for (int i=1; i<max_width; ++i) {
		// water height
		wd[i] = max(min(ghmaxl[i], ghmaxr[i]) - gh[i], 0);
		// intで集計するため一旦単に和を取る
		current_area += (wd[i-1] + wd[i]);
		if (wd[i-1] > 0 && wd[i] == 0) {
			area.push_back(current_area/2);// 所定の面積にするため2で割る
			current_area = 0;
		}
//		cout << "gh[" << i << "] = " << gh[i] << ", ghmaxl = " << ghmaxl[i];
//		cout << ", ghmaxr = " << ghmaxr[i] << ", wd = " << wd[i];
//		cout << ", current_area = " << current_area << endl;
	}
	cout << accumulate(area.begin(), area.end(), 0) << endl;
	cout << area.size();
	for (int i=0; i<area.size(); ++i) {
		cout << " " << area[i];
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 3404
import sys
def input():
	return sys.stdin.readline()[:-1]

def included(x):
	if x == "AB":
		return 0, 1
	elif x == "BC":
		return 1, 2
	else:
		return 0, 2

def ans(x):
	l = ["A", "B", "C"]
	return l[x]

n, a, b, c = map(int, input().split())
nums = [a, b, c]
s = [input() for _ in range(n)]
res = []
for i, x in enumerate(s):
	y, z = included(x)
	if nums[y] == nums[z] == 0:
		print("No")
		break
	if i == n-1:
		if nums[y] >= nums[z]:
			res.append(ans(z))
		elif nums[z] > nums[y]:
			res.append(ans(y))
	else:
		if nums[y] > nums[z]:
			res.append(ans(z))
			nums[y] -= 1
			nums[z] += 1
		elif nums[z] > nums[y]:
			res.append(ans(y))
			nums[z] -= 1
			nums[y] += 1
		elif z in included(s[i+1]):
			res.append(ans(z))
			nums[y] -= 1
			nums[z] += 1
		else:
			res.append(ans(y))
			nums[z] -= 1
			nums[y] += 1
else:
	print("Yes")
	print(*res, sep="\n")

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

#define ALL(v) v.begin(), v.end()

int main() {
  std::cout << std::fixed << std::setprecision(20);
  int K, N;
  cin >> N >> K;
  vector<int> p(N);
  REP(i,N) cin >> p[i];
  sort(ALL(p));
  int ans = 0;
  REP(i,K) ans += p[i];
  cout << ans << endl;
}

Measured memory_bytes: 3600
package main

import "fmt"

func main() {

	var n int
	fmt.Scanf("%d\n", &n)

	for i := 0; i <= n; i++ {
		if i != 0 {
			if i%3 == 0 || i%10 == 3 {
				fmt.Printf(" %d", i)

			} else {
				x := i
				for true {
					x = x / 10
					if x <= 0 {
						break
					} else if x%10 == 3 {
						fmt.Printf(" %d", i)
						break
					}
				}
			}

		}
	}
	fmt.Println("")
}



Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
char s[10];
int main(){
	scanf("%s",s);
	if(s[0]==s[1]&&s[1]==s[2]||s[1]==s[2]&&s[2]==s[3])puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = (1001001001);
const ll N =(100+5); // TODO : change value as per problem
const ll MOD = 1e9+7;

int adj[N][N];
int wt[N][N];
void solve(){
	int n,m;
	cin >> n >> m;	
	for(int i =1;i<=n;i++){
		for(int j =1;j<=n;j++){
			adj[i][j]=INF;
		}
		adj[i][i]=0;
	}
	for(int i =1;i<=m;i++){
		int u,vv,c;
		cin >> u >> vv >> c;
		adj[u][vv] = c;
		adj[vv][u] = c;
		wt[u][vv] = c;
		wt[vv][u] = c;
	}
	for(int k=1;k<=n;k++){
		for(int i =1;i<=n;i++){
			for(int j =1;j<=n;j++){
				
				adj[i][j] = min(adj[i][j],adj[i][k] + adj[k][j]);
			}	
		}
	}
	int ans = 0;
	for(int i =1;i<=n;i++){

		for(int j = i+1;j<=n;j++){
			if(wt[i][j] == 0) continue;
			bool p = false;
			// cout << i << " " << j << endl;
			for(int a = 1;a<= n;a++){
				// if(a == i || a == j) continue;
				for(int b=  1;b<=n;b++){
					// if(b == i || b == j) continue;
					if(adj[a][b] == (adj[a][i] + adj[j][b] + wt[i][j])) p=true;
				}
			}
			if(p) ans++;
		}
	}
	cout << m-ans << endl;
}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

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

int main() {
  string s;
  cin >> s;
  vector<int> com(2);
  rep(i, 2) com[i] = 0;
  rep(i, 3)
    if (s[i] == 'A') com[0] = 1;
    else if (s[i] == 'B') com[1] = 1;
  if (com[0]+com[1] < 2) cout << "No";
  else cout << "Yes";
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;

double a,b,c,d;
int main(){
	cin >> a >> b >> c >> d;
	double e = sqrt((a-c)*(a-c)+(b-d)*(b-d));
	printf("%.6f\n",e);
}


Measured memory_bytes: 3292
#C問題
#gcd(二つの数)
def gcd(GCD1,GCD2):
    x = min(GCD1,GCD2)
    y = max(GCD1,GCD2)
    if y%x == 0:
        return x
    else:
        return gcd(x,y%x)
N,X = map(int,input().split())
C = list(map(int,input().split()))

D = []
for c in C:
    D.append(abs(X-c))
    

for i in range(N):
    if i == 0:
        g = D[0]
    else:
        g = gcd(g,D[i])
        
print(g)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
			using namespace std;
			#define rep(i,a,n) for (int i=a;i<n;i++)
			#define per(i,a,n) for (int i=n-1;i>=a;i--)
			#define pb push_back
			#define mp make_pair
			#define all(x) (x).begin(),(x).end()
			#define fi first
			#define se second
			#define SZ(x) ((int)(x).size())
			typedef vector<int> VI;
			typedef long long ll;
			typedef pair<int,int> PII;
			typedef double db;
			mt19937 mrand(random_device{}()); 
			const ll mod=1000000007;
			int rnd(int x) { return mrand() % x;}
			ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
			ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
			int main() {
				 ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
					int n;
					double m;
					cin>>n>>m;
					double a[n];
					for(int i=0;i<n;i++)
					cin>>a[i];
					int c=0;
					double sum=0;
					for(int i=0;i<n;i++)
					sum=sum+a[i];
					for(int i=0;i<n;i++)
					{
						double k=sum*(double)(1/(4*m));
						if(a[i]>=k)
						c++;
					}
					if(c>=m)
					cout<<"Yes"<<"\n";
					else
					cout<<"No"<<"\n";
			}


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

int main() {
    int n, q; cin >> n >> q;
    vector<queue<int>> que(n);
    while (q--) {
        int com; cin >> com;
        if (com == 0) {
            int t, x; cin >> t >> x; que[t].emplace(x);
        } else if (com == 1) {
            int t; cin >> t;
            if (!que[t].empty()) cout << que[t].front() << endl;
        } else if (com == 2) {
            int t; cin >> t;
            if (!que[t].empty()) que[t].pop();
        }
    }
    return 0;
}


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

using namespace std;

long long a[1000005];

int main()

{

	long long sum=1;

	int n,i;

	cin>>n;

	for(i=0;i<n;i++)

	{

		cin>>a[i];

		if(!a[i])

		{

			cout<<0;

			return 0;

		}

	}

	for(i=0;i<n;i++)

	{

		if(1000000000000000000ll/sum<a[i]){

			cout<<-1;

			return 0;

		}

		sum*=a[i];

	}

	cout<<sum;

	return 0;

}

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

int main(){
  ll n=0,a=0,b=0,c=0,cnt=0;

  cin >> n;

  for(a=1;a<n;a++){
  	for(b=1;b<n;b++){
      if(a*b >=n){break;}
      else if(n - (a*b) >0){cnt++;}
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int mx=199999;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
inline void _plus(int x,int y,int z){
	printf("+ %d %d %d\n",x,y,z);
}
inline void _cmp(int x,int y,int z){
	printf("< %d %d %d\n",x,y,z);
}
void get_1(){
	_plus(0,1,mx-1);
	_plus(mx-1,mx-1,mx);
	_cmp(mx-1,mx,mx);
}
void get_pw2(){
	for(int i=1;i<=60;++i){
		_plus(mx-i+1,mx-i+1,mx-i);
	}
}
void Mul_01(int x,int y,int z){
	static const int tmp=114514;
	_plus(y,mx,tmp+2);
	_plus(tmp+4,tmp+4,tmp+3);
	for(int i=60;i>=0;--i){
		_plus(tmp+3,mx-i,tmp+1);
		_cmp(tmp+1,tmp+2,tmp);
		_plus(tmp,x,tmp);
		_cmp(mx,tmp,tmp);
		for(int j=1;j<=i;++j){
			_plus(tmp,tmp,tmp);
		}
		_plus(tmp+3,tmp,tmp+3);
	}
	_plus(z,tmp+3,z);
}
void Solve(){
	static const int tmp=115414;
	_plus(0,3,3);
	for(int i=1;i<=30;++i){
		_plus(3+i-1,3+i-1,3+i);
	}
	_plus(1,mx,tmp+2);
	_plus(tmp+4,tmp+4,tmp+3);
	for(int i=30;i>=0;--i){
		_plus(tmp+3,mx-i,tmp+1);
		_cmp(tmp+1,tmp+2,tmp);
		Mul_01(tmp,3+i,2);
		for(int j=1;j<=i;++j){
			_plus(tmp,tmp,tmp);
		}
		_plus(tmp+3,tmp,tmp+3);
	}
}
int main(){
	//freopen("E.ans","w",stdout);
	printf("66932\n");
	get_1();
	get_pw2();
	Solve();
	return 0;
}



Measured memory_bytes: 3668
a,p,q,o,x,b;
main(){
  for(scanf("%d",&p),q=p;~scanf("%s",&a);o=o==3?b=x=!printf("%d\n",x):o){
    //printf("%d\n",a%9);
    ///*
    //printf("bef x:%d b:%d o:%d\n",x,b,o);
    if(a%9==7)b=b*2+1,x+=b>>3&1;
    if(a%9==8)o++;
    if(a%9==6)for(x++,b&=7;b;b/=2)x+=b&1;
    //printf("x:%d b:%d o:%d\n",x,b,o);
     //*/
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <bitset>
#include <fstream>
using namespace std;
typedef long long ll;

int main()
{
	string str;
	char buf;
	//while(cin>>buf) cout<<(int)buf<<endl;
	cin>>str;
	for(int i = 0; i < str.size(); i++){
		if(str.at(i) > 67) cout<<(char)(str.at(i)-3);
		else if(str.at(i) == 65) cout<<'X';
		else if(str.at(i) == 66) cout<<'Y';
		else if(str.at(i) == 67) cout<<'Z';
	}
	cout<<endl;
	//cin.sync(); cin.get();
}

Measured memory_bytes: 0
import java.util.Scanner;
import java.util.*;
public class Main {
    static int[] f = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    static int INF = Integer.MAX_VALUE;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            a.add(sc.nextInt());
        }
        Collections.sort(a);
        int[] dp = new int[n + 1];
        Arrays.fill(dp, -INF);
        dp[0] = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < m; j++) {
                if (i - f[a.get(j)] < 0) {
                    continue;
                }
                dp[i] = Math.max(dp[i - f[a.get(j)]] + 1, dp[i]);
            }
        }

        int remain = dp[n];
        int match = n;
        String ans = "";
        while (match > 0) {
            for (int i = m - 1; i >= 0; i--) {
                if (match - f[a.get(i)] < 0) {
                    continue;
                }
                if (dp[match - f[a.get(i)]] == remain - 1) {
                    remain--;
                    match -= f[a.get(i)];
                    ans += String.valueOf(a.get(i));
                    break;
                }
            }
        }
        System.out.println(ans);
    }
}


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

int main() {
  int N, A;
  cin >> N >> A;
  
  if ((N%500) == 0) {
  	cout << "Yes" << endl;
  }
  else {
  	if ((N%500) <= A) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

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

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(){

    ll a;
    double b;
    cin >> a >> b;
    // a *= 100;
    ll lb = (ll)(b*100.000000+0.1);

	// ll l = a/1000000;
	// ll r = a/1000000000000 


    ll ans = a*lb;
    ans /= 100;
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// ?????????????????\????????????
		Scanner sc = new Scanner(System.in);

		// ?????°?????????
		int cnt1 = 0;
		int cnt2 = 0;

		while(true) {

			int H = sc.nextInt();
			int W = sc.nextInt();

			if(H == 0 && W == 0)
				break;

			for(cnt1 = 0; cnt1 < H; cnt1++ ) {

				for(cnt2 = 0; cnt2 < W ; cnt2++ ) {
					System.out.print("#");
				}
			System.out.println("");

			}
			System.out.println("");
		}
		sc.close();
	}
}

Measured memory_bytes: 34528
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<vector<int>> d(n, vector<int>(2));
  for (int i=0; i<n; i++) {
    cin >> d.at(i).at(0);
    cin >> d.at(i).at(1);
  }
  
  bool b=false;
  for (int i=0; i<n-2; i++) {
    if (d.at(i).at(0) == d.at(i).at(1) && d.at(i+1).at(0) == d.at(i+1).at(1) && d.at(i+2).at(0) == d.at(i+2).at(1)) {
      cout << "Yes\n";
      b = true;
      break;
    }
  }
  
  if (!b) cout << "No\n";
}

Measured memory_bytes: 3620
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        a = S()
        if a == '0':
            break
        b = S()
        c = S()
        ml = max([len(a),len(b),len(c)])
        if len(a) < ml:
            a = '0' * (ml-len(a)) + a
        if len(b) < ml:
            b = '0' * (ml-len(b)) + b
        if len(c) < ml:
            c = '0' * (ml-len(c)) + c

        r = [[0,0] for _ in range(ml+1)]
        r[0][0] = 1
        for i in range(ml):
            ai = a[ml-i-1]
            bi = b[ml-i-1]
            ci = c[ml-i-1]
            r0 = [0,0]
            r1 = [0,0]
            si = 0
            if i == ml - 1:
                si = 1
            al = range(si,10)
            if ai != '?':
                al = [int(ai)]
            bl = range(si,10)
            if bi != '?':
                bl = [int(bi)]
            cl = range(si,10)
            if ci != '?':
                cl = [int(ci)]

            for ac,bc,cc in itertools.product(al,bl,cl):
                abc = ac+bc
                if abc % 10 == cc:
                    if abc > 9:
                        r0[1] += 1
                    else:
                        r0[0] += 1
                elif (abc+1) % 10 == cc:
                    if abc > 8:
                        r1[1] += 1
                    else:
                        r1[0] += 1
            r[i+1][0] += r0[0] * r[i][0]
            r[i+1][0] += r1[0] * r[i][1]
            r[i+1][1] += r0[1] * r[i][0]
            r[i+1][1] += r1[1] * r[i][1]

        rr.append(r[ml][0] % mod)


    return '\n'.join(map(str,rr))



print(main())



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

using namespace std;

int main(){
    long long int sum=0,N,b;
    int n=0;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        A[i] -= (i+1);
    }

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

    if(N%2==1){
        b = A[N/2];
    }else{
        b = A[N/2] + A[N/2 -1];
        b /= 2;
    }

    for(int i=0;i<N;i++){
        sum += abs(A[i]-b);
    }

    cout << sum << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 998244353
typedef double ld;
#define PI 3.14159265


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

    int n;
    cin >> n;
    vector<PII> arr;
    vector<int> temp;
    int v;
    for(int i = 0 ; i < n ; i++) {
        cin >> v;
        arr.pb({v , i + 1});
        temp.pb(v);
    }
    sort(allr(arr));
    int mid = n / 2;
    map<PII , int> mp;
    int k = 1;
    for(auto it : arr) {
        //cout << it.first << " " << it.second << endl;
        mp[{it.first , it.second}] = k++;
    }
    vector<PII> vv;
    for(int i = 0 ; i < n ; i++) {
        int ind = mp[{temp[i] , i + 1}];
        if(ind > mid) {
            cout << arr[mid - 1].first << endl;
        }
        else if(ind == mid) {
            cout << arr[mid].first << endl;
        }
        else {
            cout << arr[ind + (mid - ind)].first << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 17008