akhauriyash/Code-Regression huggingface dataset:
// problem: "https://atcoder.jp/contests/abc157/tasks/abc157_e"

#include<bits/stdc++.h>

using namespace std;

void updateST(vector<vector<bool>>&ST,int t,char c1,char c2,int i,int j,int p)
{
    // c1 - old
    // c2 - new

    if(i == j)
    {
        ST[p][c1-'a'] = 0;
        ST[p][c2-'a'] = 1;
        return ;
    }

    int m = (i+j)/2;

    if(t <= m)
        updateST(ST,t,c1,c2,i,m,2*p);
    else
        updateST(ST,t,c1,c2,m+1,j,2*p+1);

    ST[p][c1-'a'] = ST[2*p][c1-'a'] || ST[2*p+1][c1-'a'];
    ST[p][c2-'a'] = ST[2*p][c2-'a'] || ST[2*p+1][c2-'a'];

    return ;
}

void findST(vector<vector<bool>>&ST,int l,int r,int i,int j,int p,vector<bool>&V)
{
    if(l == i && r == j)
    {
        int k;
        for(k=0;k!=26;k++)
            V[k] = V[k] || ST[p][k];

        return ;
    }

    int m = (i+j)/2;

    if(r <= m)
        findST(ST,l,r,i,m,2*p,V);
    else if(l > m)
        findST(ST,l,r,m+1,j,2*p+1,V);
    else
    {
        findST(ST,l,m,i,m,2*p,V);
        findST(ST,m+1,r,m+1,j,2*p+1,V);
    }

    return ;
}

void printST(vector<vector<bool>>&ST,int n)
{
    int k,x;
    for(k=1;k!=2*n;k++)
    {
        cout<<k<<'\n';
        for(x=0;x!=26;x++)
            cout<<ST[k][x]<<' ';

        cout<<'\n';
    }
}

int main()
{
    int n;
    string s;

    cin>>n>>s;

    int k;
    vector<vector<bool>>ST(4*n,vector<bool>(26,false));
    for(k=0;k!=n;k++)
        updateST(ST,k,'a',s[k],0,n-1,1);        // define


    int q;
    cin>>q;

    while(q--)
    {
        int j;
        cin>>j;

        if(j == 1)
        {
            int i;
            char c2,c1;
            cin>>i>>c2;

            // c1 - old character
            // c2 - new character
            i--;
            c1 = s[i];
            s[i] = c2;

            updateST(ST,i,c1,c2,0,n-1,1);       // define

            // cout<<s<<'\n';
            // printST(ST,n);
        }
        else
        {
            int l,r;
            cin>>l>>r;

            l--;
            r--;
            vector<bool>V(26,false);
            findST(ST,l,r,0,n-1,1,V);     // define

            int t,c=0;
            for(t=0;t!=26;t++)
                if(V[t])
                    c++;

            cout<<c<<'\n';
        }
    }

    return 0;
}


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

// clang-format off
#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

#define rep(i, n) for (int i = 0; i < (int)(n); ++(i))
#define reps(i, n) for (int i = 1; i <= (int)(n); ++(i))
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --(i))
#define rreps(i, n) for (int i = (int)(n); i > 0; --(i))

#define range(i, l, r) for (int i = (int)l; i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = ((int)(r) - 1); i >= (int)l; --(i))

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)

using int32 = int;
using int64 = long long;

constexpr int mod     = 1e9 + 7;
constexpr int32 inf   = 1001001001;
constexpr int64 infll = 1001001001001001001ll;
constexpr int dx[]    = {0, -1, 1, 0, -1, 1, -1, 1},
              dy[]    = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

template<typename T = int> T input() { T x; cin >> x; return x; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

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); }
// clang-format on

void solver() {
    int N = input();

    int A = input(), B = input(), C = input();
    vector<int> l(N);
    cin >> l;

    debug(l);

    // int ans = inf;

    function<int(int, int, int, int)> f = [&](int idx, int a, int b, int c) {
        if (idx == N) {
            return min({a, b, c}) == 0 ? inf : abs(a - A) + abs(b - B) + abs(c - C);
        }


        int res0 = f(idx + 1, a, b, c);
        int res1 = f(idx + 1, a + l[idx], b, c) + (a ? 10 : 0);
        int res2 = f(idx + 1, a, b + l[idx], c) + (b ? 10 : 0);
        int res3 = f(idx + 1, a, b, c + l[idx]) + (c ? 10 : 0);

        return min({res1, res2, res3, res0});
    };

    cout << f(0, 0, 0, 0) << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


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

#define lld long long
#define pi pair<int, int>
#define pl pair<lld, lld>
#define mem0(x) memset(x, 0, sizeof(x))
#define fillnum(x, n) fill(begin(x), end(x), n)
#define asort(x) sort(x.begin(), x.end())
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>())

