akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll      	long long int
#define PI      	acos(-1)
#define read    	freopen("in.txt","r",stdin)
#define uu      	first
#define vv      	second
#define write   	freopen("out.txt","w",stdout)
#define pii     	pair<int,int>
#define pll         pair<ll,ll>
#define INF     	1e18
#define EPS     	1e-8
#define MAX     	1000006
#define MOD     	1000000007
#define fastRead 	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll n , w;
ll wt[200];
int val[200] ;
ll dp[200][100005];

ll solve(int id , int tgt) {

    if( tgt < 0) return INF;
    if( id == n ) {
        if( tgt == 0 ) return  0;
        return INF;
    }
    ll &ret = dp[id][tgt];
    if( ret != -1 ) return ret;

    ret =solve(id+1 , tgt);

    ret = min( ret , wt[id] + solve(id+1 , tgt-val[id] ) );
    return ret;
}

int main()
{
    fastRead;
    cin>>n>>w;
    int tot = 0;
    for(int i =0 ; i < n ; i++ ) {
        cin>>wt[i]>>val[i];
        tot += val[i];
    }

    memset(dp , -1 , sizeof dp);
    int ans = 0;
    for(int i = 1 ; i <=  tot; i++ ) {

        ll wt = solve(0 , i);
        if( wt <= w) ans = i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 156544
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}

int main() {
   fast();
   map<int,long long int> m;
   int n;
   cin>>n;
   long long ans=1;
   for(int i=2;i<=n;i++){
    int k=i;
     for(int j=2;j<=sqrt(i);j++){
      while(k%j==0){
        m[j]++;
        k=k/j;
      }
     }
     if(k>1){
      m[k]++;
     }
   }
   for(auto i:m){
      ans*=(i.second+1);
      ans%=mod;
      //cout<<i.second<<"\n";
   }
   cout<<ans<<"\n";




}

Measured memory_bytes: 3604
/* Atcoder abc170a
 * See tasks at: https://atcoder.jp/contests/abc170/tasks/abc170_a
 */
#include <bits/stdc++.h>

#define until(symbol, max) for (int symbol = 0; (symbol) < (max); (symbol)++)

using namespace std;
using ll = long long;
int main()
{
    until(i, 5)
    {
        int val;
        cin >> val;
        if (val == 0)
        {
            cout << (i + 1);
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3596
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextString() string {
	sc.Scan()
	return sc.Text()
}
func main() {
	s, t := nextString(), nextString()
	sr := []rune(s)
	tr := []rune(t)

	match := 0
	for i := 0; i < 3; i++ {
		if sr[i] == tr[i] {
			match++
		}
	}
	fmt.Println(match)
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

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

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

int main(){
	int n;
	cin>>n;
	string a,b;
	cin>>a>>b;

	for (int i = 0; i < n; i++){
		cout<<a[i]<<b[i];
	}
	cout<<endl;

	return 0;
}

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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

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

int n,m,ans; string str;

int solve(){
    cin>>str;
    if(str[0]=='S') cout<<"Cloudy";
    else if(str[0]=='C') cout<<"Rainy";
    else cout<<"Sunny";
    return 0;
}

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

Measured memory_bytes: 384
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
using namespace std;
// clang-format on

template<typename InputIterator> constexpr std::string join(InputIterator first, InputIterator last, const std::string &sep) {
  if (first == last) return "";
  std::stringstream ss;
  ss << *(first++);
  for_each(first, last, [&](auto &x) { ss << sep << x; });
  return ss.str();
}

main {
  int n;
  cin >> n;
  vi a(n);
  cin >> a;
  reverse(all(a));
  cout << join(all(a), " ") << endl;
}

Measured memory_bytes: 3168
#include<stdio.h>
int main(){
	int i,i2,n,m,a,b,core,aa,bb,ans;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%d%d",&a,&b);
		aa=a;
		bb=b;
		core=n/2;
		if(n%2==1)core++;
		if(a>core)aa=n-aa+1;
		if(b>core)bb=n-bb+1;
		if(aa>bb){
			ans=bb;
		}
		else{
			ans=aa;
		}
		ans%=3;
		if(ans==0)ans=3;
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 2664
def bingo():
    for i in a:
        tmp=0
        for j in i:
            if j in b:
                tmp+=1
        if tmp==3:
            return True
    for i in range(3):
        tmp=0
        for j in a:
            if j[i] in b:
                tmp+=1
        if tmp==3:
            return True
    tmp=[(a[i][i] in b) for i in range(3)]
    if tmp.count(True)==3:
        return True
    tmp=[a[0][2] in b,a[1][1] in b,a[2][0] in b]
    if tmp.count(True)==3:
        return True

a=[[int(i)for i in input().split()]for j in range(3)]
n=int(input())
b=[int(input())for i in range(n)]
bingo=bingo()
print("Yes" if bingo else "No")

Measured memory_bytes: 9224
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    int sum = 0;
    rep(i, N) {
        cin >> A[i];
        sum += A[i];
    }
    sort(A.begin(), A.end(), greater<int>());

    bool ok = (sum <= 4*M*A[M-1]);
    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}


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

using namespace std;

class Dice{
public:
    int dice[6];

    void move(char c){
        int tmp;
        switch(c){
            case('S'):
                tmp = dice[5];
                dice[5] = dice[1];
                dice[1] = dice[0];
                dice[0] = dice[4];
                dice[4] = tmp;
                break;
            case('N'):
                tmp = dice[5];
                dice[5] = dice[4];
                dice[4] = dice[0];
                dice[0] = dice[1];
                dice[1] = tmp;
                break;
            case('E'):
                tmp = dice[5];
                dice[5] = dice[2];
                dice[2] = dice[0];
                dice[0] = dice[3];
                dice[3] = tmp;
                break;
            case('W'):
                tmp = dice[5];
                dice[5] = dice[3];
                dice[3] = dice[0];
                dice[0] = dice[2];
                dice[2] = tmp;
                break;
        }
    }
};

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

    vector<Dice> Dices(n);
    for(int i =0; i<n; ++i){
        for(int j=0; j<6; ++j){
            cin >> Dices[i].dice[j];
        }
    }

    int num = 0;

    for(int i=0; i<n; ++i){
        for(int j=i+1; j<n; ++j){
            for(int s=0; s<4; ++s){
                Dices[j].move('S');
                for(int e=0; e<4; ++e){
                    Dices[j].move('E');
                    for(int n=0; n<4; ++n){
                        Dices[j].move('N');
                        for(int w=0; w<4; ++w){
                            Dices[j].move('W');
                            if( Dices[i].dice[0] == Dices[j].dice[0] and Dices[i].dice[1]== Dices[j].dice[1] and Dices[i].dice[2] == Dices[j].dice[2] and
                                Dices[i].dice[3] == Dices[j].dice[3] and Dices[i].dice[4]== Dices[j].dice[4] and Dices[i].dice[5] == Dices[j].dice[5]){
                                num++;
                            }
                        }
                    }
                }
            }
        }
    }

    if( num != 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}


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

int main(){
  long A, B, M;
  cin >> A >> B >> M;

  vector<long> va(A);
  vector<long> vb(B);
  vector<long> vx(M);
  vector<long> vy(M);
  vector<long> vc(M);

  for(int i=0; i<A; i++) cin >> va[i];
  for(int i=0; i<B; i++) cin >> vb[i];
  for(int i=0; i<M; i++){
    cin >> vx[i] >> vy[i] >> vc[i];
  }

  long min_cost = *min_element(va.begin(), va.end()) + *min_element(vb.begin(), vb.end());
  for(int i=0; i<M; i++){
    long cost = va[vx[i]-1] + vb[vy[i]-1] - vc[i];
    min_cost = min(cost, min_cost);
  }
  cout << min_cost << endl;
}


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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

long long gcd(long long a, long long b){
    // 最大公約数
    // ユークリッドの互除法
    if(a < b){
        long long temp = a;
        a = b;
        b = temp;
    }
    long long r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

long long lcm(long long a, long long b){
    // 最小公倍数
    return a * b / gcd(a, b);
}

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << b - a + 1 + (a-1) / c + (a-1) / d - (a-1) / (lcm(c,d)) - b / c - b / d + b / (lcm(c,d));
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c,i;
    scanf("%d %d %d",&a,&b,&c);
    for(i=b;i<=c;i++)
            {
        if(i%a==0)
        {
            printf("OK\n");
            return 0;
        }
        }
        printf("NG\n");

            return 0;
    }




Measured memory_bytes: 1620
import java.util.*;

public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String name = "";
      for(int i = 0;i<3;i++){
        String a = sc.next();
        name = name + a.substring(0,1);
      }
      System.out.println(name);
     	
    }
}

Measured memory_bytes: 39164
import java.util.*;
public class Main {
	public static void main(String[] args) {
		int N = 0;
		int T = 0;
		int A = 0;
		Scanner scan = new Scanner(System.in);
		N = scan.nextInt();
		T = scan.nextInt();
		A = scan.nextInt();
		int arr[] = new int[N];
		for (int i = 0; i < arr.length; i++) {
			arr[i] = scan.nextInt();
		}
		
		double arr2[] = new double[N];
		
		double temp = 0;
		int address = 1;
		temp = Math.abs(T - arr[0] *0.006 -A);
		for (int i = 1; i < arr.length; i++) {
			arr2[i] = Math.abs(T - arr[i] *0.006 - A);
			if(arr2[i] < temp){
				temp = arr2[i];
				address = i + 1;
			}
		}
		System.out.println(address);
	}
}

Measured memory_bytes: 24020
#include "bits/stdc++.h"
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const int MOD = 1e9+7;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

char s[100005];
ll dp[100005][13];
int main() {
	int n;
	cin >> s;
	n = strlen(s);

	dp[0][0] = 1;
	rep(i, n){
		int c;
		if(s[i] == '?') c = -1;
		else c = s[i] - '0';

		rep(j, 10){
			if(c != -1 && c != j) continue;
			rep(ki, 13){
				dp[i+1][(ki*10+j)%13] += dp[i][ki];
			}
		}
		rep(j, 13) dp[i+1][j]%= MOD;
	}
	cout << dp[n][5];
}


Measured memory_bytes: 10496
import math
n=int(input())
s=0
for i in range(n):
    a=int(input())
    b=math.ceil(a**0.5)
    if a==2:
        s+=1
    elif a%2==0 or a < 2:
        continue
    else:
        c=0
        j=3
        while j <= b:
            if a%j==0:
                c+=1
                break
            j+=2
        if c==0:
            s+=1
print(s)

Measured memory_bytes: 7948
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int main(){
  int n,m,i,j,k,d[110][110],a[1010],b[1010],c[1010];
  for(i=0;i<110*110;i++)d[i/110][i%110]=1e9;
  for(i=0;i<110;i++)d[i][i]=0;
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d %d %d",&a[i],&b[i],&c[i]);
    d[a[i]][b[i]]=d[b[i]][a[i]]=c[i];
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      for(k=1;k<=n;k++)d[j][k]=MIN(d[j][k],d[j][i]+d[i][k]);
    }
  }
  for(i=j=0;i<m;i++){
    if(d[a[i]][b[i]]-c[i])j++;
  }
  printf("%d\n",j);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.awt.Point;
import static java.lang.Math.*;

import java.awt.SystemTray;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int dx[] = {0, 1, 0, -1};
        int dy[] = {1, 0, -1, 0};

        int h = sc.nextInt();
        int w = sc.nextInt();
        char map[][] = new char[h][w];
        int a[][] = new int[h][w];
        int INF = Integer.MAX_VALUE;
        for(int[] n: a){
            Arrays.fill(n,INF);
        }
        Queue<Point> queue = new ArrayDeque<>();
        for(int i = 0; i < h; i++){
            map[i] = sc.next().toCharArray();
            for(int j=0; j<w; j++){
                if(map[i][j] == '#'){
                queue.add(new Point(i, j));
                a[i][j] = 0;
                }
            }
        }
        int memo = 0;
        while(!queue.isEmpty()){
            Point p = queue.poll();
            for(int k=0; k<4; k++){
                int X = p.x + dx[k];
                int Y = p.y + dy[k];
                if(X>=0 && X<h && Y>=0 && Y<w && a[X][Y]==INF){
                    a[X][Y] = a[p.x][p.y] + 1;
                    queue.add(new Point(X,Y));
                    memo = a[X][Y];
                }
            }
        }
        System.out.println(memo);
    }

}


