akhauriyash/Code-Regression huggingface dataset:
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main() {

	int n;
	scanf("%d", &n);
	while (!(to_string(n)[0] == to_string(n)[1] && to_string(n)[1] == to_string(n)[2]))++n;
	printf("%d\n", n);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
typedef long long ll;
ll rc[3001][3001];
int r,c,k;
ll dp[3001][3001][4]; 
int main(){
	 scanf("%d%d%d",&r,&c,&k);
	 for(int i=1;i<=k;i++){
	 	int x,y,w;
	 	scanf("%d%d%d",&x,&y,&w);
	 	rc[x][y]=w;
	 }	 
	 for(int i=1;i<=r;i++){
	 	for(int j=1;j<=c;j++){
	 		dp[i][j][0]=max(max(dp[i-1][j][0],dp[i-1][j][1]),dp[i-1][j][2])+rc[i][j];
			 for(int k=0;k<3;k++){
			 	dp[i][j][k]=max(dp[i][j-1][k],dp[i][j][k]);
	 			if(dp[i][j-1][k]==0){
	 				dp[i][j][k]=max(dp[i][j][k],rc[i][j]);
	 				break;
				 }else{
				 	dp[i][j][k+1]=max(dp[i][j-1][k]+rc[i][j],dp[i][j][k+1]);
				 }
			 }
		 }
	 }
	 ll res=0;
	 for(int i=0;i<3;i++)
	 res=max(res,dp[r][c][i]);
	 printf("%lld\n",res);
}

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

long long graph[500][500];
char mas[500][500];

int h, w;
int zip(int y, int x){
    return y * w + x;
}

bool isOK(int y, int x){
    return 0 <= y && y < h && 0 <= x && x < w && mas[y][x] == '.';
}

int main(){
    cin >> h >> w;
    int n = h*w;

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

    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            for(int k = 0;k < h;k++){
                for(int l = 0;l < w;l++){
                    graph[zip(i, j)][zip(k, l)] = INT_MAX;
                }
            }
        }
    }

    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            if(mas[i][j] != '#'){
                graph[zip(i, j)][zip(i, j)] = 0;
                if(isOK(i, j+1)) graph[zip(i, j)][zip(i, j+1)] = 1;
                if(isOK(i, j-1)) graph[zip(i, j)][zip(i, j-1)] = 1;
                if(isOK(i+1, j)) graph[zip(i, j)][zip(i+1, j)] = 1;
                if(isOK(i-1, j)) graph[zip(i, j)][zip(i-1, j)] = 1;
            }
        }
    }

    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            for(int k = 0;k < n;k++){
                graph[j][k] = min(graph[j][k], graph[j][i] + graph[i][k]);
            }
        }
    }

    int ans = 0;
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            for(int k = 0;k < h;k++){
                for(int l = 0;l < w;l++){
                    int tmp = graph[zip(i, j)][zip(k, l)];
                    if(tmp < INT_MAX){
                        ans = max(ans, tmp);
                    }
                }
            }
        }
    }

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

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

int main(void) {
	int H, W;
	std::cin >> H >> W;
	std::vector<std::vector<bool> > red(H, std::vector<bool>(W, false));
	std::vector<std::vector<bool> > blue(H, std::vector<bool>(W, false));
	for(int h = 0; h < H; ++h) {
		for(int w = 0; w < W; ++w) {
			if(w == 0) {
				red[h][w] = true;
			} else if(w == W - 1) {
				blue[h][w] = true;
			} else if(h % 2 == 0) {
				red[h][w] = true;
			} else {
				blue[h][w] = true;
			}
		}
	}
	char c;
	std::cin >> c;//LF
	for(int h = 0; h < H; ++h) {
		std::string line;
		std::getline(std::cin, line);
		for(int w = 0; w < W; ++w) {
			if(line[w] == '#') {
				red[h][w] = true;
				blue[h][w] = true;
			}
		}
	}
	for(int h = 0; h < H; ++h) {
		for(int w = 0; w < W; ++w) {
			std::cout << (red[h][w] ? '#' : '.');
		}
		std::cout << '\n';
	}
	std::cout << '\n';
	for(int h = 0; h < H; ++h) {
		for(int w = 0; w < W; ++w) {
			std::cout << (blue[h][w] ? '#' : '.');
		}
		std::cout << '\n';
	}
	return 0;
}



Measured memory_bytes: 896
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int n,bil,ans,maxi;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    int mini=1e9;
    for(int i=1;i<=n;i++){
        cin>>bil;
        if(bil<=mini) ans++;
        mini=min(mini,bil);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.map!(to!int).array; }

bool isParallel(Vec2 a, Vec2 b, Vec2 c, Vec2 d) {
    auto ab = b - a;
    auto cd = d - c;
    return ab.cross(cd) == 0;
}

bool isOrthogonal(Vec2 a, Vec2 b, Vec2 c, Vec2 d) {
    auto ab = b - a;
    auto cd = d - c;
    return ab.dot(cd) == 0;
}

int calc(Vec2 a, Vec2 b, Vec2 c, Vec2 d) {
    if (isParallel(a, b, c, d)) return 2;
    if (isOrthogonal(a, b, c, d)) return 1;
    return 0;
}

void main() {
    int n = readint();
    for (int i = 0; i < n; i++) {
        auto ps = readints();
        auto a = Vec2(ps[0], ps[1]);
        auto b = Vec2(ps[2], ps[3]);
        auto c = Vec2(ps[4], ps[5]);
        auto d = Vec2(ps[6], ps[7]);

        writeln(calc(a, b, c, d));
    }
}

