akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bitset>
#include <string>

class MonochromeImage{
public:
	static constexpr std::size_t MaxSize{50};

private:
	using DataType = std::bitset<MaxSize * MaxSize>;

public:
	MonochromeImage(std::size_t size) : m_size{size}, m_valid{}, m_data{} {}

	void set(std::size_t x, std::size_t y, bool value = true) {
		m_valid.set(index(x, y));
		m_data.set(index(x, y), value);
	}
	void reset(std::size_t x, std::size_t y) {
		m_valid.reset(index(x, y));
		m_data.reset(index(x, y));
	}

	std::size_t size() const { return m_size; }
	DataType valid() const { return m_valid; }
	DataType data() const { return m_data; }
	DataType valid_data() const { return (m_data & m_valid); }

	bool is_including(const MonochromeImage& image) {
		if (m_size < image.size()) { return false; }
		for (std::size_t i = 0; i <= (m_size - image.size()); i++) {
			for (std::size_t j = 0; j <= (m_size - image.size()); j++) {
				std::size_t offset = index(i, j);
				if ((valid_data() & (image.valid() << offset))
							== (image.valid_data() << offset)) {
					return true;
				}
			}
		}
		return false;
	}

private:
	static constexpr std::size_t index(std::size_t x, std::size_t y) {
		return x * MaxSize + y;
	}

	std::size_t m_size;
	DataType m_valid;
	DataType m_data;
};

inline std::istream& operator>>(std::istream& is, MonochromeImage& image) {
	for (std::size_t i = 0; i < image.size(); i++) {
		std::string buffer;
		is >> buffer;
		for (std::size_t j = 0; j < image.size(); j++) {
			switch (buffer.at(j)) {
			case '#' : image.set(i, j, true); break;
			case '.' : image.set(i, j, false); break;
			default  : std::cerr << "ERROR: no matching image color!" << std::endl; break;
			}
		}
	}
	return is;
}

int main()
{
	std::size_t a_size, b_size;
	std::cin >> a_size >> b_size;
	
	MonochromeImage a{a_size};
	MonochromeImage b{b_size};

	std::cin >> a >> b;

	if (a.is_including(b)) {
		std::cout << "Yes" << std::endl;
	} else {
		std::cout << "No" << std::endl;
	}

	return 0;
}

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

using namespace std;

const int N = 24;

int n, x[N], y[N], r[N], c[N], p[N];
bool vis[1<<N];

bool lap(int a, int b){
  int d = (x[a] - x[b]) * (x[a] - x[b]) + (y[a] - y[b]) * (y[a] - y[b]);
  return d < r[a] * r[a] + 2 * r[a] * r[b] + r[b] * r[b];
}

int rec(int s){
  //cout << "#" << s << endl;
  int res = 0;
  vis[s] = true;
  for(int i=0;i<n;i++){
    if((s >> i & 1) == 0) continue;
    for(int j=i+1;j<n;j++){
      if((s >> j & 1) == 0) continue;
      if(c[i] != c[j]) continue;
      if((p[i] & s) == 0 && (p[j] & s) == 0){
        s &= ~(1 << i);
        if((p[j] & s) == 0){
          s &= ~(1 << j);
          if(!vis[s]) res = max(res, rec(s));
          s |= 1 << j;
        }
        s |= 1 << i;
      }
    }
  }
  if(s == (1 << n) - 1) return res;
  return res + 2;
}

main(){
  while(cin >> n && n){
    for(int i=0;i<n;i++) cin >> x[i] >> y[i] >> r[i] >> c[i];
    fill(p, p+n, 0);
    fill(vis, vis+(1<<n), false);
    for(int i=0;i<n;i++) for(int j=0;j<i;j++) if(lap(i, j)) p[i] |= 1 << j;
    //for(int i=0;i<n;i++) cout << p[i] << ' '; cout << endl;
    cout << rec((1<<n)-1) << endl;
    //break;
  }
}

Measured memory_bytes: 17544
import itertools

def prime_boolean_table(n):
    primes = [True] * (n + 1)
    primes[0] = False
    primes[1] = False
    for i in range(2, n + 1):
        if primes[i]:
            for j in range(i + i, n + 1, i):
                primes[j] = False
    return primes