Measured memory_bytes: 66360
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair

using namespace std;
const int N=2002, MOD=1e9+7;
int n, k, arr[N], sarr[N], inv=0;
signed main() 
{
	cin >> n >> k;
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	sort(sarr, sarr+n);
	for(int i = 0; i < n; i++)
	{
		int currinv=0;
		for(int j = i+1; j < n; j++)
		{
			if(arr[i]>arr[j]) currinv++;
		}
		inv+=currinv*k;
		inv%=MOD;
		for(int j = 0; j < n; j++)
		{
			if(i!=j && arr[i]>arr[j]) sarr[i]++;
		}
		inv+=sarr[i]*(((k-1)*k/2)%MOD);
		inv%=MOD;
	}
	cout << inv;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n, m, x;
	int a[110] = {};
	scanf("%d %d %d", &n, &m, &x);
	for (int i = 0; i < m; i++) {
		int tmp;
		scanf("%d", &tmp);
		a[tmp] = 1;
	}

	int answer1 = 0, answer2 = 0;
	for (int i = x; i < n; i++) {
		answer1 += a[i];
	}
	for (int i = x; i > 0; i--) {
		answer2 += a[i];
	}
	if (answer1 < answer2) printf("%d\n", answer1);
	else printf("%d\n", answer2);
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
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();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,ans=0LL,mx=0LL;
  cin>>N;
  vector<pair<ll,ll>> LR;
  REP(i,N){
    ll l,r;
    cin>>l>>r;
    LR.PB(MP(l,r));
  }
  
  SORT(LR);
  
  ll Amn[N],Amx[N],Bmn[N],Bmx[N];
  Amn[0]=LR[0].first;
  Amx[0]=LR[0].second;
  for(int i=1; i<N; ++i){
    Amn[i]=max(Amn[i-1],LR[i].first);
    Amx[i]=min(Amx[i-1],LR[i].second);
  }
  Bmn[N-1]=LR[N-1].first;
  Bmx[N-1]=LR[N-1].second;
  for(int i=N-2; i>=0; --i){
    Bmn[i]=max(Bmn[i+1],LR[i].first);
    Bmx[i]=min(Bmx[i+1],LR[i].second);
  }
  
  for(int i=1; i<=N-2; ++i){
    chmax(ans,LR[i].second-LR[i].first+1+max(min(Amx[i-1],Bmx[i+1])-max(Amn[i-1],Bmn[i+1])+1,0LL));
  }
  chmax(ans,LR[0].second-LR[0].first+1+max(Bmx[1]-Bmn[1]+1,0LL));
  chmax(ans,LR[N-1].second-LR[N-1].first+1+max(Amx[N-2]-Amn[N-2]+1,0LL));
  
  for(int i=0; i<=N-2; ++i){
    chmax(ans,Amx[i]-Amn[i]+1+Bmx[i+1]-Bmn[i]+1);
  }
  
  co(ans);
  return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll x; cin >> x;
  cout << 1000LL * (x / 500) + ((x % 500) / 5) * 5 << '\n';
  return 0;
}


