akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <stack>
#include<queue>
#include<list>

using std::vector;

int main()
{
    int n,q,ope,t,x,s;
    std::cin>>n>>q;
    std::list<int> S[n];

    for(int i = 0; i < q; i++)
    {
        std::cin>>ope;
        if(ope==0){std::cin>>t>>x;S[t].push_back(x);}
        else if(ope==1){std::cin>>t;      
        for(std::list<int>::iterator it = S[t].begin();it != S[t].end();it++){
        if(it != S[t].begin()) std::cout << " ";
        std::cout<<*it;}
        std::cout<<std::endl;
        }
        else{ std::cin>>s>>t; S[t].splice(S[t].end(), S[s]);}
    }

    return 0;
}



Measured memory_bytes: 18752
from itertools import*
_,*s=open(0)
s=[a[0]!=b[0]for a,b in zip(*map(groupby,s))]
c=3*2**s[0]
for a,b in zip(s,s[1:-1]):c=c*(a+2if b else(1^a)+1)%(10**9+7)
print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

class NoNeed
{
private:
	int n, k;
	int sum;
	vector<vector<bool> > l_dp;
	vector<vector<bool> > r_dp;
	vector<int> a;
public:
	NoNeed(){
		cin >> n >> k;
		a.resize(n);
		sum = 0;
		for (int i = 0; i < n; ++i)
		{
			cin >> a[i];
			sum += a[i];
		}
		l_dp = vector<vector<bool> >(n, vector<bool>(k+1, false));
		r_dp = vector<vector<bool> >(n, vector<bool>(k+1, false));
	}

	bool is_valid(int med){
		if(a[med] >= k){
			return true;
		}

		for (int i = k - a[med]; i < k; ++i)
		{
			if(med == 0){
				if(r_dp[1][i]) return true;
				continue;
			}

			if(med == n-1){
				if(l_dp[n-2][i]) return true;
				continue;
			}

			for (int j = 0; j <= i; ++j)
			{
				if(l_dp[med-1][j] && r_dp[med+1][i-j]){
					return  true;
				}
			}
		}
		return false;
	}

	void set_dp(){
		l_dp[0][0] = true;
		if(a[0] <= k) l_dp[0][a[0]] = true; 
		for (int i = 1; i < n; ++i)
		{
			for (int j = 0; j <= k; ++j)
			{
				if(l_dp[i-1][j] || (j - a[i] >= 0 && l_dp[i-1][j - a[i]]) ){
					l_dp[i][j] = true;
				}
			}
		}
		r_dp[n-1][0] = true;
		if(a[n-1] <= k) r_dp[n-1][a[n-1]] = true;
		for (int i = n-2; i >= 0; --i)
		{
			for (int j = 0; j <= k; ++j)
			{
				if(r_dp[i+1][j] || (j -  a[i] >= 0 && r_dp[i+1][j - a[i]]) ){
					r_dp[i][j] = true;
				}
			}
		}

	}

	void exec(){
		sort(a.begin(), a.end());
		// if(sum < k){
		// 	cout << n << endl;
		// 	return;
		// }

		set_dp();
		// int left = 0;
		// int right = n-1;
		// while(left < right){
		// 	int med = (left + right) / 2;
		// 	if(is_valid(med)){
		// 		right = med;
		// 	}else{
		// 		left = med + 1;
		// 	}
		// }
		// cout << right << endl;
		for (int i = 0; i < n; ++i)
		{
			if(is_valid(i)){
				cout << i << endl;
				return;
			}
		}
		cout << n << endl;


	}
};


int main(){
	NoNeed nn = NoNeed();
	nn.exec();
}

