akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	string s;
	cin >> s;
	string t = "";
	rep(i,s.size()) if (s[i] != 'x') t = t + s[i];
	int tn = t.size() - 1;
	rep(i,t.size() / 2) {
		if (t[i] != t[tn - i]) {
			cout << -1 << endl;
			return;
		}
	}
	// if (t == "") {
	// 	cout << 0 << endl;
	// 	return;
	// }
	int l = 0;
	int r = s.size() - 1;
	int ans = 0;
	for (int i = 0; i < (t.size() + 1) / 2; i++) {
		while (s[l] == 'x' && s[r] == 'x') l++, r--;
		while (s[l] == 'x') {
			ans++;
			l++;
		}
		while (s[r] == 'x') {
			ans++;
			r--;
		}
		l++, r--;
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 3972
import heapq
import sys

input = sys.stdin.readline
INF = 10**18

n,m,s,t = map(int,input().split())
edge = [list(map(int,input().split())) for _ in range(m)]

graph_s = [[] for _ in range(n)]
graph_t = [[] for _ in range(n)]

for e in edge:
    graph_s[e[0]-1].append([e[1]-1,e[2]])
    graph_s[e[1]-1].append([e[0]-1,e[2]])
    graph_t[e[0]-1].append([e[1]-1,e[3]])
    graph_t[e[1]-1].append([e[0]-1,e[3]])

dist_s = [INF]*n
dist_t = [INF]*n

dist_s[s-1] = 0
dist_t[t-1] = 0

heap_s = [[0,s-1]]
heapq.heapify(heap_s)

heap_t = [[0,t-1]]
heapq.heapify(heap_t)

while heap_s:
    cost,node = heapq.heappop(heap_s)
    if dist_s[node] < cost:
        continue
    for adj,adjcost in graph_s[node]:
        if dist_s[node] + adjcost < dist_s[adj]:
            dist_s[adj] = dist_s[node] + adjcost
            heapq.heappush(heap_s,[dist_s[adj],adj])

while heap_t:
    cost,node = heapq.heappop(heap_t)
    if dist_t[node] < cost:
        continue
    for adj,adjcost in graph_t[node]:
        if dist_t[node] + adjcost < dist_t[adj]:
            dist_t[adj] = dist_t[node] + adjcost
            heapq.heappush(heap_t,[dist_t[adj],adj])

dist = INF
ans = []
                                              
for i in range(n):
    dist = min(dist,dist_t[-1-i]+dist_s[-1-i])
    ans.append(10**15-dist)
    
for i in range(n):
    print(ans[-1-i])

Measured memory_bytes: 126556
#include<stdio.h>
#include<algorithm>
using namespace std;

struct intv {
	int s, e;
	bool operator< (const intv& c) const {
		return s<c.s;
	}
} ba[101010];

int R, C, N, cnt, stk[101010], scn;

int val(int x, int y){
	if(y==0) return x;
	if(x==R) return y+R;
	if(y==C) return R+C+(R-x);
	if(x==0) return R+C+R+(C-y);
	return -1;
}

int main(){
	scanf("%d%d%d", &R, &C, &N);
	for(int i=0; i<N; i++){
		int x1, y1, x2, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		x1=val(x1,y1), x2=val(x2,y2);
		if(x1<0 || x2<0) continue;
		if(x1>x2)swap(x1,x2);
		ba[cnt].s = x1, ba[cnt].e = x2;
		cnt++;
	}
	sort(ba, ba+cnt);
	for(int i=0; i<N; i++){
		while(scn){
			if(stk[scn-1] > ba[i].e) break;
			if(stk[scn-1] > ba[i].s){ puts("NO"); return 0; }
			scn--;
		}
		stk[scn++] = ba[i].e;
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
// main
int main(){
    int N; cin >> N;
    for(int i = 0; i <= (N / 4); ++i){
        if( (N - 4 * i) % 7 == 0 ){
            cout << "Yes" << "\n";
            return 0;
        }
    }
    cout << "No" << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 998244353

const int N = 300;
int n, m;
int A[N + 7][N + 7];

ll power(ll a, int k){
	ll ans = 1;
	while(k > 0){
		if(k&1)
			ans = ans * a % MOD;
		a = a * a % MOD;
		k >>= 1;
	}
	return ans;
}

int main(){
	cin >> n >> m;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			cin >> A[i][j];

	int myi = 0;
	for(int j = 0; j < m && myi < n; j++){
		for(int i = myi; i < n; i++)
			if(A[i][j]){
				swap(A[i], A[myi]);
				break;
			}
		if(!A[myi][j])
			continue;
		for(int i = myi; i < n; i++)
			for(int jj = j; jj < m; jj++)
				A[i][jj] = A[i][jj] ^ (A[myi][jj] * A[i][j]);
		myi++; 
	}

	ll ans = power(2, n + m - 1);
	ll ans2 = power(2, n + m - 1 - myi);
	ans -= ans2;
	if(ans < 0)
		ans += MOD;
	cout << ans << "\n";
}

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

int main(){
  int N,M,C,count=0;
  cin >>N>>M>>C;
  
  vector<int> B(M);
  
  for (int i=0;i<M;i++){
    cin >>B.at(i);
  }
  for (int i=0;i<N;i++){
    vector<int> Ai(M);
    int sum=0;
    for (int j=0;j<M;j++){
      cin >> Ai.at(j);
      sum+=Ai.at(j)*B.at(j);
    }
    if (sum+C>0){
      count++;
    }
  }
  cout << count <<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

// union find
class UnionFind {
  public:
    vector<ll> par; // 各元の親を表す配列
    vector<ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1) {
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1);
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y])
            swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

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

    int N, M, K;
    cin >> N >> M >> K;
    vector<int> ans(N, -1);
    UnionFind tree(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        tree.merge(a, b);
        ans[a] -= 1;
        ans[b] -= 1;
    }

    rep(i, K) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        if (tree.issame(a, b))
            ans[a] -= 1, ans[b] -= 1;
    }

    rep(i, N) { cout << tree.size(i) + ans[i] << " "; }
}

Measured memory_bytes: 5336
<?php
fscanf(STDIN, "%d", $n);
$num = 0;
if($n >= 10){
	$num += 9;
}else{
	$num += $n;
}
 
if($n >= 1000){
	$num += 900;
}elseif($n >= 100){
  	$num = $num + $n - 99;
}else{
	;
}
 
if($n === 100000){
	$num += 90000;
}elseif($n >= 10000){
  	$num = $num + $n - 9999;
}else{
	;
}
 
echo $num . "\n";
?>

Measured memory_bytes: 3956
n,m=map(int,input().split())
s=[]
for _ in range(m):
    _,*t=map(int,input().split())
    s.append(t)
p=list(map(int,input().split()))
a=0
for i in range(2**n):
    f=1
    for j in range(m):
        g=1
        g&=(sum([int(bin(i>>(u-1)),2) for u in s[j]])%2==p[j])
        f&=g
    a+=f
print(a)

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

int N, K;
int R, S, P;
string T;


int main() {
    cin >> N >> K;
    cin >> R >> S >> P >> T;

    long long ans = 0;
    // cout << l_r << endl;
    map<long long, char> record;
    for (long long i = 0; i < T.size(); i++) {
        if (T[i] == 'r' && record[i - K] != 'p') {
        // p パー で勝つ
            // l_p = i;
            record[i] = 'p';
            ans += P;
        } else if (T[i] == 'p' && record[i - K] != 's') {
        // s チョキ で win
            // l_s = i;
            record[i] = 's';
            ans += S;
        } else if (T[i] == 's' && record[i - K] != 'r') {
            // r グー で win
            // l_r = i;
            record[i] = 'r';
            ans += R;
        } 
    }

    cout << ans << endl;
}

Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N = 0;
  int K = 0;
  cin >> N >> K;
  int A[N]={};
  int Okashi[K]={};
  int tmp = 0;
  int result = 0;
  
  for(int icounts = 0; icounts < K; icounts++){
    cin >> Okashi[icounts];
    for(int iA = 0; iA < Okashi[icounts]; iA++){
      cin >> tmp;
      A[tmp-1] = 1;
      tmp = 0;
    }
  }
  for(int icounts = 0; icounts < N; icounts++){
    if(A[icounts]==0) result++;
  }
  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int u[99],w[99],fl[99],n;
bool rec(int c,int s,int from){
	int prev=-1,f;
	if(c==0){
		for(s=0;s<n&&u[s];s++);
		if(s==n)return 1;
		for(int i=from+1;i<n;i++)if(fl[i]&&w[i]!=prev){
			fl[i]=0; prev=w[i]; f=rec(prev,i+1,i);
			fl[i]=1;
			if(f)return 1;
		}
	}else{
		for(int i=s;i<n;i++)if(!u[i]&&w[i]!=prev&&w[i]<=c){
			u[i]=fl[i]=1; f=rec(c-w[i],i+1,from);
			u[i]=fl[i]=0; prev=w[i];
			if(f)return 1;
		}
	}
	return 0;
}
int main(){
	while(cin>>n,n){
		rep(i,n)cin>>w[i],u[i]=fl[i]=0;
		sort(w,w+n,greater<int>());
		u[0]=1;
		cout<<(n==1||rec(w[0],1,0)?"YES":"NO")<<endl;
	}
	return 0;
}

Measured memory_bytes: 852
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;

typedef pair<ll, ll> P;

const int MOD = 1000000007;
const ll INF = 1LL << 60;


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

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int main(int argc, char**argv){
    int a, b, c;
    cin >> a >> b >> c;

    cout << min(b/a, c) << endl;

    return 0;
}

















Measured memory_bytes: 256
n = int(input())
ab = []
for i in range(n):
    ab.append(list(map(int, input().split())))


ab = sorted(ab, key=lambda x:x[0])
ab = sorted(ab, key=lambda x:x[1])

def solve():
    time = 0
    for task in ab:
        if task[1] < task[0]+time:
            return False
        time = task[0]+time
    return True

res = solve()
if res:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 55248
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
  long long x = 1;
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  ll n,k;
  std::cin>>n>>k;

  ll ans=1,temp=1;

  while(temp*k<=n){
    ans++;
    temp*=k;
  }

  std::cout<<ans<<"\n";

  return 0;
}


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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

