akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(){
    int S[4];
    int a;
    scanf("%d",&a);
    S[0]=a/1000;
    S[1]=(a/100)%10;
    S[2]=(a/10)%10;
    S[3]=a%10;
    if(12<S[0]*10+S[1]){
        if(S[2]*10+S[3]<=12){
            if(S[2]==0 && S[3]==0){printf("NA\n");}
            else{printf("YYMM\n");}}
        else{printf("NA\n");}
    }
    else{if(S[2]*10+S[3]>12){if(S[0]==0 && S[1]==0){printf("NA\n");}
                             else{printf("MMYY\n");}}
        else{if(S[0]==0 && S[1]==0 && S[2]== 0 && S[3]==0){printf("NA\n");}
             else if(S[0]==0 && S[1]==0){printf("YYMM\n");}
             else if(S[2]==0 && S[3]==0){printf("MMYY\n");}
             else{printf("AMBIGUOUS\n");}
             }
    }
    return 0;
}

Measured memory_bytes: 128
a = int(input())
b = int(input())
c = int(input())
x = int(input())
res = 0

for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if (500*i)+(100*j)+(50*k) == x:
        res += 1

print(res)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;

template <class T> using V = vector<T>;

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

const long long INF = 1LL << 60;

using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;



#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);



ll Sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}



const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


#define comuse Comuse()

ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}


ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}