Measured memory_bytes: 6912
#include <iostream>
#include <string>
using namespace std;
int main(){
    int mon,day,ans=0,answer=0,sum[13]={1,31,60,91,121,152,182,213,244,274,305,335,366};
    string date[8]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
    while(cin>>mon>>day){
        if(mon==0)break;
        mon=mon-1;
        if(mon>0){
            ans=day+sum[mon];
        }else{
            ans=day;
        }
        answer=ans%7;
        cout<<date[answer]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
typedef tuple<int,int,int,int>T;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX =510000;

int main(){
  	string S;
  	cin >>S;
  	ll N=S.size();
  	ll dp[13][N+1];
  	rep(i,13){rep(j,N+1){dp[i][j]=0;}}
  	ll memo[N+1];
  	rep(i,N+1){memo[i]=0;}
  	memo[0]=1;
  	rep(i,N){
      memo[i+1]=(memo[i]*10)%13;
    }
  	char p=S[N-1];
  	if(p=='?'){rep(i,10){dp[i][0]=1;}}
  	else{
        int g=p-'0';
        dp[g][0]=1;
    }
  	for(int i=1;i<=N-1;i++){
    	int b=memo[i];	
    	if(S[N-i-1]!='?'){
        	int g=S[N-i-1]-'0';
          	g=(g*b)%13;
          	for(int j=0;j<=12;j++){
              if(j+g<=12){dp[j+g][i]+=dp[j][i-1];dp[j+g][i]%=MOD;}
              else{dp[j+g-13][i]+=dp[j][i-1];dp[j+g-13][i]%=MOD;}
            }
        }	
    	else{
          rep(h,10){
            	int g=(h*b)%13;
            for(int j=0;j<=12;j++){
              if(j+g<=12){dp[j+g][i]+=dp[j][i-1];dp[j+g][i]%=MOD;}
              else{dp[j+g-13][i]+=dp[j][i-1];dp[j+g-13][i]%=MOD;}
            } 	
          }
        }//else
    }
  	cout<<dp[5][N-1]<<endl;
}


Measured memory_bytes: 11392
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  cout << (n <= k ? x * n : x * k + y * (n-k)) << endl;
  return 0;
}


Measured memory_bytes: 256
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  char sign;
  int a, b;
  scanf("%d%*c%c%*c%d", &a, &sign, &b);
  if (sign == '+')
    printf("%d\n", a + b);
  else
    printf("%d\n", a - b);
  return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env pypy3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import math
from collections import defaultdict
pc = True
n = int(input())
a = list(map(int,input().split()))
g = math.gcd(a[0],a[1])
for i in range(2,n):
    g = math.gcd(g,a[i])
M = max(a)

LIMIT=max(a)
minPrime = [0]*(LIMIT+1)
minPrime[1] = 1
def make():
    for i in range(2,LIMIT+1):
        if minPrime[i] == 0:
            minPrime[i] = i
            #print(i)
            for j in range(i+i,LIMIT+1,i):
                #print(i,j)
                if minPrime[j] == 0:
                    minPrime[j] = i
make()
class Sieve_of_Eratosthenes:
    def __init__(self, N):
        self.sieve = [-1] * (N+1)

        for i in range(2,N+1):
            if self.sieve[i] == -1:
                for j in range(1,1+N//i):
                    self.sieve[i*j] = i

    def isprime(self, num):
        if num <= 1:
            return False
        else:
            return self.sieve[num] == num

    def factorization(self, num):
        ret = set([])
        while num != 1:
            div = self.sieve[num]
            ret.add(div)
            num //= div
        return ret

def factrial(N):
    ret = set()
    while 1 != N:
        ret.add(minPrime[N])
        N = N//minPrime[N]
    if N != 1:
        ret.add(N)
    return ret


sofe = Sieve_of_Eratosthenes(M)
ddic = defaultdict()
judge = set([])

for i in a:
    if not pc:
        break
    #asf = sofe.factorization(i)
    asf = factrial(i)

    if judge & asf != set():
        pc = False
    judge |= asf
if pc:
    print("pairwise coprime")
elif g == 1:
    print("setwise coprime")
else:
    print("not coprime")
# import sys,collections

# N = int(sys.stdin.readline())
# #a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = list(map(int,input().split()))

# import math

# # def factrial(N):
# #     ret = []
# #     while minPrime[N] != N:
# #         ret.append(minPrime[N])
# #         N = N//minPrime[N]
# #     if N != 1:
# #         ret.append(N)
# #     return ret

# def factrial(N):
#     ret = set()
#     while 1 != N:
#         ret.add(minPrime[N])
#         N = N//minPrime[N]
#     if N != 1:
#         ret.add(N)
#     return ret

# for i in range(N):
#     acc = math.gcd(acc,a[i])
# if acc != 1:
#     print("not coprime")
#     exit()

# pairwise = True
# p = set() #all prime
# for e in a:
#     if not pairwise:
#         break
#     f = factrial(e)
#     if p & f != set():
#         pairwise = False
#         print("setwise coprime")
#         exit(0)
#     p = p | f

# if pairwise:
#     print("pairwise coprime")
# else:
#     print("setwise coprime")


Measured memory_bytes: 195192
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

int main() {
    int N;
    cin >> N;
    vector<vector<ll>> A(N, vector<ll>(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) cin >> A[i][j];
    }
    
    vector<ll> dp(1<<N, 0);
    for (int i = 0; i < (1<<N); i++) {
        for (int j = 0; j < N; j++) {
            for (int k = j+1; k < N; k++) {
                if ((i>>j)&(i>>k)&1) dp[i] += A[j][k];
            }
        }
    }
    
    for (int i = 1; i < (1<<N); i++) {
        for (int j = ((i-1)&i); j > 0; j = ((j-1)&i)) {
            dp[i] = max(dp[i], dp[j]+dp[i-j]);
        }
    }
    cout << dp[(1<<N)-1] << endl;
    return 0;
}

Measured memory_bytes: 3788
#include <stdio.h>
#include <ctype.h>
int main(void) {
	char c;
	while(scanf("%c",&c)!=EOF && c!='\n'){
		if(islower(c)){
			printf("%c",toupper(c));
		}else if(isupper(c)){
			printf("%c",tolower(c));
		}else{
			printf("%c",c);
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> A){
  vector<bool> flags(1000000005);
  REP(i, N) {
    if (flags.at(A.at(i))){
      cout << NO << endl;
      return;
    } 
    flags.at(A.at(i)) = true;
  }
  cout << YES << endl;
}

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


Measured memory_bytes: 123904
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  int T[N]; rep(i,N) cin >> T[i];
  int sum = 0; rep(i,N) sum += T[i];

  int M; cin >> M;
  rep(i,M) {
    int P, X; cin >> P >> X;
    int result = sum - T[P-1] + X;
    cout << result << endl;
  }
  return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0)
# define CF
int dp[5005][5005];
const int mod = 1e9 + 7;
int pow(int a,int b,int mod)
{
    int ans = 1;
    while (b)
    {
        if (b&1) ans = (1ll * ans * a) % mod;
        a = (1ll * a * a) % mod;
        b /= 2;
    }
    return ans;
}
int main(void)
{
    #ifdef CF
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    dp[0][0] = 1;
    int n,k;
    string str;
    fi>>n>>str;
    k = str.length();
    for (int i = 0;i < n;++i)
        for (int j = 0;j <= n;++j)
        {
            (dp[i+1][j+1] += dp[i][j] * 2ll) %= mod;
            (dp[i+1][max(0,j-1)] += dp[i][j]) %= mod;
        }
    fo << (1ll * dp[n][k] * pow(pow(2,mod - 2,mod),k,mod)) % mod << '\n';
    return 0;
}




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

int main() {
	int a = 0;
	for(int n = 0;n < 4;n++) {
         	char b;
  	        cin >> b;
		if(b == '-') {
			a--;
		}else{
			a++;
		}
	}
	cout << a << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int N;
  int i, j, v;
  scanf("%d\n", &N);
  int A[N];
  for (i = 0; i < N; i++){
    scanf("%d", &A[i]);
  }

  //Insertion Sort
  for (i = 0; i < N; i++){
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;

    for (int k = 0; k < N; k++){
      if (k < N-1){
        printf("%d ", A[k]);
      }else{
        printf("%d\n", A[k]);
      }
    }
  }

  return 0;
}



Measured memory_bytes: 2104
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <climits>

using namespace std;
using ll=long long;

void solve(){
  int a,b;
  cin >> a >> b;
  cout << a*b << " " << 2*(a+b) << endl;
}

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



Measured memory_bytes: 3192
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int hok;
        int n = sc.nextInt();
        int num[] = new int[n];
        for(int i = 1;i <= n; i++){
            num[i-1] = sc.nextInt();
        }
        for(int j = 0; j <= n; j++){
            for(int i = 0; i < n - 1; i++){
                if(num[i] < num[i + 1]){
                    hok = num[i];
                    num[i] = num[i + 1];
                    num[i + 1] = hok;
                }
            }
        }
        int s = n;
        for(int k = 0;k < n - 1;k++){
            if(num[k] == num[k + 1]){
                s = s - 1;
            }
        }
        System.out.println(s);
        sc.close();
    }
}

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

using namespace std;

#define ll long long
#define F first
#define S second
#define ii pair < int , int >

const int N=1;

int main()
{
  ll a,b,c,d;
  scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
  ll ans=max(max(a*c,a*d),max(b*c,b*d));
  printf("%lld",ans);
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int K, A, B;
  cin >> K >> A >> B;
  for (int i = A; i <= B; i++)
  {
    if (i % K == 0)
    {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if (n%2==1)
	{
		n=n*2;
		cout<<n<<endl;
	}
	else
	{
		cout<<n<<endl;
    }
	return 0; 
} 

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val a = sc.nextInt
    val b = sc.nextInt

    var n = a
    if (b < a) n -= 1
    n.toString
  }
}


Measured memory_bytes: 27196
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
  
  
      
int main(){
 
    long long int a,b,n,s,t,a1,b1;
  
    while(scanf("%lld%lld",&a,&b)!=EOF){
 
   
	n=1;
	a1=a;
	b1=b;
 
    for(;;){
		t=b;
		b=a%b;
		a=t;
		
		if(b==0)break;


	}
 
 
 printf("%lld %lld\n",t,a1*b1/t);
    
	}
    return 0;
}

Measured memory_bytes: 592
def f(e):
 a=[[*map(int,input().split())]for _ in[0]*int(e)]
 s,t=min(a)
 b={tuple(map(int,input().split()))for _ in[0]*int(input())}
 m=max(b)[0]-max(a)[0]+s
 for x,y in b:
  if x<=m:
   for u,v in a:
    if(x+u-s,y+v-t)not in b:break
   else:return print(x-s,y-t)
for e in iter(input,'0'):f(e)


Measured memory_bytes: 5908
#include<bits/stdc++.h>
using namespace std;
int a[12];
bool cmp(int a,int b){
	return a>b;
}
int main(){
	int n,ans=0;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n,cmp);
	a[0]/=2;
	for(int i=0;i<n;i++)ans+=a[i];
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
MOD = 998244353
n, s = map(int, input().split())
a = list(map(int, input().split()))
f = [0] * (s + 1)
f[0] = pow(2, n, MOD)
v = pow(2, MOD - 2, MOD)
for x in a:
    for j in range(s, x - 1, -1):
        f[j] += f[j - x] * v
    for j in range(s + 1):
        f[j] %= MOD
print(f[s])


Measured memory_bytes: 68236
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
A = list(map(int,input().split()))

B = [0]*(N+1)
Ans = []

for k in range(N,0,-1):
    cnt = 0
    for i in range(k,N+1,k):
        cnt += B[i]
    cnt %= 2
    if A[k-1] != cnt:
        B[k] = 1
        Ans.append(k)

print(len(Ans))
if Ans:
    print(*Ans)

Measured memory_bytes: 14028
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int> > vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=(int)(n); i>=0; --i)

