akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int POW(int a,int n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return (int)ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  LL N,M,i,l=1,ans=0;
  scanf("%lld%lld",&N,&M);
  M*=2;
  LL a[N];
  FOR(i,0,N)scanf("%lld",&a[i]);
  FOR(i,0,N){
    l=LCM(l,a[i]);
    if(l>M){
      printf("0\n");
      return 0;
    }
  }
  FOR(i,0,N)if((l/2)%a[i]==0){
    printf("0\n");
  	return 0;
  }
  ans=M/l;
  ans=(ans+1)/2;

  printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 896
import collections
N = int(input())
S = input()
pre = collections.Counter(S[1:])["E"]
mi = pre
for i in range(1,N):
    if S[i-1] == "W":
        pre += 1
    if S[i] == "E":
        pre -= 1
    mi = min(mi, pre)
print(mi)

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

int main(){
  string S;

  cin>>S;

  for(int i=0;i<4;i++)
    cout<<S[i];

  cout<<" ";

  for(int i=4;i<12;i++)
    cout<< S[i];

  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
import math

n = int(input())
arr = [0] * n

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            ans = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if ans <= n:
                arr[ans - 1] += 1

for i in range(n):
    print(arr[i])

Measured memory_bytes: 73504
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define MAXN 300010

int ct[MAXN], ans[MAXN];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	long long n, m, i, j, k, a, b, ans;
	cin >> n >> m;
	vector<vector<long long>> plist(100100);
	for (i = 0; i < n; i++) {
		cin >> a >> b;
		if (a <= m) {
			plist[m - a].push_back(b);
		}
	}

	ans = 0;
	priority_queue<long long> pq;
	for (i = m; i >= 0; i--) {
		for (auto p : plist[i]) pq.push(p);
		if (!pq.empty()) {
			ans += pq.top();
			pq.pop();
		}
	}
	cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 5632
#include <iostream>
#include <iomanip>
#include <utility>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <map>
#include <climits>
#include <bitset>

#define ll long long
const ll MOD = 1e9 + 7;
const ll INF = 1 << 29;

int main()
{
    struct Edge
    {
        Edge(int from, int to) : _from(from), _to(to){}
        int _from, _to;
    };

    std::ios::sync_with_stdio(false);

    int N, M;
    std::cin >> N >> M;

    std::vector<Edge> edges;
    std::vector<bool> bridges(N-1);

    for (auto i=0; i<M; ++i)
    {
        int from, to;
        std::cin >> from >> to;
        from--;
        to--;
        edges.emplace_back(Edge(from, to));
    }

    std::sort(edges.begin(), edges.end(),
            [](const Edge& lhs, const Edge& rhs) { return lhs._to < rhs._to; });

    auto result = 0;
    for (auto& e : edges)
    {
        bool shouldBrake = true;
        for (auto j=e._from; j<e._to; ++j)
        {
            // from ~ to までのどこかが壊れてた
            if (bridges[j])
            {
                shouldBrake = false;
                break;
            }
        }

        if (shouldBrake)
        {
            bridges[e._to-1] = true;
            result++;
        }
    }

    std::cout << result << std::endl;
}


Measured memory_bytes: 4340
#include<iostream>
using namespace std;
int main ()
{
    int n;
    cin>>n;
    int arr[n];
    //  int arr2[1000];
    int c=0,b=0,x;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }

//    for (int i=0; i<n; i++)
//    {
//        if (arr[i]%2==0)
//        {
//            arr2[i]=arr[i];
//            b++;
//    }
//    }
//    x=b;

    for (int i=0; i<n; i++)
    {
        if (arr[i]%2==0)
        {
            b++;
            if  ( arr[i]%3==0 || arr[i]%5==0)
           c++;
        }

    }

    if (c==b)
        cout<<"APPROVED"<<endl;

     else
     cout<<"DENIED"<<endl;

    return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;

class Main {

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

		int a = sc.nextInt();
		sc.nextInt();
		sc.nextInt();
		sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();

		String ans = e - a > k ? ":(" : "Yay!";

		System.out.println(ans);

		sc.close();
	}
}


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

int main(void){
  int k,n;
  cin >> k >> n;
  std::vector<int> a(n) ;
  rep(i,n) cin >> a[i];
  a[n] = a[0] + k;
  int longest = 0;
  rep(i,n+1) {
     longest = max(longest, a[i+1] - a[i]);
  }
  
  int ans = k - longest;
  cout << ans << endl;
 
}


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

int main(){
  string N;
  cin >> N;
  if(N[0] == N[1] && N[1] == N[2]) cout << "Yes" << endl;
  else if(N[1] == N[2] && N[2] == N[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int i = 1;
        while(i <= 10000){
            int x = sc.nextInt();
            if(x != 0){
               
                System.out.println("Case " + i + ": " + x);
                i++;
            }else{
                break;
            }
        }
        
    }
}


Measured memory_bytes: 41392
a,b,c,d = map(int,input().split())

if(a > 0 and b > 0):
    if(c <= 0 and d <= 0):
        print(a * d)
        exit()
if(c > 0 and d > 0):
    if(a <= 0 and b <= 0):
        print(c * b)
        exit()

print(max(a * c, b * d))

Measured memory_bytes: 9184
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,cnt[10005];
int32_t main(){
CODE_START;
ll ans=0;
cin>>n;
for(ll x=1;x<=100;x++)
{
    for(ll y=1;y<=100;y++)
    {
        for(ll z=1;z<=100;z++)
        {
ll val=x*x+y*y+z*z+x*y+y*z+x*z;
if(val>10000){
    continue;
}
cnt[val]++;
        }
    }
}
for(ll i=1;i<=n;i++)
{
    cout<<cnt[i]<<endl;
}
}



Measured memory_bytes: 3720
#define RUN
#ifdef RUN
#include <bits/stdc++.h>
using namespace std;

#define int long long

int N, K;
vector<int> H;

signed main() {
    cin >> N >> K;
    for (int i = 0; i < N; ++i) {
        int h;
        cin >> h;
        H.push_back(h);
    }
    sort(H.begin(), H.end(), greater<int>());
    int ans = 0;
    for (int i = K; i < N; ++i) {
        ans += H[i];
    }
    cout << ans << endl;
    return 0;
}
#endif


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

using namespace std;

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

  sort(S.begin(), S.end());
  bool flag = true;
  if(S[0] != 'a'){
    cout << "a" << endl;
    return 0;
  }
  for (int i = 1; i < S.size(); i++) {
    if (S[i] - S[i - 1] > 1) {
      printf("%c\n", S[i - 1] + 1);
      flag = false;
      return 0;
    }
  }
  
  
  if (S[S.size() - 1] != 'z') {
    printf("%c\n", S[S.size() - 1] + 1);
    return 0;
  }

  if (flag) {
    cout << "None" << endl;
  }
}

Measured memory_bytes: 764
N, K = map(int,input().split())
tele = list(map(int, input().split()))

now = 0
goal,loop,visit = [],[],[0]*N

while visit[now]!=2:

  if visit[now]==0:
    goal.append(now)
  else:
    loop.append(now)
    
  visit[now] += 1
  now = tele[now]-1

if len(goal)>K:
  print(goal[K]+1)
else:
  res= len(goal)-len(loop)
  print(loop[(K-res)%len(loop)]+1)

Measured memory_bytes: 32912
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<climits>
#include<vector>
#include<map>
using namespace std;
typedef pair<int,int>P;	//<x,y>
int F(P a,P b){return abs(a.first-b.first)+abs(a.second-b.second);}
int main()
{
	int w,h,i,j,k,n,c;
	char s[9];
	vector<P>p[2502];
	vector<int>d[2502];
	P g;
	while(scanf("%d%d",&w,&h),w)
	{
		for(n=i=0;i<2502;++i)p[i].clear();
		for(i=0;i<h;++i)for(j=0;j<w;++j)
		{
			scanf("%s",s);
			if(*s=='S')p[0].push_back(P(j,i));
			if(*s=='G')g=P(j,i);
			if(isdigit(*s))
			{
				c=atoi(s);
				if(n<c)n=c;
				p[c].push_back(P(j,i));
			}
		}
		p[n+1].push_back(g);
		n+=2;
		for(i=0;i<n;++i)
		{
			d[i].resize(c=p[i].size());
			for(j=0;j<c;++j)d[i][j]=INT_MAX;
		}
		d[0][0]=0;
		for(i=1;i<n;++i)
			for(j=0;j<d[i-1].size();++j)
				for(k=0;k<d[i].size();++k)
					d[i][k]=min(d[i][k],d[i-1][j]+F(p[i-1][j],p[i][k]));
		printf("%d\n",d[n-1][0]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
#define LEN 1000000
 
typedef struct{
    char name[10];
    int t;
}QUEUE;
 
QUEUE queue[LEN];
int head,tail;
 
void enqueue(QUEUE x){
    queue[tail] = x;
    tail = (tail+1)%LEN;    //????????°????????????????????????????????§???????¶???????????????????
}
 
QUEUE dequeue(){
    QUEUE x = queue[head];
    head = (head+1)%LEN;
    return x;
}
 
int main(int argc, char const *argv[])
{
    int n,quantum;
    int total_time=0;
    QUEUE output;    //????????¨
 
    cin >> n;
    cin >> quantum;
 
    head=0;    tail=n;
 
    for (int i = 0; i < n; ++i)    //queue?????????????????\???
    {
         cin >> queue[i].name;
         cin >> queue[i].t;
    }
 
    while(head != tail)    //?????£????????¨head=tail
    {
        output=dequeue();
 
        if (output.t <= quantum)
        {
            total_time += output.t;
            cout << output.name << " " << total_time << endl;
        }
        else
        {
            output.t -= quantum;
            total_time += quantum;
            enqueue(output);
        }
    }
    return 0;
}

Measured memory_bytes: 6028
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int n;
ll a[225816],memo[2][225816][20];
bool done[2][225816][20];

ll f(int i, int p){
	int j,c = 0;
	ll s,t;
	if(p>15){
		return f(i,15)+(p-15)*(n-i);
	}
	if(done[0][i][p]){
		return memo[0][i][p];
	}
	done[0][i][p] = true;
	if(i==n-1){
		memo[0][i][p] = p;
		return memo[0][i][p];
	}
	s = a[i];
	t = a[i+1];
	for(j=0; j<p; ++j){
		s *= 4ll;
	}
	while(s > t){
		t *= 4ll;
		++c;
	}
	memo[0][i][p] = f(i+1,c)+p;
	return memo[0][i][p];
}

ll g(int i, int p){
	int j,c = 0;
	ll s,t;
	if(p>15){
		return g(i,15)+(p-15)*(i+1);
	}
	if(done[1][i][p]){
		return memo[1][i][p];
	}
	done[1][i][p] = true;
	if(i==0){
		memo[1][i][p] = p;
		return memo[1][i][p];
	}
	s = a[i];
	t = a[i-1];
	for(j=0; j<p; ++j){
		s *= 4ll;
	}
	while(s > t){
		t *= 4ll;
		++c;
	}
	memo[1][i][p] = g(i-1,c)+p;
	return memo[1][i][p];
}


int main(void){
	int i;
	ll ans;
	cin >> n;
	fill(done[0][0],done[2][0],false);
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	ans = min(2*f(0,0),n+2*g(n-1,0));
	for(i=1; i<n; ++i){
		ans = min(ans,i+2*f(i,0)+2*g(i-1,0));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 95872
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

int a[100005], n, pref[100005], cop[100005];
ll inv = 0;

void merges(int lef, int mid, int rig)
{
    int uk1 = lef, uk2 = mid + 1, uk = lef;
    while (uk1 <= mid || uk2 <= rig)
    {
        if (uk1 <= mid && (uk2 > rig || pref[uk1] < pref[uk2]))
        {
            inv += (ll) (rig - uk2 + 1);
            cop[uk] = pref[uk1];
            uk++, uk1++;
        }
        else
        {
            cop[uk] = pref[uk2];
            uk++, uk2++;
        }
    }
    for (int i = lef; i <= rig; i++)
        pref[i] = cop[i];
    return;
}

void mergesort(int lef, int rig)
{
    if (lef == rig) return;
    int mid = (lef + rig) / 2;
    mergesort(lef, mid);
    mergesort(mid + 1, rig);
    merges(lef, mid, rig);
    return;
}

bool ok(int val, ll kol)
{
    pref[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        pref[i] = pref[i - 1];
        if (a[i] > val) pref[i]--;
        else pref[i]++;
    }
    inv = 0;
    mergesort(0, n);
    return inv >= kol;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    ll kol = (ll) n * (ll) (n + 1) / 2;
    ll pos = kol / 2 + 1;
    int lef = 0, rig = (int) 1e9;
    while (lef + 1 < rig)
    {
        int mid = (lef + rig) / 2;
        if (ok(mid, pos)) rig = mid;
        else lef = mid;
    }
    cout << rig;
    return 0;
}


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

int main() {
  int board[3][3];
  rep (i, 3) {
    rep (j, 3) {
      cin >> board[i][j];
    }
  }

  int a[3], b[3];
  bool ans;

  rep (i, board[0][0] + 1) {
    a[0] = board[0][0] - i;
    rep (j, 3) {
      b[j] = board[0][j] - a[0];
    }
    for (int j = 1; j < 3; j++) {
      a[j] = board[j][0] - b[0];
    }

    bool flag = true;
    rep (j, 3) {
      rep (k, 3) {
        int tmp = a[j] + b[k];
        if (tmp != board[j][k]) {
          flag = false;
          break;
        }
      }
      if (!flag) break;
    }
    ans = flag;
    if (flag) break;
  }

  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#define pi acos(-1.0)
using namespace std;
int main() {
	int s = -1, e = -1;
	char str[100000+5];
	scanf("%s", str);
	int len = strlen(str);
	for(int i = 0; str[i]; i++) {
		if(str[i] == str[i + 1]) {
			s = i + 1;
			e = i + 2;
			break;
		} else if(str[i] == str[i + 2]) {
			s = i + 1;
			e = i + 3;
			break;
		}
	}
	printf("%d %d\n",s,e);	
	return 0;
}

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

using namespace std;
 
#define ll long long 
#define IOS ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

int main()
{
	char c;
	cin >> c;
	cout << char(c+1);
	return 0;
}


Measured memory_bytes: 256
A,B,K=input().split()
A=int(A)
B=int(B)
K=int(K)
turn=0
while(1):
	if(turn==K):
		break
	if(turn%2==0):#高橋くん
		if(A%2==1):
			A-=1
		B+=A//2
		A-=A//2
	else:#青木くん
		if(B%2==1):
			B-=1
			
		A+=B//2
		B-=B//2
	turn+=1
print(str(A)+" "+str(B))

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  vector<string> s(3); REP(i, 3) cin >> s[i];
  string ans = "";
  REP(i, 3) ans += toupper(s[i].front());
  cout << ans << '\n';
  return 0;
}


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

const int mod = 1e9 + 7;

int last[200010];
int dp[200010];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	dp[0]=1;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		dp[i]=dp[i-1];
		if(last[x]!=i-1&&last[x]){
			dp[i]+=dp[last[x]];
			if(dp[i]>=mod)
				dp[i]-=mod;
		}
		last[x]=i;
	}
	cout<<dp[n]<<endl;
	
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x,a,b;
	cin >> x;
	cin >> a;
	cin >> b;

	x = x - a;
	int y = x / b;
	x = x - y * b;

	cout << x << endl;

	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

    int ans = 0;
    rep(i,n){
        double dis = sqrt(x[i] * x[i] + y[i] * y[i]);
        if (dis <= d) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6488
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    s.at(5) = ' ';
    s.at(13) = ' ';
    cout << s << endl;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;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 FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  int a, b;
  cin >> a >> b;

  if(a > b){
    cout << a - 1 << endl;
  }else{
    cout << a << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;
int da[6]={1,2,3,4,5,6};
string str;
int main(){
    int n,i;
    int a,b;
    int count=1;
    while(cin>>n){
        if(n==0)break;
        count=1;
        for(i=0;i<n;i++){
            cin>>str;
            if(str=="North"){
                a=da[0];
                da[0]=da[1];
                da[1]=da[5];
                da[5]=da[4];
                da[4]=a;
                count+=da[0];
            }
            else if(str=="East"){
                a=da[0];
                da[0]=da[3];
                da[3]=da[5];
                da[5]=da[2];
                da[2]=a;
                count+=da[0];
            }
            else if(str=="West"){
                a=da[0];
                da[0]=da[2];
                da[2]=da[5];
                da[5]=da[3];
                da[3]=a;
                count+=da[0];
            }
            else if(str=="South"){
                a=da[0];
                da[0]=da[4];
                da[4]=da[5];
                da[5]=da[1];
                da[1]=a;
                count+=da[0];
            }
            else if(str=="Right"){
                b=da[1];
                da[1]=da[2];
                da[2]=da[4];
                da[4]=da[3];
                da[3]=b;
                count+=da[0];
            }
            else if(str=="Left"){
                b=da[1];
                da[1]=da[3];
                da[3]=da[4];
                da[4]=da[2];
                da[2]=b;
                count+=da[0];
            }
        }
        cout<<count<<endl;
        count=1;
        for(i=0;i<6;i++){
        da[i]=i+1;
        }
        
    }
    return 0;
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=111,mod=1000000007,inv2=500000004;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
template<typename T>
inline void read(T &x){
	x=0;
	char ch=getchar();bool f=false;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	if(f) x=-x;
}
int n,h[maxn],dp[maxn][maxn][2][2][2],mn[maxn][maxn],tmp[2][2][2],ans;
inline int qpow(int a,int b){
	int ans=1;
	for(;b;b>>=1,a=1ll*a*a%mod) if(b&1) ans=1ll*ans*a%mod;
	return ans;
}
void go_lower(int f[][2][2],int cnt){
	if(!cnt) return;
	int g[2][2][2];
	MEM(g,0);
	FOR(a,0,1) FOR(b,0,1) FOR(c,0,1) if(c){
		if(cnt%2==0) g[a][b][c]=f[a][b][c];
		else g[a^1][b^1][c]=f[a][b][c];
	}
	else{
		g[a][b][c]=(g[a][b][c]+1ll*f[a][b][c]*qpow(2,cnt-1))%mod;
		g[a^1][b^1][c]=(g[a^1][b^1][c]+1ll*f[a][b][c]*qpow(2,cnt-1))%mod;
	}
	FOR(a,0,1) FOR(b,0,1) FOR(c,0,1) f[a][b][c]=g[a][b][c];
}
void merge(int f[][2][2],int g[][2][2]){
	int h[2][2][2];
	MEM(h,0);
	FOR(a,0,1) FOR(b,0,1) FOR(c,0,1) FOR(d,0,1) FOR(e,0,1) FOR(f_,0,1){
		int to=c|f_|(b==d);
		h[a][e][to]=(h[a][e][to]+1ll*f[a][b][c]*g[d][e][f_])%mod;
	}
	FOR(a,0,1) FOR(b,0,1) FOR(c,0,1) f[a][b][c]=h[a][b][c];
}
void dfs(int l,int r){
	if(l>r) return;
	if(l==r){
		dp[l][r][0][0][0]=dp[l][r][1][1][0]=1;
		return;
	}
	int last=l-1;
	FOR(i,l,r) if(h[i]==mn[l][r]){
		if(last+1<=i-1){
			dfs(last+1,i-1);
			go_lower(dp[last+1][i-1],mn[last+1][i-1]-mn[l][r]);
			if(last==l-1){
				FOR(a,0,1) FOR(b,0,1) FOR(c,0,1) dp[l][r][a][b][c]=dp[last+1][i-1][a][b][c];
			}
			else merge(dp[l][r],dp[last+1][i-1]);
		}
		if(i==l) FOR(a,0,1) FOR(b,0,1) FOR(c,0,1) dp[l][r][a][b][c]=tmp[a][b][c]; 
		else merge(dp[l][r],tmp);
		last=i;
	}
	if(last!=r){
		dfs(last+1,r);
		go_lower(dp[last+1][r],mn[last+1][r]-mn[l][r]);
		if(last==l-1){
			FOR(a,0,1) FOR(b,0,1) FOR(c,0,1) dp[l][r][a][b][c]=dp[last+1][r][a][b][c];
		}
		else merge(dp[l][r],dp[last+1][r]);
	}
}
int main(){
	read(n);
	FOR(i,1,n) read(h[i]);
	FOR(i,1,n){
		mn[i][i]=h[i];
		FOR(j,i+1,n) mn[i][j]=min(mn[i][j-1],h[j]);
	}
	tmp[0][0][0]=tmp[1][1][0]=1;
	dfs(1,n);
	go_lower(dp[1][n],mn[1][n]-1);
	FOR(a,0,1) FOR(b,0,1) FOR(c,0,1) ans=(ans+dp[1][n][a][b][c])%mod;
	printf("%d\n",ans);
	return 0;
}

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

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


void solve()
{
   string s,t;
   cin>>s;
   cin>>t;
   int res=0;
   for(int i=0;i<s.length();i++)
   {
       if(s[i]!=t[i])
       res++;
   }
   cout<<res<<endl;
   
}


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

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

int main(){
    int N;
    int C[51], V[51];
    int ans = 0;

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

    for(int i=0;i<N;i++){
        ans += max(0, V[i]-C[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
#define mx 300007
#define mod 1000000007
using namespace std;
typedef long long int LL;
LL cnt[64];
int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	LL ans = 0;
	for(int i = 1; i <= n; i++) {
		LL num;
		cin >> num;
		for(int j = 0; j <= 60; j++) {
			if(num & (1LL << j)) {
				LL add = i - 1 - cnt[j];
				// cout << add << endl;
				LL now = ((1LL << j) % mod) * (add % mod);
				now %= mod;
				ans = (ans + now) % mod; 
			} else {
				LL add = cnt[j];
				LL now = ((1LL << j) % mod) * (add % mod);
				now %= mod;
				ans = (ans + now) % mod; 
			}
		}
		for(int j = 0; j <= 60; j++) {
			if(num & (1LL << j)) cnt[j]++;
		}
		// cout << i <<" ans " << ans << endl;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int A,B,C,D,E,F;
    scanf("%d %d %d %d",&A,&B,&C,&D);
    if(C%B == 0){
        E = C/B;
    }else{
        E = C/B+1;
    }
    if(A%D == 0){
        F = A/D;
    }else{
        F = A/D+1;
    }
    if(E <= F){
        printf("Yes");
    }else{
        printf("No");
    }
}

Measured memory_bytes: 1736
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,x = imn()
a = sorted(iln())

ans = 0
for ai in a:
    x -= ai
    if x < 0: break
    ans += 1
if x > 0:
    ans -= 1
print(ans)

Measured memory_bytes: 5680
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int ans=0;
  if(a>=b)
    ans=b;
  else
    ans=a;
  if(c>=d)
    ans+=d;
  else
    ans+=c;
  cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  int t = N, c = 0;
  while (t > 0) {
    c += t % 10;
    t /= 10;
  }
  
  if (N % c == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3640
n, q = map(int, input().split())
s = input()
lr = []
for i in range(q):
    lr.append(list(map(int, input().split())))

ac = [0] * n
for i in range(n - 1):
    ac[i + 1] = ac[i] + (1 if s[i:i + 2] == 'AC' else 0)

for i in range(q):
    left = lr[i][0] - 1
    right = lr[i][1] - 1
    ans = ac[right] - ac[left]
    print(ans)


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

int main(){
    int n,t;
    cin>>n>>t;
    int res=1e9;

    for(int i=0;i<n;i++){
        int c,tn;
        cin>>c>>tn;
        if(tn<=t) res=min(res,c);
    }
    if(res==1e9){
        cout<<"TLE"<<endl;
    }
    else{
        cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  i64 N, X, D;
  cin >> N >> X >> D;
  if(D == 0) {
    if(X == 0) {
      cout << 1 << endl;
    }
    else {
      cout << N + 1 << endl;
    }
    return 0;
  }
  if(D < 0) {
    D *= -1;
    X *= -1;
  }
  map<i64, vector<pair<i64, i64>>> mp;
  auto diffsum = [](i64 s, i64 k) {
    return (s + (s + k - 1)) * k / 2;
  };
  rep(i,0,N + 1) {
    i64 x = ((X * i) % D + D) % D;
    i64 l = diffsum(0, i) + (X * i) / D;
    i64 r = diffsum(N - i, i) + (X * i) / D + 1;
    mp[x].emplace_back(l, r);
  }
  i64 ans = 0;
  for(auto& p: mp) {
    i64 x = p.first;
    auto& vec = p.second;
    sort(all(vec));
    i64 last = -1e18;
    for(auto ran: vec) {
      if(ran.second <= last) continue;
      if(last < ran.first) last = ran.first;
      ans += ran.second - last;
      last = ran.second;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 22272
#include<algorithm>  
#include<iostream>  
#include<cstdio>  
#include<map>  
#include<set>  
using namespace std;  
string s, t;  
set<string> S;  
  
void Work()  
{  
    int lens = s.size();  
    int lent = t.size();  
    for(int i = 0; i < lens; i++)  
    {  
        if(s[i] == '?' || s[i] == t[0])//如果字符相等  
        {  
            string tmp = s;              //构造判断子串之前的字符  
            for(int j = 0; j < i; j++)  
                if(tmp[j] == '?')  
                    tmp[j] ='a';      
            bool can = false;  
            for(int j = 0; j < lent; j++)    //判断是否为子串  
            {  
  
                if(tmp[i+j]!= '?' && tmp[i+j] != t[j])  //字符匹配  
                    break;  
                tmp[i+j] = t[j];  
                if(j == lent - 1) can = true;  
            }  
            if(can)  
            {  
                for(int j = i + lent; j < lens; j++) if(tmp[j] == '?') tmp[j] = 'a';//处理匹配后的字符  
                S.insert(tmp);  //压入容器  
            }  
        }  
    }  
    if(S.size() == 0) cout << "UNRESTORABLE" << endl;  
    else cout << *S.begin() << endl;  
}  
int main()  
{  
    cin >> s >> t;  
    Work();  
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

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

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};




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

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

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


int main() {
  ll A,B;
  cin>>A>>B;
  ll ans=A*3+B;
  ans=ans/2;


  cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	//freopen("input.txt", "r", stdin); // redirects standard input
	//freopen("output.txt", "w", stdout); // redirects standard output

	string s;
	cin >> s;
	if (s == "ARC") s = "ABC";
	else s = "ARC";
	cout << s << "\n";

	return 0;
}

Measured memory_bytes: 3128
from _collections import deque

def cacl(seq):
    score = 0
    for a, b, c, d in req:
        if seq[b-1] - seq[a-1] == c:
            score += d
    return score

n, m, q = list(map(int, input().split()))
req = [list(map(int, input().split())) for _ in range(q)]

ans = 0
que = deque()

for i in range(1, m+1):
    que.append([i])

while que:
    seq = que.popleft()

    if len(seq) == n:
        score = cacl(seq)
        ans = max(ans, score)
    else:
        for i in range(seq[-1], m + 1):
            seq_next = seq + [i]
            que.append(seq_next)
print(ans)

Measured memory_bytes: 22652
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<vector<ll>> F(N,vector<ll>(10));
    for(int i = 0; i < N;i++){
        for(int j = 0; j < 10;j++){
            cin >> F[i][j];
        }
    }
    vector<vector<ll>> P(N,vector<ll>(11));
    for(int i = 0; i < N;i++){
        for(int j = 0; j < 11;j++){
            cin >> P[i][j];
        }
    }
    ll ans = -(LINF);
    for(int i = 1; i < (1<<10);i++){
        ll tmp = 0;
        vector<int> cnt(N,0);
        for(int j = 0; j < 10;j++){
            if(!((i>>j)&1))continue;
            for(int k = 0; k < N;k++){
                if(F[k][j] == 1){
                    cnt[k]++;
                }
            }
        }
        for(int j = 0; j < N;j++){
            tmp += P[j][cnt[j]];
        }
        ans = max(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
S = input()
s1 = S[0] + S[1]
s2 = S[2] + S[3]

if "00" < s1 < "13" and "00" < s2 < "13" :
    print("AMBIGUOUS")
elif "00" < s2 < "13" :
    print("YYMM")
elif "00" < s1 < "13" :
    print("MMYY")
else :
    print("NA")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


int main() {
    ll n;
    cin >> n;
    vector<ll> nums;
    nums.push_back(26);
    while(nums.back() < 1e17) {
        nums.push_back(nums.back() + pow(26, nums.size()+1));
    }
    ll digit = distance(nums.begin(), lower_bound(all(nums), n)) + 1;
    if (digit > 1) {
        n -= nums[digit-2];
    }
    n--;
    string ans;
    rep (i, digit) {
        int p = n % 26;
        p += 'a';
        string s;
        s += p;
        ans = s + ans;
        n /= 26;
    }
    cout << ans << endl;
}




Measured memory_bytes: 4104
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
????????????????????????????????? ??§?????§  
??????????????? ??§?????§ ???????´<_??? ?????? Welcome to My Coding Space!
???????????? ??? ?´_???`??????/??? ???i     
?????????????????????????????? ???  |???|     
????????? /?????? /??£??£??£??£/??????|  
??? ???_(__??????/???    ???/ .| .|????????????  
??? ????????????/????????????/??????u??????  
---------------------------------------------------------------------------------------------------*/





int theta;
//--------------------------------------------------------------------------------------------------
void _main() {
    cin >> theta;

    int h = theta / 30;
    int m = (theta % 30) * 2;

    printf("%d %d\n", h, m);
}

Measured memory_bytes: 3228
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        double ans = 0;
        for (int i = 1; i <= n; i++) {
            int j = i;
            int c = 0;
            while (j < k) {
                j *= 2;
                c++;
            }

            ans += 1d / (n * (1 << c));
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 25812
(* O(n) *)
let n = read_int ()
let s = read_line ()
let accs = Array.init 2 @@ fun _ -> Array.make (n + 1) 0
let ans = ref max_int
let _ =
  let cs = [|ref 0; ref 0|] in
  for i = 0 to n - 1 do
    incr @@ if s.[i] = 'W' then cs.(0) else cs.(1);
    for j = 0 to 1 do accs.(j).(i + 1) <- !(cs.(j)) done
  done;
  for i = 0 to n - 1 do
    ans := min !ans @@ accs.(0).(i) + accs.(1).(n) - accs.(1).(i + 1)
  done;
  Printf.printf "%d\n" !ans

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

using namespace std;
int a[10] = { 0 };
int p[10] = { 0 };
int N, M;


int main()
{
	int N, Q;
	string S;
	vector<int>l, r;
	int L, R;
	cin >> N >> Q;
	cin >> S;
	vector<int> acrecord;
	int i;
	for (i = 0; i < N-1; i++) {
		if (S[i] == 'A'&&S[i + 1] == 'C')
			S[i+1] = 'c';
	}
	int acount = 0;
	acrecord.push_back(acount);
	for (i = 0; i < N ; i++) {
		if (S[i] == 'c') {
			acount++;
		}
		acrecord.push_back(acount);
	}

	for (i = 0; i < Q; i++) {
		cin >> L >> R;
		l.push_back(L);
		r.push_back(R);
	}
	size_t n;
	int v, m;
	int Count = 0;
	int t;
	for (i = 0; i < Q; i++) {
		v = l[i];
		m = r[i];
		cout << acrecord[m] - acrecord[v] << endl;
	}
	

	return 0;
}


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int suff[200005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    string s;
    cin >> n >> s;

    for (int i=n-1; i>=0; i--)
        suff[i] = suff[i+1] + (s[i] == 'R');
    int ret = suff[0], numWhite = 0;
    for (int i=0; i<n; i++) {
        numWhite += (s[i] == 'W');
        ret = min(ret, max(numWhite, suff[i+1]));
    }

    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 4540
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long  ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

//�ő����
ll gcd(ll a,ll b){
    
    if(a==0 || b==0)return 0;
    if(a<b){
        ll sw;
        sw=a;
        a=b;
        b=sw;
    }
    
    ll r;
    while((r=a%b)!=0){
        a=b;
        b=r;
    }
    return b;
}
//�ŏ����{��
ll lcm(ll a,ll b){


    if(a==0 || b==0)return 0;

    return a/gcd(a,b)*b;

}

int ans;

signed main(){
	
	int n;
	int a[111];
	cin>>n;
	int G,G2=0;
	rep(i,n){
		cin>>a[i];
	}
	G=gcd(a[0],a[1]);
	rep(i,n){
		if(i!=0)G=lcm(G,a[i]);
	}
	//DEB(G)END
	rep(i,n){
		G2+=G/a[i];
	}
	double ans2=double(G)/double(G2);
	if(n==1)ans2=double(a[0]);
	printf("%.6lf",ans2);
	
}

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

int n, k;

int a[101];
int memo[100002];

int dp (int wt) { // 0 if current player wins, 1 o/w 
	if (wt < a[0]) {
		memo[wt] = 1; // next player wins
		return 1; 
	}
	if (memo[wt] != -1)
		return memo[wt];
	for (int i = 0; i < n; i++) {
		if (wt >= a[i]) {
			if (dp(wt - a[i])) { // at this state (wt - a[i]), next player wins
				memo[wt] = 0; // this player wins
				return 0;
			}
		}
	}
	memo[wt] = 1; // no nxt state at which nxt player can win, curr loses 
	return 1;
}

int main () {
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i <= k; i++) // IMP TODO
		memo[i] = -1;
	if (dp(k))
		cout << "Second\n";
	else
		cout << "First\n";
	return 0;
}

Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

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

        int h = scanner.nextInt();
        int w = scanner.nextInt();

        int area = h * W + w * H - h * w;

        int ans = H * W - area;

        System.out.println(ans);

    }

}


Measured memory_bytes: 21844
def main():
    A = [list(map(int, input().split())) for _ in range(3)]
    N = int(input())

    for _ in range(N):
        b = int(input())
        for a_i in range(3):
            for a_j in range(3):
                if A[a_i][a_j] == b:
                    A[a_i][a_j] = "empty"

    ans = "No"
    for i in range(3):
        if A[i][0] == "empty" and A[i][1] == "empty" and A[i][2] == "empty":
            ans = "Yes"
            break

    for j in range(3):
        if A[0][j] == "empty" and A[1][j] == "empty" and A[2][j] == "empty":
            ans = "Yes"
            break

    if A[0][0] == "empty" and A[1][1] == "empty" and A[2][2] == "empty":
        ans = "Yes"

    if A[2][0] == "empty" and A[1][1] == "empty" and A[0][2] == "empty":
        ans = "Yes"

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064