ll modpow(ll a,ll n,ll mod){
  ll ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
//segtreeの葉の先頭の添え字はn-1
void Solve(){
  //vll segtree(524287);
  //ll N=262144;
  ll n;
    cin>>n;
  if(n%2==1){
    cout<<0<<"\n";
    return;
  }

  ll count=10;
  ll ans=0;
  while(n/count){
    ll now=n/count;
    ans+=now;
    count*=5;
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int a[4];
int main(){
	string s;
	getline(cin,s);
	for(int i=0;i<s.length();i++){
		a[i]=s[i]-48;
	}
	if((a[0]==a[1]&&a[0]==a[2]&&a[1]==a[2])||(a[1]==a[2]&&a[1]==a[3]&&a[2]==a[3]))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

Int a[200005];
int main(){
    int N; cin >> N;
    for (int i = 0; i < N; i++) cin >> a[i];

    Int ans = 0;
    Int crt = 0;
    for (int i = N-1; i >= 0; i--){
        if (crt > a[i] || a[i] > i){
            ans = -1;
            break;
        }
        if (crt < a[i]){
            ans += a[i];
            crt = a[i];
        }
        crt--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdint>
#include <cstring>
#include <vector>

using namespace std;

typedef vector<uint32_t> vec;
// using vec = vector<uint32_t>;

void CountingSort(const vec& A, vec& B, const uint32_t k);

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

	uint32_t n;
	cin >> n;

	vec A(n), B(n, 0);
	uint32_t max = 0;
	for(auto&& e : A) {
		cin >> e;
		if(max < e) { max = e; }
	}

	CountingSort(A, B, max);

	for(uint32_t i = 0; i < n; i++) {
		cout << B[i] << ((i == n - 1) ? "\n" : " ");
	}

	return 0;
}

void CountingSort(const vec& A, vec& B, const uint32_t k) {
	uint32_t n = A.size();
	uint32_t C[k + 1];
	memset(C, 0, sizeof(C));

	/* C[i] に i の出現数を記録する */
	for(uint32_t j = 0; j < n; j++) {
		C[A[j]]++;
	}

	/* C[i] に i 以下の数の出現数を記録する*/
	for(uint32_t i = 1; i <= k; i++) {
		C[i] += C[i - 1];
	}

	for(int32_t j = (int32_t)n - 1; j >= 0; j--) {
		B[C[A[j]] - 1] = A[j];
		C[A[j]]--;
	}
}


Measured memory_bytes: 18216
#include <bits/stdc++.h>
using namespace std;
char Ga[610][610];
char Gb[310][310];

int main()
{
  int64_t N, ans = 0;
  cin >> N;
  char c;
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      cin >> c;
      Ga[i][j] = Ga[i + N][j] = Ga[i][j + N] = Ga[i + N][j + N] = c;
    }
  }
  for (int a = 0; a < N; a++)
  {
    bool ok = 1;
    for (int i = a + 1; i < N + a; i++)
    {
      for (int j = 0; j < (i - a); j++)
      {
        if (Ga[i][j] != Ga[j + a][i - a]) // i-a, j-b -> j-b, i-a -> j-b+a, i-a+b
        {
          ok = 0;
          break;
        }
      }
      if (!ok)
        break;
    }
    if (ok)
      ans++;
  }
  cout << ans * N << endl;
}


Measured memory_bytes: 3924
//package abc124.B;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		String t = "ACGT";
		
		int ans = 0, cnt = 0;
		
		for (int i = 0; i < s.length(); i++) {
			if (t.indexOf(s.charAt(i)) >= 0) cnt++;
			else cnt = 0;
			ans = Math.max(ans, cnt);
		}
		
		System.out.println(ans);
	}

}


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

int main() {
    int n, temp, ans = INT_MAX;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    for(int i = -100; i <= 100; i++) {
        temp = 0;
        rep(j, n) temp += (a.at(j) - i) * (a.at(j) - i);
        ans = min(ans, temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Arrays;
import java.util.Set;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt()-1;
        int m=sc.nextInt()-1;
        System.out.println(n*m);

}
        
        
    }


Measured memory_bytes: 23764
import math

n = int(input())
cell = map(lambda x: {"B": True, "W": False}[x], input())
section = 0
ans = 1
for val in cell:
    if section % 2 == 0:
        buf = val
    else:
        buf = not val
    if buf:
        section += 1
    else:
        ans *= section
        ans %= 10 ** 9 + 7
        section -= 1
if section == 0:
    print(((math.factorial(n) % (10 ** 9 + 7)) * ans) % (10 ** 9 + 7))
else:
    print(0)

Measured memory_bytes: 46028
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,h,w = map(int,input().split())
for i in range(n):
    a,b=map(int,input().split())
    if (a>=h) and (b>=w):
        count+=1
print(count)

Measured memory_bytes: 38256
#import <Foundation/Foundation.h>
typedef long long Int;
Int gcd(Int a, Int b){
	Int M = MAX(a, b);
	Int m = MIN(a, b);
	while (YES) {
		Int r = M % m;
		if (r==0) break;
		M = m;
		m = r;
	}
	return m;
}
Int lcm(Int a, Int b){
	return a/gcd(a,b)*b;
}
Int f(Int a, Int b, Int m){
	return b/m-(a-1)/m;
}
int main() {
	Int a,b,c,d;
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	printf("%lld",(b-a+1)-f(a,b,c)-f(a,b,d)+f(a,b,lcm(c,d)));
}

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1e9 + 7, N = 1e6 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    double r, ans = 0 ;
    cin >> r ;
    cout.precision(12) ;
    ans = 2 * PI * r ;
    cout << ans ;

    return 0 ;
}


Measured memory_bytes: 3764
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<iostream>
using namespace std;
const int S=0,T=2001,inf=0x3f3f3f3f;
const long long finf=0xc0c0c0c0c0c0c0c0ll;
struct bian
{
	int to,nxt,f,va;
}bi[3000030];
int n,head[2020],num=1,rx[1010],ry[1010],rc[1010],bx[1010],by[1010],bc[1010],from[2020];
long long dis[2020],ans;
bool bj[2020];
queue<int>q;
void add(int from,int to,int f,int va)
{
	bi[++num].nxt=head[from];
	head[from]=num;
	bi[num].to=to;
	bi[num].f=f;
	bi[num].va=va;
}
void ADD(int from,int to,int f,int va)
{
	add(from,to,f,va);
	add(to,from,0,-va);
}
bool spfa()
{
	bj[S]=1;
	q.push(S);
	memset(dis,0xc0,sizeof(dis));
//	printf("%lld",dis[0]-1);
	dis[S]=0;
	int x,y;
	while(!q.empty())
	{
		x=q.front();q.pop();
		bj[x]=0;
		for(int i=head[x];i;i=bi[i].nxt)
			if(bi[i].f)
			{
				y=bi[i].to;
				if(dis[x]+bi[i].va>dis[y])
				{
					dis[y]=dis[x]+bi[i].va;
					from[y]=i;
					if(!bj[y])bj[y]=1,q.push(y);
				}
			}
	}
//	cout<<dis[T]<<' '<<0xc0c0c0c0c0c0c0c0ll<<' '<<(dis[T]>=((long long)0xc0c0c0c0c0c0c0c0ll))<<endl;
//	printf("%lld %llu %d\n",dis[T],0xc0c0c0c0c0c0c0c0ll,dis[T]>=(0xc0c0c0c0c0c0c0c0ll));
	return dis[T]>finf;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d %d %d",&rx[i],&ry[i],&rc[i]);
		ADD(S,i,rc[i],0);
	} 
	for(int i=1;i<=n;++i)
	{
		scanf("%d %d %d",&bx[i],&by[i],&bc[i]);
		ADD(i+n,T,bc[i],0);
	}
	for(int i=1;i<=n;++i)
	{
		ADD(i,2002,inf,rx[i]+ry[i]);
		ADD(i,2003,inf,rx[i]-ry[i]);
		ADD(i,2004,inf,-rx[i]+ry[i]);
		ADD(i,2005,inf,-rx[i]-ry[i]);
	}
	for(int i=1;i<=n;++i)
	{
		ADD(2002,i+n,inf,-bx[i]-by[i]);
		ADD(2003,i+n,inf,-bx[i]+by[i]);
		ADD(2004,i+n,inf,bx[i]-by[i]);
		ADD(2005,i+n,inf,bx[i]+by[i]);
	}
	while(spfa())
	{
	//	printf("!");
		int x=T,flow=inf;
		while(x)flow=min(flow,bi[from[x]].f),x=bi[from[x]^1].to;
		ans+=1ll*flow*dis[T];
		x=T;
		while(x)bi[from[x]].f-=flow,bi[from[x]^1].f+=flow,x=bi[from[x]^1].to;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 768
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {

      ll n;
      cin>>n;
      string s;
      cin>>s;
      string s1, s2;

      for(int i=0; i<n/2; i++) {
        s1 += s[i];
      }
      for(int i=(n/2); i<n; i++) {
        s2 += s[i];
      }
      //cout<<"s1 = "<<s1<<" "<<"s2 = "<<s2<<endl;
      if(s1 == s2) cout<<"Yes";
      else cout<<"No";


}


Measured memory_bytes: 256
a, b, c, x, y = gets.split(" ").map(&:to_i)
ans = a * x + b * y
(1..[x, y].max).each do |i|
  s = 2 * c * i
  s += a * (x - i) if x > i
  s += b * (y - i) if y > i
  ans = s if ans > s
end
puts ans

Measured memory_bytes: 1788
# Union Find 木
from sys import setrecursionlimit, stdin


def find(parent, diff_weight, i):
    t = parent[i]
    if t < 0:
        return i
    t = find(parent, diff_weight, t)
    diff_weight[i] += diff_weight[parent[i]]
    parent[i] = t
    return t


def weight(parent, diff_weight, i):
    find(parent, diff_weight, i)
    return diff_weight[i]


def unite(parent, diff_weight, i, j, d):
    d -= weight(parent, diff_weight, j)
    d += weight(parent, diff_weight, i)
    i = find(parent, diff_weight, i)
    j = find(parent, diff_weight, j)
    if i == j:
        return
    diff_weight[j] = d
    parent[i] += parent[j]
    parent[j] = i


setrecursionlimit(10 ** 6)

N, M = map(int, stdin.readline().split())
LRD = [tuple(map(int, stdin.readline().split())) for _ in range(M)]

parent = [-1] * (N + 1)
diff_weight = [0] * (N + 1)
for L, R, D in LRD:
    i = find(parent, diff_weight, L)
    j = find(parent, diff_weight, R)
    if i != j:
        unite(parent, diff_weight, L, R, D)
    else:
        if weight(parent, diff_weight, L) + D != weight(parent, diff_weight, R):
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 39088
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] sp;
        int max = 0;
        int num = 0;
        sp = s.split("");
        for (int i = 0; i < sp.length; i++) {
            if (sp[i].equals("A") || sp[i].equals("C") || sp[i].equals("G") || sp[i].equals("T"))
                num++;
            else {
                if (max < num)
                    max = num;
                num = 0;
            }
        }
        if (max < num)
            max = num;
        System.out.println(max);
    }
}

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

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
typedef long long int ll;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  rep(i, n) cin >> a.at(i);
  rep(i, n) cin >> b.at(i);
  rep(i, n) cin >> c.at(i);
  sort(all(a));
  sort(all(b));
  sort(all(c));


  vector<ll> fira(n), secb(n);
  rep(i, n) secb.at(i) = n-distance(c.begin(), upper_bound(all(c), b.at(i)));
  sort(all(secb));
  vector<ll> sumsecb(n+1);

  rep(i, n) sumsecb.at(i+1) = sumsecb.at(i) + secb.at(i);
  rep(i, n) fira.at(i) = n-distance(b.begin(), upper_bound(all(b), a.at(i)));


  ll sum = 0;
  for (const auto& i: fira){
    sum += sumsecb.at(i);
  }


  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 4992