const int INF = (int)1e6+5;
const int NAX = (int)50+5;
const int MOD = (int)1e9+7;

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
} 
int a[NAX];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    forn(i, n){
      cin >> a[i];
      --a[i];
    }
    int c = 0, f = 0, issort = 1;
    forn(i, n){
      if(a[a[i]] == i && a[i] != i)
        ++c;
      if(a[i] == i)
         ++f;
      if(i+1<n&& a[i] > a[i+1]) issort =0;
    }
    if((c == 2 && f == n-2) || issort)
      cout << "YES\n";
    else
      cout << "NO\n";
    return 0;
  }


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<deque>
using namespace std;
vector<int> graph[114514];
int main() {
	int n, m, k; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b; k = a;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	bool b[114514]; for (int i = 1; i <= n; i++)b[i] = false;
	deque<int>ans;
	while (true) {
		b[k] = true;
		ans.push_back(k);
		int p = 0;
		for (int i = 0; i < graph[k].size(); i++) {
			if (!b[graph[k][i]])p = graph[k][i];
		}
		if (!p)break;
		else k = p;
	}
	k = ans.front();
	while (true) {
		int p = 0;
		for (int i = 0; i < graph[k].size(); i++) {
			if (!b[graph[k][i]])p = graph[k][i];
		}
		if (!p)break;
		else k = p;
		ans.push_front(k);
		b[k] = true;
	}
	cout << ans.size() << endl;
	for (auto i = ans.begin(); i != ans.end(); i++) {
		if (i != ans.begin())cout << ' ';
		cout << *i;
	}cout << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

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

using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;

struct mint
{
  ll x; // typedef long long ll;
  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
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

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

int main()
{
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int ans = min(a, k);
  k -= ans;
  if(k > b) ans -= k-b;
  cout << ans << endl;
}

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

using namespace std;

#define ll long long
#define f1 for (int i=0; i<n; i++)
#define pb push_back
#define fs first
#define sd second
#define mkp make_pair
#define Pi acos(-1)
#define IOS ios_base::sync_with_stdio(false);
#define CI cin.tie(0);
#define CO cout.tie(0);

template <class T>  inline void smax(T &x,T y){x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){x = min((x), (y));}

int main()
{
    IOS
    CI
    CO

    ll n,m;
    cin>>n>>m;
    m/=2;
    cout<<n+m<<endl;
}


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 m = sc.nextInt();
        System.out.println((1900 * m + 100 * (n - m)) * (long) Math.pow(2, m));
    }

}