Measured memory_bytes: 256
s = gets
a = s.split('').map(&:to_i) 
y = 'Yes'
b = 0
t = []
2.times do |i|
  if a[i] == a[i+1]
    b += 1
    if b == 2
      t << 'Yes'
      break
    end
  end
end
for num in 2..3 do
  if a[num] == a[num+1]
    b += 1
    if b == 3
      t << 'Yes'
      break
    end
  end
end
if t.include?('Yes')
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 3836
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        float count = 0;
        float ave = 0;
        float distance[] = new float[n];
        float min = 101;

        ArrayList<Integer> array = new ArrayList<Integer>();

        for(int i=0;i<n;i++){
            a[i] = sc.nextInt();
            count += a[i];
        }
        ave = count/(float)n;

        for(int i=0;i<n;i++){
            distance[i] = Math.abs(a[i]-ave);
            if(distance[i] <= min){
                min = distance[i];
            }
        }

        for(int i=0;i<n;i++){
            if(distance[i] == min){
                array.add(i);
            }
        }

        int x = Collections.min(array);

        System.out.println(x);
    }
}

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

int main() {
  
  ll n,s_n;
  cin >> n;
  ll t=n,acc=0;

  while(t / 10 != 0) {
    acc += t%10;
    t = t/10;
      }

  acc += t;

  if (n % acc == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}



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

int main() {
  string s, t;

  cin >> s >> t;

  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) != t.at(i)) {
      cout << "No";
      return 0;
    }
  }

  cout << "Yes";

  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9