def main():
    pl = prime_boolean_table(10**5)
    ql = [0]*(10**5+1)
    for i in range(1,10**5+1):
        if pl[i] and pl[(i+1)//2]:
            ql[i] += 1
    ql = list(itertools.accumulate(ql))
    q = int(input())
    for _ in range(q):
        l,r = map(int,input().split())
        print(ql[r]-ql[l-1])

if __name__=='__main__':
    main()

Measured memory_bytes: 7716
#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(0);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";


using namespace std;

ll a,b,c,d,e;

int main(){
FLASH;
cin>>a>>b>>c>>d>>e;
if(a==0)cout<<1<<endl;
else if(b==0)cout<<2<<endl;
else if(c==0)cout<<3<<endl;
else if(d==0)cout<<4<<endl;
else cout<<5<<endl;






return 0;
} 


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

vector<int>to[100005];
int n;

vector<int>dist;
void dfs(int v,int d = 0, int p = -1) {
 dist[v] = d;
 for (int u : to[v]) {
  if (u == p) continue;
  dfs(u, d+1, v);
 }
}

vector<int>calcDist(int s) {
 dist = vector<int>(n);
 dfs(s);
 return dist;
}

int main() {
 cin >> n;
 int s, t;
 cin >> s >> t;
 --s;
 --t;
 for (int i=0; i < n-1; i++) {
  int a, b;
  cin >> a >> b;
  --a;
  --b;
  to[a].push_back(b);
  to[b].push_back(a);
 }

 vector<int>distS = calcDist(s);
 vector<int>distT = calcDist(t);

 int mx = 0;
 for (int i = 0; i < n; i++) {
  if (distS[i] < distT[i]) {
   mx = max(mx, distT[i]);
  }
 }
 int ans = mx - 1;
 cout << ans << endl;
 return 0;
}


Measured memory_bytes: 10744
# https://atcoder.jp/contests/abc079/tasks/abc079_b
n = int(input())


def func(n, memo):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    if n - 1 in memo:
        l = memo[n - 1]
    else:
        l = func(n - 1, memo)
        memo[n - 1] = l
    if n - 2 in memo:
        r = memo[n - 2]
    else:
        r = func(n - 2, memo)
        memo[n - 2] = r
    return l + r

memo = {}
ans = func(n, memo)
print(ans)

Measured memory_bytes: 38480
void main() {
	auto ip = readAs!(int[]), N = ip[0], M = ip[1];
	auto uf = new UnionFind!int(M+1);
	auto rbt = redBlackTree!int;
	foreach(i; 0..N) readAs!(int[])[1..$].tee!(i => rbt.insert(i)).array.zurasu(2).filter!(i => i.length == 2).each!(v => uf.unite(v[0], v[1]));
	auto rbt2 = redBlackTree!int;
	foreach(v; rbt) rbt2.insert(uf.root(v));
	if(rbt2.array.length == 1) writeln("YES");
	else writeln("NO");
}

// AtCoder上のDMDのバージョンが低いので、slideが使えない。代替策。
int[][] zurasu(int[] arr, ulong n) {
	typeof(return) res;
	foreach(i; 0..max(0, arr.length.to!int-n+1)) {
		res ~= arr[i..i+n];
	}
	return res;
}

class UnionFind(T) {
	T[] arr;
	this(ulong n) {
		arr.length = n;
		arr[] = -1;
	}
	T root(T x) {
		return arr[x] < 0 ? x : root(arr[x]);
	}
	bool same(T x, T y) {
		return root(x) == root(y);
	}
	bool unite(T x, T y) {
		x = root(x);
		y = root(y);
		if(x == y) return false;
		if(arr[x] > arr[y]) swap(x, y);
		arr[x] += arr[y];
		arr[y] = x;
		return true;
	}
	T size(T a) {
		return -arr[root(a)];
	}
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

using namespace std;

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

  vector<int> h(N, 0), dp(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }

  dp[1] = abs(h[1] - h[0]);
  for (int j = 2; j < N; j++) {
    dp[j] = min(abs(h[j] - h[j-1]) + dp[j-1], abs(h[j] - h[j-2]) + dp[j-2]);
  }

  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    
    int n;
    int x;
    int l;
    int sum = 0;
    int loop = 1;
    
    scanf("%d%d", &n, &x);
    
    for(int i=0; i<n; i++){
        
        scanf("%d", &l);
        sum += l;
        
        if(sum>x){
            
            printf("%d", loop);
            return 0;
            
        }
        
        loop += 1;
        
    }
    
    printf("%d", loop);
    return 0;
    
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    string t;
    cin >> t;
    int c=0,m=0;
    for(int i=0;i<t.size();i++){
        if(t[i]=='A'||t[i]=='T'||t[i]=='C'||t[i]=='G'){
            c++;
        }
        else{
            if(c>m){
                m=c;
                c=0;
            }
        }
    }
    if(c>m) m=c;
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;


struct UnionFind {
	VI par;
	UnionFind(int N) :par(N) {
		REP(i, N)par[i] = i;
	}
	int root(int x) {
		if (par[x] == x)return x;
		return par[x] = root(par[x]);
	}
	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)return;
		par[rx] = ry;
	}
	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

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

	string S, T; cin >> S >> T;
	if (S.size() > T.size()) {
		cout << "GREATER" << endl;
		return 0;
	}
	else if (S.size() < T.size()) {
		cout << "LESS" << endl;
		return 0;
	}
	if (S > T) {
		cout << "GREATER" << endl;
		return 0;
	}
	else if (S < T) {
		cout << "LESS" << endl;
		return 0;
	}

	cout << "EQUAL" << endl;

	return 0;
}



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

int blood[101];