int main() {
    lld N, M;
    lld H[100001];
    bool flg[100001];
    mem0(flg);
    cin >> N >> M;
    for(int i = 0; i < N; i++) {
        cin >> H[i];
    }
    for(int i = 0; i < M; i++) {
        lld a, b;
        cin >> a >> b;
        a--;
        b--;
        if(H[a] > H[b]) {
            flg[b] = true;
        } else if(H[b] > H[a]) {
            flg[a] = true;
        } else {
            flg[a] = flg[b] = true;
        }
    }
    lld ans = 0;
    for(int i = 0; i < N; i++) {
        if(flg[i] == false) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4552
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    static class Pair {
        int left;
        int right;
        Pair(int l, int r) {
            left = l;
            right = r;
        }
    }

    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        PriorityQueue<Pair> pq = new PriorityQueue<>(n, new Comparator<Pair>() {
            @Override
            public int compare(Pair o1, Pair o2) {
                return o1.right - o2.right;
            }
        });
        for (int i = 0; i < n; i++) {
            int a = std.nextInt();
            pq.add(new Pair(i + 1, a));
        }

        List<Integer> sorted = new ArrayList<>();
        while (!pq.isEmpty()) {
            Pair p = pq.poll();
            sorted.add(p.left);
        }

        String results = sorted.stream().map(Object::toString).collect(Collectors.joining(" "));
        System.out.println(results);
    }
}


Measured memory_bytes: 65624
#include<bits/stdc++.h>
using namespace std;
#define For(start,end) for(int i = (int)start;i<(int)end;i++)
using Int = long long int;
int main(){
   int N;
   cin >> N;
   set<int>mochi;
   For(0,N)
   {
       int d;
       cin>>d;
       mochi.insert(d);
   }
    cout<<mochi.size()<<endl;


}

Measured memory_bytes: 3608
#include<stdio.h>
 
int main(void){
	int N;

	scanf("%d",&N);

	if(N<=111)
		printf("111");
	else if(N<=222)
		printf("222");
	else if(N<=333)
		printf("333");
	else if(N<=444)
		printf("444");
	else if(N<=555)
		printf("555");
	else if(N<=666)
		printf("666");
	else if(N<=777)
		printf("777");
	else if(N<=888)
		printf("888");
	else if(N<=999)
		printf("999");

	return 0;
	}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n,m,x,y;
    cin>>n>>m>>x>>y;
    int x_right=x,y_left=y,tmp;

    REP(i,n){
        cin>>tmp;
        x_right = max(x_right, tmp);
    }

    REP(i,m){
        cin>>tmp;
        y_left = min(y_left, tmp);
    }

    if(x_right<y_left){
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }

    return 0;
}


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

int main() {
  int K,N;
  string S,T="";
  cin>>K>>S;
  N=S.size();
  
  if(N<=K) cout<<S;
  else{
    for(int i=0;i<K;i++){
      T+=S[i];
    }
    cout<<T<<"...";
  }
}

Measured memory_bytes: 3628
#include <utility>
#include <vector>
#include <algorithm>
#include <iostream>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
using namespace std;

#define y0 y910831
#define y1 y923456
#define j0 j771912
#define j1 j442401
#define next next18181
#define prev prev18181

using ll = long long;
using ul = unsigned long;
#define INF 1LL<<60
#define PRIME 1000000007
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, 1, -1};
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll k,a,b;
	cin >> k >> a >> b ;
	if(b-a<=2 || k <= a){
		cout << (k+1);
		return 0;
	}
	k-=(a-1);//ビスケットはa枚ある　残り回数はk回
	ll res;
	res = a+(b-a)*(k/2);
	if(k%2==1)res++;
	cout << res;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int a,b,c,yaku,d;
	yaku = 0;
	scanf("%d\n%d\n%d",&a,&b,&c);
	while(1){
	    if(a>b){
		     printf("%d\n",yaku);
			 break;
	    }
	    else if(a<=b){
		     d = c % a;
			 a = a + 1;
		     if(d==0){
			     yaku = yaku + 1;
		     }else{
		     }
		}
	}



	return 0;
}

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


int main(){
	bool ok=true;
	int n,d=0;
	cin>>n;
	while(n--){
		char p;
		int x;
		cin>>p>>x;
		if(p=='('){
			d+=x;
		}else{
			d-=x;
			if(d<0)ok=false;
		}
	}
	if(ok&&!d)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll k, a, b;
    cin >> k >> a >> b;
    auto d = (b/k)*k ;
    if (a <= d && d <= b) {
        cout << "OK" <<endl;
    } else {
        cout << "NG" <<endl;
    }
}


Measured memory_bytes: 3620
A,B,C,K = map(int,input().split())

for i in range(K%2):
    tmp1 = A+B
    tmp2 = A+C
    tmp3 = B+C

    A = tmp3
    B = tmp2
    C = tmp1
if abs(A-B)>=10**18:
    print("Unfair")
else:
    print(A-B)

Measured memory_bytes: 3060
fun main(args: Array<String>) {
    ddcc2020qualb()
}

fun ddcc2020qualb() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map { it.toLong() }.toLongArray()

    val sum = aList.sum()
    val halved = sum / 2 + if (sum % 2 == 0L) 0 else 1

    var currSum = 0L
    var i = 0
    while (currSum < halved && i < aList.lastIndex) currSum += aList[i++]

    val answer = Math.min(
        Math.abs(aList.slice(0..i - 1).sum() - aList.slice(i..aList.lastIndex).sum()),
        Math.abs(aList.slice(0..i - 2).sum() - aList.slice(i - 1..aList.lastIndex).sum())
    )

    println(answer)
}


Measured memory_bytes: 80896
H,W,A,B = list(map(int,input().split()))
M = [[0]*W for _ in range(H)]



for ih in range(H):
    for iw in range(W):
        if (ih<B and iw <A) or (ih>=B and iw >= A):
            M[ih][iw] = 1