struct Vec2 {
    immutable double x;
    immutable double y;

    this(double x, double y) {
        this.x = x;
        this.y = y;
    }

    Vec2 opNeg() { return Vec2(-this.x, -this.y); }
    Vec2 opAdd(Vec2 other) { return Vec2(this.x + other.x, this.y + other.y); }
    Vec2 opSub(Vec2 other) { return Vec2(this.x - other.x, this.y - other.y); }
    Vec2 opMul(double d) { return Vec2(this.x * d, this.y * d); }

    double dot(Vec2 other) { return this.x * other.x + this.y * other.y; }
    double cross(Vec2 other) { return this.x * other.y - other.x * this.y; }
    double mag() { return sqrt(magSq()); }
    double magSq() { return this.x * this.x + this.y * this.y; }

    Vec2 normalized() {
        auto m = mag();
        if (m != 0 && m != 1)
            return Vec2(this.x / m, this.y / m);
        return this;
    }

    static double distance(Vec2 a, Vec2 b) {
        return (a - b).mag();
    }
}



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

int main(){
  int n, m; scanf("%d %d", &n, &m);
  vector<priority_queue<int>> v(n);
  rep(i, m){
    int a, b; scanf("%d %d", &a, &b); --a; --b;
    v[a].push(b);
    v[b].push(a);
  }
  bool b = 0;
 while(!v[0].empty()){
   int c = v[0].top();
    if(v[c].top() == n-1){
      b = 1;
      break;
    }
   v[0].pop();
  }
  if(b) printf("POSSIBLE\n");
  else printf("IMPOSSIBLE\n");
  return 0;
}

Measured memory_bytes: 13552
from itertools import permutations
n = int(input())
a = tuple(map(int ,input().split()))
b = tuple(map(int ,input().split()))

np = [i for i in range(1, n+1)]
p = list(permutations(np))
ai = p.index(a)
bi = p.index(b)
print(abs(ai-bi))

Measured memory_bytes: 44912
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  string s;
  cin >> s;

  ll p = -1, q = 0;

  REP(i, s.size()){
    if(p == -1 && s[i] == 'A') p = i;
    if(s[i] == 'Z') q = i;
  }

  cout << q - p + 1 << endl;
}


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

using namespace std;

void solve() {
    long long N, K;
    cin >> N >> K;
    vector<pair<int, int>> p(N);
    for (int i = 0; i < N; i++)
    {
        int a, b;
        cin >> a >> b;
        p[i] = make_pair(a, b);
    }
    sort(p.begin(), p.end());

    long long arr_sum = 0;
    for (int i = 0; i < N; i++)
    {
        arr_sum += p[i].second;
        if (arr_sum >= K)
        {
            cout << p[i].first << endl;
            return;
        }
    }
}

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

Measured memory_bytes: 4024
acgt = ["A", "C", "G", "T"]
S = list(input())

ans = 0
for i in range(len(S)):
    if S[i] in acgt:
        cnt = 1
        i += 1
        while 1:
            if i == len(S):
                break
            if not S[i] in acgt:
                break
            i += 1
            cnt += 1
        if ans < cnt:
            ans = cnt
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
int a[3];
for(int i = 0;i < 3;i++)
scanf("%d",&a[i]);
	if((a[0]!=a[1])&&(a[1]!=a[2])&&(a[2]!=a[0])||(a[0]==a[1])&&(a[1]==a[2])&&(a[0]==a[2]))
		printf("No");
	else
		printf("Yes");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,ans=0,s=1,d;
    cin>>n;
    f(i,0,n){
        cin>>d;
        if(d==s){
            ans++;
            s++;
        }
    }
   if(ans==0){
       cout<<-1<<endl;
   }
   else{
       cout<<n-ans<<endl;
   }
    return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