bool solve(int N)
{
    for (int d = 1; d <= 9; ++d)
    {
        if (N % d == 0 and N / d < 10)
            return true;
    }
 
    return false;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    
    cout << (solve(N) ? "Yes": "No") << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */

public class Main {
    public static void main(String[] args) {
        InputStream    inputStream    = System.in;
        OutputStream outputStream = System.out;
        InputReader    in                      = new InputReader(inputStream);
        PrintWriter      out                    = new PrintWriter(outputStream);
        Task                 solver               = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
    	public void solve(int testNumber, InputReader in, PrintWriter out) {
    		int AB = in.nextInt();
    		int BC = in.nextInt();
    		int CA = in.nextInt();
    		out.println(AB * BC / 2);
    		
    	}
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23380
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <cmath>
#include <algorithm>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    
    
    /////////
    //write//
    /////////
    
    while(1){
        int x, y, s; cin >> x >> y >> s;
        if(x==0 && y==0 && s==0)break;
        int ori = s;
        int ma = 0;
        
        for(int i=1; i<ori+1; i++){
            for(int j=1; j<ori+1; j++){
                int a = i*(100+x)/100;
                int b = j*(100+x)/100;
                
                if(a+b==ori){
                    int tmp = i*(100+y)/100 + j*(100+y)/100;
                    ma = max(tmp,ma);
                }
            }
        }
        
        cout << ma << endl;
    }
    return 0;
}



Measured memory_bytes: 3020
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
if x > sum(a):
        print(n-1)
else:
        for _a in a:
                x -= _a
                if x < 0:
                        print(ans)
                        exit()
                else:
                        ans += 1
        print(ans)

Measured memory_bytes: 38448
N, x = map(int, input().split())
a = [int(x) for x in input().split()]
ans = 0
for i in range(N-1):
    eat = max(0, a[i] + a[i+1] - x)
    ans += eat
    eat1 = min(a[i+1], eat)
    eat2 = eat - eat1
    a[i+1] -= eat1
    a[i] -= eat2
print(ans)

Measured memory_bytes: 14152
#!/usr/bin/env python3
# -*- coding: utf-8-*-
if __name__ == '__main__':
    N = int(input())
    a = list(map(int, input().split()))
    sum = 0
    for i in range(N):
        if i == a[a[i]-1]-1:
            sum += 1
    sum = sum // 2
    print(sum)


Measured memory_bytes: 14008
def main(input_str):
    input_list = list(input_str)
    count = 0
    if input_list[0] == "0":
        ans = []
        for i, _ in enumerate(input_list):
            if i % 2 == 0:
                ans.append("0")
            else:
                ans.append("1")
        for i, _ in enumerate(input_list):
            if input_list[i] != ans[i]:
                count += 1

    else:
        ans = []
        for i, _ in enumerate(input_list):
            if i % 2 == 0:
                ans.append("1")
            else:
                ans.append("0")
        for i, _ in enumerate(input_list):
            if input_list[i] != ans[i]:
                count += 1

    return count


if __name__ == "__main__":
    input_str = input()
    print(main(input_str))


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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp std::make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

#define fcout(n) std::cout << std::fixed << std::setprecision((n))

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::pair<int,int> PII;

typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::vector<PII> VPII;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

int N, K;
VI A;
int main() {
    std::cin >> N >> K;
    A.resize(N);

    int idx_1 = -1;
    REP(i, N) {
        std::cin >> A[i];
        if(A[i] == 1) {
            idx_1 = i;
        }
    }

    int cnt = 0;
    int i = idx_1;
    while(i > 0) {
        ++cnt;
        i -= K - 1;
    }
    i = idx_1 + std::abs(i);
    while(i < N-1) {
        ++cnt;
        i += K - 1;
    }
    std::cout << cnt << std::endl;
}


Measured memory_bytes: 640
letters = input()
q = int(input())
for _ in range(q):
    words = input().split()
    command = words[0]
    a, b = map(int, words[1:3])

    if command == 'replace':
        letters = ''.join([letters[:a], words[3], letters[b+1:]])
    elif command == 'reverse':
        letters = ''.join([letters[:a ], letters[a:b+1][::-1], letters[b+1:]])
    elif command == 'print':
        print(letters[a:b+1])
        


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

using namespace std;

const int mod = 1e9 + 7;
int dp[1002][1002], n, m;
char v[1002][1002];

int main()
{
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      cin >> v[i][j];
  dp[1][0] = dp[0][1] = 1;
  for (int i = 1; i <= m; i++)
    if (v[1][i] == '.')
    dp[1][i] = dp[1][i - 1];
  for (int i = 1; i <= n ; i++)
    if (v[i][1] == '.')
    dp[i][1] = dp[i - 1][1];
  for (int i = 2; i <= n; i++)
    for (int j = 2; j <= m; j++) {
      if (v[i][j] == '.')
        dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
    }
  cout << dp[n][m];
  return 0;
}


Measured memory_bytes: 5120
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main {
	public static void main(String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		try {
			String buf = null;
			int score[] = new int[2];
			int n;
			while (!(buf = br.readLine()).equals("0")) {
				n = Integer.parseInt(buf);
				score[0] = score[1] = 0;
				for (int i=0;i<n;i++) {
					StringTokenizer st = new StringTokenizer(br.readLine(), " ");
					int a_score = Integer.parseInt(st.nextToken());
					int b_score = Integer.parseInt(st.nextToken());
					if (a_score>b_score) {
						score[0] += (a_score+b_score);
					} else if (a_score<b_score) {
						score[1] += (a_score+b_score);
					} else {
						score[0] += a_score;
						score[1] += b_score;
					}
				}
				System.out.println(score[0]+" "+score[1]);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 32684
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<string>
using namespace std;


int main(){
    int  n;
    cin >> n;
    int v[n],c[n];
    int ans = 0;
    for(int i = 0;i < n;i++){
        cin >> v[i];
    }
    for(int i = 0;i < n;i++){
        cin >> c[i];
    }
    for(int i = 0;i < n;i++){

        int tmp = v[i]-c[i];
        if(tmp > 0) ans += tmp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
# B
import copy
S = list(input())
N = len(S)
S1 = copy.copy(S)
S2 = S[:(N-1)//2]
S3 = S[(N+3)//2-1:]

reverse_S1 = list(reversed(S1))
reverse_S2 = list(reversed(S2))
reverse_S3 = list(reversed(S3))

ans = 'No'

if (S1 == reverse_S1 and S2 == reverse_S2 and S3 == reverse_S3):
    ans = 'Yes'
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    int ac = 0;
    int bc = 0;
    int cc = 0;

    char player = 'a';
    string winner = "";

    while(1){
        if(ac > a.size()) winner = "A";
        if(bc > b.size()) winner = "B";
        if(cc > c.size()) winner = "C";

        if(winner != "") break;

        if(player == 'a'){
            player = a[ac];
            ac++;
            continue;
        }
        if(player == 'b'){
            player = b[bc];
            bc++;
            continue;
        }
        if(player == 'c'){
            player = c[cc];
            cc++;
            continue;
        }

    }

    cout << winner << endl;
}
    


Measured memory_bytes: 256
#include<stdio.h>
#define NUM 1000000007
typedef long long ll;
ll sum(ll begin,ll end){
    return (begin + end) * (end - begin + 1)/2;
}
int main(){
    ll N,K;
    scanf("%lld %lld",&N,&K);
    ll ans = 0;
    for(ll i=K;i<=N+1;i++){
        ans += sum(N-(i-1),N) - sum(0,i-1) + 1;
        ans %= NUM;
    }
    printf("%lld",ans);
}


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

int main() {
    int n;
    cin >> n;
    int m = n/2;

    int v[n];
    rep(i, n) {
        cin >> v[i];
    }

    int o[m], e[m];     //v[n]の奇数番目(1-index)の項がo[m],偶数番目(1-index)の項がe[m]
    rep(i, m) {
        o[i] = v[2*i];
        e[i] = v[2*i+1];
    }
    sort(o, o+m);
    sort(e, e+m);

    int t1 = o[0];
    int k1 = 0;
    vector<int> co(m);
    rep(i, m) {
        if(t1 < o[i]) {
            t1 = o[i];
            k1++;
            co[k1]++;
        } 
        else {
            co[k1]++;
        }
    }

    int t2 = e[0];
    int k2 = 0;
    vector<int> ce(m);
    rep(i, m) {
        if(t2 < e[i]) {
            t2 = e[i];
            k2++;
            ce[k2]++;
        } 
        else {
            ce[k2]++;
        }
    }

    sort(co.begin(), co.end());
    reverse(co.begin(), co.end());
    sort(ce.begin(), ce.end());
    reverse(ce.begin(), ce.end());

    int a1 = o[0];  //a1にはoの最頻値(oにco[0]個ある数)が入る
    int b1 = 0;
    rep(i, m) {
        if(a1 < o[i]) {
            if(b1 == co[0]) {
                break;
            }
            a1 = o[i];
            b1 = 0;
        }
        b1++;
    }

    int a2 = e[0];  //a2にはeの最頻値(eにce[0]個ある数)が入る
    int b2 = 0;
    rep(i, m) {
        if(a2 < e[i]) {
            if(b2 == ce[0]) {
                break;
            }
            a2 = e[i];
            b2 = 0;
        }
        b2++;
    }

    int ans;
    if(a1 != a2) {  //最頻値が異なる数の場合
        ans = n - (co[0] + ce[0]);
    }
    else {  //最頻値が同じ数の場合
        int u = co[0] + ce[1];
        int v = co[1] + ce[0];
        ans = n - max(u, v);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <climits>
#include <algorithm>
using namespace std;

int main()
{
	int N, K, x[100000], i, j, dis, min_dis = INT_MAX;
	scanf("%d %d", &N, &K);
	for (i = 0; i < N; i++)
		scanf("%d", x+i);

	for (i = 0; x[i] < 0 && i < N; i++);
	const int pmin = i;
	const int right = min(N-K, pmin);
	const int left = max(pmin-K, 0);

	for (i = left; i <= right; i++)
	{
		if (i+K-1 < pmin)
			dis = -x[i];
		else if (i >= pmin)
			dis = x[i+K-1];
		else
			dis = -x[i] + x[i+K-1] + min(-x[i], x[i+K-1]);

		min_dis = min(dis, min_dis);
	}

	printf("%d\n", min_dis);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int h, w; cin >> h >> w;
	vector<vi> d(h, vi(w));
	rep(it, 2) rep(i, h) rep(j, w){
		d[i][j] *= -1;
		int x; cin >> x;
		d[i][j] += x;
	}
	
	const int MX = 26000;
	const int GETA = MX / 2;
	vector<vector<bitset<MX>>> dp(h, vector<bitset<MX>>(w));
	dp[0][0][d[0][0] + GETA] = 1;
	dp[0][0][-d[0][0] + GETA] = 1;
	
	rep(i, h) rep(j, w) rep(k, MX) if(dp[i][j][k]) for(int s = -1; s < 2; s += 2){
		if(i + 1 < h) dp[i + 1][j][k + s * d[i + 1][j]] = 1;
		if(j + 1 < w) dp[i][j + 1][k + s * d[i][j + 1]] = 1;
	}
	int ans = inf;
	rep(i, MX) if(dp[h - 1][w - 1][i]) ans = min(ans, abs(i - GETA));
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 20992
#include <stdio.h>

int main(void){
    int m, d, d1_max, d10_max, d1, d10, cnt = 0;
    
    scanf("%d %d", &m, &d);
    
    d1_max = d % 10;
    d10_max = d / 10;
    
    for (d10 = 2; d10 < d10_max; d10++)
    {
        for (d1 = 2; d1 < 10; d1++)
        {
            if (d1 * d10 <= m)
            {
                cnt++;
            }
            else
            {
                break;
            }
        }
    }
    
    if (d10_max >= 2)
    {
        for (d1 = 2; d1 <= d1_max; d1++)
        {
            if (d1 * d10_max <= m)
            {
                cnt++;
            }
            else
            {
                break;
            }
        }
    }
    
    printf("%d\n", cnt);
    
    return 0;
}


Measured memory_bytes: 128
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

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();}

int main(){
    std::ios::sync_with_stdio(false);

    int n, k, ret;
    cin >> n >> k;

    if ((n%2) == 1)
    {
        ret = n / 2 + 1;
    }
    else
    {
        ret = n / 2;
    }
    
    if (ret >= k)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    
}

Measured memory_bytes: 256
<?php
  fscanf(STDIN, "%s", $input);
  $result = "";
 
 if($input=="Sunny"){
     $result = "Cloudy";
 }else if($input=="Cloudy"){
     $result = "Rainy";
 }else if($input =="Rainy"){
     $result ="Sunny";
 }
  
 echo $result;
  
  
 ?>

Measured memory_bytes: 3700
<?php
// Your code here!
$n = trim(fgets(STDIN));
$line = explode(" ",(trim(fgets(STDIN))));

$sum = 1;
if(in_array("0", $line)){
    echo "0";
    return 0;
}

foreach($line as $v){
    $sum *= $v;
    if($sum > 10**18){
        echo "-1";
        return 0;
    }
}

echo $sum;

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

using namespace std;

const int N = 200000;
int a[N];
int n;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  int xr = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    xr ^= x;
  }
  if (xr == 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3 1");
            //Yes
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("1 2");
            //No
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("2 2");
            //No
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();

        int A = wkArr[0];
        int B = wkArr[1];
        for (int I = 1; I <= 3; I++) {
            int Prod = A * B * I;
            if (Prod % 2 == 1) {
                Console.WriteLine("Yes");
                return;
            }
        }
        Console.WriteLine("No");
    }
}


Measured memory_bytes: 13268
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = sorted(A)
B = sorted(B)
C = sorted(C)

# for this we will use binary search.
import bisect as bis

BSC = [0]*N
ASB = [0]*N

for i in range (0, N):
	BSC[i] = N-bis.bisect_right(C, B[i])

for i in range (0, N):
	ASB[i] = bis.bisect_right(B, A[i])
    
for i in range (1, N):
	BSC[N-1-i] += BSC[N-i]

count = 0
for i in range (0, N):
	if ASB[i] ==N:
		continue
	else:
		count+=BSC[ASB[i]]

print(count)

Measured memory_bytes: 30988
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
#include<tuple>
#include<iomanip>
#include<stack>
#include<cmath>
#define ll long long
using namespace std;
typedef struct{
	int x, y;
}Coor;
int main() {
	int n, m;
	while (cin >> n && n) {
		bool map[21][21] = {}, tre[21][21] = {};
		map[10][10] = 1;
		int l;
		char dir[] = "NESW", d;
		Coor data, cur = { 10,10 }, move[4] = { {0,1},{1,0},{0,-1},{-1,0} };
		for (int i = 0; i < n; ++i) {
			cin >> data.x >> data.y;
			tre[data.y][data.x] = true;
		}
		cin >> m;
		for (int i = 0; i < m; ++i) {
			int k = 0;
			cin >> d >> l;
			for (k = 0; k < 4; ++k) if (dir[k] == d) break;
			for (int j = 1; j <= l; ++j) {
				cur.x += move[k].x; cur.y += move[k].y;
				map[cur.y][cur.x] = true;
			}
		}
		int cnt = 0;
		for (int i = 0; i <= 20; ++i)
			for (int j = 0; j <= 20; ++j)
				if (map[i][j] && tre[i][j]) ++cnt;
		cout << (cnt == n ? "Yes" : "No") << endl;
	}
	return 0;
}


Measured memory_bytes: 3016
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){
		// 標準入力をするための準備
		Scanner stdin = new Scanner(System.in);
		
		// A枚のクッキーが入った缶
		int A;
		// B枚のクッキーが入った缶
		int B;
		
		// ヤギの数
		int yagi = 3;
		
		// クッキー缶Aにクッキーを入れる
		A = stdin.nextInt();
		
		// クッキー缶Bにクッキーを入れる
		B = stdin.nextInt();
		
		
		
		String outputStr = "Impossible";
		
		/**
		 * クッキー缶A,Bのクッキーをyagiの数で
		 * 割り切れるかどうかの判定
		 */
		if (A % yagi == 0 || B % yagi == 0) {
			outputStr = "Possible";
		}
		
		/**
		 * クッキー缶A,Bのクッキーの数の合計が
		 * yagiの数で割り切れるかどうかの判定
		 */
		if ((A + B) % yagi == 0) {
			outputStr = "Possible";
		}
		
		System.out.println(outputStr);
	}
	
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;

int main(){
	cin >> n;
	vector<ll> a(n);
	map<ll,ll> ml;
	rep(i,n){
		cin >> a[i];
		ml[a[i]]++;
	}
	sort(ALL(a));
	reverse(ALL(a));
	ll num = (1LL << 60);
	ll ans = 0;
	rep(i,n){
		ll x = a[i];
		if(ml[x] <= 0)continue;
		while(2*x < num)num /= 2;
		ml[x]--;
		if(ml[num - x] > 0){
			ml[num - x]--;
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 26752
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <map>
#define MOD (1000000007l)

using namespace std;

int main(void) {
  long N, M;
  cin >> N >> M;
  vector<long> A, B;
  for (long i = 0; i < N; i++) {
    long a, b;
    cin >> a >> b;
    A.push_back(a);
    B.push_back(b);
  }
  map<long, long> m;
  for (long i = 0; i < N; i++) {
    m[A[i]] += B[i];
  }
  long result = 0;
  long current = 0;
  for (auto it: m) {
    if (it.second >= M - current) {
      result += it.first * (M - current);
      current = M;
      break;
    } else {
      result += it.first * it.second;
      current += it.second;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 8044
use std::io;
use std::str::FromStr;

fn input_tuple() -> (f64, f64, f64, f64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<f64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2], vec[3])
}

fn main() {
    let (w, h, x, y) = input_tuple();
    print!("{} ", w * h / 2f64);
    if x == w / 2f64 && y == h / 2f64 {
        println!("1");
    } else {
        println!("0");
    }

}

Measured memory_bytes: 2196
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <bitset>
#include <cstdio>
using namespace std;
typedef long long int lli;
const int MAX_H = 20;
int L, H;
lli nums[MAX_H];
int s_nums[MAX_H], hit[MAX_H], blow[MAX_H];
lli ans;
void print_bits(lli n){
  for(int i = 0; i < L; ++i){
    cout << static_cast<bitset<4> >(n&15) << ".";
    n >>= 4;
  }
  cout << endl;
}
inline lli conv_64(const char* s){
  lli ret = 0;
  for(int i = 0; i < L; ++i){
    ret <<= 4;
    ret += (lli)(s[i]-'0');
  }
  return ret;
}
inline string deco_64(lli n){
  string ret;
  for(int i = 0; i < L; ++i){
    ret += (char)((n&15)+'0');
    n >>= 4;
  }
  reverse(ret.begin(), ret.end());
  return ret;
}
inline int conv(const char* s){
  int ret = 0;
  for(int i = 0; i < L; ++i){
    ret += 1 << (s[i]-'0');
  }
  return ret;
}
inline int check_64(lli n, lli m){
  lli tmp = n ^ m;
  int ret = 0;
  for(int i = 0; i < L; ++i){
    if((15&tmp) == 0){
      ++ret;
    }
    tmp >>= 4;
  }
  return ret;
}
inline int check(int n, int m){
  return __builtin_popcount(n&m);
}
inline bool solve(lli n, int m){
  for(int i = 0; i < H; ++i){
    int h = check_64(n, nums[i]);
    int b = check(m, s_nums[i]) - h;
    if(hit[i] != h || blow[i] != b){
      return false;
    } 
  }
  return true;
}
inline int dfs(lli n, int used, int depth, int ret){  
  if(depth == L){
    if(solve(n, used)){
      ans = n;
      return ret + 1;
    }
    return ret;
  }  
  for(int i = 0; i < 10; ++i){
    if(((used >> i) & 1) != 1){
      ret = dfs((n<<4)+i, used|(1<<i), depth+1, ret);
      if(ret >= 2){
        return ret;
      }
    }
  }
  return ret;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  char tmp[11];
  while(true){
    scanf("%d %d", &L, &H);
    if(L == 0 && H == 0){
      break;
    }
    for(int i = 0; i < H; ++i){
      scanf("%s", tmp);
      nums[i] = conv_64(tmp);
      s_nums[i] = conv(tmp);      
      scanf("%d %d", &hit[i], &blow[i]);
    }
    int a = dfs(0L, 0, 0, 0);
    if(a == 1){
      //print_bits(ans);
      cout << deco_64(ans) << endl;
    }
    else{
      cout << "NO" << endl;
    }
  }
  return 0;
}
//uncode

Measured memory_bytes: 1240
#![allow(non_snake_case)]
#![allow(unused_imports)]
use ascii::AsciiChar;
use ascii::AsciiStr;
use itertools::Itertools as _;
use permutohedron::LexicalPermutation as _;
use petgraph::algo::dijkstra;
use petgraph::algo::min_spanning_tree;
use petgraph::data::FromElements;
use petgraph::graph::NodeIndex;
use petgraph::graph::UnGraph;
use petgraph::unionfind::UnionFind;
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;
use proconio::marker::Usize1;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;
use superslice::Ext as _;

#[fastout]
fn main() {
    input! {
        N: usize,
    }

    // a
    // |aa
    // |ab
    // |aaa
    // |aab
    // |aba
    // |abb
    // |abc

    // lunlun_numberみたいにキューに突っ込んで無限に生成していく

    let mut q: VecDeque<(Vec<char>, u8)> = VecDeque::new();
    let initial = (vec!['a'], 'a' as u8);
    q.push_back(initial);

    let mut anss: Vec<String> = vec![];

    while !q.is_empty() {
        let (chars, largest_ch_u8) = q.pop_front().unwrap();

        if chars.len() == N {
            let s: String = chars.iter().collect();
            anss.push(s);
        } else if chars.len() < N {
            for c in ('a' as u8)..=largest_ch_u8 {
                let mut next_chars = chars.clone();
                next_chars.push(c as char);
                let tpl = (next_chars, largest_ch_u8);
                q.push_back(tpl);
            }

            let c = largest_ch_u8 + 1;
            let mut next_chars = chars.clone();
            next_chars.push(c as char);
            let tpl = (next_chars, c);
            q.push_back(tpl);
        }
    }

    for ans in anss.iter() {
        println!("{}", ans);
    }
}


Measured memory_bytes: 17960
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int ans1(int s){
  int ans1{1};
  while(1){
    if((180-s)*ans1%360==0){
      return ans1;
    }
    ans1++;
  }
  return -1;
}
int ans2(int s){
  double pi = acos(-1);
  double x{},y{};
  int ans2{1};
  //s = 180 - s;
  int nows{};
  while(1){
    x += cos(nows*pi/180);
    y += sin(nows*pi/180);
    nows += s;
    //cout << fixed << setprecision(10);
    //cout << x << ' '<<y<<endl;
    if(abs(x)<1e-6&&abs(y)<1e-6){
      return ans2;
    }
    ans2++;
    if(ans2>400) break;
  }
  return -1;
}

int main(){
  
  int s; cin>>s;
  cout << ans2(s) << endl;
  
  
  
}

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

int main(){
  int n,m,x,p,i,j,min,ok,cost,k,exist,q;
  cin >> n >> m >> x;
  vector<int> c(n),buy(n),skill(m);
  vector<vector<int>> a(n,vector<int>(m));
  for(i=0;i<n;i++){
    cin >> c.at(i);
    for(j=0;j<m;j++){
      cin >> a.at(i).at(j);
    }
  }
  
  p=1;
  for(i=0;i<n;i++){
    p=p*2;
  }
  
  exist=0;
  min=100000000;
  for(i=0;i<p;i++){
    q=i;
    for(j=0;j<n;j++){
      buy.at(j)=q%2;
      q=q/2;
    }
    cost=0;
    for(j=0;j<m;j++){
      skill.at(j)=0;
    }
    ok=1;
    for(j=0;j<n;j++){
      if(buy.at(j)==1){
        cost+=c.at(j);
        for(k=0;k<m;k++){
          skill.at(k)+=a.at(j).at(k);
        }
      }
    }
    for(j=0;j<m;j++){
      if(skill.at(j)<x){
        ok=0;
      }
    }
    if(ok==1){
      exist=1;
      if(cost<min){
        min=cost;
      }
    }
  }
  
  if(exist==0){
    min=-1;
  }
  
  cout << min << endl;
}

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

//int _; 

int a;
long long b,n;
 
int main()
{
	//for(scanf("%d",&_);_;_--)
	cin >> a >> b >> n;
	cout << a*min(n,b-1)/b << endl;
	return 0;
}

Measured memory_bytes: 3624
// Poll

#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>

using namespace std;

const int INF = 1 << 29;

int main ()
{
    int N;
    cin >> N;
    map <string,int> S;
    int m = 0;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        S[s]++;

        m = max(m,S[s]);
    }

    for (auto iter = S.begin(); iter != S.end(); iter++) {
        if (iter->second == m) {
            cout << iter->first << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 17664
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <iomanip>
using namespace std;

int main(void){
   double a,b;
   double x1,x2,y1,y2;
   cin >> x1 >> y1 >> x2 >> y2;
   
   a=x2-x1;
   b=y2-y1;
   double c=hypot(a,b);
  
   cout << fixed << setprecision(8) << c;
   cout << endl;
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    string s;
    cin >> s;
    bool a = false;
    bool b = false;
    for (int i = 0; i < 3; i++) {
        if (s[i] == 'A') a = true;
        if (s[i] == 'B') b = true;
    }
    dump(a and b ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    ll n, k;
    cin >> n >> k;
    static int imos[4009][4009] = {};
    rep(i, n) {
        ll x, y;
        char c;
        cin >> x >> y >> c;
        if(c == 'B') y += k;
        x++;
        y++;
        x %= 2 * k;
        y %= 2 * k;
        rep(j, 2) {
            imos[x][y]++;
            imos[x][y + k]--;
            imos[x + k][y]--;
            imos[x + k][y + k]++;
            x += k;
            y += k;
        }
    }
    rep(i, 4009) rep(j, 4008) imos[i][j + 1] += imos[i][j];
    rep(j, 4009) rep(i, 4008) imos[i + 1][j] += imos[i][j];
    static int cnt[2009][2009];
    rep(i, 4009) rep(j, 4009) cnt[i % (2 * k)][j % (2 * k)] += imos[i][j];
    int ans = 0;
    rep(i, 2 * k) rep(j, 2 * k) chmax(ans, cnt[i][j]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 78848
s=input()
c1=0
c2=0
for i in range(len(s)):
    if i%2==0:
        if s[i]!="0":
            c1+=1
    else:
        if s[i]!="1":
            c1+=1
for i in range(len(s)):
    if i%2==0:
        if s[i]!="1":
            c2+=1
    else:
        if s[i]!="0":
            c2+=1

print(min(c1,c2))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
typedef long long LL;
const LL mod = 1e9 + 7;
const int N = 3e5 + 5;

LL n, cur, s = 1;
int ans;

int main() {
	cin>>n;
	cur = 0;
	while(cur*10 + 9 <= n) {
		cur = cur*10 + 9;
		ans += 9;
		s *= 10;
	}
	n -= cur;
	ans += n/s;
	cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>
 
int main(void) {
    int a, b, n;
    int x, step;
    for (;;) {
        scanf("%d", &a);
        scanf("%d", &b);
        if (a >= 2 && a <= (pow(2.0, 31.0) - 1) && b >= 2 && b <= (pow(2.0, 31.0) - 1)) {
            if (a < b) {
                x = a;
                a = b;
                b = x;
            }
            step = 1;
            if (a != 0 && b != 0) {
                while (a%b != 0) {
                    x = a % b;
                    a = b;
                    b = x;
                    step++;
                }
                printf("%d %d\n", b, step);
            }
 
            else break;
        }
        else break;
    }
         
         
 
        return 0;
}


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

int main(){
  int A,B;
  cin >> A >> B;
  for(int i=1;i<4;i++){
    if((A*B*i)%2==1){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double l = (double)6.0 * m;
  double s = (double)30.0 * h + (double)0.5 * m;
  double res = min(abs(l - s), abs(360.0 - (l - s)));
  if(res > 180.0) res = 360.0 - res;
  double ans = (double)pow(a, 2.0) + (double)pow(b, 2.0) - (double)(2 * a * b * cos(res *  M_PI/ 180.0));
  ans = sqrt(ans);
  cout << fixed << setprecision(12) << ans << endl;
}

Measured memory_bytes: 4220