for i in range(H):
    print(''.join(list(map(str,M[i]))))



Measured memory_bytes: 17052
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
const LL MOD = 1e9 + 7;
void marmot0814() {
    int n; cin >> n;
    string s; cin >> s;
    vector<LL> dp(n + 1, 0); dp[1] = 1;
    for (int i = 2 ; i <= n ; i++) {
        vector<LL> tmp(n + 1, 0);
        if (s[i - 2] == '<') {
            LL sum = 0;
            for (int j = 1 ; j <= i ; j++) {
                tmp[j] = sum;
                (sum += dp[j]) %= MOD;
            }
        } else {
            LL sum = 0;
            for (int j = i ; j >= 1 ; j--) {
                (sum += dp[j]) %= MOD;
                tmp[j] = sum;
            }
        }
        dp = tmp;
    }
    LL sum = 0;
    for (int i = 1 ; i <= n ; i++)
        (sum += dp[i]) %= MOD;
    cout << sum << '\n';
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t = 1, kase = 0; // cin >> t;
    while (t--) {
        // cout << "Case #" << ++kase << ":";
        marmot0814();
    }
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

const long long MOD = 2019;

void solve(long long L, long long R) {
  R = min(L + 2019 * 2, R);
  ll ans = INF;
  for (int i = L; i <= R; i++) {
    for (int j = i + 1; j <= R; j++) {
      ans = min(ans, (ll)i * j % 2019);
    }
  }
  cout << ans << endl;
}

int main() {
  long long L;
  scanf("%lld", &L);
  long long R;
  scanf("%lld", &R);
  solve(L, R);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A, B;
    cin >> A >> B;
    if (A == B) cout << "Draw" << endl;
    else if (A == 1) cout << "Alice" << endl;
    else if (B == 1) cout << "Bob" << endl;
    else if (A > B) cout << "Alice" << endl;
    else cout << "Bob" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define CS
using namespace std;
int main(){
   speed;
   double  n;
   cin >> n;
   double sm=0;
   vector<int>vc(n);
   for (int i = 0 ;i < n;i++){
        cin >> vc[i];
        double a = 1;
        a /= vc[i];
        sm += a;
    }
    double b = 1;
    b /= sm;
    cout << setprecision(15) << b;

}






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

#include <iostream>
#include <iterator>
#include <vector>

using namespace std;
using ll = long long;

int main() {
    ll N, X, M;
    cin >> N >> X >> M;

    vector<ll> A;
    A.push_back(X);
    ll index = -1;
    ll tmp;
    for (ll i = 1; i < N; i++) {
        tmp = (A[i - 1] * A[i - 1]) % M;
        if (find(A.begin(), A.end(), tmp) != A.end()) {
            // cout << tmp << " " << A[i - 1] << " " << A[i - 1] * A[i - 1] % M
            // << endl;
            index = find(A.begin(), A.end(), tmp) - A.begin();
            break;
        }
        A.push_back(tmp);
    }

    // for (int i = 0; i < A.size(); i++) {
    // cout << i << " " << A[i] << endl;
    // }
    // cout << index << " " << A[index] << endl;

    if (index == -1) {
        ll output = 0;
        for (ll i = 0; i < N; i++) {
            output += A[i];
        }
        cout << output << endl;
        return 0;
    }

    ll repeat = 0;
    for (ll i = index; i < A.size(); i++) {
        repeat += A[i];
    }
    ll output = 0;
    for (ll i = 0; i < index; i++) {
        output += A[i];
    }
    N -= index;
    ll tmp2 = A.size() - index;
    ll m, n;
    if (tmp2 == 0) {
        m = N;
        n = 0;
    } else {
        m = N / tmp2;
        n = N % tmp2;
    }
    // cout << "re" << repeat << endl;
    output += m * repeat;
    for (ll i = index; i < index + n; i++) {
        output += A[i];
    }

    cout << output << endl;

    return 0;
}


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

int main() {
  int N, x;
  cin >> N >> x;
  vector<int>a(N);
  for(int i=0; i<N; i++) cin >> a.at(i);
  
  sort(a.begin(), a.end());
  
  int ans =0;
  for(int i=0; i<N; i++){
    x -= a.at(i);
    
    if(x>=0) ans ++;
    else break;
  }
  
  if(x>0)ans --;
  
  cout << ans << endl;
  
}

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

#define INT_MAX 2147483647

int func(int x){
    return x<0?-1 * x: x;
}


int main(){
    int n;
    scanf("%d", &n);
    int a[n];
    int cnt = 0;
    int min = INT_MAX;
    long long int sum = 0;
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
        if(a[i] < 0){
            cnt++;
        }
        if(min > func(a[i])){
            min = func(a[i]);
        }
        sum += func(a[i]);
    }
    if(cnt % 2){
        sum -= 2*min;
    }
    printf("%lld", sum);

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<cmath>
using namespace std;
#define int long long int
int memo[3005][3005][5];
int mat[3001][3001]={0};
int function2(int mat[3001][3001],int i,int j,int r,int c,int count)
{
	if(i==r&&j==c)
	{
		if(count<3)
		   return mat[i][j];
		else
		   return 0;
	}
	if(i>r||j>c)
	   return -10000000000000000;
	if(memo[i][j][count]!=-1)
	     return memo[i][j][count];
	else
	{
		if(count<3)
		{
			int val1=mat[i][j]+function2(mat,i,j+1,r,c,count+1);
			int val2=mat[i][j]+function2(mat,i+1,j,r,c,0);
			int val3=function2(mat,i,j+1,r,c,count);
			int val4=function2(mat,i+1,j,r,c,0);
			int here=max(val1,max(val2,max(val3,val4)));
			memo[i][j][count]=here;
			return memo[i][j][count];
		}
		else
		{
			int val1=function2(mat,i+1,j,r,c,0);
			int val2=function2(mat,i,j+1,r,c,count);
			memo[i][j][count]=max(val1,val2);
			return memo[i][j][count];
		}
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int r,c,k;
	cin>>r>>c>>k;
	int i,j,p;
	for(i=0;i<=3004;i++)
	{
		for(j=0;j<=3004;j++)
		{
			for(p=0;p<=4;p++)
			{
				memo[i][j][p]=-1;
			}
		}
	}
	for(j=0;j<k;j++)
	{
		int r1,c1,v;
		cin>>r1>>c1>>v;
		mat[r1][c1]=v;
	}
	int answer=function2(mat,1,1,r,c,0);
	cout<<answer<<endl;
}


Measured memory_bytes: 427344
def inputcase():
	global n,s
	n,s = map(int,input().split())
	return n!=0 or s!=0

memo = [[[0 for j in range(123)] for i in range(11)] for k in range(11)]
done = [[[False for j in range(123)] for i in range(11)] for k in range(11)]

def dfs(k, l, t):
	if t < 0:
		return 0
	elif k == 0 and t > 0:
		return 0
	elif k == 0:
		return 1
	elif l > 9:
		return 0
	if done[k][l][t]:
		return memo[k][l][t]
	done[k][l][t] = True
	for i in range(l,10):
		memo[k][l][t] += dfs(k-1,i+1,t-i)
	return memo[k][l][t]

while inputcase():
	print(dfs(n,0,s))



Measured memory_bytes: 5828
#include<iostream>

using namespace std;

#define IOS ios::sync_with_stdio(0);cin.tie(0);

int n,y;

bool solve(int a,int b){
	int kc=y-a*10-b*5;
	if(kc<0){
		return false;
	}
	else{
		if(a+b+kc!=n){
			return false;
		}
		else{
			if(a*10+b*5+kc == y){
				return true;
			}
			else{
				return false;
			}
		}
	}
	
}

int main(){
	IOS;
	int a,b,c;
	while(cin>>n>>y){
		y/=1000;
		bool flag=false;
		for(int i=y/10;i>=0;i--){
			for(int j=y/5;j>=0;j--){
				if(solve(i,j)){
					flag=true;
					a=i;
					b=j;
					c=y-a*10-b*5;
					break;
				}
				
			}
			if(flag){
				break;
			}
		}
		if(flag){
			cout<<a<<" "<<b<<" "<<c<<endl;
		}
		else{
			cout<<-1<<" "<<-1<<" "<<-1<<endl;
		}
	}
	return 0;
}

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

template <typename T>
class stack{
  T a[101];
  unsigned n;
public:
  stack():a(),n(0){}
  T& top(){return a[n-1];}
  T pop(){return a[--n];}
  void push(T in){a[n++]=in;}
};

int main(){
  std::ios::sync_with_stdio(false);
  stack<int> s;
  char buf[100];

  while(std::cin >> buf){
    int a;
    switch(buf[0]){
      case '+' : a = s.pop(); s.top() += a; break;
      case '-' : a = s.pop(); s.top() -= a; break;
      case '*' : a = s.pop(); s.top() *= a; break;
      default  : s.push(atoi(buf));
    }
  }
  std::cout << s.top() << '\n';
}

Measured memory_bytes: 1184
n = int(input())

c = list(input())
cnt = 0
l = 0
r = n-1
while l < r:
    while c[l] == "R" and l < r:
        l += 1

    while c[r] == "W" and l < r:
        r -= 1

    if c[l] == c[r]:
        break

    c[l], c[r] = c[r], c[l]

    l += 1
    r -= 1
    cnt += 1

print(cnt)

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

int main() {
  char c;
  cin >> c;

  if(c == 'a' || c == 'e' || c =='i' || c == 'o' || c == 'u') {
	cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        freopen("error.txt","w",stderr);
    #endif
}
int main()
{
    vok();
    int n;
    IN n;
    vll a(n);
    loop(i,0,n)
    {
        IN a[i];
    }
    int nn=n-1;
    sort(a.begin(),a.end());
    vll aa;
    loop(i,0,n-1)
    {
        aa.pb(a[i]);
        aa.pb(a[i]);
    }
    nn--;
    ll ans=a[n-1];
    int j=int(aa.size())-1;
    while(nn--)
    {
        ans+=aa[j];
        j--;
    }
    OUT ans<<endl
    return 0;
}

Measured memory_bytes: 8988
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#include <complex>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

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

typedef unsigned long long ull;
typedef std::complex<double> P;

double snorm(const P& p){
    return std::sqrt(norm(p));
}

P toUnit(const P& p){
    return {real(p) / snorm(p), imag(p) / snorm(p)};
}

double cross(const P& lp, const P& rp){
    return real(lp) * imag(rp) - imag(lp) * real(rp);
}

double dot(const P& lp, const P& rp){
    return real(lp) * real(rp) + imag(lp) * imag(rp);
}



int main(){
    P p1, p2, q;
    double x1, y1, x2, y2, xq, yq;
    while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq)){
        p1 = P{x1, y1};
        p2 = P{x2, y2};
        q = P{xq, yq};

        if(real(p1) > real(p2)){std::swap(p1, p2);}
        P p = p2 - p1, q_ = q - p1;

    
        double c = dot(p, q_) / (snorm(p) * snorm(q_)),
            s = cross(p, q_) / (snorm(p) * snorm(q_));

        p = toUnit(p) * snorm(q_);
        double rx = c * real(p) + s * imag(p) + real(p1),
            ry = -s * real(p) + c * imag(p) + imag(p1);
    
        printf("%.4f %.4f\n", rx, ry);
    }
}

Measured memory_bytes: 1244
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 1'000'000'009;

int main()
{
	LLONG a, b, c, d; cin >> a >> b >> c >> d;
	cout << max(a * c, max(a * d, max(b * c, b * d))) << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>

int main(void){

	double a,b,c,d,e,f;
	double y;

	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF){

		y = (f-d/a*c)/(-d/a*b+e);

		printf("%.3lf %.3lf\n",(c - b*y)/a,y);

	}

	return 0;
}

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define vcin(a); rp(i,a.size()){cin>>a[i];}
#define vcout(a); rp(i,a.size()){cout<<a[i]<<endl;}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;

bool isOK(int index, int key,vi a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key,vi a) {
    int left = -1;
    int right = (int)a.size();
    while (right - left > 1) {
        int mid = left + (right - left) / 2;
        
        if (isOK(mid, key,a)) right = mid;
        else left = mid;
    }
    return right;
}

int modpow(int a,int b,int p){
    if(b==0){
        return 1;
    }elif(b%2==0){
        return modpow((a*a)%p,b/2,p);
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,T;
    cin >> n >> T;
    vi c(n),t(n);
    rp(i,n){
        cin >> c[i] >> t[i];
    }
    int ans=INT_MAX,cnt=0;
    rp(i,n){
        if(t[i]<=T){
            ans=min(ans,c[i]);
        }else{
            cnt++;
        }
    }
    if(cnt==n){
        cout << "TLE" << endl;
    }else{
        cout << ans << endl;
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sstream>

using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    cout << max(A + B, max(A - B, A * B));

    return 0;
}

Measured memory_bytes: 256
T1, T2 = map(int,input().split())
A1, A2 = map(int,input().split())
B1, B2 = map(int,input().split())

T = T1*A1+T2*A2
A = T1*B1+T2*B2
if T == A:
  print("infinity")
  exit()

if T > A:
  if A1 > B1:
    print(0)
    exit()
  else:
    tdif = T-A #7-5
    pdif = T1*(B1-A1) #5
    if pdif%tdif == 0:
      ans = 2*(pdif//tdif)+1
    else:
      ans = 2*(1+pdif//tdif)
    ans -=1 #原点の分を引く
else:
  if B1 > A1:
    print(0)
    exit()
  else:
    tdif = A-T #7-5
    pdif = T1*(A1-B1) #5
    if pdif%tdif == 0:
      ans = 2*(pdif//tdif)+1
    else:
      ans = 2*(1+pdif//tdif)
    ans -=1 #原点の分を引く    
print(ans)

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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

ll f(ll a) {
  ll res = 0;
  while (a >= 0) {
    if (a % 2 == 0) {
      a /= 2;
      res++;
    } else {
      break;
    }
  }
  return res;
}

void solve(ll N, std::vector<ll> a) {
  ll sum = 0;
  rep(i, N) { sum += f(a.at(i)); }
  cout << sum << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  std::vector<ll> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, std::move(a));

  return 0;
}


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

// @author: pashka

const int MAX = 2501;

struct edge {
    int dest;
    long time;
};

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

    int n, m, s;
    cin >> n >> m >> s;

    s = min(s, MAX - 1);
    int nn = n * MAX;
    vector<vector<edge>> g(nn);

    for (int i = 0; i < m; i++) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        for (int j = a; j < MAX; j++) {
            g[j * n + u].push_back({(j - a) * n + v, b});
            g[j * n + v].push_back({(j - a) * n + u, b});
        }
    }
    for (int i = 0; i < n; i++) {
        int c, d;
        cin >> c >> d;
        for (int j = 0; j < MAX; j++) {
            g[j * n + i].push_back({min(j + c, MAX - 1) * n + i, d});
        }
    }

    set<pair<int, int>> q;
    vector<long> d(nn, LLONG_MAX);
    s = s * n;
    d[s] = 0;
    q.insert({d[s], s});
    while (!q.empty()) {
        auto p = *q.begin();
        q.erase(p);
        int x = p.second;
        for (auto e : g[x]) {
            int y = e.dest;
            long dd = d[x] + e.time;
            if (dd < d[y]) {
                q.erase({d[y], y});
                d[y] = dd;
                q.insert({d[y], y});
            }
        }
    }
    for (int i = 1; i < n; i++) {
        long res = LLONG_MAX;
        for (int j = 0; j < MAX; j++) {
            res = min(res, d[j * n + i]);
        }
        cout << res << " ";
    }

    return 0;
}

Measured memory_bytes: 24860
import numpy as np
N=int(input())
A=list(map(int, input().split()))

for i in range(N):
  A[i]-=(i+1)
A=np.array(A)



med=np.median(A)
def sudness(A):
  sad=0
  for a in A:
    sad+=abs(a)
  return int(sad)

print(sudness(A-med))



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

int32_t main()
{
 ios_base::sync_with_stdio(0);  cout.tie(0); cin.tie(0);
 string s,t;
  cin>>s;
  cin>>t;
  int l=s.length();
  int p=t.length();
  int flag=0;
  for(int i=0;i<l;i++){
    if(s[i]!=t[i]){flag=1;}
  }
  if(flag==1){cout<<"No";}
  else{cout<<"Yes";}

 
 



}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

long long int count_factor(long long int n, int factor) {
	return (n == 0) ? 0 : n / factor + count_factor(n / factor, factor);
}
int main() {
	long long int n; std::cin >> n;
	if (n % 2 == 1) {
		std::cout << 0 << std::endl;
	}
	else {
		std::cout << count_factor(n / 2, 5) << std::endl;
	}
}


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

int main(){
  int n, t;
  cin >> n >> t;
  vector<vector<int>> dp(t, vector<int>(2,0));
  for(int i=0; i<n; ++i){
    int a, b;
    cin >> a >> b;
    for(int j=t-1; j>=0; --j){
      dp[j][0] = max(dp[j][0], dp[j][1]+b);
      if(j>=a)dp[j][0] = max(dp[j][0], dp[j-a][0]+b);
      if(j>=a)dp[j][1] = max(dp[j][1], dp[j-a][1]+b);
    }
  }
  cout << dp[t-1][0] << endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    static const int MAXN=1e5+10;
    int N,K;
    class Sushi{
    public:
        int t;
        ll d;
        Sushi(){}
        Sushi(int tt,ll dd):t(tt),d(dd){}
    };
    vector<Sushi>sushis;
    int vis[MAXN];
    static bool cmp(Sushi s1,Sushi s2){
        return s1.d>s2.d;
    }
    void solve(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        cin>>N>>K;
        for(int u=0;u<N;u++){
            int t;
            ll d;
            cin>>t>>d;
            sushis.push_back(Sushi(t,d));
        }
        sort(sushis.begin(),sushis.end(),cmp);
        stack<ll>st;
        ll acc=0,ans=0;
        int cnt=0,ty=0;
        for(int u=0;u<N;u++){
            int t=sushis[u].t;
            ll d=sushis[u].d;
            if(cnt<K){
                if(vis[t]==0){
                    vis[t]=1;
                    ty++;
                }
                else st.push(d);
                acc+=d;
                cnt++;
                ans=max(ans,acc+(ll)ty*ty);
            }
            else {
                if(st.empty())break;
                if(vis[t])continue;
                //对重复的进行替换
                vis[t]=1;
                ty++;
                acc-=st.top();
                st.pop();
                acc+=d;
                ans=max(ans,acc+(ll)ty*ty);
            }
        }
        cout<<ans;
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> city(N);

	for (int i = 0; i < M; i++) {
		vector<int> tmp(2);
		cin >> tmp.at(0) >> tmp.at(1);
		city.at(tmp.at(0) - 1) += 1;
		city.at(tmp.at(1) - 1) += 1;
	}

	for (int i = 0; i < N; i++) {
		cout << city.at(i) << endl;
	}
}

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

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

int main(){
    long long H,W;
    cin >> H >> W;
    //even * even
    long long S = H * W;
    long long res=LONG_LONG_MAX;
    for(int i=1;i<W;i++){
        long long S1 = H*i;
        //
        long long ma=S1,mi=S1;
        long long S2 = (H/2) * (W-i);
        ma=max(ma,S2),mi=min(mi,S2);
        long long S3 = S - S1 - S2;
        ma=max(ma,S3),mi=min(mi,S3);
        res=min(res,ma-mi);
        //
        ma=S1,mi=S1;
        S2 = ((W-i)/2) * H;
        ma=max(ma,S2),mi=min(mi,S2);
        S3 = S - S1 - S2;
        ma=max(ma,S3),mi=min(mi,S3);
        res=min(res,ma-mi);
    }
    swap(W,H);
    for(int i=1;i<W;i++){
        long long S1 = H*i;
        //
        long long ma=S1,mi=S1;
        long long S2 = (H/2) * (W-i);
        ma=max(ma,S2),mi=min(mi,S2);
        long long S3 = S - S1 - S2;
        ma=max(ma,S3),mi=min(mi,S3);
        res=min(res,ma-mi);
        //
        ma=S1,mi=S1;
        S2 = ((W-i)/2) * H;
        ma=max(ma,S2),mi=min(mi,S2);
        S3 = S - S1 - S2;
        ma=max(ma,S3),mi=min(mi,S3);
        res=min(res,ma-mi);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  string s;
  while(cin >> s) {
    int const N = s.size();
    string ans;
    bool ok = 1;
    
    if(N % 2) ok = 0;
    
    for(int i=1; i<N; i+=2) {
      int a = s[i-1]-'0', b = s[i]-'0';

      if(a<1 || 6<a || b<1 || 5<b ) ok = 0;
      char ch = (a-1)*5 + (b-1) + 'a';
      if(!isalpha(ch)) {
	if(a == 6 && b == 2) ch = '.';
	else if(a == 6 && b == 3) ch = '?';
	else if(a == 6 && b == 4) ch = '!';
	else if(a == 6 && b == 5) ch = ' ';
	else ok = 0;
      }
      if(ok) ans += ch;
      else break;
    }

    if(ok) {
      cout << ans << endl;
    }
    else {
      cout << "NA" << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1188
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vll = vector<vector<ll> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;
using lthe = pair<ll, 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 int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

int main()
{
    int a[4];
    string s;
    cin >> s;
    rep(i, s.size()) {
        a[i] = s[i] - '0';
    }
    //cout << a[0] << a[1] << a[2] << a[3];

    char op[3];
    int sum = a[0];
    for (int bit = 0; bit < (1 << 3); ++bit)
    {
        for (int i = 0; i < 3; ++i) {
            if (bit & (1 << i)) { // i が bit に入るかどうか
                sum += a[i + 1];
                op[i] = '+';
            }
            else {
                sum -= a[i + 1];
                op[i] = '-';
            }
        }
        if (sum == 7) {
            break;
        }
        sum = a[0];
    }

    cout << a[0] << op[0] << a[1] << op[1] << a[2] << op[2] << a[3] << "=7" << endl;
}


Measured memory_bytes: 256
N,M,Q = map(int,input().split())
abcd = [list(map(int,input().split())) for _ in range(Q)]
ans = 0
def res(lis,place,now_number,M,N,result):
  if place==N-1:
    lis[place]=now_number
    result.append(lis.copy())
    return
  else:
    lis[place]=now_number
    for j in range(now_number,M+1):
      res(lis,place+1,j,M,N,result)

for i in range(1,M+1):
  result = []
  place = 0
  l = [0]*N
  res(l,place,i,M,N,result)
  for A in result:
    tmp = 0
    for q in abcd:
      if A[q[1]-1]-A[q[0]-1]==q[2]:
        tmp+=q[3]
    ans=max(ans,tmp)
    
print(ans)

Measured memory_bytes: 16332
package main

import "fmt"

func main() {
	a := make([]int, 1)
	b := make([]int, 1)
	op := make([]string, 1)

	for {
		var anum, bnum int
		var opsample string
		fmt.Scan(&anum)
		fmt.Scan(&opsample)
		fmt.Scan(&bnum)

		if opsample == "?"{
			break
		}

		a = append(a, anum)
		b = append(b, bnum)
		op = append(op, opsample)
	}

	for i:=0; i<len(a); i++{
		switch op[i] {
		case "+":
			fmt.Println(a[i] + b[i])
		case "-":
			fmt.Println(a[i] - b[i])
		case "*":
			fmt.Println(a[i] * b[i])
		case "/":
			fmt.Println(a[i] / b[i])
		case "?":
			break
		}
	}
}


Measured memory_bytes: 1128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  long int N,K,tmp,a1,a2;
  scanf("%ld %ld",&N,&K);

  tmp = N/K;
  a1 = N - tmp*K;
  a2 = K - a1;

  if(a1 > a2)
  {
    printf("%ld\n",a2);
  }
  else
  {
    printf("%ld\n",a1);
  }

  return 0;
}

Measured memory_bytes: 128
#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() {
    Int a, b, m;
    cin >> a >> b >> m;
    vector<Int> as(a), bs(b);
    for (Int i = 0; i < a; i++) {
        cin >> as[i];
    }
    for (Int i = 0; i < b; i++) {
        cin >> bs[i];
    }
    vector<Int> x(m), y(m), c(m);
    for (Int i = 0; i < m; i++) {
        cin >> x[i] >> y[i] >> c[i];
        x[i]--;
        y[i]--;
    }
    Int mi = INF;
    for (Int i = 0; i < m; i++) {
        mi = min(mi, as[x[i]] + bs[y[i]] - c[i]);
    }
    sort(all(as));
    sort(all(bs));
    mi = min(mi, as.front() + bs.front());
    dump(mi);
    return 0;
}


Measured memory_bytes: 4224
data = gets.chomp.split
longestString = ""
freq = {}

data.each do |elem|
  longestString = elem if longestString.size < elem.size
  if freq.key?(elem)
    freq[elem] += 1
  else
    freq[elem] = 1
  end
end

keys = freq.keys
values = freq.values

puts "#{keys[values.index(values.max)]} #{longestString}"

# あんまりきれいな書き方ではないけど，
# ” There is only one word which is arise most frequently in given text.”よりindexを使った

Measured memory_bytes: 6096
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST

static bool COUNTUP = false;
bool countup(vector<ll>& A, const ll &end, ll depth)
{
    bool loop_end = true;
    //最初はカウントアップしない
    if(!COUNTUP)
    {
        COUNTUP=true;
        return true;
    }
    if(A[depth]< end) A[depth]++;
    else
    {
        if (depth == 0) return false;
        loop_end = countup(A, end, depth-1);
        A[depth] = A[depth-1];
    }
    return loop_end;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    ll N, M, Q;
    cin >> N >> M >> Q;
    ll a[Q], b[Q], c[Q], d[Q];
    ll max_total = 0;
    vector<ll> A(N,1);
    for(size_t i=0;i<Q; i++)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    while(countup(A, M, A.size()-1))
    {
        ll total = 0;
        for(size_t i=0;i<Q; i++)
        {
            if(A[b[i]-1] - A[a[i]-1] == c[i]) total += d[i];
        }
        max_total = max(max_total, total);
    }
    cout << max_total << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}


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

using namespace std;

typedef long long ll;

ll h, w;
ll ans = 1e9;

void solve(ll k, ll j){
  for(ll i=1; i<=k; i++){
    ll a = i * j * 1ll;
    ll b =  (j / 2) * (k - i) * 1ll;
    ll c = ((j+1) / 2) * (k - i) * 1ll;
    ll mi = min(a, min(b, c));
    ll mx = max(a, max(b, c));
    ans = min(ans, mx - mi);
  }
}

void solve2(ll k, ll j){
  for(ll i=1; i<=k; i++){
    ll a = i * j * 1ll;
    ll b =  ((k - i) / 2) * j * 1ll;
    ll c = ((k - i + 1) / 2) * j * 1ll;
    ll mi = min(a, min(b, c));
    ll mx = max(a, max(b, c));
    ans = min(ans, mx - mi);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> h >> w;
  solve(h, w);
  solve2(h, w);
  solve(w, h);
  solve2(w, h);
  cout << ans << endl;
  return 0;
}


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


int main() {
  ll n;
  cin>>n;
  vector<ll>a(3*n+5);
  rep(i,n*3)cin>>a[i];
  ll bef=0;
  ll las=0;
  priority_queue<ll, vector<ll>,greater<ll>>qb;
  priority_queue<ll>ql;
  rep(i,n){
    qb.push(a[i]);
    ql.push(a[i+2*n]);
    bef+=a[i];
    las+=a[i+2*n];

  }
vector<ll>B(n+1);
vector<ll>L(n+1);
B[0]=bef;
L[n]=las;
  rep(i,n){
    qb.push(a[n+i]);
    bef+=a[n+i];
    ll now=qb.top();
    bef-=now;
    qb.pop();
    B[i+1]=bef;
  //  cout<<bef<<endl;
  }
  rep(i,n){
    ql.push(a[2*n-1-i]);
    las+=a[2*n-1-i];
    ll now=ql.top();
    las-=now;
    ql.pop();
    L[n-1-i]=las;
  //  cout<<las<<endl;

  }
  ll ans=-INF;
  rep(i,n+1){
    ans=max(ans,B[i]-L[i]);
  //  cout<<ans<<endl;
  }
cout<<ans;

}


Measured memory_bytes: 5996
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;
// const int imax = 100000;

int main(){
	int n;
	cin >> n;
	double x;
	string u;
	double sum = 0;
	rep(i,n){
		cin >> x >> u;
		if(u == "JPY") sum += x;
		else sum +=  380000.0 * x;
	}
	printf("%lf\n",sum);
	return 0;
}


Measured memory_bytes: 3796
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

int main()
{
  uint64_t H;
  cin >> H;

  uint64_t ans = 1;
  while (H>1) {
    ans = 2*ans + 1;
    H /= 2;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ll=long long;
 
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m);i>=(int)(n);--i)
#define rrep(i,m) RREP(i,m,0)
#define debug(x) cout << #x << "=" << (x) << endl;
const int MOD=1e9+7;
 
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;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
 
void solve(){
}
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int num;
  cin >> num;
  int v[num];
  rep(i,num){
    int a;
    cin >> a;
    v[--a]=i+1;
  }
  rep(i,num)
    cout << v[i] << " ";
  solve();
  return 0;
}

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

int main()
{
	string s,t;
	cin >> s;
	cin >>t;
	int n = s.length();
	int m = t.length();
	vector<vector<int> > dp(n+1 ,vector<int> (m+1,0));

	for (int i = 1; i <=n; ++i)
	{
		for(int j=1;j<=m;j++)
		{
			if (s[i-1]==t[j-1])
			{
				dp[i][j] = dp[i-1][j-1]+1;
			}
			else
			{
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}
	int i=n;
	string ans;
	int j=m;
	if(dp[n][m]==0)
		cout << " ";
	else
	{
		while(i-1 >=0 && j-1>=0)
		{
			if (s[i-1]==t[j-1])
			{
				ans.push_back(s[i-1]);
				i--;
				j--;
			}
			else
			{
				if(dp[i-1][j] > dp[i][j-1])
					i--;
				else
					j--;
			}
		}
		reverse(ans.begin(),ans.end());
		cout <<  ans;
	}
	return 0;
}

Measured memory_bytes: 35584
def divisors(M):#Mの約数列 O(n^(0.5+e))
    import math
    d=[]
    i=1
    while math.sqrt(M)>=i:
        if M%i==0:
            d.append(i)
            if i**2!=M:
                d.append(M//i)
        i=i+1
    d.sort()
    return d

def Ind(b,n):
    count=0
    while n%b==0:
        count+=1
        n//=b
    return count

N=int(input())
X=input()
x=0
for i in range(N):
    x=2*x+int(X[i])

a=Ind(2,N)
n=N//(2**a)
d=divisors(n)
data={i*2**(a+1):0 for i in d}
mod=998244353

for i in d:
    Q=((2**(i*2**a)+1)*(x+1))//(2**N+1)
    Q%=mod
    data[i*2**(a+1)]+=Q
    data[i*2**(a+1)]%=mod


for i in d:
    for j in d:
        if i>j and i%j==0:
            data[i*2**(a+1)]-=data[j*2**(a+1)]
            data[i*2**(a+1)]%=mod


ans=0
for i in data:
    ans+=data[i]*i
    ans%=mod
print(ans)

Measured memory_bytes: 3688