#include<iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s=="SUN"){
    cout << 7 << endl;
  }
  else if(s=="MON"){
    cout << 6 << endl;
  }
  else if(s=="TUE"){
    cout << 5 << endl;
  }
  else if(s=="WED"){
    cout << 4 << endl;
  }
  else if(s=="THU"){
    cout << 3 << endl;
  }
  else if(s=="FRI"){
    cout << 2 << endl;
  }
  else if(s=="SAT"){
    cout << 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#define mp make_pair
#define pb push_back

using namespace std;

const int MAX = 101;

int main() 
{
	int n, m, x;
	cin >> n >> m >> x;
	int g[MAX];
	for (int i = 0; i<=n; ++i) {
		g[i] = 0;
	}
	for (int i = 0; i<m; ++i) {
		int a;
		cin >> a;
		g[a] = 1;
	}
	int dp[MAX];
	dp[0] = 0;
	for (int i = 1; i<=n; ++i) {
		dp[i] = dp[i-1] + g[i];
	}
	cout << min(dp[x], dp[n]-dp[x]) << '\n';;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
    n=int(input())
    A=[0]*n
    for i in range(n):
        A[i]=''.join(sorted(input()))
    A.sort()
    from itertools import groupby
    ans=0
    for k,v in groupby(A):
        a=len(list(v))
        if a>=2: ans+=a*(a-1)//2
    print(ans)

resolve()

Measured memory_bytes: 59980
from itertools import combinations

import math
N = int(input())

x = []
y = []

for i in range(N):
    _x, _y = map(int, input().split())
    x.append(_x)
    y.append(_y)
    
s = 0
for c in combinations(zip(x, y), 2):
    s += math.sqrt((c[0][0] - c[1][0]) ** 2 + (c[0][1] - c[1][1]) ** 2)

print(s * 2 / N)

Measured memory_bytes: 9096
import java.util.*;
public class Main {

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

        int w, h, x, y;
        w = sc.nextInt();
        h = sc.nextInt();
        x = sc.nextInt();
        y = sc.nextInt();
        int b;
        if ((w==x+x) && (h==y+y)) b=1;
        else b = 0;
        System.out.println(String.format("%.6f", (double)w*(double)h/2)+" "+b);
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;

int main()
{
 	int a,b,c;
 	cin>>a>>b>>c;
 	if(a==5&&b==5&&c==7)
	 cout<<"YES"<<endl;
	 
	 else if(a==5&&c==5&&b==7)
	cout<<"YES"<<endl;
	
	else if(a==7&&b==5&&c==5)
	cout<<"YES"<<endl;
	else cout<<"NO"<<endl; 
 	return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll H, W, A, B;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> H >> W >> A >> B;
    REP(i, H) {
        REP(j, W) cout << ((j<A)^(i<B));
        cout << "\n";
    }
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#define Max 50
using namespace std;

int main() {
    int a,dice1,dice2,cnt = 0;
        cin >> a;
    for(int i = 0; i < a; i++){
        cin >> dice1 >> dice2;
        if(dice1 == dice2){
            cnt++;
        }else{
            cnt = 0;
        }
        if(2 < cnt){
            break;
        }
    }
    
    if(cnt < 3){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3032
import heapq

def calc_minus(n):
    return n * (-1)

N, M = map(int, input().split())
values = list(map(int, input().split()))
tmp = 0

values_minus = []
for val1 in values:
    values_minus.append(calc_minus(val1))

heapq.heapify(values_minus)

for i in range(M):
    tmp = heapq.heappop(values_minus)
    tmp_push = ((tmp * (-1)) // 2) * (-1)
    heapq.heappush(values_minus, tmp_push)

values_plus = []
for val2 in values_minus:
    values_plus.append(calc_minus(val2))

result = 0
for val3 in values_plus:
    result += val3

print(result)

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


signed main() {
    string s;
    ll k;
    cin >> s >> k;
    int i = 0;
    bool is_1 = true;
    rep(j, k){
        if(s[j] != '1'){
            is_1 = false;
            break;
        }
    }
    while(s[i] == '1'){
        i++;
    }
    if(is_1) cout << 1 << endl;
    else cout << s[i] << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#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 n;

cin >> n;
string ans ="No";
rep(i,n.size())
{if(n[i]=='7')
{ans="Yes";}}

cout << ans <<endl;
}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

Measured memory_bytes: 3632
Scanf.scanf "%s" (fun s ->
    let n = String.length s in

    let rec loop k acc =
        if k = n - 1 then acc else
            if s.[k] = s.[k + 1] then loop (k + 1) acc else
                let l = k + 1 in
                loop (k + 1) (min acc (max l (n - l)))
    in
    loop 0 n |> Printf.printf "%d\n"
)

Measured memory_bytes: 4176
#include <iostream>
#include <vector>

using namespace std;

vector<int> node[1000];
vector<string> M;

void dfs(int i, int dots){
    cout<<string(dots,'.')<<M[i]<<endl;
    for(auto v:node[i]) dfs(v,dots+1);
}

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        k--;
        if(k>=0)node[k].push_back(i);
        string s;
        cin>>s;
        M.push_back(s);
    }
    dfs(0,0);
    return 0;
}

Measured memory_bytes: 3388
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<deque>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF (3000)
#define MAX 100000
int main() {
	int A, B, C;
	scanf("%d%d%d", &A, &B, &C);
	printf("%d %d %d\n", C, A, B);
	return 0;
}

Measured memory_bytes: 128
# Xi = 0, Ki = 1となる場所を探す旅に出る。
# K+=1して、Xi=0, Ki=1となる場所を作ればX =< Kの条件を満たすことができる。
N, K = map(int, input().split())
A = list(map(int, input().split()))
K += 1
K_bit = format(K, "b")
# iを探す
tmp = ""  # まず最適な数字を探す
for i in reversed(range(len(K_bit))):
    # 上からi桁目のビットが立っているか確認
    bit = 1 << i
    count = 0
    for a in A:
        if a & bit:
            count += 1
    if count > N - count:
        tmp += "0"
    else:
        tmp += "1"
# 最適なtmpができた
ans = 0
for i in range(len(K_bit)):
    bit = 1 << i
    if K_bit[i] == "1":  # i桁目が立っている時に初めてXi=0, Ki=1にできる
        num = K_bit[:i] + "0" + tmp[i+1:]
        num = int(num, 2)
        fx = 0
        for a in A:
            fx += num ^ a
        ans = max(ans, fx)
    else:
        continue
print(ans)


Measured memory_bytes: 14984
n=int(input())
trans=[int(input()) for i in range(5)]
d=min(trans)
 
if n%d == 0:
    print(n//d +4)#(n//d +(0 or 1))最も運べる人数が少ない交通機関がn人を運ぶのにかかる時間
else:
    print((n//d +1) +4) 

Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N ((1<<17)+10)
#define P (1000000007)
#define M (666)
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c) {
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
int n,m,bin[M],e[N],pc[N],f[N];
bool yes(int x){return ((x&3)==3||(x&3)==0);}
int main(){
	read(n),read(m),bin[0]=1;
	for(int i=1;i<=m;i++)bin[i]=(bin[i-1]<<1)%P;
	for(int i=1;i<=m;i++){
		int x,y;
		read(x),read(y);
		e[x]|=(1<<y-1);
	}
	for(int i=1;i<(1<<n);i++)pc[i]=pc[i>>1]+(i&1);
	f[0]=1;
	for(int i=1;i<(1<<n);i++)
	if(yes(i)){
		for(int j=i;j;(--j)&=i)if(yes(j)){
			int C=i^j,v=f[C];
			for(int u=1;u<=n;u++)
			if(j&(1<<u-1))v=1ll*v*bin[pc[e[u]&C]]%P;
			else if(C&(1<<u-1))v=1ll*v*(bin[pc[e[u]&j]]-1)%P;
			(f[i]+=v)%=P;
		}
	}
	printf("%lld\n",(bin[m]-f[(1<<n)-1]+P)%P);
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>

typedef std::pair<int,int> P;

int dp[200];//何番目のまとりょーしかが一番大きいか＝数

int main(){
	int ichiro,jiro,M=0;
	while(true){
		P doll[200];//高さ　半径
		std::cin>>ichiro;
		if(!ichiro){
			break;
		}
		for(int i=0;i<ichiro;i++){
			std::cin>>doll[i].first>>doll[i].second;
		}
		std::cin>>jiro;
		for(int i=0;i<jiro;i++){
			std::cin>>doll[i+ichiro].first>>doll[i+ichiro].second;
		}
		std::sort(doll,doll+ichiro+jiro);

		for(int i=0;i<ichiro+jiro;i++)dp[i]=1;
		for(int i=1;i<ichiro+jiro;i++){
			for(int j=i-1;j>=0;j--){
				if(doll[i].first!=doll[j].first&&doll[i].second>doll[j].second){
					dp[i]=std::max(dp[i],dp[j]+1);
				}
			}
			M=std::max(M,dp[i]);
		}
		std::cout<<M<<std::endl;
		M=0;
		for(int i=0;i<ichiro+jiro;i++)dp[i]=0;
	}
	return 0;
}

Measured memory_bytes: 1164
main = do
  s <- getLine
  let toInt x = read x :: Int
  let sort a b = putStrLn $ if a < b then (show a) ++ " " ++ (show b) else (show b) ++ " " ++ (show a)
  let [a,b] = map toInt . words $ s
  if (a,b) == (0,0) then return ()
  else do
    sort a b
    main

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

int main(){
  int a,b,c,k,sum=0;
  cin>>a>>b>>c>>k;
  sum+=min(a,k);
  k=max(0,k-a-b);
  sum-=k;
  cout<<sum<<endl;
  
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<string>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)

int main(){
    string str;
    getline(cin, str);
    REP(i, str.length()) cout <<(char)(toupper(str[i]));
    cout <<endl;
    return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define re register int
using namespace std;

int n,a[100010];
long long ans;

int main()
{
    std::cin>>n;
    for(re i=1;i<=n;i++)
    	std::cin>>a[i];
    
	for(re i=1;i<=n;i++)
    {
        if(a[i]==0)
			continue;
        ans+=a[i]/2;
        a[i]%=2;
        
        if(a[i]>0&&a[i+1]>0)
		{
			a[i]--;
			a[i+1]--;
			ans++;
		}
    }
    
    std::cout<<ans;
    return 0;
}

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

using namespace std;

int c[10][10];

int main()
{
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < 10; i++)
		for (int j = 0; j < 10; j++)
			cin >> c[i][j];
	for (int i = 0; i < 10; i++)
		for (int j = 0; j < 10; j++)
			for (int k = 0; k < 10; k++)
				c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
	int r = 0, a;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a;
			if (a > -1)
				r += c[a][1];
		}
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
    if a[i] == ans +1: ans +=1
if ans == 0: print(-1)
else: print(n - ans)

Measured memory_bytes: 26268
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N,X,Y = LI()

X -= 1
Y -= 1
d = defaultdict(int)
for i in range(N):
    for j in range(i+1,N):
        val = min(abs(X-i)+1+abs(Y-j), abs(X-j)+1+abs(Y-i), abs(i-j))
        d[val] += 1

for i in range(1,N):
    print(d[i])

Measured memory_bytes: 52316
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,x1[4]={0,0,1,-1},y1[4]={1,-1,0,0};
char island[13][13];
int serch(int x,int y)
{
    island[x][y]='0';
    for(int i=0;i<4;i++){
        int x2=x+x1[i],y2=y+y1[i];
        if(x2>=0&&x2<=11&&y2>=0&&y2<=11&&island[x2][y2]=='1')serch(x2,y2);
    }
    //cout<<"end\n";
}
int main(void)
{
    int A=0;
    while(1){
            A=0;
    for(int i=0;i<12;i++){
           if(scanf("%s",island[i])==EOF)goto end1;
    }
    for(int i=0;i<12;i++){
        for(int j=0;j<12;j++){
            if(island[i][j]=='1'){
               // cout<<"str\n";
                serch(i,j);
                A++;
            }
        }
    }
    cout<<A<<"\n";
    }
    end1:;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int main(){
  ll a;
  double b;
  cin >> a >> b;
  b*=100;
  ll c=llround(b);
  a*=c;
  cout << a/100 << endl;
}


Measured memory_bytes: 3752
n,m = map(int,input().split())
total = 0

for a in range(n+1):
  for b in range(n+1):
    total=10000*a+5000*b+1000*(n-a-b)
    if total == m and a+b <=n:
      print(a,b,n-a-b)
      exit()
    
print(-1,-1,-1)

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

#define ll long long int
#define vll vector<ll>
#define vi vector<int>

int main() {

    int N;
    cin >> N;

    vi A;
    int a;
    for (int i = 0; i < N; i++) {
        cin >> a;
        A.push_back(a);
    }

    int M = 0;
    vi B;
    B = A;
    int count;
    for (int i = N; i > 0; i--) {
        if (i * 2 > N) {
            if (B[i-1] == 1) {
                M++;
            }
        }
        else {
            count = 0;
            for (int j = 1; j*i <= N; j++) {
                if (B[j*i-1] == 1) {
                    count++;
                }
            }
            if (count%2 == 1) {
                B[i-1] = 1;
                M++;
            }
            else {
                B[i-1] = 0;
            }
            // cout << "hoge " << i << endl;
            // cout << "count " << count << endl;
        }
        // cout << "i : " << i << endl;
        // for (int i = 0; i < N; i++) {
        //     cout << B[i] << " ";
        // }
        // cout << endl;
    }

    cout << M << endl;
    if (M > 0) {
        for (int i = 0; i < N; i++) {
            if (B[i] == 1) {
                cout << i+1 << " ";
            }
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 2548
#include<iostream>
using namespace std;
int main()
{
	char a;
	cin>>a;
	if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
	{
		cout<<"vowel";
	}
	else
	{
		cout<<"consonant";
	}
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class EHandshake {
public:
    void solve(std::istream& in, std::ostream& out) {
        int N, M;
        in >> N >> M;
        vector<int> A(N);
        REP(i,0,N) in >> A[i];
        sort(all(A), greater<int>());

        vector<int> sum(N);
        sum[0] = A[0];
        REP(i,1,N) sum[i] = sum[i-1] + A[i];

        int left = 1, right = 2 * 1e5 + 1;
        while (right - left > 1) {
            int middle = (right + left) / 2;
            int cnt = 0;
            int r = N-1;
            REP(l,0,N) {
                while (r >= 0 && A[l] + A[r] < middle) r--;
                if (r < 0) break;
                cnt += r+1;
            }
            if (cnt >= M) {
                left = middle;
            } else {
                right = middle;
            }
        }
        const int X = left;
        int cnt = 0;
        int r = N-1;
        ll answer = 0;
        REP(l,0,N) {
            while (r >= 0 && A[l] + A[r] < X) r--;
            if (r < 0) break;
            cnt += r+1;
            answer += sum[r] + (r+1) * A[l];
        }
        answer -= X * (cnt - M);
        out << answer << "\n";
    }
};


signed main() {
    EHandshake solver;
    std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1792
N = int(input())
A = list(map(int,input().split()))
A.sort()
inf = 10**9 + 7
if N%2 == 1:
    ans = 1
    for i in range((N-1)//2):
        ans = (ans*2)%inf
    for i in range(N):
        if A[i] != i+i%2:
            ans = 0
else:
    ans = 1
    for i in range(N//2):
        ans = (ans*2)%inf
    for i in range(N):
        if A[i] != i+1-i%2:
            ans = 0
print(ans)   

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

int a[5];

int main() {
    for (int i = 1; i <= 3; i++) scanf("%d", &a[i]);
    sort(a + 1, a + 4);
    if((a[3] - (a[1] + a[3] - a[2])) % 2 == 0) {
        printf("%d\n",a[3] - a[2] + (a[3] - (a[1] + a[3] - a[2])) / 2);
    } else {
        a[3]++, a[1]++;
        if (a[2] < a[1]) swap(a[2], a[1]);
        int cnt = 1 + a[3] - a[2] + (a[3] - (a[1] + a[3] - a[2])) / 2;
        printf("%d\n",cnt);
    }
    return 0;
}


Measured memory_bytes: 256
A = [input().split() for l in range(3)]
N = int(input())
B = [input() for i in range(N)]

for i in range(3):
	for j in range(3):
		if A[i][j] in B:
			A[i][j] = 1
		else: A[i][j] = 0

def bingo(A):
	for i in range(3):
		tmp = 0 
		for j in range(3):
			tmp += A[i][j]
		if tmp == 3:
			return True

	for i in range(3):
		tmp = 0 
		for j in range(3):
			tmp += A[j][i]
		if tmp == 3:
			return True

	if A[0][2] + A[1][1] + A[2][0] == 3 or A[0][0] + A[1][1] + A[2][2] == 3:
		return True

	else:
		return False


if bingo(A):
	print("Yes")
else: print("No")

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

int main() {

	int n; cin >> n;
	const int INF = 2147483647;
	vector<int> dp(n + 10, INF); dp[0] = 0;

	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= i; j *= 6) {
			dp[i] = min(dp[i], dp[i - j] + 1);
		}
		for (int j = 9; j <= i; j *= 9) {
			dp[i] = min(dp[i], dp[i - j] + 1);
		}
	}

	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 998244353;
const int N = 1e5 + 5;

int a,b;

void solve(){
    cin>>a>>b;
    cout<<a*b;
}

signed main(){
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int A, P, res;
  rd(A);
  rd(P);
  res = (3*A + P) / 2;
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190526-1

// --- original code ---
// {
//   int A, P, res;
//   rd(A, P);
//   res = (3A + P) / 2;
//   wt(res);
// }


Measured memory_bytes: 256
def main():
    a = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    for i in range(3):
        for j in range(3):
            if a[i][j] in b:
                a[i][j] = -1
    answer = 0
    for i in range(3):
        if a[i] == [-1, -1, -1]:
            answer += 1
    for i in range(3):
        if a[0][i] == a[1][i] == a[2][i] == -1:
            answer += 1
    if a[0][0] == a[1][1] == a[2][2] == -1:
        answer += 1
    if a[0][2] == a[1][1] == a[2][0] == -1:
        answer += 1
    print("Yes" if answer > 0 else "No")


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
long long fact(int n){
	if (n == 0) return 1;
	else return n * (fact(n-1) % (1000000007));
}

int main() {
	int N;
	cin >> N;
	int S[300000];
	for (int i=0; i<2*N; i++){
		char s;
		cin >> s;
		if(s=='B') S[i] = 1;
		else S[i] = 0;
	}

	//Lなら0、Rなら1
	int A[300000];
	A[0] = 0;
	for (int i=1; i<2*N; i++){
		if (S[i-1] == S[i]){
			if (A[i-1]==1) A[i] = 0;
			else A[i] = 1;
		}
		else A[i] = A[i-1];
	}

	int L[300000];
	int R[300000];
	int l = 0;
	int r = 0;
	L[0] = 0;
	R[0] = 0;
	for (int i = 0; i<2*N; i++){
		if(A[i] == 0) l++;
		else r++;
		L[i+1] = l;
		R[i+1] = r;
	}

	long long ans;
	if(l==r && S[0] != 0 && S[2*N-1] != 0) {

	ans = 1;
	for (int i = 0; i<2*N; i++){
		if(A[i] == 1) ans = ans * (L[i]-R[i]) % (1000000007);
	}

	ans = (ans * (fact(N)% (1000000007))) % (1000000007);
	}
	else ans = 0;


	cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6272
N, M = list(map(int, input().split()))
s, c = [], []
mapSC = {}
for _ in range(M):
    si, ci = list(map(int, input().split()))
    s.append(si)
    c.append(ci)
    if si not in mapSC:
        mapSC[si] = ci
    else:
        if mapSC[si] != ci:
            print("-1")
            exit(0)

if len(mapSC) > N:
    print("-1")
    exit(0)

# if N > 1 and s[0] == 0:
#     print("-1")
#     exit(0)

if N == 1:
    rb, re = 0, 10
elif N == 2:
    rb, re = 10, 100
else:
    rb, re = 100, 1000

ans = -1
for v in range(rb, re):
    sv = "{}".format(v)
    lf = []
    for i in range(M):
        lf.append(int(sv[s[i] - 1]) == int(c[i]))
    if all(lf):
        ans = v
        break
    # print(sv, lf, all(lf))

print(ans)

Measured memory_bytes: 39408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<vector<ll>>dp;
ll f(vector<ll>&A,int i,int j)
{
    if(i>j)
        return 0;
    if(i==j)return A[i];
    if(dp[i][j]!=-1)
        return dp[i][j];
    dp[i][j]=max(A[i]+min(f(A,i+1,j-1),f(A,i+2,j)),A[j]+min(f(A,i+1,j-1),f(A,i,j-2)));
    return dp[i][j];
}
int main()
{
    int n;
    cin>>n;
    vector<ll>A(n);
    long long total=0;
    for(ll &i:A){
        cin>>i;
        total+=i;
    }
    dp.resize(n+1,vector<ll>(n+1,-1));
    cout<<2*f(A,0,n-1)-total;
}

Measured memory_bytes: 70912
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    l_s = list(input())
    ans = 0
    target = 0

    one_cnt = 0
    ans = 0
    for cnt, l in enumerate(l_s, 1):

        if l == "1":
            # これを、上位桁の1の個数×2パターン作成できる。
            pattern1 = pow(2, one_cnt, 1000000007)
            # 該当桁より後ろのパターン = 3^残り桁数乗
            pattern0 = pow(3, len(l_s) - cnt, 1000000007)

            ans += pattern0 * pattern1 % 1000000007
            one_cnt += 1

    # これを、上位桁の1の個数×2パターン作成できる。
    pattern1 = pow(2, one_cnt, 1000000007)
    # 該当桁より後ろのパターン = 3^残り桁数乗
    pattern0 = pow(3, 0, 1000000007)
    ans += pattern0 * pattern1 % 1000000007

    print(ans % 1000000007)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """10"""
        output = """5"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """1111111111111111111"""
        output = """162261460"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


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

int main(){
  int n;cin>>n;
  set<string> se;

  REP(i,n) {
      string tmp;
      cin>>tmp;
      se.insert(tmp);
  }

  cout<<se.size();
}




Measured memory_bytes: 19224
#include<iostream>
using namespace std;
int main()
{
	int n,m;
	cin>>n;
	for(int i=n;;i++)
	{
		int a=i/100;
		int b=i/10%10;
		int c=i%10;
		if(a==b&&b==c)
		{
			m=i;
			break;
		}
	}
	cout<<m<<endl;
}

Measured memory_bytes: 888
#include<cstdio>
#include<cstring>
const int MAXN=10005,MOD=998244353;

int PowMod(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)
			res=1LL*res*a%MOD;
		a=1LL*a*a%MOD;
		b>>=1;
	}
	return res;
}

int N;
char A[MAXN],B[MAXN];
int dp[MAXN][MAXN];

int fac[MAXN],ifac[MAXN];
int C(int n,int r)
{return 1LL*fac[n]*ifac[n-r]%MOD*ifac[r]%MOD;}

int main()
{
	scanf("%s%s",A+1,B+1);
	N=strlen(A+1);
	int X=0,Y=0;
	for(int i=1;i<=N;i++)
	{
		if(A[i]=='1'&&B[i]=='1')
			X++;
		else if(A[i]=='1')
			Y++;
	}
	
	fac[0]=1;
	for(int i=1;i<=N;i++)
		fac[i]=1LL*fac[i-1]*i%MOD;
	ifac[N]=PowMod(fac[N],MOD-2);
	for(int i=N-1;i>=0;i--)
		ifac[i]=1LL*ifac[i+1]*(i+1)%MOD;
	
	for(int j=0;j<=Y;j++)
		dp[0][j]=1LL*fac[j]*fac[j]%MOD;
	for(int i=1;i<=X;i++)
		for(int j=1;j<=Y;j++)
			dp[i][j]=(1LL*dp[i-1][j]*i%MOD*j%MOD+1LL*dp[i][j-1]*j%MOD*j%MOD)%MOD;
	int ans=0;
	for(int i=0;i<=X;i++)
		ans=(ans+1LL*dp[X-i][Y]*fac[i]%MOD*fac[i]%MOD*C(X,i)%MOD*C(X+Y,i)%MOD)%MOD;
	printf("%d\n",ans);
	
	return 0;
}


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

#define ll long long
#define inf 1e18
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define sp(x, y) fixed << setprecision(y) << x;
#define em emplace_back
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
#define nl '\n'

typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

const int maxn = 1e6;
const int mod = 1e9 + 7;

void solve() {
  ll n;
  cin >> n;
  string ans;
  while (n) {
    ll k = n / 26;
    int r = n % 26;
    if (r == 0) {
      ans.push_back('z');
      k--;
    } else {
      ans.push_back('a' + r - 1);
    }
    n = k;
  }
  reverse(all(ans));
  cout << ans << nl;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ll test = 1;
  /* cin >> test; */
  while (test--) {
    solve();
  }
  return 0;
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;
// (2^x - 1) * 2^(n-x)
int main(){
    int n, p;
    cin >> n >> p;
    int one = 0;
    rep(i,n) {
        int a;
        cin >> a;
        if(a%2) one++;
    }
    if(one==0) {
        if(p==0) cout << (1LL<<n) << endl;
        else cout << 0 << endl;
    }
    else{
        cout << (1LL << (n-1)) << endl;
    }
    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>

int main(){

   int a,b,c;

   scanf("%d%d%d",&a,&b,&c);

   if(a == b){
      printf("%d\n",c);
   }else if(a == c){
      printf("%d\n",b);
   }else{
      printf("%d\n",a);
   }

   return 0;

}


Measured memory_bytes: 128
A=[c=0]*(2*D=86400)
gets.to_i.times{
	a,b=gets.split.map &:to_i
	A[c=(c+a)%D]+=1
	A[c+D]+=1
	c=(c+b)%D
}
(D*2-1).times{|i|A[i+1]+=A[i]}
p D.times.map{|i|A[i+10801]-A[i]}.max

Measured memory_bytes: 3836
#!/usr/bin/ruby
# encoding: utf-8

n = gets.to_i
h = gets.split.map(&:to_i)

ans = 0
flag = true
(0..n-1).each do |i|
  (0..i-1).each do |j|
    if h[i] < h[j] then
      flag = false
    end
  end
  
  if flag == true then
    ans += 1
  end

  flag = true
end

puts ans


Measured memory_bytes: 1788