struct Puzzle {
int f[N2];

int space;
string path;
bool operator < (const Puzzle &p) const{
for (int i=0; i<N2; i++ ){
if(f[i] == p.f[i]) continue;
return f[i] > p.f[i];
}
return false;
}
};
static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char dir[4] = {'u', 'l', 'd', 'r'};
bool isTarget (Puzzle p) {
for (int i = 0; i< N2; i++ )
if(p.f[i] != (i + 1)) return false;
return true;
}
string bfs (Puzzle s) {
queue<Puzzle> Q;
map<Puzzle, bool> V;
Puzzle u, v;
s.path = "";
Q.push(s);
V[s] = true;

while (!Q.empty()){
u = Q. front(); Q.pop();
if (isTarget(u)) return u.path;
int sx = u.space / N;
int sy = u.space % N;
for (int r= 0; r< 4;r++ ){
int tx = sx + dx[r];
int ty = sy + dy[r];
if (tx<0 || ty <0 || tx >= N || ty >= N) continue;

v=u;
swap(v.f[u.space], v.f[tx * N + ty]);
v.space = tx * N + ty;
if (!V[v]){
V[v] = true;
v.path += dir[r];
Q.push(v);


}
}
}


return "unsolvable";
}
int main(){
Puzzle in;
for (int i = 0; i < N2; i++ ){
cin >> in.f[i];
if (in.f[i] == 0){
in.f[i] = N2; // set space
in.space = i;
}
}
string ans = bfs(in);
cout << ans.size() << endl;
return 0;
}