int main(){

	int n, k;
	while (std::cin >> n >> k, n || k){

		memset(blood, 0, sizeof(blood));

		for (int i = 0; i < k; i++){
			std::cin >> blood[i];
		}
		for (int i = 0; i < n; i++){
			for (int j = 0; j < k; j++){
				int a;
				std::cin >> a;
				blood[j] -= a;
			}
		}

		for (int i = 0; i < k; i++){
			if (blood[i] < 0){
				std::cout << "No" << std::endl;
				break;
			}
			if (i == k - 1)std::cout << "Yes" << std::endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
using namespace std;
int main()
{
    string s; cin >> s;
    int count=0;
    if(s.size()%2)
    {
         cout << "No";
         return 0;
    }
    for(int i=0;i<s.size();i+=2)
        if(s[i]=='h'&&s[i+1]=='i')
            count++;
    if(count==s.size()/2) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), H = ip[0], W = ip[1];
	auto N = ri;
	auto a = readAs!(int[]);
	a.enumerate(1) // それぞれの個数の配列に、担当する値を付ける
		.map!(i => i.index.repeat(i.value)) // それぞれ必要な分だけ値を配列に入れておく
		.join // 統合(concat) so that 一列に全部並ぶ
		//.slide(W, W) // W個ごとに要素を分ける。バージョンが低いのでAtCoder上でコンパイルが通らない
		.wakeru(W)
		.enumerate // 分けた要素(配列)に添字をつける
		.map!(i => i.index % 2 == 1 ? i.value.retro.array : i.value) // 奇数番目は逆にする
		.each!(i => writefln("%(%s %)", i)); // 出力
	// 一行シリーズ
}

int[][] wakeru(int[] arr, ulong n) {
	int[][] res;
	foreach(i; 0..arr.length / n) {
		res ~= arr[i*n..(i+1)*n];
	}
	return res;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 636
using System;
using System.IO;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var max = arr.Max();
        var count = new int[max + 1];
        for (int i = 0; i < n; i++)
        {
            count[arr[i]]++;
        }
        var isMultiples = Enumerable.Repeat(true, max + 1).ToArray();
        foreach (var value in arr.Distinct())
        {
            for (int i = value * 2; i <= max; i += value)
                isMultiples[i] = false;
        }
        var answer = 0;
        for (int i = 0; i < n; i++)
        {
            if (isMultiples[arr[i]] && count[arr[i]] == 1) answer++;
        }
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}

Measured memory_bytes: 53092
import sys
from collections import defaultdict
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
tmp = list(map(int, input().split()))
# 偶奇で分けて辞書作る
odd = defaultdict(int)
even = defaultdict(int)
for i in range(n):
    if i % 2 == 0:
        odd[tmp[i]] += 1
    else:
        even[tmp[i]] += 1

# 降順ソート
odd = sorted(odd.items(), key=lambda x: -x[1])
even = sorted(even.items(), key=lambda x: -x[1])
# 各配列の最頻，二番目を取ってくる
o1 = odd[0]
e1 = even[0]
# 1種類しかない場合は適当に二番目を作成
if len(odd) != 1:
    o2 = odd[1]
else:
    o2 = (0, 0)
if len(even) != 1:
    e2 = even[1]
else:
    e2 = (0, 0)

# 最多文字が異なる
if o1[0] != e1[0]:
    print(n - (o1[1] + e1[1]))
# 最多文字が同じ
else:
    ans = min((n - (o2[1] + e1[1])), (n - (o1[1] + e2[1])))
    print(ans)


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

int main(){
  long int x,y,z;
  cin>>x>>y>>z;
  long int t=x/y;
  while(t){
    if(x-t*y>=(t+1)*z) { cout<<t; return 0; }
    t--;
  }

}


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

int main(){
  int a,n,x,l,count;
  cin >> n >> x;
  count = 1;
  for(int i; i < n; i++){
    cin >> l;
    a += l;
    if(a <= x)
      count++;
    else
      break;
  }
  cout << count << endl;
    
    
}
             
            
          
      
    


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

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

int main()
{
    cout << fixed << setprecision(15);
    ll N, M, C;
    cin >> N >> M >> C;

    vector<ll> B(M);
    vector<vector<ll>> A(N, vector<ll>(M));

    REP(i, M){
        cin >> B[i];
    }

    REP(i, N){
        REP(j, M){
            cin >> A[i][j];
        }
    }

    ll ans = 0;

    REP(i, N){
        ll t = 0;
        REP(j, M){
            t += A[i][j] * B[j];
        }
        t += C;
        if(t > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import Data.List (unfoldr)
import qualified Data.ByteString.Char8 as B
import Data.Char (isSpace)
import Data.Bits ((.&.), shiftR)

readInt = B.readInt . B.dropWhile isSpace

fact2 x
 | even x = fact2 (shiftR x 1) + 1
 | otherwise = 0

main = do
 getLine
 as <- unfoldr readInt <$> B.getLine :: IO [Int]
 print . sum . map fact2 $ as

Measured memory_bytes: 1916
S = str(input())
front = int(S[:2])
back = int(S[2:])
if 0 < front <= 12 and 0 < back <= 12:
    print("AMBIGUOUS")
elif (front > 12 and 0 < back <= 12) or (front == 0 and 0 < back <= 12):
    print("YYMM")
elif (0 < front <= 12 and back > 12) or (0 < front <= 12 and back == 0):
    print("MMYY")
else:
    print("NA")


Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;

int main(){
	int N;
	string S;

	cin >> N >> S;

	int count = 0;
	string check;

	for(int i = 0; i < N; i++){
		if(S.at(i) == 'A'){
			check = S.substr(i, 3);
			if(check == "ABC"){
				count++;
			}
		}
	}

	cout << count << endl;


	return 0;
}


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

const int maxN = 100; int n;
int b[maxN], a[maxN];

int main()
{
  scanf("%d", &n);
  for (int i = 0; i < n; i ++)
    a[i] = -1e9;

  for (int i = 0; i < n - 1; i ++)
    scanf("%d", &b[i]);

  a[0] = b[0]; a[n - 1] = b[n - 2];
  for (int i = 1; i < n - 1; i ++)
    a[i] = min({b[i - 1], b[i]});
  // for (int i = 1; i < n - 2; i ++)1
  //   if (b[i] >= b[i + 1] && b[i] >= b[i - 1])
  //     a[i] = a[i + 1] = max(b[i + 1], b[i - 1]);
  // a[0] = b[0];
  // a[1] = min(b[0], b[1]);
  // a[n - 1] = b[n - 2];
  // a[n - 2] = min(b[n - 2], n > 2 ? b[n - 3] : 0);

  for (int i = 1; i < n - 1; i ++)
    if (a[i] == -1e9)
      a[i] = max({a[i], a[i - 1], a[i + 1]});
  // for (int i = 0; i < n; i ++)
  //   printf("%d%c", a[i], i < n - 1 ? ' ' : '\n');

  int ans = 0;
  for (int i = 0; i < n; i ++)
    ans += a[i];

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

  return(0);
}

Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int k,n;
	cin >> k >> n;
	vector<int> a(n), sub(n);
	REP(i,n) cin >> a[i];
	REP(i,n-1) sub[i] = a[i+1] - a[i];
	sub[n-1] = k - a[n-1] + a[0];
	sort(ALL(sub), greater<int>());
	cout << k - sub[0] << '\n';
	return 0;
}



Measured memory_bytes: 1792
import java.util.*;
import java.awt.geom.Point2D;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
//Loopで使う文字列の長さは固定！
//intで大丈夫？オーバーフローしない？
//Loop回数は本当に10⁹以内になってる？Loopは回る？？
public class Main {
    public static void main(String[]$){
        Scanner sc = new Scanner(in);
        int a=sc.nextInt();
        String op=sc.next();
        int b=sc.nextInt();
        if(op.equals("+"))out.println(a+b);
        else out.println(a-b);
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int M, D;

void solve() {
	cin >> M >> D;
	int res = 0;
	for(int i = 1; i <= M; i++) {
		for(int j = 1; j <= D; j++) {
			int a = j / 10, b = j % 10;
			if(a >= 2 && b >= 2 && i == a * b) {
				res++;
			}
		}
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define   ll  long long int
#define   sz  1000100

using namespace std;

ll num[sz];

int main()
{


    ll n,i,j,a,b,t,s=0;

    cin>>n>>t;

    for(i=1;i<=n;i++)
    {
        cin>>num[i];
    }

    for(i=2;i<=n;i++)
    {
        a=num[i]-num[i-1];
        if(a>=t)s+=t;
        else
            s+=a;

    }
    s+=t;

    cout<<s<<endl;


    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define ll long long

using namespace std;

int main(){
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	cout << (s[0] == s[1] && s[2] == s[3] && s[0] != s[2] ? "Yes" : "No");
}



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

int main()
{
    int n, d = 1;
    vector<int> r;
    cin >> n;
    if (!n)
    {
        cout << 0 << endl;
        return 0;
    }
    while (n != 0)
    {
        if (n % 2)
        {
            r.push_back(1);
            n -= d;
            n /= 2;
            d *= -1;
        }
        else
        {
            r.push_back(0);
            n /= 2;
            d *= -1;
        }
    }
    reverse(r.begin(), r.end());
    for (int i = 0; i < r.size(); i++)
        cout << r.at(i);
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
#include <set>
#include <stack>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
using namespace std;
const int MAXN=1e6+50;
const int inf=0x3f3f3f3f;
const int M=5000*4;
char ch[MAXN];
int main()
{
    cin>>(ch+1);
    int f1=0,f2=0;
    for(int i=1;i<=3;i++){
        if(ch[i]=='A')f1++;
        if(ch[i]=='B')f2++;
    }
    if(f1==0||f2==0)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}
/*

*/


Measured memory_bytes: 256
#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) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}


int main(){
    int n,k;cin >> n >> k;
    int r,s,p;cin >> r >> s >> p;
    string t;cin >> t;
    
    ll ans = 0;
    string route = "";
    for(int i=0;i<n;i++){
        if(t[i] == 'r'){
            if(i>=k && route[i-k] == 'p'){
                route += "a";
                continue;
            }
            ans += p;
            route += "p";
        }else if(t[i] == 's'){
            if(i>=k && route[i-k] == 'r'){
                route += "a";
                continue;
            }
            ans += r;
            route += "r";
        }else if(t[i] == 'p'){
            if(i>=k && route[i-k] == 's'){
                route += "a";
                continue;
            }
            ans += s;
            route += "s";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
    	BufferedReader in = new  BufferedReader(new InputStreamReader(System.in));
    	StringTokenizer st = new StringTokenizer(in.readLine());
    	int a = Integer.parseInt(st.nextToken()),
    		b =	Integer.parseInt(st.nextToken()),
    		c =	Integer.parseInt(st.nextToken());
    	boolean r;
    	if(a == b) {
    		if(c == b) {
    			r = false;
    		}else {
    			r = true;
    		}
    	}else if(a == c) {
    		if( c== b) {
    			r = false;
    		}else {
    			r = true;
    		}
    	}else {
    		if(c == b) {
    			r = true;
    		}else {
    			r = false;
    		}

    	}
    	if(r) {
    		System.out.println("Yes");
    	}else {
    		System.out.println("No");
    	}
    }
}

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

int main() {
  int N;
  cin >> N;
  // ここにプログラムを追記

  int total = 0;

/*
  int d1, d2, d3, d4, d5, d6, d7, d8;

  d8 = N % (10 * 8) / 10000000;
  d7 = N % (10 * 7) / 1000000;
  d6 = N % (10 * 6) / 100000;
  d5 = N % (10 * 5) / 10000;
  d4 = N % (10 * 4) / 1000;
  d3 = N % (10 * 3) / 100;
  d2 = N % (10 * 2) / 10;
  d1 = N % (10 * 1) / 1;
*/

  for (int i = 0; i < 8; i++) {
    int div = 1;
    int mod = 1;

    for (int j = 0; j < i; j++) {
      div *= 10;
    }

    for (int k = 0; k < i + 1; k++) {
      mod *= 10;
    }

//    cout << "i:" << i << " div:" << div << " mod:" << mod << endl;

    total += N % mod / div;
  }

  if (N % total == 0) {
      cout << "Yes";
  } else {
      cout << "No";
  }

  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(k,i,n) for(long long i=k;i<n;++i)
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    ll N,sum1=0,sum2=0,ans=1e9;
    cin>>N;
    ll a[N];
    rep(0,i,N){
        cin>>a[i];
    }
    rep(0,i,N){
        rep(0,j,N){
            if(i<=j)sum1+=a[j];
            else sum2+=a[j];
        }
        ans=min(ans,abs(sum1-sum2));
        sum1=0,sum2=0;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
X, Y, Z, K = list(map(int, input().split()))
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

E = sorted([a+b for a in A for b in B], reverse=True)

E = E[:K]
nums = sorted([e+c for e in E for c in C], reverse=True)

for n in nums[:K]:
    print(n)

Measured memory_bytes: 184844
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
//https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
 
using namespace std;
typedef long long ll;


int main()
{
    ll N, M;
    cin >> N >> M ;
    ll* X = new ll[M];

    for(ll i = 0; i < M; i ++){
        cin >> X[i];
    }

    ll* diff = new ll[M - 1];

    sort(X, X+M);

    for(ll i = 0; i < M - 1; i ++){
        diff[i] = X[i + 1] - X[i];
    }

    sort(diff, diff+M-1);

    if(N >= M){
        cout << "0" << endl;
    }

    else{

        ll result = 0;
        for(ll i = 0; i < M - N; i ++){
            result += diff[i];
        }
        cout << result << endl;
    }
}

Measured memory_bytes: 1792
#include <stdio.h>

typedef long long i64;

i64 fact(i64 n) {
	i64 f = 1;
	for (; n > 0; --n) {
		f *= n;
	}
	return f;
}

int main() {
	i64 n;
	scanf("%lld", &n);
	printf("%lld\n", fact(n));
	return 0;
}

Measured memory_bytes: 0
N = int(input())
A = list(map(int, input().split()))
D = {}
for a in A:
  if a not in D: D[a]=0
  D[a]+=1

S = 0
for n in D.values():
  S += n*(n-1)//2

for a in A:
  n = D[a]
  print(S - n*(n-1)//2 +(n-1)*(n-2)//2)

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

bool dp[1005][1005];

int main(){
    int n;
    while(cin >> n, n != 0){
        int sum = 0, maxi = 0, rsum = 0, wsum = 0;
        vector<pair<int, int>> v;
        for(int i=0;i<n;++i){
            int r, w;
            cin >> r >> w;
            v.emplace_back(r, w);
            sum += r;
            rsum += r;
            wsum += w;
            maxi = max(maxi, r);
        }
        sum -= maxi;
        if(sum >= maxi){
            cout << rsum + wsum << endl;
        }else{
            for(int i=0;i<=1000;++i){
                for(int j=0;j<=1000;++j){
                    dp[i][j] = false;
                }
            }
            dp[0][0] = true;

            int diff = maxi - sum;
            for(int i=1;i<=n;++i){
                for(int j=0;j<=diff;++j){
                    dp[i][j] |= dp[i-1][j];
                    if(v[i-1].first == maxi || v[i-1].second > j)continue;
                    dp[i][j] |= dp[i-1][j-v[i-1].second];
                }
            }

            int t = 0;
            for(int i=diff;i>=0;--i){
                if(dp[n][i])break;
                t++;
            }

            cout << rsum + wsum + t << endl;
        }
    }

    return 0;
}



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

int x,y,ans;

inline void Initial() {
  std::ios::sync_with_stdio(false);
  cout.tie(0); cin.tie(0);
}
inline void Input() {
  cin>>x>>y;
}
inline int GreatestCommonDivisor(int x,int y) {
  if (x<y) {
    swap(x,y);
  }
  if (y==0) {
    return ans=x;
  }
  return GreatestCommonDivisor(y,x%y);
}
inline void Output() {
  cout<<ans<<endl;
}
int main() {
  Initial(),Input(),GreatestCommonDivisor(x,y),Output();
  return 0;
}



Measured memory_bytes: 3192
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};

fn main() {
    let h: usize = read();
    let w: usize = read();
    let mut map: Vec<Vec<char>> = vec![];

    for _ in 0..h {
        let row: String = read();
        map.push(row.chars().collect::<Vec<char>>())
    }

    let mut cmap = vec![vec![0; w]; h];
    // row
    for i in 0..h {
        let mut cnt = 0;
        let mut head = 0;
        for j in 0..w {
            if map[i][j] == '.' {
                cnt += 1;
            }
            if map[i][j] == '#' {
                for k in head..j {
                    cmap[i][k] += cnt;
                }
                cnt = 0;
                head = j + 1;
            }
            if j == w - 1 {
                for k in head..w {
                    cmap[i][k] += cnt;
                }
            }
        }
    }

    for i in 0..w {
        let mut cnt = 0;
        let mut head = 0;

        for j in 0..h {
            if map[j][i] == '.' {
                cnt += 1;
            }
            if map[j][i] == '#' {
                for k in head..j {
                    cmap[k][i] += cnt;
                }
                cnt = 0;
                head = j + 1;
            }
            if j == h - 1 {
                for k in head..h {
                    cmap[k][i] += cnt;
                }
            }
        }
    }

    let mut ans = 0;
    for i in 0..h {
        for j in 0..w {
            ans = max(ans, cmap[i][j]);
        }
    }
    println!("{}", ans - 1);
    // for i in 0..cmap.len() {
    //     let row = &cmap[i];
    //     println!("{:?}", row);
    // }
}


Measured memory_bytes: 33368
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

# MOD = 998244353


N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))
A = np.array(A, dtype=int) - np.arange(N, dtype=int)
A.sort()

cum = A.cumsum()

ans = cum[-1] - A[0] * N
# どこで切るか決める
for i in range(1, N):
    # 右側
    r = cum[N - 1] - cum[i - 1] - A[i] * (N - i)
    # 左側
    l = A[i] * i - cum[i - 1]
    ans = min(l + r, ans)
print(ans)


Measured memory_bytes: 31012
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int pic1[103][103],pic2[52][52],pic3[52][52];

int main(){
	
	int i,j,p,q,k,n,m,x,y,z;
	
	while(1){
		scanf("%d%d",&n,&m);
		if(n==0 && m==0)break;
		for(i=0;i<n;i++)for(j=0;j<n;j++)scanf("%d",&pic1[i][j]);
		for(i=0;i<m;i++)for(j=0;j<m;j++)scanf("%d",&pic2[i][j]);
		
		x=y=1000;
		for(k=0;k<4;k++){
			/*for(i=0;i<m;i++){
				for(j=0;j<m;j++)printf("%3d ",pic2[i][j]);
				printf("\n");
			}*/
			for(i=0;i<=n-m;i++)for(j=0;j<=n-m;j++){
				for(p=0;p<m;p++)for(q=0;q<m;q++){
					if(pic2[p][q]!=-1 && pic1[i+p][j+q]!=pic2[p][q])goto nex;
				}
				nex:
				if(p==m && q==m){
					z=0;
					while(pic2[0][z]==-1)z++;
					j+=z;
					if(i<y)y=i,x=j;
					else if(i==y && j<x)x=j;
					goto nex2;
				}
			}
			nex2:
			
			//printf("(%d %d)%d %d\n",i,j,x,y);
			
			for(i=0;i<m;i++)for(j=0;j<m;j++)pic3[j][m-1-i]=pic2[i][j];
			memcpy(pic2,pic3,sizeof(pic3));
		}
		if(x==1000 && y==1000)printf("NA\n");
		else printf("%d %d\n",x+1,y+1);
	}
	
	return 0;
}

Measured memory_bytes: 684
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n;
 a=7%n;
 while(1)
 {
   if(a==0) break;
   if(b!=1 && b>n+100){ b=-1;break;}
   a*=10;
   a+=7;
   a%=n;
   ++b;
 }
 cout<<b;
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3632
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


from math import sqrt


def is_prime(x):
    if x == 1:
        return False
    if x % 2 == 0:
        if x == 2:
            return True
        else:
            return False

    for i in range(3, int(sqrt(x)) + 1):
        if x % i == 0:
            return False

    return True


X = read_a_int()

while not is_prime(X):
    X += 1
print(X)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;
int p = 1e9 + 7;

int32_t main()
{	
	IOS;
	int a, b, c, n;
	cin >> a >> b >> c >> n;
	int ans = 0;
	for(int i = 0; i <= n/a; i++)
		for(int j = 0; j <= n/b; j++)
		{
			if(i*a + j*b <= n)
			{
				if((n - i*a - j*b) % c == 0)
					ans++;
			}
		}
	cout<<ans;
	return 0;
} 


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> piipi;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

int a[100005];
ll dp[100005][5];
int main(){
    int n;
    scanf("%d", &n);

    for(int i=1;i<=n;i++){
        for(int j=0;j<4;j++) dp[i][j] = -1e18;
    }

    scanf("%d", &a[1]);
    dp[1][0] = a[1];
    for(int i=2;i<=n;i++){
        char s[2];
        scanf("%s", s);
        scanf("%d", &a[i]);
        for(int j=0;j<4;j++){
            int op = j%2;
            if(s[0] == '-') op = (op+1)%2;

            // open
            if(s[0] == '-'){
                if(op == 0) dp[i][j+1] = max(dp[i][j+1], dp[i-1][j] + a[i]);
                else dp[i][j+1] = max(dp[i][j+1], dp[i-1][j] - a[i]);
            }

            // close
            if(j > 0){
                if(op == 0) dp[i][j-1] = max(dp[i][j-1], dp[i-1][j] + a[i]);
                else dp[i][j-1] = max(dp[i][j-1], dp[i-1][j] - a[i]);
            }

            // none
            if(op == 0) dp[i][j] = max(dp[i][j], dp[i-1][j] + a[i]);
            else dp[i][j] = max(dp[i][j], dp[i-1][j] - a[i]);
        }
    }   
    ll ans = -1e18;
    for(int j=0;j<4;j++) ans = max(ans, dp[n][j]);
    printf("%lld\n", ans);
}

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

int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  for(auto& x : X){
    cin >> x;
  }
  sort(X.begin(), X.end());
  int min_MSE = INT_MAX;
  for(int ii=0; ii<=100; ii++){
    int MSE = 0;
    for(auto& x : X){
      MSE += (x-ii)*(x-ii);
    }
    min_MSE = min(min_MSE, MSE);
  }
  cout << min_MSE << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int a[107];
int main()
{
    //freopen("a.in","r",stdin);
    int n,x;
    scanf("%d%d",&n,&x);
    for(int i=1;i<=n;++i)
    scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    for(int i=1;i<=n;++i)
    {
        if(a[i]>x){cout<<i-1;return 0;}
        x-=a[i];
    }
    if(x==0)cout<<n;
    else cout<<n-1;
    return 0;
}

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

signed main(void)
{
	int n, a, b;
	int cnt, sum, tmp;

	cin >> n >> a >> b;
	cnt = 0;
	rep(i, n + 1)
	{
		sum = 0;
		tmp = i;
		while(tmp)
		{
			sum += tmp % 10;
			tmp /= 10;
		}
		if (sum >= a && sum <= b)
			cnt += i; 
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
ans = []
for i in range(100000):
  m, f, r = map(int, input().split())
  mf_sum = m + f

  if m == -1 or f == -1 or mf_sum < 30:
    val = 'F'
  elif mf_sum >= 80:
    val = 'A'
  elif 65 <= mf_sum < 80:
    val = 'B'
  elif 50 <= mf_sum < 65 or (30 <= mf_sum < 50 and r >= 50):
    val = 'C'
  elif 30 <= mf_sum < 50:
    val = 'D'

  if m == -1 and f == -1 and r == -1:
    break
  ans.append(val)

[print(x) for x in ans]



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1000000000000000000ll;
template<class T> inline void fix(T &x) {if(x >= mod || x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n, ans = 1;
    cin >> n;
    for(int i = 0; i < n; i ++) {
        ll a;
        cin >> a;
        if(a == 0) {
            cout << 0 << endl;
            return 0;
        } else if(a > (2 * mod) / ans) {
            ans = 2 * mod;
        } else {
            ans *= a;
        }
    }
    if(ans > mod) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
using namespace std;
#define ll long long
const int maxn = 1e5 + 5;
int a[maxn];
long long T, n, m, k, x;
bool is[102];
void init()
{

}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> x >> n;
	//is[x] = 1;
	for (int i = 1; i <= n; i++) { cin >> T; is[T] = 1; }
	int l = x, r = x, ans = 0;
	while (1)
	{
		if (is[l]) { l--; }
		else { ans = l; break; }
		if (is[r]) { r++; }
		else { ans = r; break; }
	}
	cout << ans << endl;
}

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

using ll = long long;

template <typename T> T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;

int main() {
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    bool ok = false;
    for(int i = 0; i <= N - 1; ++i) {
        ok |= (-D * i + C * (N - 1 - i) <= B - A && B - A <= -C * i + D * (N - 1 - i));
    }
    if(ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
// review
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAXN = 1e5+10;

int n, m;
int a[MAXN], b[MAXN];

void solve() {
  vector<P> v;
  for (int i=0;i<n;i++) {
    if (m >= a[i]) {
      v.push_back(P(m - a[i], b[i]));
    }
  }
  sort(v.begin(), v.end());
  ll sum = 0;
  int currentTime = m;
  int cur = v.size()-1;
  priority_queue<int> que;
  while (currentTime >= 0) {
    while(cur >= 0 && v[cur].first == currentTime) {
      que.push(v[cur--].second);
    }
    currentTime--;
    if (!que.empty()) {
      sum += que.top();
      que.pop();
    }
  }
  cout << sum << endl;
}

int main() {
  cin >> n >> m;
  for (int i=0;i<n;i++) {
    cin >> a[i] >> b[i];
  }
  solve();
}


Measured memory_bytes: 2804
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	for sc.Scan() {
		if sc.Text() == "0 0" {
			break
		}
		chunks := strings.Split(sc.Text(), " ")
		n, _ := strconv.Atoi(chunks[0])
		p, _ := strconv.Atoi(chunks[1])
		cnts := make([]int, n, n)
		for i := 0; true; i++ {
			j := i % n
			if p == 0 {
				p, cnts[j] = cnts[j], 0
			} else {
				cnts[j]++
				p--
			}

			if p == 0 {
				noneCnt := 0
				winner := 0
				for j, c := range cnts {
					if c == 0 {
						noneCnt++
					} else {
						winner = j
					}
				}
				if noneCnt == n-1 {
					fmt.Println(winner)
					break
				}
			}
		}
	}
}

Measured memory_bytes: 1100
<?php
list($r, $n) = ints();
echo $n + 100*max(0, 10-$r);

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}
/**
 * 座圧対象の配列を渡すと以下の値を返す
 * ・圧縮された配列
 * ・復元用のMap
 * ・圧縮用のMap
 **/
function atsu($array){
    $a = array_flip($array);
    $fuku = array_flip($a);
    sort($fuku);
    $atsu = array_flip($fuku);
    foreach($array as $i => $val)$array[$i] = $atsu[$val];
    return [$array, $fuku, $atsu];
}
//配列の最大公約数
function gcdAll($array){
    $gcd = $array[0];
    for($i = 1; $i < count($array); $i++){
        $gcd = gcd($gcd, $array[$i]);
    }
    return $gcd;
}

//最大公約数
function gcd($m, $n){
    if(!$n)return $m;
    return gcd($n, $m % $n);
}

//配列の最小公倍数
function lcmAll($array){
    $lcm = $array[0];
    for($i = 1; $i < count($array); $i++){
        $lcm = lcm($lcm, $array[$i]);
    }
    return $lcm;
}

//最小公倍数
function lcm($a, $b) {
    return $a / gcd($a, $b) * $b;
}
//ビットカウント-1の数を数える
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}


Measured memory_bytes: 4728
#include <stdio.h>

int main() {
    int h, w;
    scanf("%d %d", &h, &w);

    char hw[h][w+1];
    for (int i = 0; i < h; i++) {
        scanf("%s", hw[i]);
    }

    for (int i = 0; i < h; i++) {
        puts(hw[i]);
        puts(hw[i]);
    }

    return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif 


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

    int H, W, K; cin >> H >> W >> K;
    K--;
    const ll MOD = 1e9 + 7;

    vvl dp(H + 1, vl(W, 0));
    // dp[i][j] := number of lottery whose height is i and output is j 
    dp[0][0] = 1;

    int M = 0x01 << (W-1);
    REP(i, H) {        
        REP(p, M) {
            int ptn = p;
            bool ok = true;
            while(ptn > 0) {
                if ((ptn&0b11) == 0b11) {
                    ok = false;
                    break;
                }
                ptn >>= 1;
            }
            if (!ok) continue;

            ptn = p;
            vi dst(W);
            REP(j, W) dst[j] = j;

            int b = W - 1;
            while(ptn > 0) {
                if (ptn&0b01) {
                    swap(dst[b-1], dst[b]);
                }
                ptn >>= 1;
                b--;
            }

            REP(j, W) {
                dp[i + 1][dst[j]] += dp[i][j];
                dp[i + 1][dst[j]] %= MOD;
            }
        }
    }

    ll ans = dp[H][K] % MOD;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256