Measured memory_bytes: 23120
n = int(input())
L = []
for _ in range(n):
    a,b = map(int,input().split())
    L.append((a,b))
L.sort(key = lambda x:(x[1],x[0]))
cur = 0
for a,b in L:
    if cur +a >b:
        print('No');exit()
    cur += a
print('Yes')

Measured memory_bytes: 104220
// abc127_a
#include "iostream"
#include "algorithm"

using namespace std;

int main(int argc, char *argv[])
{
  int a, b, ans = 0;
  cin >> a >> b;
  if (a >= 13) ans += b;
  else if (a >= 6 && a <= 12) ans += b/2;
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

  string o, e;
  cin >> o >> e;
  for (size_t i = 0; i < o.size() + e.size(); ++i) {
    if (i % 2 == 0) {
      cout << o[i / 2];
    } else {
      cout << e[i / 2];
    }
  }
  cout << "\n";
}


Measured memory_bytes: 256
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define endl '\n'

const int max4 = 10004;
const int maxx = 100005;
const int max6 = 1000006;
const int lg5 = 17;

const int INF = 2 * 1000000007;
const long long INFLL = 4LL * 1000000000 * 1000000000;

/***************/

int powmod (int a, int b, int mod) {
    int res = 1; a %= mod;
    for (; b; b >>= 1) {
        if (b & 1) {
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
    }
    return res;
}
#define ll long long
ll gcd (ll a, ll b) {
    while (b > 0) {
        ll t = a % b;
        a = b, b = t;
    }
    return a;
}

int lcm (int a, int b) {
    return (a / gcd (a, b)) * b;
}

int is_prime (int n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (int i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/******Don't forget to use long long when needed!!******/

int arr[maxx];
int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, x;
    cin >> n >> x;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    sort(arr + 1, arr + n + 1);
    int res = 0;
    for (int i = 1; i <= n; i++) {
        if (arr[i] <= x) {
            x -= arr[i];
            res++;
        } else {
            break;
        }
    }
    if (res == n && x > 0) res--;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
using namespace std;
#define pb push_back
#define pf push_front

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

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
#define INF 1e5
int main(){
	int n;
	cin>>n;
	vi p(n);
	rep(i,n) cin>>p[i];
	vi v=p;
	sort(p.begin(), p.end());
	int cnt=0;
	rep(i,n){
		if(v[i]!=p[i]) cnt++;
	}
	if(cnt<=2) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}
	

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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N,ans=1;
int a[100010];
int gcd(int x,int y){if(x==0)return y;return gcd(y%x,x);}
int lcm(int x, int y){return(x*y/gcd(x, y));}

signed main() {
    std::cin >> N;
    rep(i,0,N){
        cin>>a[i];
        ans=lcm(ans,a[i]);
    }
    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 3120
import copy
n,m = map(int,input().split(' '))
route = [[]for i in range(n+1)]
already = [0 for i in range(n+1)]
already[0:2]=[1,1]
cnt=0

for i in range(m):
    a,b = map(int,input().split(' '))
    route[a].append(b)
    route[b].append(a)

def trace(index,already):
    global cnt
    # print(index,already)
    if not(0 in already):
        cnt += 1
    else:
        for new_point in route[index]:
            if already[new_point]!=1:
                new_already = copy.copy(already)
                new_already[new_point] = 1
                trace(new_point,new_already)

trace(1,already)

print(cnt)

Measured memory_bytes: 3444
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, K;
    cin >> n >> K;

    vl a(n), b(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
    }
    
    ll ans = 0;
    rep(i, n) {
        ll lim = K;
        bool ok = true;
        rep(j, 31) {
            if(!(lim & 1<<j) && (a[i] & 1<<j)) {
                ok = false;
            }
        }
        if(ok) {
            ans += b[i];
        }
    }

    for(ll d = 30; d >= 0; d--) {
        ll mask = 1<<d;
        ll lim = K;
        if(K & mask) {
            lim &= ~mask;
            lim |= (mask - 1);
            ll now = 0;
            rep(i, n) {
                bool ok = true;
                rep(j, 31) {
                    if(!(lim & 1<<j) && (a[i] & 1<<j)) {
                        ok = false;
                    }
                }
                if(ok) {
                    now += b[i];
                }
            }
            chmax(ans, now);
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#define ll long long
#define INF 0x3f3f3f3f
#define N 100005
using namespace std;
struct node{
	int v;
	ll d;
};
int n,m;
ll d[N];
bool vis[N*2];
vector<node> adj[N];

void dfs(int x)
{
	vis[x]=1;
	for(int i=0;i<adj[x].size();i++)
	{
		node nd=adj[x][i];
		if(vis[nd.v]){
			if(d[nd.v]!=d[x]+nd.d){
				puts("No");
				exit(0);
			}
		}else{
			d[nd.v]=d[x]+nd.d;
			dfs(nd.v);
		}
	}
}

 
int main()
{
	ios::sync_with_stdio(false);
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int l,r,d;
		scanf("%d%d%d",&l,&r,&d);
		node nd;
		nd.v=r;nd.d=d;
		adj[l].push_back(nd);
		nd.v=l;nd.d=-d;
		adj[r].push_back(nd);
	}
	for(int i=1;i<=n;i++)
	if(!vis[i]) dfs(i);
//	for(int i=1;i<=n;i++)
//	cout<<d[i]<<' ';
//	puts("");
	puts("Yes");
	return 0;
}

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

int main(void)
{
  string line;
  getline(cin, line);

  for (int i = 0, size = line.size(); i < size; i++)
  {
    if ('A' <= line[i] && line[i] <= 'C')
    {
      cout << (char)(line[i] + 23);
    }
    else
    {
      cout << (char)(line[i] - 3);
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<int(n); i++)
#define print(x) cout << (x) << endl

bool f(string s) {
    string revs = s;
    reverse(revs.begin(), revs.end());
    if (revs == s) return true;
    return false;
}

int main() {
    string s; cin >> s;
    int n = s.size();
    bool ans;
    string a = s.substr(0,(n-1)/2);
    string b = s.substr((n+2)/2);
    if (f(s) && f(a) && f(b)) ans = true;
    else ans = false;
    print(ans ? "Yes" : "No");

}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String str_scan = scan.nextLine();
    // int型へ変換
    var point = Integer.parseInt(str_scan);
    int ans = 8;

    // 初期
    point = point - 400;

    for (var i = 0;i < 7;i++) {
      if (point < 200) {
        break;
      }
      point = point - 200;
      ans--;
    }

    System.out.println(ans);
    scan.close();
  }
}

Measured memory_bytes: 35828
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;
const int MAX = 200100;
const int MOD = 2019;

int dp[MOD];
int dpdp[MOD];

int main(){
  string s; cin >> s;
  int n = s.size();
  vector<int> a(n+1);
  a[0] = 0;
  rep(i, n) a[i+1] = s[i] - '0';

  int ans = 0;
  REP(i, 1, n){
    fill(dpdp, dpdp+MOD, 0);
    REP(j, 0, 2018){
      dpdp[(j*10+a[i])%MOD] += dp[j];
    }
    dpdp[a[i]]++;
    REP(j, 0, 2018){
      dp[j] = dpdp[j];
    }
    ans += dp[0];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4340
#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>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#include <math.h>

int r;
double solve(){
   return 2*M_PI*r;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>r;
    cout<<setprecision(23)<<solve()<<endl;
    return 0;
}

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

int main(void){
    string s,t;
    cin >> s >> t;
    int cnt = 0;
    rep(i,s.size()){
        if (s[i] != t[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3916
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String
    }
    println!(
        "{}",
        s.chars()
            .fold(0, |acc, c| acc + if c == '1' { 1 } else { 0 })
    )
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define N             (int)(1e6+5)
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    cin>>n;
    int a[n]; rep(i,0,n-1) cin>>a[i];
    sort(a,a+n);
    rep(i,0,n-2) ans+=a[i];
    ans+=a[n-1]/2;
    cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define all(V) (V).begin(), (V).end() 
using namespace std;
typedef long long ll;
string to_string(string s) {
  return '"' + s + '"';
}
string to_string(const char* s) {
  return to_string((string) s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef KEK
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

vector <int> L(vector <int> P) {
	int N = P.size();
	vector <int> stk;
	vector <int> left(N);
	for(int i = 0; i < N; i++) {
		while(!stk.empty() && P[stk.back()] > P[i]) {
			stk.pop_back();
		}
		left[i] = i + 1 - (stk.empty() ? 0 : stk.back() + 1);
		stk.push_back(i);
	}
	return left;
}
int main() {fio;
	int n;
	cin >> n;
	vector <int> P(n);
	for(int i = 0; i < n; i++) {
		cin >> P[i];
	}
	vector <int> left = L(P);
	reverse(all(P));
	vector <int> right = L(P);
	reverse(all(right));
	reverse(all(P));
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		ans += (ll) P[i] * left[i] * right[i];
	}
	debug(left, right);
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7904
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;


int main()
{
    int n;
    cin >>n;
    vector<int> a(n);
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum = (sum^a[i]);
    }

    rep(i,n)cout<<(sum^a[i])<<endl;
    //cout<<sum<<endl;
    return 0; 
}


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

    using namespace std;
    const int maxn = 4;
    typedef long long ll;
    const int INF = 1e9+7;

    list<int>sta[maxn];
    void action()
    {   //cout<<sqrt(880)<<endl;
        int n;
        scanf("%d",&n);
        while(n--)
        {
            ll a,b;
            scanf("%lld%lld",&a,&b);


            ll cnt = a*b;
            if(a<b)swap(a,b);

            if(a==b)
            {
                cout<<a+a-2<<endl;
                continue;

            }
            else if(a == b+1)
            {
                cout<<2*(b-1)<<endl;
                continue;
            }

            ll sq = sqrt(cnt);
            ll sq1 = sq-1;
            ll sq2 = sq-1;
          
            if(sq*sq==cnt)
                sq1--;

            ll cnt22 = ceil(sqrt(cnt));
            if(cnt22 * sq <cnt )
                sq1++;
            printf("%lld\n",sq1+sq2);

        }

    }
    int main()
    {

        action();
        return 0;
    }


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

int main() {
  int n,i;
  bool judge = true;
  cin >> n;
  vector<int> t(n+1);
  vector<int> x(n+1);
  vector<int> y(n+1);
  t.at(0)=0;
  x.at(0)=0;
  y.at(0)=0;
  for(i=1;i<n+1;i++){
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  }
  for(i=0;i<n;i++){
  int dis = (t.at(i+1)-t.at(i)) - abs(x.at(i+1)+y.at(i+1)-x.at(i)-y.at(i));
    if( dis%2==0 && dis>=0
            ){
           }else{
             judge=false;
           }
  }
  if(judge){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1536
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (true)
		{
			int n = sc.nextInt(),
				m = sc.nextInt();
			if (n == 0) break;
			String luckNum[] = new String[n];
			long value[] = new long[n];
			for (int i = 0; i < n; i++)
			{
				luckNum[i] = sc.next();
				value[i] = sc.nextInt();
			}
			long total = 0;
			for (int i = 0; i < m; i++)
			{
				String str = sc.next();
				for (int j = 0; j < n; j++)
				{
					NUMBERCHECK: {
						for (int k = 0; k < 8; k++)
						{
							char c = luckNum[j].charAt(k);
							if (c != '*' && str.charAt(k) != c)
								break NUMBERCHECK;
						}
						total += value[j];
					}
				}
			}
			System.out.println(total);
		}
	}
}

Measured memory_bytes: 12000
using System.Linq;
using System;
using static System.Console;

class Program
{
  static void Main() => new Program().solve();

  void solve()
  {
    var param = ReadLine().Split(' ').Select(int.Parse).ToArray();
    var k = param[3];

    var seqA = ReadLine().Split(' ').Select(long.Parse).OrderByDescending(i => i).ToArray();
    var seqB = ReadLine().Split(' ').Select(long.Parse).OrderByDescending(i => i).ToArray();
    var seqC = ReadLine().Split(' ').Select(long.Parse).OrderByDescending(i => i).ToArray();

    var seqAB = seqA.SelectMany((a,i) =>
        seqB.TakeWhile((b,j) => i * j <= k).Select(b => a + b)
      ).OrderByDescending(ab => ab)
      .Take(k).ToList();
    var seqABC = seqAB.SelectMany((ab, i) =>
        seqC.TakeWhile((c, j) => i * j <= k).Select(c => ab + c)
      ).OrderByDescending(abc => abc)
      .Take(k).ToList();
    WriteLine(String.Join("\n", seqABC));
  }
}

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

int main()
{
  int K, A, B;
  cin >> K >> A >> B;
  if (A + 2 >= B) {
    cout << K + 1 << endl;
    return 0;
  }
  
  long int x;
  for (int i=0; i < 10000000000; i++) {
    if ((A - 1) + 2 * i > K) {
      x = i - 1;
      break;
    }
  }

  long int ans = (B - A) * x + K - ((A - 1) + 2 * x) + A;
  cout << ans << endl;
  return 0;
}

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

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
using namespace std;

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int N;

signed main()
{
    cin >> N;

    if(N==0){
        cout<<0<<endl;
        return 0;
    }
   
    string s;
    

    while(N){
      
        if(N%2){
            s+='1';
            N -=1;
        }
        
        else{
            s+='0';
        }

        N/=-2;

    }
    reverse(all(s));
    cout<<s<<endl;

    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;



int main() {
	int n;
	cin >> n;
	map<ll, int> mp;
	rep(i, n) {
		ll k;
		cin >> k;
		mp[k]++;
	}
	int ans = 0;
	for (auto i = mp.begin(); i != mp.end(); i++) {
		if (i->second < i->first) ans += i->second;
		else ans += i->second - i->first;
	}
	cout << ans << endl;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, m;
  cin >> n >> m;
  vl h(n);
  rep(i, n) cin >> h[i];
  vector<vl> g(n);
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  ll ans = 0;
  rep(i, n) {
    bool ok = true;
    for(auto v : g[i])
      if(h[i] <= h[v]) ok = false;
    if(ok) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 9808
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int i, n;
	
	cin >> n;
	long *a = new long[n + 1];
	long b,ans;

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

	ans = 0;
	for (i = 0; i < n; i++) {
		cin >> b;
		if (a[i] < b) {
			ans += a[i];
			b = b - a[i];
			ans += min(b, a[i + 1]);
			a[i + 1] -= min(b, a[i + 1]);
			a[i] = 0;
		}
		else {
			ans += b;
			a[i] = a[i] - b;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,M;
ll K;
vector<ll> A,B;
void input(){
    fast_io();
    cin >> N >> M >> K;
    A = fetch_vec<ll>(N);
    B = fetch_vec<ll>(M);
}

int solve(){
    vector<ll> AS(N+1,0);
    vector<ll> BS(M+1,0);
    for (int i = 0; i < N; i++) AS[i+1] = AS[i]+A[i];
    for (int i = 0; i < M; i++) BS[i+1] = BS[i]+B[i];
    BS.push_back(LL_INF);
    int ans = 0;
    DBG(AS)
    DBG(BS)
    for (int i = 0; i <= N; i++)
    {
        if(AS[i]>K) break;
        // int it = upper_bound(BS.begin(),BS.end(),K-AS[i])-BS.begin();
        // if(it) it--;
        int ok = 0, ng = M+2;
        while (ng-ok>1)
        {
            int mid = (ok+ng)/2;
            if(BS[mid]<=(K-AS[i])) ok=mid;
            else ng=mid;
        }
        ans = max(ans,i+ok);
    }
    cout << ans << endl; 
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

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

int main()
{
  int n[5], k, maxd = 0;
  for(int i = 0; i < 5; ++i) cin >> n[i];
  cin >> k;
  for(int i = 0; i < 4; ++i)
  {
    for(int j = i + 1; j < 5; ++j)
    {
      if(n[j] - n[i] > k)
      {
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
}

Measured memory_bytes: 256
# 2019/09/07
# AtCoder Beginner Contest 140 - C

# Input
n = int(input())
b = list(map(int,input().split()))

# Calc
sum = b[0]
for i in range(n-2):
    sum = sum + min(b[i], b[i+1])

sum = sum + b[n-2]

# Output
print(sum)


Measured memory_bytes: 2940