Measured memory_bytes: 30612
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()




using namespace std;





int main(){
  string S; cin>>S;
  if(S == "ABC") cout<<"ARC"<<endl;
  else cout<<"ABC"<<endl;
 



  return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <complex>
#define repi(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) repi(i, 0, n)
#define endl "\n"
#define ing long long
using namespace std;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

#define MAX 255
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    while(true){
        int N, M;
        vector<int> C, x;
        vector<vector<int>> dp;
        int ans = INF;
        
        cin>>N>>M;

        if(!N && !M) break;

        C.resize(M);
        x.resize(N);
        
        dp.resize(N+3, vector<int>(MAX+10, INF));
        
        for(int i = 0; i < M; i++){
            cin>>C[i];
        }

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

        dp[0][128] = 0;
        
        for(int i = 0; i < N; i++){
            for(int j = 0; j <= MAX; j++){
                if(dp[i][j] >= INF) continue;
                for(int k = 0; k < M; k++){
                    int num = j + C[k];

                    
                    if(num >= 0 && num <= MAX){
                        dp[i+1][num] = min(dp[i][j] + (num-x[i])*(num-x[i]),dp[i+1][num]);
                    } else if(num < 0){
                        num = 0;
                        dp[i+1][num] = min(dp[i][j] + (num-x[i])*(num-x[i]),dp[i+1][num]);
                    } else {
                        num = MAX;
                        dp[i+1][num] = min(dp[i][j] + (num-x[i])*(num-x[i]),dp[i+1][num]);
                    }
                }
            }
        }
        for(int i = 0; i <= MAX; i++){
            ans = min(ans, dp[N][i]);
        }

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



Measured memory_bytes: 24336
n,m = map(int,input().split())
light = []
for i in range(m):
  light.append(list(map(int,input().split())))
p = list(map(int,input().split()))
# bit全探索 nで スイッチのパターンを全てためす
# 
ans = 0
for i in range(2**n):
  ng = 0
  for j in range(m):
    ans_j = 0
    for k in range(n):
      if i >> k & 1 and k+1 in light[j][1:]:#電球on かつk[i]の電球がついているなら+=1
        #print(light[j][1:],k)
        ans_j += 1
    #print(ans_j,i,p[j],ng)
    if ans_j % 2 != p[j]:
      ng = 1
  if ng == 0:
    ans += 1
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
int d, dp[10005][2][105];
std::string s;

int dp_solve(int idx, bool lim, int mod) {
	if(idx == (int) s.size()) return (int) mod == 0;
	int &ans = dp[idx][lim][mod];
	if(~ans) return ans;
	ans = 0;
	for(int i = 0; i <= (lim ? 9 : s[idx] - '0'); i++) ans = (ans + dp_solve(idx+1, lim || i < s[idx] - '0', (mod + i) % d)) % 1000000007;
	return ans;
}

int main() {
	std::cin >> s >> d;
	memset(dp, -1, sizeof dp);
	std::cout << (dp_solve(0, 0, 0) - 1 + 1000000007) % 1000000007 << '\n';
	return 0;
}


Measured memory_bytes: 9472
#include <iostream>
using namespace std;
 
int main() 
{
  int n;
  cin >> n;
  int a[3];
  a[0] = n/100;
  n = n-a[0]*100;
  a[1] = n/10;
  a[2] = n-a[1]*10;
  int i;
  for(i = 0;i < 3;i++){
    if(a[i] == 9){
      a[i] = 1;
    }else{
      a[i] = 9;
    }
  }
  n = a[0]*100+a[1]*10+a[2];
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int A, B, C, D, E, K;
	cin >> A >> B >> C >> D >> E >> K;
    if((E-A)<=K){
        cout<<"Yay!"<<endl;
    }
    else {
        cout<<":("<<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, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  cout << max(0, min(b, d) - max(a, c)) << endl;;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fori(i,n) for(int i =0;i<n;i++)
#define pb push_back
#define ll long long
#define int long long
#define F first
#define S second
#define mp make_pair
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout.precision(15);
 
 
int mod = 1e9+7;
 
int pow(int a, int b) {
    int ans = 1;
    a %= mod;
    while(b) {
        if(b%2) {
            ans *= a;
            ans %= mod;
        }
        b /= 2;
        a *= a;
        a %= mod;
    }
    return ans;
}

int inv(int a) {
    return pow(a,mod-2);
}

int mul (int a,int b) {
    return ((a%mod)*(b%mod))% mod;
}

struct cmp {
    bool operator() (pair<int,int> a, pair<int,int> b) const {
        int x = a.F;
        int y = b.F;
        return x>=y;
    }
};


int32_t main() {
    FAST;
    int t;
    // cin>>t;
    t = 1;
    while(t--) {
        string s,a;
        cin>>s>>a;
        int n = s.size();
        int ans = 0;
        fori(i,n) {
            ans += s[i] != a[i];
        }
        cout<<ans;
    }
    
    return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define f first
long long const mod = 1000000007; 
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<pair<ll,ll>, null_type,less<pair<ll,ll> >, rb_tree_tag,tree_order_statistics_node_update> */

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
}

ll power(ll x,ll y,ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
}

ll modInv(ll x)
{
    return power(x,mod-2,mod)%mod;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
	
    ll x;
    cin>>x;
    if(x>=30)
    {
        cout<<"Yes\n";
    }
    else
    cout<<"No\n";
    
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
int main(){
    int c[3][3] , ca[3][3];
    int a[3] , b[3] ;

    for(int i = 0 ; i < 3 ; i++){
        for(int j = 0 ; j < 3 ; j++){
            cin >> c[i][j] ;
        }
    }
    
    a[0] = 0 ;
    b[0] = c[0][0] - a[0] ;
    b[1] = c[0][1] - a[0] ;
    b[2] = c[0][2] - a[0] ; 
    a[1] = c[1][0] - b[0] ;
    a[2] = c[2][0] - b[0] ;
    
    bool flag = true ;
    for(int i = 0 ; i < 3 ; i++){
        for(int j = 0 ; j < 3 ; j++){
            if(c[i][j]!=a[i] + b[j]){
                flag = false ;
            }
        }
    }

    if(flag == true){
        cout <<"Yes"<< endl;
    }else{
        cout << "No"<< endl;
    }

    return 0 ;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = input()

num_win = 0
num_win_f = 0
num_next = A + B
for s in S:
  if s == "a" and num_win < num_next:
    print("Yes")
    num_win += 1
  elif s == "b" and num_win < num_next and num_win_f < B:
    print("Yes")
    num_win += 1
    num_win_f += 1
  else:
    print("No")

Measured memory_bytes: 9236
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  int n;
  while (true) {
    cin >> n;
    if (n == 0)
      break;
    int a = 0, b = 0, s, t;
    for (int i = 0; i < n; i++) {
      cin >> s >> t;
      if (s > t) {
        a += s + t;
      } else if (s < t) {
        b += s + t;
      } else {
        a += s;
        b += t;
      }
    }
    cout << a << ' ' << b << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<map>
#include<utility>
using namespace std;
int main(){
  int n,m;
  char x,y;
  while(true){
    map<char,char> ma;
    cin >> n;
    if(n == 0)
      break;
    for(int i = 0 ; i < n ; i++){
      cin >> x;
      cin >> y;
      ma[x] = y;
    }
    cin >> m;
    char str[m];
    for(int i = 0 ; i < m ; i++){
      cin >> str[i];
      if(ma.find(str[i]) != ma.end())
        str[i] = ma[str[i]];
    }
    for(int i = 0 ; i < m ; i++)
      cout << str[i];
    cout << endl;
  }
}





Measured memory_bytes: 3100
/*  chuckie   */
#include <bits/stdc++.h>
//#define CHUCKIE

 
#define cint(d) scanf("%d", &d)
#define cint2(a, b) scanf("%d %d", &a, &b)
#define cint3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define cint4(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
 
#define clong(d) scanf("%lld", &d)
#define clong2(a, b) scanf("%lld %lld", &a, &b)
#define clong3(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define clong4(a, b, c, d) scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
 
const long long MOD = 1000000007;
#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODR(d) ((d)>=MOD?(d)%MOD:(d))
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define MODADDSET(d) if ((d) >= MOD) d -= MOD;
#define MODADDWHILESET(d) while ((d) >= MOD) d -= MOD;
 
#define foreach(it,c) for(__typeof((c).begin()) it = (c).begin(); it!=(c).end(); it++) 
#define MAX 1000000
#define ll long long
#define mp make_pair
#define pb push_back
 
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;


int main()
{
	
	#ifdef CHUCKIE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n,t,curr,ans=0;
	cin>>n>>t;
	
	ll prev=0;
	
	cin>>prev;
	
	for(int i=1;i<n;i++)
	{
		cin>>curr;
		if(curr-prev >=t)
		{
			ans+=t;
		}
		
		else
		{
			ans+=curr-prev;
		}
		
		prev=curr;
		
	}
	
	cout<<ans+t;
	
	
	return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

ans = 0
hk = 0
for i in range(n):
    if hk == h[i]:
        continue
    elif hk < h[i]:
        while hk < h[i]:
            hk += 1
            ans += 1
    elif hk > h[i]:
        while hk > h[i]:
            hk -= 1
print(ans)

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
totalA = sum(A)
for i in range(len(A)-1):
  if B[i] >= A[i]:
    B[i] += -A[i]
    A[i] = 0
    if A[i+1] >= B[i]:
      A[i+1] += -B[i]
      B[i] = 0
    else:
      B[i] += -A[i+1]
      A[i+1] = 0
  else:
    A[i] += -B[i]
    B[i] = 0
print(totalA - sum(A))
    
  

Measured memory_bytes: 19004
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

int N,X,Y;
int A[200010];
int ans[200010];
signed main(){
    scanf("%lld %lld %lld",&N,&X,&Y);X--;Y--;
    rep(i,N){
        for(int j=i+1;j<N;j++){
            //X-Yを使わない最短距離
            int k1=j-i;
            //X-Yを使う最短距離
            int k2=abs(i-X)+abs(j-Y)+1;
            ans[min(k1,k2)]++;
        }
    }
    for(int i=1;i<N;i++){
        printf("%lld\n",ans[i]);
    }
    return 0;
}


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

int main() {
  int n,k;
  cin >> n >> k;

  int cnt = 0;
  rep(i,n) {
    int x;
    cin >> x;
    if (k <= x) cnt++;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 3648
#include "iostream"
#include "vector"
#include "string"
#include <iomanip>
#include <algorithm>

//const double PI = 3.14159265358979323846;

using namespace std;

int vector_finder(std::vector<int> vec, int number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

int main() {
	int X,N;
	int SubP = 0;
	int MinP = 0;
	int MinSubP = 10000;
	vector<int> V, P;
	cin >> X >> N;

	for (int i = 0; i < N; i++) {
		int temp;
		cin >> temp;
		P.push_back(temp);
	}

	for (int i = -1; i < 101; i++) {
		bool exists = vector_finder(P,i+1);
		
		if (!exists) {
			V.push_back(i + 1);
		}
	}

		
	for (int i = 0; i < V.size(); i++) {

		SubP = abs(V[i] - X);

		if (SubP < MinSubP) {
			MinP = V[i];
			MinSubP = SubP;
		}

	}

	cout << MinP << endl;

	return 0;

}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = 0;
        for(int i = 1; i <= n; i++){
            int x = i;
            int sum = 0;
            while(x > 0){
                sum += x % 10;
                x /= 10;
            }
            if(a <= sum && sum <= b){
                ans += i;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <set>

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

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

using namespace std;

int main(){
  int n = getInt();
  int m = getInt();
  int ans = 0;

  REP(i,n){
    int tmp = 0;
    REP(j,m) tmp += getInt();
    ans = max(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
#define endl "\n"
//#define int long long
#define ALL(x) begin(x),end(x)
#define resort(v) sort((v).rbegin(), (v).rend())
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
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;
}
int fact(int i) {
    if (i == 0) return 1;
    return ((fact(i - 1)) * i) % MOD;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
int modpow(int a, int n, int mod) {
    int hi = 1;
    while (n > 0) {
        if (n & 1) hi = hi * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return hi;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
/*signed*/int main(void) {
    string s;
    cin >> s;
    string t = "";
    rep(i, s.size()) {
        if (s[i] == '0') {
            t += '0';
        }
        else if (s[i] == '1') {
            t += '1';
        }
        else {
            if (!t.empty()) {
                t.erase(t.size()-1);
            }
        }
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3600
tailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)

fun main(args: Array<String>) {
    val (a,b,c,d) = readLine()!!.split(" ").map { it.toLong() }
    val bc = b/c
    val bd = b/d
    val ac = (a-1)/c
    val ad = (a-1)/d
    val bcd = b/( c/gcd(c,d)*d )
    val acd = (a-1)/( c/gcd(c,d)*d )
    println(b-(a-1) -(bc-ac) -(bd-ad) +(bcd-acd))
}

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

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

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

  bool allzero = true;
  rep(i, n) if (a[i] != 0) allzero = false;
  if (allzero) {
    cout << "Yes" << endl;
    return 0;
  }

  if (n%3 != 0) {
    cout << "No" << endl;
    return 0;
  }

  map<ll, ll> mp;
  rep(i, n) mp[a[i]]++;
  if (mp.find(0) != mp.end()) {
    if ((int)(mp.size()) > 2) {
      cout << "No" << endl;
      return 0;
    }
    bool flg = true;
    for (auto v:mp) {
      if (v.first == 0 && v.second != n/3) flg = false;
      if (v.first != 0 && v.second != 2*n/3) flg = false;
    }
    if (flg) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
  }

  if ((int)(mp.size()) != 3) {
    cout << "No" << endl;
    return 0;
  }
  vector<ll> d;
  for (auto v:mp) {
    d.push_back(v.first);
    if (v.second != n/3) {
      cout << "No" << endl;
      return 0;
    }
  }
  if ((d[0]^(d[1]^d[2])) == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 8648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", _dmp_(#__VA_ARGS__, __VA_ARGS__);
void _dmp_(const char*) { cerr << endl; }
template <class T, class... U>
void _dmp_(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; _dmp_(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, greater<T> >;
#define CONAINER_OUTPUT os << "{"; for (auto const& x : v) os << " " << x; return os << " }";
template <class T> ostream& operator<<(ostream& os, vector<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, deque<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, set<T> const& v) { CONAINER_OUTPUT }
template <class T, class U> ostream& operator<<(ostream& os, map<T,U> const& v) { CONAINER_OUTPUT }
#undef CONAINER_OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S> const& p) { return is >> p.first >> p.second; }
struct _Init_ { _Init_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } _init_;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
#define YesNo(c) ((c) ? "Yes" : "No")
////////////////////////////////
int mod(int x, int m) { return (x%=m) < 0 ? x+m : x; }

int32_t main() {
    string s,t; cin >> s >> t;
    int n = s.size();
    s += s;
    vector<int> a[26];
    rep (x,26) a[x].resize(n*2);
    rep (x,26) rep (i,2*n) a[x][i] = -1;
    
    repR (i,n*2-1) {
        rep (x,26) a[x][i] = a[x][i+1];
        a[s[i+1]-'a'][i] = i+1;
    }
    rep (i,n*2) rep (x,26) if (a[x][i] != -1) a[x][i] -= i;

    int idx = -1;
    for (char c : t) {
        int y = a[c-'a'][mod(idx,n)];
        if (y == -1) quit(-1);
        idx += y;
    }
    cout << idx+1 << endl;
}


Measured memory_bytes: 41324
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

char c[100005];
int a[100005],ans=0,s=0,b[100005];

int main(void){
	scanf("%s",c);
	int l=strlen(c);
	for(int i=0;i<l;i++)
	a[i+1]=c[i]-'0';
	for(int i=1;i<=l;i++)
	if(i%2==0)b[i]=1;
	else b[i]=0;
	for(int i=1;i<=l;i++)
	if(a[i]!=b[i])s++;
	ans=s;
	s=0;
	for(int i=1;i<=l;i++)
	if(i%2==0)b[i]=0;
	else b[i]=1;
	for(int i=1;i<=l;i++)
	if(a[i]!=b[i])s++;
	ans=min(ans,s);
	printf("%d",ans);
}

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

#define int ll

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 998244353
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N;
  cin>>N;
  vector<int>A(N),B(N);
  for(int i=0;i<N;i++)cin>>A[i]>>B[i];
  sort(rng(A));
  sort(rng(B));
  if(N%2)cout<<B[N/2]-A[N/2]+1<<endl;
  else cout<<(B[N/2-1]+B[N/2])-(A[N/2-1]+A[N/2])+1<<endl;

  return 0;
}


Measured memory_bytes: 6264
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let m: usize = read();

    let mut count = vec![0; m];

    for _ in 0..n {
        let k: usize = read();
        for _ in 0..k {
            let a: usize = read();
            count[a - 1] += 1;
        }
    }
    println!("{}", count.iter().filter(|&&x| x == n).count());
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll W, H, x, y;
    cin >> W >> H >> x >> y;
    int m = ( x * 2 == W && y * 2 == H ) ? 1 : 0;
    double s = (double)W * H / 2;
    cout.precision(15);
    cout << s << " " << m << '\n';
    return 0;
}

Measured memory_bytes: 256