void solve(){
   double a,b,h,m;
   cin>>a>>b>>h>>m;
   double theta = (30*h)-(11*m)/2;
   theta = min(360-theta,theta);
   double pi = 3.141592653589793;
   double x = (theta * pi) / 180.0;
   double ans = (double)(a*a + b*b - 2*a*b*cos(x));
   cout.precision(17);
   cout<<fixed<<sqrt(ans)<<endl;
}
int main(){
    int t;
    t = 1;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 4224
n, k = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
for i in range(k):
    ans += (p[i] + 1) / 2
calc = ans
for i in range(1, n - k + 1):
    calc += ((p[i + k - 1] + 1) - (p[i - 1] + 1)) / 2
    ans = max(ans, calc)
print(ans)

Measured memory_bytes: 25060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std; using ll = long long;
using ull = unsigned long long; using P = pair<int, int>;
const int INF = 1e9; const int MOD = 1000000007;
const int dx[] = {-1,0,1,0}; const int dy[] = {0,-1,0,1};
//const int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1}; const int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1};
#define PI 3.14159265358979323846264338327950L //setprecision(15)

int main() {
	int N; cin >> N;
	int ans = 1;
	int tmp = 1;
	while (1) {
		if (tmp * 2 > N ) {
			break;
		}
		tmp *= 2; ans *= 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3608
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;
int n , k , a[N];
int main() {
    abdelrahman010
    cin >> n >> k;
    int j = n;
    for(int i = 0;i < n;i++) {
        cin >> a[i];
        if(a[i] > 0 && j == n)
            j = i;
    }
    if(j == 0)
        return cout << a[k - 1] , 0;
    if(j == n)
        return cout << abs(a[n - k]) , 0;
    int mn = 1e9;
    for(int i = j;i < min(j + k , n);i++) {
        if(k - (i - j + 1) > j)
            continue;
        int req = 2 * a[i] + abs(a[j - (k - (i - j + 1))]);
        mn = min(mn , req);
    }
    for(int i = j - 1;i >= 0;i--) {
        if(k - (j - i) > n - j)
            continue;
        int req = 2 * abs(a[i]) + a[k - (j - i) + j - 1];
        mn = min(mn , req);
    }
    cout << mn;
    return 0;
}

Measured memory_bytes: 640
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std; 
int a,b;
int main(){
    cin>>a;
    int cnt=0;
    int ans=0;
    for (int i=1;i<=a;i++)
    {
        b=i;
        if (b%2==1) {for (int j=1;j<=b;j++)
                         if (b%j==0) cnt++;
                     if (cnt==8) ans++;
                     }
        cnt=0;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;


// Union-Find Disjoint Sets Library written in OOP manner, using both path compression and union by rank heuristics
// initialize: UnionFind UF(N)

class UnionFind {                                              // OOP style
private:
	vector<int> p, rank, setSize;
	// p = path toward the root of disjoint set; p[i] = i means it is root
	// rank = upper bound of the actual height of the tree; not reliable as accurate measure
	// setSize = size of each disjoint set

	int numSets;
public:
	UnionFind(int N) {
		setSize.assign(N, 1);
		numSets = N;
		rank.assign(N, 0);
		p.assign(N, 0);
		for (int i = 0; i < N; i++) p[i] = i;	// each belongs to its own set
	}

	int findSet(int i) {
		return (p[i] == i) ? i : (p[i] = findSet(p[i]));		// path compression: cut short of the path if possible
	}

	bool isSameSet(int i, int j) {
		return findSet(i) == findSet(j);
	}

	void unionSet(int i, int j) {
		if (!isSameSet(i, j)) {
			numSets--;
			int x = findSet(i), y = findSet(j);
			// rank is used to keep the tree short
			if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
			else {
				p[x] = y; setSize[y] += setSize[x];
				if (rank[x] == rank[y]) rank[y]++;
			}
		}
	}

	int numDisjointSets() {		// # of disjoint sets
		return numSets;
	}

	int sizeOfSet(int i) {		// size of set
		return setSize[findSet(i)];
	}
};


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

	long long n, m, i, j, k, s, aa, bb;
	cin >> n >> m;
	vector<long long> a(m), b(m), ans(m + 1);
	for (i = 0; i < m; i++) cin >> a[i] >> b[i];
	UnionFind uf(n + 1);

	s = 0;
	ans[m] = 0;
	for (i = m - 1; i >= 0; i--) {
		aa = uf.findSet(a[i]);
		bb = uf.findSet(b[i]);
		if (aa != bb) {
			s += (long long)uf.sizeOfSet(aa) * uf.sizeOfSet(bb);
			uf.unionSet(a[i], b[i]);
		}
		ans[i] = s;
	}

	for (i = 1; i <= m; i++) cout << n * (n - 1) / 2 - ans[i] << "\n";

	return 0;
}

Measured memory_bytes: 4864
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{

    static void Main(string[] args)
    {
        ProblemB();
    }
   static void ProblemB()
    {
        int N = int.Parse(System.Console.ReadLine());
        string S = System.Console.ReadLine();
        int K = int.Parse(System.Console.ReadLine());

        char kChar = S[K - 1];
        var sb = new StringBuilder();
        for (int i = 0; i < S.Length; i++)
        {
            if (S[i] == kChar)
            {
                sb.Append(kChar);
            }
            else
            {
                sb.Append('*');
            }
        }

        System.Console.WriteLine(sb.ToString());

    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
# define ll long long
# define mo 1000000009
using namespace std;
int main()
{
	int x;cin>>x;
	int j=5;
	for(int i=100;i<=100000;i=i+100)
	{
		if(x>=i&&x<=i+j){
		cout<<1;
		return 0;}
		j+=5;
	}
	cout<<0;
	return 0;
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
book_lists = [list(map(int, input().split())) for i in range(N)]
max_cost = 10**5*12+1
min_cost = max_cost

for i in range(1, 2**N):
    score_list = [0 for _ in range(M)]
    cost = 0
    for j in range(N):
        if i >> j & 1:
            cost += book_lists[j][0]
            for k in range(M):
                score_list[k] += book_lists[j][k+1]
    if min(score_list) >= X:
        min_cost = min(cost, min_cost)

print(min_cost if not min_cost == max_cost else -1)

Measured memory_bytes: 9112
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;
const int inf = 1e9;

int n, m, dis[N], from[N];
vector<int> adj[N];

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

	cin >> n >> m;

	for(int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	for(int i = 0; i < n; i++) {
		dis[i] = inf;
	}

	dis[0] = 0;

	queue<int> q;

	q.push(0);

	while(!q.empty()) {
		int u = q.front();
		q.pop();
		for(int v : adj[u]) {
			if(dis[v] > dis[u] + 1) {
				from[v] = u;
				dis[v] = dis[u] + 1;
				q.push(v);
			}
		}
	}

	for(int i = 1; i < n; i++) {
		if(dis[i] == inf) {
			cout << "No";
			exit(0);
		}
	}

	cout << "Yes\n";

	for(int i = 1; i < n; i++) {
		cout << from[i] + 1 << "\n";
	}

	
	return 0;
}


Measured memory_bytes: 10860
N = int(input())
xyh = []
xyh1 = []
for _ in range(N):
	x0, y0, h0 = map(int, input().split())
	xyh.append([x0,y0,h0])
	if h0 > 0:
		xyh1.append([x0,y0,h0])

def absum(x, y, h, Cx, Cy):
	return abs(x - Cx) + abs(y - Cy) + h

if len(xyh1) > 1:
	for Cx in range(101):
		for Cy in range(101):
			for i in range(len(xyh1)-1):
				if absum(xyh1[i][0], xyh1[i][1], xyh1[i][2], Cx, Cy) != absum(xyh1[i+1][0], xyh1[i+1][1], xyh1[i+1][2], Cx, Cy):
					break
			else:
				H = absum(xyh1[i][0], xyh1[i][1], xyh1[i][2], Cx, Cy)
				print(Cx, Cy, H)
else:
	print(xyh1[0][0], xyh1[0][1], xyh1[0][2])

Measured memory_bytes: 3064
N = int(input())
D = [set(list(map(int,input().split()))) for x in range(N)]
ren = 0

for i in range(N):
    if len(D[i]) == 1:
        ren += 1
    else:
        ren = 0

    if ren == 3:
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
const int mod=1e9+7;
const int maxn=2e5;
int main()
{
    //freopen("ce.in","r",stdin);
    int a,n;
    cin>>a>>n;
    while(n--)
    {
        int x;
        scanf("%d",&x);
        a-=x;
    }
    if(a<=0) puts("Yes");else puts("No");
    return 0;
}

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

int main(void)
{
  int n,i,ans;
  double t,temp,a,h,min=1000;
  scanf("%d%lf%lf",&n,&t,&a);
  for(i=0;i<n;i++){
    scanf("%lf",&h);
    temp=t-h*0.006;
    if(fabs(a-temp)<min){
      min=fabs(a-temp);
      ans=i;
    }
  }
  printf("%d",ans+1);
  return 0;

}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	int N,x;
	cin>>N>>x;
	int y=x;
	vll A;
	ll sum=0;
	for(int i=0;i<N;i++){
		ll a;
		cin>>a;
		sum+=a;
		A.pb(a);
	}
	sort(A.begin(),A.end());
	int ans=0;
	for(int i=0;i<N;i++){
		if(x>=A[i]){
			x-=A[i];
			ans++;
		}
		//cout<<ans<<endl;
	}
	//cout<<x<<" "<<sum<<endl;
	if(ans==N && y>sum)
		ans--;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	char a[1] = {0};

	scanf("%c", &a[0]);

	if(a[0]>=65&&a[0]<=90)
	{
		printf("A");
	}

	if (a[0] >= 97 && a[0] <= 122)
	{
		printf("a");
	}
	return 0;
}

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

int main()
{
    string s;
   vector<char> T;

    cin >> s;
    int cnt = 0;

    for (int i = 0; i < (int)s.length(); i++) {
        if (!T.empty() && T.back() != s[i]) T.pop_back(), cnt += 2;

        else T.push_back(s[i]);
    }

    cout << cnt << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll A,B,C,K;
int main(){
    cin>>A>>B>>C>>K;
	if(A>=K){
		cout<<K<<endl;
		return 0;
	}
	if(A+B>=K){
		cout<<A;
		return 0;
	}
	cout<<A-(K-(A+B));


    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define COUT(x) cout << (x) << endl
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const ll LINF = 1e17;
const int INF = 1001001001;
const int MOD = 1000000007;

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


int main() {
    ll H, N; cin >> H >> N;
    vector<ll> A(N);
    ll ans = 0;
    rep(i, N) {
        cin >> A[i];
        ans += A[i];
    }
    if(ans >= H) COUT("Yes");
    else COUT("No");

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

vector<int> all(51);
vector<int> pate(51);

int dfs(int level, int remain){
  if(level == 0) return 1;

  int ret = 0;
  if(remain >= 1) remain--;

  if(remain >= 1){
    if(all[level-1] <= remain){
      remain -= all[level-1];
      ret += pate[level-1];
    }else{
      ret += dfs(level-1, remain);
      remain = 0;
    }
  }

  if(remain >= 1){
    remain--;
    ret++;
  }


  if(remain >= 1){
    if(all[level-1] <= remain){
      remain -= all[level-1];
      ret += pate[level-1];
    }else{
      ret += dfs(level-1, remain);
      remain = 0;
    }
  }

  if(remain >= 1) remain--;
  
  return ret;
}

signed main() {
  int N, X;
  cin >> N >> X;

  all[0] = 1;
  pate[0] = 1;
  FOR(i, 1, 50){
    all[i] = all[i-1]*2+3;
    pate[i] = pate[i-1]*2+1;
  }

  cout << dfs(N, X) << "\n";

  return 0;
}

Measured memory_bytes: 256
/*
  AtCoder Beginner Contest 102
  D - Equal Cur
*/

#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<limits>
using namespace std;

unsigned int N;
long long A[200001];
unsigned int l, c, r;

long long getVal() {
  long long prev_diff, curr_diff;
  long long cval = A[c], eval = A[N];

  // left side
  prev_diff = numeric_limits<long long>::max();
  while (1) {
    curr_diff = abs((cval - A[l]) - (A[l] - 0));
    if (curr_diff > prev_diff) {
      --l;
      break;
    }

    prev_diff = curr_diff;
    ++l;
    if (l >= c) {
      --l;
      break;
    }
  }

  // right side
  prev_diff = numeric_limits<long long>::max();
  while(1) {
    curr_diff = abs((eval - A[r]) - (A[r] - cval));
    if (curr_diff > prev_diff) {
      --r;
      break;
    }

    prev_diff = curr_diff;
    ++r;
    if (r >= N) {
      --r;
      break;
    }
  }

  // calc val
  long long sum[4];
  sum[0] = A[l] - 0;
  sum[1] = cval - A[l];
  sum[2] = A[r] - cval;
  sum[3] = eval - A[r];
  long long maxval = *max_element(sum, sum+4);
  long long minval = *min_element(sum, sum+4);
  return maxval - minval;
}

int main() {
  scanf("%u", &N);

  A[0] = 0;
  for (int i = 0; i < N; ++i) {
    scanf("%llu", &A[i+1]);
    A[i+1] += A[i];
  }

  long long minval = numeric_limits<long long>::max();
  for (l = 1, c = 2, r = 3; c <= N - 2; ++c) {
    if (r <= c) r = c + 1;   
    long long val = getVal();
    if (val < minval) minval = val;
  }

  printf("%llu\n", minval);
  return 0;
}

Measured memory_bytes: 1792
n = int(input())
graph = [[0]*(n+1) for _ in range(n+1)]
if n%2 == 0:
  l = [[i,n-i+1] for i in range(1,n//2+1)]
else:
  l = [[i,n-i] for i in range(1,n//2+1)]+[[n]]
for i in range(len(l)):
  for j in l[i]:
    for k in range(1,n+1):
      if k not in l[i]:
        graph[j][k] = 1
ans = 0
l = []
for i in range(1,n):
  for j in range(i+1,n+1):
    if graph[i][j]:
      ans += 1
      l.append([i,j])
print(ans)
for lst in l:
  print(*lst)

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end())
#define pb push_back
#define mp make_pair
#define MODP(A,B) A=(A+B)%mod
typedef pair<ll,ll> P;
typedef pair<double,double> Pd;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
    string S; cin>>S;
    string ans="Yes";
    if(S.at(2)!=S.at(3)) ans="No";
    if(S.at(4)!=S.at(5)) ans="No";
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-'0', (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-'0')<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
int main() {
	int n=rd();
	std::vector<int> size(n, 1), fa(n);
	std::vector<long long> depsum(n);
	std::map<long long, int> id;
	for(int i=0; i<n; ++i) id.emplace(read<long long>(), i);
	for(auto it=id.end(); --it!=id.begin(); ) {
		int x=it->second;
		auto i=id.find(it->first+2*size[x]-n);
		if(2*size[x]>=n||i==id.end()) {
			puts("-1");
			return 0;
		}
		fa[x]=i->second;
		size[fa[x]]+=size[x];
		depsum[fa[x]]+=depsum[x]+size[x];
	}
	int root=id.begin()->second;
	if(depsum[root]!=id.begin()->first) {
		puts("-1");
		return 0;
	}
	for(int i=0; i<n; ++i) if(i!=root) printf("%d %d\n", fa[i]+1, i+1);
	return 0;
}


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

int main() {
  long N, K;
  cin >> N >> K;

  vector<int> vec(N);

  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  sort(vec.begin(), vec.end());

  long ans = 0;

  for (int i = 0; i < N - K; i++) {
    ans += vec.at(i);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest
{
	class Program
	{
		static void Main()
		{
            var abc = Console.ReadLine().Split().Select(int.Parse);
            Console.WriteLine(abc.Sum() - abc.Max());
#if DEBUG
            Console.ReadKey();
#endif
		}
	}
}

Measured memory_bytes: 11220
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <float.h>
#include <random>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
#define debugArrayP(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge].first<< " " << x[hoge].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/2;
const ll MOD = 1e9+7;


int N;
double dp[3010];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>N;
  dp[0]=1;
  repeat(i,N){
    double p;cin>>p;
    for(int j=i+1;j>=0;j--){
      if(j>0)dp[j] = dp[j]*(1-p)+dp[j-1]*p;
      else dp[j] = dp[j]*(1-p);
    }
  }
  double ans=0;
  for(int i=(N+1)/2;i<=N;i++){
    ans+=dp[i];
  }
  printf("%.10lf\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int W, H, x, y, r;

	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	if((r<=x) && (r<=y) && (0<x) && (x<W) && (0<y) && (y<H))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 584
{-# LANGUAGE BangPatterns #-}
import Control.Arrow (second)
import Control.Monad
import Control.Monad.Fix
import Data.Foldable (foldl')
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import Data.ByteString.Internal (accursedUnutterablePerformIO)

uread :: VUM.Unbox a => Int -> VUM.IOVector a -> a
uread i v = accursedUnutterablePerformIO $ VUM.unsafeRead v i

uwrite :: VUM.Unbox a => Int -> a -> VUM.IOVector a -> VUM.IOVector a
uwrite i a v = accursedUnutterablePerformIO $ VUM.unsafeWrite v i a >> return v

uswap :: VUM.Unbox a => Int -> Int -> VUM.IOVector a -> VUM.IOVector a
uswap i j v = accursedUnutterablePerformIO $ VUM.unsafeSwap v i j >> return v

ufreeze :: VUM.Unbox a => VUM.IOVector a -> VU.Vector a
ufreeze v = accursedUnutterablePerformIO $ VU.unsafeFreeze v

uthaw :: VUM.Unbox a => VU.Vector a -> VUM.IOVector a
uthaw v = accursedUnutterablePerformIO $ VU.unsafeThaw v

newtype UnionFind = UnionFind (VUM.IOVector Int, VUM.IOVector Int)

findUF :: UnionFind -> Int -> Int
findUF (UnionFind (elems, _)) k = fix
  ( \f (elems, k, path) -> case uread k elems of
    n | n == k -> foldl' (\acc p -> uwrite p n acc) elems path `seq` n
    n          -> f (elems, n, n : path)
  )
  (elems, k, [k])

sizeUF :: UnionFind -> Int -> Int
sizeUF (UnionFind (_, sizes)) i = uread i sizes

uwriteElem :: Int -> Int -> UnionFind -> UnionFind
uwriteElem i a (UnionFind (elem, sizes)) = UnionFind (uwrite i a elem, sizes)

uwriteSize :: Int -> Int -> UnionFind -> UnionFind
uwriteSize i a (UnionFind (elem, sizes)) = UnionFind (elem, uwrite i a sizes)

unionUF :: UnionFind -> Int -> Int -> (UnionFind, Int)
unionUF uf i j =
  let pi = findUF uf i
      pj = findUF uf j
      si = sizeUF uf pi
      sj = sizeUF uf pj
  in  pi `seq` pj `seq` if pi == pj
        then (uf, 0)
        else
          let sij = si + sj
          in  ( if si < sj
                then uwriteSize pi 0 $ uwriteSize pj sij $ uwriteElem pi pj uf
                else uwriteSize pj 0 $ uwriteSize pi sij $ uwriteElem pj pi uf
              , si * sj
              )

comb2 k = k * (k - 1) `div` 2

solve :: Int -> Int -> VU.Vector (Int, Int) -> VU.Vector Int
solve n m abs = ufreeze $ (\(_, _, acc) -> acc) $ VU.foldr'
  go
  (group, 0, accursedUnutterablePerformIO $ VUM.replicate m 0)
  abs
 where
  go (a, b) (uf, k, acc) =
    let (uf', d) = unionUF uf a b
        prev     = if k == 0 then 0 else uread (k - 1) acc
    in  (uf', k + 1, uwrite k (prev + d) acc)

  nC2 = comb2 n

  group :: UnionFind
  group = UnionFind
    (uthaw $ VU.enumFromN 0 n, accursedUnutterablePerformIO $ VUM.replicate n 1)

main = do
  let readInt = fmap (second B.tail) . B.readInt

  nm  <- VU.unfoldrN 2 readInt <$> B.getLine
  abs <- VU.replicateM
    (nm VU.! 1)
    (   (\vec -> (vec VU.! 0 - 1, vec VU.! 1 - 1))
    .   VU.unfoldrN 2 readInt
    <$> B.getLine
    )

  let solutions = solve (nm VU.! 0) (nm VU.! 1) abs
  let nC2       = comb2 $ nm VU.! 0

  mapM_ (print . (nC2 -) . (solutions VU.!)) [nm VU.! 1 - 2, nm VU.! 1 - 3 .. 0]
  print nC2


Measured memory_bytes: 34044
//
// binary 行列 (行列累乗と、掃き出し法)
//
// verified:
//   みんなのプロコン 2019 E - Odd Subrectangles
//     https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_e
// 


#include <iostream>
#include <vector>
#include <bitset>
using namespace std;


const int MAX_ROW = 510; // to be set appropriately
const int MAX_COL = 510; // to be set appropriately
struct BitMatrix {
    int H, W;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
    inline bitset<MAX_COL>& operator [] (int i) {return val[i];}
};

ostream& operator << (ostream& s, BitMatrix A) {
    s << endl; 
    for (int i = 0; i < A.H; ++i) {
        for (int j = 0; j < A.W; ++j) {
            s << A[i][j] << ", ";
        }
        s << endl;
    }
    return s;
}

inline BitMatrix operator * (BitMatrix A, BitMatrix B) {
    BitMatrix R(A.H, B.W);
    BitMatrix tB(B.W, B.H);
    for (int i = 0; i < tB.H; ++i) for (int j = 0; j < tB.W; ++j) tB[i][j] = B[j][i];
    for (int i = 0; i < R.H; ++i) for (int j = 0; j < R.W; ++j) R[i][j] = (A[i] & tB[j]).any();
    return R;
}

inline BitMatrix pow(BitMatrix A, long long n) {
    BitMatrix R(A.H, A.H);
    for (int i = 0; i < A.H; ++i) R[i][i] = 1;
    while (n > 0) {
        if (n & 1) R = R * A;
        A = A * A;
        n >>= 1;
    }
    return R;
}

int GaussJordan(BitMatrix &A, bool is_extended = false) {
    int rank = 0;
    for (int col = 0; col < A.W; ++col) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        for (int row = rank; row < A.H; ++row) {
            if (A[row][col]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        for (int row = 0; row < A.H; ++row) {
            if (row != rank && A[row][col]) A[row] ^= A[rank];
        }
        ++rank;
    }
    return rank;
}

int linear_equation(BitMatrix A, vector<int> b, vector<int> &res) {
    int m = A.H, n = A.W;
    BitMatrix M(m, n + 1);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) M[i][j] = A[i][j];
        M[i][n] = b[i];
    }
    int rank = GaussJordan(M, true);

    // check if it has no solution
    for (int row = rank; row < m; ++row) if (M[row][n]) return -1;

    // answer
    res.assign(n, 0);
    for (int i = 0; i < rank; ++i) res[i] = M[i][n];
    return rank;
};


const int MOD = 998244353;
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() { 
    int N, M; cin >> N >> M;
    BitMatrix A(N, M);
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < M; ++j) {
            int a; cin >> a;
            if (a) A[i][j] = 1;
        }
    }
    vector<int> res;
    int r = GaussJordan(A);  
    cout << (modpow(2LL, N+M-1, MOD) - modpow(2LL, N+M-r-1, MOD) + MOD) % MOD << endl;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    A, B, C, D = MAP()

    for i in range(101):
        A -= D
        C -= B
        if C <= 0:
            print("Yes")
            sys.exit()
        elif A <= 0:
            print("No")
            sys.exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 10044
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

string S = "12+1290";
int cur = 0;

int digit() {
    assert(isdigit(S[cur]));
    int n = S[cur] - '0';
    cur++;
    return n;
}

ll number() {
    ll n = digit();
    while (cur < S.size() && isdigit(S[cur])) {
        n = n * 10 + digit();
    }
    return n;
}

ll expression();

ll factor() {
    if (S[cur] != '(') {
        return number();
    }
    cur++;
    int n = expression();
    assert(S[cur] == ')');
    cur += 1;
    return n;
}

ll term() {
    ll a = factor();
    while (cur < S.size() && (S[cur] == '*' || S[cur] == '/')) {
        char op = S[cur];
        cur++;
        ll b = factor();
        if (op == '*') {
            a *= b;
        } else {
            a /= b;
        }
    }
    return a;
}

ll expression() {
    ll a = term();
    while (cur < S.size() && (S[cur] == '+' || S[cur] == '-')) {
        char op = S[cur];
        cur++;
        ll b = term();
        if (op == '+') {
            a += b;
        } else {
            a -= b;
        }
    }
    return a;
}

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> S;
        cur = 0;
        ll ans = expression();
        cout << ans << endl;
    }
}



Measured memory_bytes: 3104
#include<stdio.h>
#include<string.h>
#include<math.h>
using namespace std;
int main()
{
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	int sum=0;
	sum=m/n;
	if(sum<=k)
	printf("%d\n",sum);
	else
	printf("%d\n",k);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

const int N = 400005;

int a[N*2];
int n,k;
char s[N];

int main(){
	scanf("%d%d",&n,&k);
	scanf("%s",s+1);
	fo(i,1,n)a[i]=s[i]=='B';
	int nt=0;
	if (k<=n*2){
		int he=1,ta=n;
		fo(i,1,k){
			if ((a[he]^nt)==1){
				nt^=1;
				he++,ta++;
				a[ta]=nt;
			}
			else a[he]^=1;
		}
		fo(i,he,ta)
		if ((a[i]^nt)==1)putchar('B');else putchar('A');
	}
	else{
		if (n&1) putchar('A'+!(k&1));
		fo(i,1,n/2) putchar('B'),putchar('A');
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 2432
N = gets.chomp.to_i
A = gets.chomp.split(" ").map(&:to_i)

X = []
a_odd = (0...N).select {|i| i % 2 == 1 }.map { |i| A[i] }
a_even = (0...N).select {|i| i % 2 == 0 }.map { |i| A[i] }
X[0] = a_even.inject(:+) - a_odd.inject(:+)
1.upto(N-1) do |i|
  X[i] = 2 * (A[i-1] - X[i-1] / 2)
end
puts X.join(" ")


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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, x, y;
    cin >> n >> x >> y;
    vector<vector<int>> d = vector<vector<int>>(n + 1, vector<int>(n + 1));
    vector<int> a = vector<int>(n);
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            d[i][j] = abs(i - j);
        }
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = i + 1; j <= n; j++)
        {
            d[i][j] = min(d[i][j], d[i][x] + d[y][j] + 1);
            a[d[i][j]]++;
        }
    }
    for (int i = 1; i <= n - 1; i++)
    {
        cout << a[i] << "\n";
    }
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
#define ll long long
#define mod pow(10,9)+7

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	string d;
	for(unsigned int i=0;i<s.length();i++)
	{
		if(s[i]=='0'||s[i]=='1')
			d.append(s,i,1);
		if(s[i]=='B'&&d.length()!=0)
			d.pop_back();
	}
	cout<<d<<endl;
	return 0;
}


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

struct stu{
	int roll, att;
};

bool comp(const stu a, const stu b){
	return a.att<b.att;
}

int main()
{
	int i, n;
	cin>>n;
	stu a[1000000];
	for(i=0;i<n;i++){
		cin>>a[i].att;
		a[i].roll = i+1;
	}

	sort(a, a+n, comp);

	for (i = 0; i < n; ++i)
	{
		cout << a[i].roll;
		if(i==n-1)cout << endl;
		else cout << " ";
	}
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll N;
  ll m = pow(10, 6)+2;
  cin >> N;
  vector<ll> a(N+1);
  vector<ll> vec(m, 0);
  REP(i, N) {
    ll x;
    cin >> x;
    a[i] = x;
    if (vec[x] != 0) {
      vec[x] = 2;
      continue;
    }

    for(int i = x; i < m; i += x) {
      vec[i]++;
    }
  }
  ll ans = 0;
  REP(i, N) {
    if (vec[a[i]] == 1) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12740
import sys

def Y_N(a,b):
    for i in range(a+1):
        if 2 * (a-i) + 4 * i == b:
            return "Yes"
    return "No"

if __name__ == '__main__':
  input = sys.stdin.readline

  s = input().rstrip()

  ar = list(map(int,s.split()))
  
  print(Y_N(ar[0],ar[1]))

Measured memory_bytes: 9180
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		int N = S.length();
		char[] C = S.toCharArray();
		char A0 = '0';
		char A1 = '1';
		int count0 =0;
		int count1 = 0;
		for(int i=0; i<N; i++) {
			if( C[i]!=A0){
				count0++;            	
            }
			if(A0=='0') {
				A0 ='1';
			}else {
				A0 ='0';
			}
			if( C[i]!=A1){
				count1++;            	
            }
			if(A1=='0') {
				A1 ='1';
			}else {
				A1='0';
			}
		}
		System.out.println(Math.min(count0,count1));
	}		
}

Measured memory_bytes: 27092
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
typedef long long ll;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define swap(a,b) {ll tp=a;a=b;b=tp;}

int p[10] = {0};
int my_next_perm(int n){
    int i, j, tmp;
    if(n <= 1) return 0;
    for(i = n-1; i > 0 && p[i-1] >= p[i]; i--);
    if(i == 0) return 0;
    for(j = n-1; j > i && p[i-1] >= p[j]; j--);
    swap(p[i-1], p[j]);
    for(j = n-1; i < j; i++, j--)
        swap(p[i], p[j]);
    return 1;
}

int P[10] = {0}, Q[10] = {0};
int main(){
    int N; scanf("%d", &N);
    rep(i,N) scanf("%d", P+i);
    rep(i,N) scanf("%d", Q+i);

    int p_a,q_b,cnt=0;
    rep(i,N) p[i] = i+1;
    do{
        if(memcmp(P,p,sizeof(p)) == 0) p_a = cnt;
        if(memcmp(Q,p,sizeof(p)) == 0) q_b = cnt;
        cnt++;
    }while(my_next_perm(N));
    
    int ans = abs(p_a-q_b);
    printf("%d\n", ans);
    return 0;
}

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

int main(){
    int N, M , X;
    cin >> N >> M >> X;
    int small = 0;
    int big = 0;
    for (int i = 0; i < M; i++){
        int a;
        cin >> a;
        if (a < X){
            small++;
        }
        else{
            big++;
        }
    }
    cout << min(small, big) << endl;
}

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

using namespace std;
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PI; 
typedef pair<LL,LL> PLL;
typedef unsigned long long ULL;
typedef pair<double,double> PD;

#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())

#define PB push_back
#define IN insert
#define ST first
#define ND second
#define INF 2000000011
#define MOD 1000000007

#define MAXSIZE 1000010

int n;
LL w;
LL dp[MAXSIZE];
int prog=0;


int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n>>w;
	
	FOR(i,1,MAXSIZE-1)
		dp[i]=INF;
		
	REP(i,n){
		int v1;
		LL w1;
		cin>>w1>>v1;
		FORD(j,prog,0)
			dp[j+v1]=min(dp[j+v1],dp[j]+w1);
		prog+=v1;
	}
	
	int wyn=0;
	FOR(i,1,prog){
		if(dp[i]<=w)
			wyn=i;
	}
	
	cout<<wyn;
	
	return 0;
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<long long> X, L;
  for (int i = 0; i < N; i++){
    long long Xi, Li;
    cin >> Xi >> Li;
    X.push_back(Xi);
    L.push_back(Li);
  }

  vector<pair<long long, long long> > A;
  for (int i = 0; i < N; i++){
    A.push_back(make_pair(X[i] + L[i], X[i] - L[i]));
  }
  
  sort(A.begin(), A.end());

  int ans=1;
  long long p = A[0].first;
  for (int i = 1; i < N; i++){
    if (A[i].second >= p){
      ans++;
      p = A[i].first;
    }
  }

  printf("%d\n", ans);

}


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

const int INF = 2e9 + 10;
const int N = 1e5 + 10;

int main() {

    int n; scanf("%d", &n);

    vector < vector <int> > dp(n + 1, vector <int> (4, -1));

    // 0 - nothing
    // 1 - a
    // 2 - b
    // 3 - c
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        vector <int> v(3);
        scanf("%d%d%d", &v[0], &v[1], &v[2]);

        for (int prev = 0; prev < 4; prev++) {
            if (dp[i][prev] == -1) continue;

            for (int nxt = 1; nxt < 4; nxt++) {
                if (nxt == prev) continue;

                int new_profit = dp[i][prev] + v[nxt - 1];
                dp[i + 1][nxt] = max(dp[i + 1][nxt], new_profit);
            }
        }
    }

    int max_result = 0;
    for (int j = 0; j < 4; j++) {
        max_result = max(max_result, dp[n][j]);
    }

    printf("%d\n", max_result);

    return 0;
}

Measured memory_bytes: 5760