akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

/* Tutorial:
  We will cook meat[i] iff dist(p, meat[i])*c <= T
  We can rewrite it as: dist(p, meat[i]) <= T / c, which
  is the same as saying that p is inside circle(center: meat[i], radious: T/c)

  So, we can use a binary search and find the minimum T in which
  there's a point inside at least K circles (from meats)

  That point will be either the center of a circle or the intersection
  of two circles (so we can test in O(n^3))
*/

const int maxN = 60; int n, k;
const double eps = 1e-7;

struct Point
{
  double x, y;
  Point operator+(const Point &other) { return Point{x + other.x, y + other.y}; }
  Point operator-(const Point &other) { return Point{x - other.x, y - other.y}; }
  Point operator*(const double a) { return Point{x * a, y * a}; }
  double operator*(const Point &other) { return x * other.x + y * other.y; }
  double distance(Point &other) { return sqrt((x - other.x)*(x - other.x) + (y - other.y)*(y - other.y)); }
  double cross(Point &other) { return x*other.y - y*other.x; }
  Point rotate(double rad) { return Point{x * cos(rad) - y * sin(rad), x * sin(rad) + y * cos(rad)}; }
  Point normalized()
  {
    double norm = sqrt(x*x + y*y);
    return Point{x / norm, y / norm};
  }
  void read() { scanf("%lf %lf", &x, &y); }
  void print() { printf("(%3.3lf, %3.3lf)\n", x, y); }
};
struct Circle
{
  Point center; double radious;
  bool contains(Point &p) { return center.distance(p) <= radious + eps; }
  pair<Point, Point> circleIntersections(Circle &other)
  {
    double d = center.distance(other.center);
    double u = acos((other.radious*other.radious + d*d - radious*radious) / (2.0*other.radious*d));
    Point dc = (center - other.center).normalized() * other.radious;
    return pair<Point, Point>
    {
      other.center + dc.rotate(u),
      other.center + dc.rotate(-u)
    };
  }
};
struct Meat
{
  Point p; double c;
  void read() { p.read(); scanf("%lf", &c); }
  Circle getCircle(double T) { return Circle{p, T / c}; }
};
Meat meats[maxN];
Circle circles[maxN];

bool valid(Point &a)
{
  int done = 0;
  for (int i = 0; i < n; i++)
    done += circles[i].contains(a);
  return done >= k;
}
bool can(double T)
{
  for (int i = 0; i < n; i++)
    circles[i] = meats[i].getCircle(T);

  for (int i = 0; i < n; i++)
  {
    if (valid(meats[i].p))
      return true;

    for (int j = i + 1; j < n; j++)
    {
      pair<Point, Point> intersections = circles[i].circleIntersections(circles[j]);
      if (valid(intersections.first) || valid(intersections.second))
        return true;
    }
  }
  return false;
}

int main()
{
  while (scanf("%d %d", &n, &k) != EOF)
  {
    for (int i = 0; i < n; i++)
      meats[i].read();

    double lo = 0, hi = 1e6;
    while (abs(hi - lo) > eps)
    {
      double mid = (lo + hi) / 2;
      if (can(mid)) hi = mid;
      else lo = mid;
    }
    printf("%lf\n", lo);
  }
  return 0;
}

Measured memory_bytes: 384
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
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 fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

x = INT()
m = x % 100
num = x // 100
if num * 5 < m:
    print(0)
else:
    print(1)

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define ld long double
#define mem(x,y) memset(x,y,sizeof x)

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
/*
 * Be careful of overflow
 * Array bounds
 * Assert a!=0 when performing x/a
 * Check base condition for recursion
 * Iterator -> O(1), Element -> O(log n) while using erase
 * 1LL<<x when x>32
 * Be sure of what you are going to code (exception dp)
 * Don't try fancy tricks during contest
 * You can always make a bad round to a good enough round
 */ 

int cnt[1000009];

void solve()
{
	int n,i;
	cin>>n;
	int g=0;
	for(i=0;i<n;i++)
	{
		int x;
		cin>>x;
		cnt[x]=1;
		g=__gcd(g,x);
	}
	if(g!=1)
	{
		cout<<"not coprime\n";
		return;
	}
	
	for(i=2;i<=1e6;i++)
	{
		int val=0;
		for(int j=i;j<=1e6;j+=i)
		val += cnt[j];
		if(val>1)
		{
			cout<<"setwise coprime\n";
			return;
		}
	}
	cout<<"pairwise coprime\n";
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 7556
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

#define LL long long
LL n, m, ans;

int main() {
    #ifdef LOCAL
        freopen("test.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    #endif // LOCAL
    ios::sync_with_stdio(false);

    while(scanf("%lld%lld", &n, &m) != EOF) {
        ans = 0;
        if(n > m) {
            swap(n, m);
        }
        if(n == 1) {
            if(m == 1) {
                printf("1\n");
            } else {
                printf("%lld\n", m - 2);
            }
            continue;
        }
        printf("%lld\n", (n - 2) * (m - 2));
    }

    return 0;
}


Measured memory_bytes: 256
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	A = getlist()
	D = defaultdict(int)
	judge = "YES"
	for i in range(N):
		if D[A[i]] == 1:
			judge = "NO"
			break

		D[A[i]] = 1

	print(judge)


if __name__ == '__main__':
	main()

Measured memory_bytes: 80776
#include<iostream>
using namespace std;
int main(){
	int n;
	int score[100001]={};
	int buf;
	int mx=0,mn=100001;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>buf;
		if(buf>mx)mx=buf;
		if(buf<mn)mn=buf;

		if(buf>0)score[buf-1]++;
		score[buf]++;
		score[buf+1]++;
	}
	int max=0;
	for(int i=(mn>0?mn-1:0);i<mx+1;i++){
		if(score[i]>max){
			max=score[i];
		}
	}
	cout<<max<<endl;

	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int main()
{
    int c=0;
    char s[15]={},t[15]={};
    scanf("%s%s",s,t);
    for(int i=0;s[i];i++) {
        if(s[i]!=t[i]) { c++; }
    }
    if(c==0) { printf("Yes"); }
    else { printf("No"); }

    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=2e5+100;
int main()
{
    FASTINOUT;
    ll x,y;
    cin>>x>>y;
    if (x>y)
        swap(x,y);
    if (x==1 &&y==1)
        cout<<1<<endl;
    else if (x==1)
        cout<<y-2<<endl;
    else
        cout<<(x-2)*(y-2)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

// dp[i][j][k][l] ::= i-1番目がj, i番目がk, i+1番目がl個落ちている時、i番目を1つ落とすコスト
// dp[i][j][k] ::= i番目がj個、i+1番目がk個落ちている時、どちらかを1つ落とすのにかかるコスト
// best[i][j][k] ::= i番目がj個、i+1番目がk個落ちている時、どちらを落とすべきか

int h, w;
vs fld, t;
pii dp[333][333][333];
int cost[333][333][333];

int get_cost(int i, int j, int k)
{
	if (i == w - 1) return 0;
	if (cost[i][j][k] >= 0) return cost[i][j][k];
	int res;
	if (j == h || k == h) res = 0;
	else
	{
		res = get_cost(i, j + 1, k + 1);
		if (t[i][h - j - 1] == t[i+1][h - k - 1]) res += 1;
		else res += 0;
	}
	return cost[i][j][k] = res;
}

pii solve(int i, int j, int k)
{
	if (dp[i][j][k].first >= 0) return dp[i][j][k];
	if (i == w - 1) return pii(0, 0);
	pii res;
	if (j == h && k == h) res = pii(0, 0);
	else if (k == h) res = pii(0, 1);
	else if (j == h) res = pii(0, 2);
	else
	{
		int c1 = solve(i, j + 1, k).first + get_cost(i, j, k);
		int c2 = solve(i, j, k + 1).first + get_cost(i, j, k);
		res = min(pii(c1, 1), pii(c2, 2));
	}
	return dp[i][j][k] = res;
}

void init()
{
	REP(i, 333)REP(j, 333)REP(k, 333)
	{
		dp[i][j][k] = pii(-1, -1);
		cost[i][j][k] = -1;
	}
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	init();
	cin >> h >> w;
	fld.resize(h);
	REP(i, h) cin >> fld[i];
	t.resize(w);
	REP(i, h)REP(j, w)
	{
		t[j] += fld[i][j];
	}
	int ans = 0;
	REP(i, w - 1)
	{
		ans += solve(i, 0, 0).first;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 433280
package main

import (
	"fmt"
	"math"
)

func sq(i float64) float64 {
	return i * i
}

func main() {
	var a, b, h, m float64
	fmt.Scan(&a, &b, &h, &m)

	mo := m * 6
	ho := h*30 + m*0.5

	result := sq(a) + sq(b) - 2*a*b*math.Cos((mo-ho)*(math.Pi/180))
	fmt.Println(math.Sqrt(result))
}


Measured memory_bytes: 1824
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
for i in range(1112):
    s = list(str(i))
    t = list(Counter(s).items())
    if len(t) == 1 and i >= n:
        print(i)
        quit()


Measured memory_bytes: 40304
/*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_A&lang=jp
所要時間は30分程度。解法の幾何的理解が足りずに無駄に時間を溶かしたという感じがする。
着席位置は{中央x中央}
*/


#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<complex>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;
using std::abs;
using std::complex;

#define INF 999999999;
#define MOD 1000000007

using ulli = unsigned long long int;

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

using Comp = complex<double>;

int n;
double SumS = 0.0;
Comp p[3];

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

    scanf("%d", &n);
    double x, y;
    scanf("%lf %lf", &x, &y);
    p[0] = Comp(x, y);
    scanf("%lf %lf", &x, &y);
    p[1] = Comp(x, y);
    Comp a = p[1] - p[0], b;
    int c = 1;
    while( c < n){
        scanf("%lf %lf", &x, &y);
        p[2] = Comp(x, y);
        b = p[2] - p[0];
        double su = (a.real() * b.imag() - a.imag() * b.real())/2;
        SumS += su;
        a = b;
        c++;
    }

    printf("%.1f\n", abs(SumS));

    return 0;
}


Measured memory_bytes: 3264
n = input()
digit_n = len(str(n))
n = int(n)
ans = 0

if digit_n % 2 == 0:
    for i in range(digit_n // 2):
        ans += 9 * 10 ** (i * 2)

else:
    if digit_n != 1:
        for i in range((digit_n - 1) // 2):
            ans += 9 * 10 ** (i * 2)
        hasuu = n - 10 ** ((i+1)*2)
        ans += hasuu + 1
    
    else:
        ans = n

    
print(ans)

# 端数の計算が間違っていた


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

using namespace std;

#define INF 1000007
#define MOD 998244353
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int mpow(int a, int b)
{
    int calc = 1;
    rep(i, b)
    {
        calc = (calc * a) % MOD;
    }
    return calc;
}
signed main()
{
    int N;
    cin >> N;
    vector<int> D;
    int A[N + 1];
    fill(A, A + N + 1, 0);
    int ans = 1;
    rep(i, N)
    {
        int a;
        cin >> a;
        D.push_back(a);
    }
    if (D[0] != 0)
    {
        cout << "0" << endl;
        return 0;
    }
    sort(D.begin(), D.end());
    if (D[1] == 0)
    {
        cout << "0" << endl;
        return 0;
    }
    for (int i = 0; i < N; i++)
    {
        A[D[i]]++;
    }
    for (int i = 1; i <= N; i++)
    {
        ans = (ans * mpow(A[i - 1], A[i])) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2168
line = list(map(int,input().split()))
cost = list(map(int,input().split()))
costl = 0
costr = 0
for i in range(line[1]):
    if cost[i] < line[2]:
        costl += 1
    if cost[i] > line[2]:
        costr += 1
print(min(costr,costl))

Measured memory_bytes: 3060
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        int[] a = new int[m], b = new int[m];
        for(int i = 0; i < m; i++){
            a[i] = sc.nextInt() - 1;
            b[i] = sc.nextInt() - 1;
        }
        boolean[] aa = new boolean[n], bb = new boolean[n];
        Arrays.fill(aa, false);
        Arrays.fill(bb, false);
        for(int i = 0; i < m; i++){
            if(a[i] == 0) bb[b[i]] = true;
            if(b[i] == n-1) aa[a[i]] = true;
        }
        String ans = "IMPOSSIBLE";
        for(int i = 0; i < n; i++)
            if(aa[i] == true && bb[i] == true)
                ans = "POSSIBLE";
        System.out.println(ans);
    }
}

Measured memory_bytes: 96976
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int n,k;
  cin >> n >> k;
  int a[n+1]={0};
  for(int i=1;i<=n;i++){
    cin >> a[i];
  }
  for(int i=k+1;i<=n;i++){
    if(a[i]>a[i-k]){
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }


return 0;
}
///....


Measured memory_bytes: 5208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define v(x) vector<x>
#define pb push_back 
#define mp make_pair
const ll maxint=2e18;
const ll minint =-2e18;
/*
(͡ ° ͜ʖ ͡ °): Hi, be careful of overflow.
*/
int main(){
	int x;
	cin>>x;
	cout<<(!x)<<'\n';
	return 0;
}

Measured memory_bytes: 3592
import math

i = []
for l in range(5):
    i.append(int(input()))
m = 0
l = 0
mx = -1
for x in range(5):
    if m < (10 - i[x] % 10) and 10 - i[x] % 10 != 10:
        if x != 0:
            l += math.ceil(i[mx] / 10) * 10
        m = 10 - i[x] % 10
        mx = x
    else:
        l += math.ceil(i[x] / 10) * 10
if mx != -1:
    l += i[mx]
print(l)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int maxn=200010;
int a[maxn],b[maxn],v[maxn<<1],p[maxn<<1],pos[maxn<<1],t[maxn],Min=1e9,Max,Mi=1e9,Mx,ma,mb,m,n;
int cmp(int a,int b) {
	return v[a]<v[b];
}
int main() {
	long long ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d%d",a+i,b+i);
		if(a[i]>b[i])swap(a[i],b[i]);
		if(Min>a[i])Min=a[ma=i];
		if(Max<b[i])Max=b[mb=i];
		Mi=min(Mi,b[i]);
		Mx=max(Mx,a[i]);
	}
	ans=1ll*(Max-Mi)*(Mx-Min);
	if(ma==mb) {
		printf("%lld\n",ans);
		return 0;
	}
	for(int i=1;i<=n;i++)
		if(ma!=i&&mb!=i) {
			p[++m]=i;
			v[m]=a[i];
			p[++m]=i;
			v[m]=b[i];
		}
	for(int i=1;i<=m;i++)pos[i]=i;
	sort(pos+1,pos+1+m,cmp);
	for(int i=1,j=0,cnt=0;i<=m;i++) {
		while(j<m&&cnt<n-2) {
			if(!t[p[pos[++j]]])cnt++;
			t[p[pos[j]]]++;
		}
		Mi=min(v[pos[i]],min(b[ma],a[mb]));
		Mx=max(v[pos[j]],max(b[ma],a[mb]));
		if(cnt>=n-2)ans=min(ans,1ll*(Max-Min)*(Mx-Mi));
		t[p[pos[i]]]--;
		if(!t[p[pos[i]]])cnt--;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
    int n, k; cin >> n >> k;
    if (n <= k) { cout << 0 << endl; return 0; }

    vector<int> hp(n);
    for (auto &item : hp)cin >> item;
    sort(hp.begin(), hp.end());

    long ret = 0;
    auto beg = hp.rbegin() + k;
    auto end = hp.rend();
    while (beg != end)ret += *beg++;

    cout << ret << endl;
}

Measured memory_bytes: 1024
/*
 * Matheus Oliveira
 * 16/06/2018
 * c.cpp
*/
 
#include <bits/stdc++.h>
using namespace std;

#define MAXN 10010

int main() {
	int counter = 0, n, v;
	scanf("%d", &n);

	for(int i = 0; i < n; i++) {
		scanf("%d", &v);
		while(v % 2 == 0) {
			v /= 2;
			counter++;
		}
	}
	printf("%d\n", counter);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;

int main() {
  ll x;
  cin >> x;
  ll xx = 100;
  for(ll i=1; ;i++) {
    xx += xx / 100;
    if(xx >= x) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int d,e;
  cin>>d>>e;
  string f;
  cin>>f;
  if(f==s)
    cout<<d-1<<" "<<e<<endl;
  else
    cout<<d<<" "<<e-1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<int> VI;
typedef vector<ll> VLL;

int main(){
    ll n,ans = 0; cin >> n;
    VLL l(n);
    for(ll i=0; i<n; ++i)cin >> l[i];

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

    for(ll i=0; i<n-2; ++i){
        for(ll j=i+1; j<n-1; ++j){

            int  it = lower_bound(l.begin()+j+1, l.end(), l[i]+l[j]) - (l.begin()+j+1);
            ans += it;
            
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<pair <ll,ll>> Pn(n),Pm(m);
    for(int i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        Pn[i]=make_pair(a,b);
    }
    
     for(int i=0;i<m;i++){
        ll a,b;
        cin>>a>>b;
        Pm[i]=make_pair(a,b);
    }
    
    for(int i=0;i<n;i++){
        ll mi=0,cnt=0;
        for(int j=0;j<m;j++){
            ll tmp=abs(Pn[i].first-Pm[j].first)+abs(Pn[i].second-Pm[j].second);
            if(j==0){
                mi=tmp;cnt=j+1;
            }else{
                if(mi>tmp){
                    mi=tmp;
                    cnt=j+1;
                }
            }
        }
        cout<<cnt<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>
using namespace std;


#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll digitsum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
int getdigit(ll a) {
	return to_string(a).size();
}
int countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}



int main() {
	IOS;
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int x = c - a, y = d - b;
	cout << c - y << ' '<< d + x << ' ' << a - y << ' '<< b + x;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    ll anss = 0, anst = (min(a,b)*100 <= f) ? min(a,b)*100 : 0;
    double cons = 0.0;
    
    for(ll i=0; i<= 30; i++){
        if(100*a*i > f) break;
        for(ll j=0; j<= 30; j++){
            if(100*a*i + 100*b*j > f) break;
            for(ll k=0;; k++){
                if(100*a*i + 100*b*j + c*k > f || (a+b)*e < c*k) break;
                for(ll l=0;; l++){
                    if(100*a*i + 100*b*j + c*k + d*l > f || (a*i+b*j)*e < c*k + d*l) break;
                    double tmp = (i == 0 && j==0 && k==0 && l== 0) ? 0.0 : (100.0*(c*k + d*l))/(100.0*a*i + 100.0*b*j + c*k + d*l);
                    if(cons < tmp){
                        cons = tmp;
                        anss = c*k + d*l;
                        anst = 100*a*i + 100*b*j + anss;
                    }
                }
            }
        }
    }
    cout << anst << " " << anss << endl;
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(num) scanf("%d",&num)
#define sff(num1,num2) scanf("%d %d",&num1,&num2)
#define sfff(num1,num2,num3) scanf("%d %d %d",&num1,&num2,&num3);
#define sl(num) scanf("%lld",&num)
#define sll(num1,num2) scanf("%lld %lld",&num1,&num2)
#define slll(num1,num2,num3) scanf("%lld %lld %lld",&num1,&num2,&num3);
#define rep(i,n) for(i=1;i<=n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define pb push_back
#define mpp make_pair
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
#define TIME cerr<<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<"s\n";
typedef long long int ll;
using namespace std;
int main()
{
    int n,k,i;
    sf(n);
    vector<int>vec,vec2;
    rep0(i,n+1)
    {
        sf(k);
        vec.pb(k);
    }
    rep0(i,n)
    {
        sf(k);
        vec2.pb(k);
    }
    ll cnt=0;
    rep0(i,n)
    {
        int x=vec2[i];
        int y=vec[i];
        //dbb(x,y);
        if(x>=y)
        {
            vec[i]=0;
            x-=y;
            cnt+=y;
        }
        else
        {
            vec[i]-=x;
            cnt+=x;
            x=0;
           // cnt+=x;
        }
        if(x)
        {
            y=vec[i+1];
            if(x>=y)
            {
                vec[i+1]=0;
                x-=y;
                cnt+=y;
            }
            else
            {
                vec[i+1]-=x;
                cnt+=x;
                x=0;
                //cnt+=x;
            }
        }
        //dbb(x,y);
        //db(cnt);
    }
    pf("%lld",cnt);
}


Measured memory_bytes: 1400
public class Main {
	public static void main(String args[]) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		String S = sc.next();

		String[] s = S.split("");

		int array10 = 0;
		int array01 = 0;
		for (int i = 0; i < s.length; i++) {
			int tmp = Integer.parseInt(s[i]);
			if (i % 2 != 0) {
				// 偶数
				if (tmp == 0) {
					array01++;
				} else {
					array10++;
				}
			} else {
				// 奇数
				if (tmp == 0) {
					array10++;
				} else {
					array01++;
				}
			}
		}

		System.out.println(Math.min(array10, array01));
	}
}


Measured memory_bytes: 35328
import itertools
def slove(n, a):
    total = sum(a)
    ans = min(map(lambda x: abs(total - x*2), itertools.accumulate(a[:-1])))
    return ans

if __name__ == "__main__":
    n = int(input())
    a_list = [int(i) for i in input().split()]
    print(slove(n, a_list))


Measured memory_bytes: 24172
#include <bits/stdc++.h>
#define ll long long

using namespace std;

char str[(int)2e5+10];

int main()
{
    int i,j,len;
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    while(cin>>str)
    {
        len=strlen(str);
        ll ans=0,cnt[2]={0,0};
        i=0;
        while(i<len)
        {
            while(i<len && str[i]=='A')
            {
                cnt[0]++;
                i++;
            }
            while(i+1<len && str[i]=='B' && str[i+1]=='C')
            {
                cnt[1]++;
                i+=2;
            }
            ans+=cnt[0]*cnt[1];
            if(str[i]!='A')
                cnt[0]=cnt[1]=0,i++;
            else
                cnt[1]=0;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
using namespace std;
 
int main() {
    int a,b;
    while(scanf("%d %d",&a,&b)!=EOF) {
        int total=a+b,ans=1;
        while((total/1)>=10) {
            total/=10;
            ++ans;
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 2728
N = int(input())
S = input()

err = 0

if N % 2 ==1:
    err = 1
else:
    harf = int(N/2)
    for i in range(harf):
        if S[i] != S[i + harf]:
            err = 1

if err == 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
		int[] b = new int[m];
		int cnt = 0;
		for(int i = 0; i < m; i++){
		    b[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++){
		    int sum = 0;
		    for(int j = 0; j < m; j++){
		        int a = sc.nextInt();
		        sum += a*b[j];
		    }
		    if(sum + c > 0) cnt++;
		}
		
		// 計算
		int result = cnt;
		
		// 出力
		System.out.println(result);
        
	}
}


Measured memory_bytes: 23892
#include<iostream>
using namespace std;
int main(){

    int n,x,sum=0,later,count = 0,min =1001;
    int m[101];
    cin >> n >> x;
    for(int i=0;i<n;i++){
        cin >> m[i];
        sum += m[i];
        count++;
        if(m[i]<=min){
            min = m[i];
        }
    }
    later = x - sum;
    if(later <=0){
        cout << count <<endl;
    }else{
        count += later/min;
        cout << count<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
// Author:: MOHAMMAD FAISAL
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
#include<bits/stdc++.h>
using namespace std;

int main()
{
  int n;
  cin >> n;
  
  bool part1=false,part2=false;
  for(int i=9;i>0;i--)
  {
    if(n%i==0){
      part1=true,n/=i;
      break;
    }
  }
  (n>=10) ? part2=false: part2=true;
  (part1==true && part2==true) ? cout<<"Yes":cout<<"No";
  return 0;
}
    

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

int main(){
  int S;
  cin >> S;
  int n = S/3;
  long long M = 1000000000+7;
  long long dp[n+1][S+1];
  memset(dp,0,sizeof(dp));
  for(int j=0;j<=S;j++){
    dp[1][j] = 1;
  }
  dp[1][0] = 0;
  dp[1][1] = 0;
  dp[1][2] = 0;
  for(int i=2;i<=n;i++){
    for(int j=3*i;j<=S;j++){
      dp[i][j] = (dp[i][j-1]+dp[i-1][j-3])%M;
    }
  }
  long long ans = 0;
  for(int i=0;i<=n;i++){
    ans += dp[i][S];
  }
  ans %= M;
  cout <<  ans << endl;
}

Measured memory_bytes: 14020
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions

import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n = ni()
    p = na()

    cnt = 0
    for i in range(1, n + 1):
        if i<n:
            if p[i - 1] == i:
                p[i - 1], p[i] = p[i], p[i - 1]
                cnt += 1
        else:
            if p[i - 1] == i:
                p[i - 1], p[i-2] = p[i-1], p[i - 2]
                cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 16048
#![allow(unused_imports)]

//input
use proconio::input;
use proconio::marker::{Bytes, Chars};
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

//use std::cmp::*;

fn main() {
    input! {
        s: Chars,
        t: Chars,
    }
    let n = s.len();
    for i in 0..n {
        if s[i] != t[i] {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    string s, t;
    cin >> s >> t;
    int n = (int)s.length();
    vector<vector<int>> dic(26);
    for(int i = 0; i < n; ++i) {
        char c = s[i];
        dic[c - 'a'].push_back(i);
    }
    for(int i = 0; i < n; ++i) {
        char c = s[i];
        dic[c - 'a'].push_back(i+n);
    }
 
    int ans = 0;
    int p = 0;
    for(int i = 0; i < (int)t.length(); ++i) {
        char c = t[i];
        if((int)dic[c-'a'].size() == 0) {
            cout << -1 << endl;
            return 0;
        }
        p = *lower_bound(all(dic[c-'a']), p)+1;
        if(p >= n) {
            p -= n;
            ans += n;
        }
    }
    ans += p;
    cout << ans << endl;
    return 0;
}

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

fn main() {
    let s: String = read();

    let weathers = ["Sunny", "Cloudy", "Rainy"];

    let mut n = 0;
    for i in 0..3 {
        if weathers[i] == s {
            n = i;
            break;
        }
    }

    let ans = if n == 2 { weathers[0] } else { weathers[n + 1] };

    println!("{}", ans);
}

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


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
  string c;
  cin >> c;
  if (c == "a" || c== "i" || c == "u" || c == "e" || c == "o"){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define db cout<<"db: "
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define all(v) v.B,v.E
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 1000005
//<<fixed << setprecision(9)

bool bad[space];
int cnt[space];
int main()
{
    int n,i,j,t;
    boost;

    cin>>n;
    rep(i,0,n)
    {
        cin>>j;
        cnt[j]++;
    }
    int ans=0;
    rep(i,1,space)
    {
        if(cnt[i]==0)continue;

        if(!bad[i] ) 
        {
            if(cnt[i]==1) ans++;
            for(j=2*i;j<space;j+=i)
            {
                bad[j]=1;
            }
        }
    }
    cout<<ans;

    return 0;
}



Measured memory_bytes: 8468
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int N, K;
vector<int> a;
bool dp[5050][5050];
// 不必要ならtrue
bool calc(int i) {
  vector<int> b;
  FOR(j,0,N) if(i != j) b.push_back(a[j]);
  CLR(dp);
  dp[0][0] = true;
  FOR(j,0,N-1) {
    FOR(k,0,K+1) {
      if(!dp[j][k]) continue;
      // b[j]を使う
      if(k+b[j] <= K) dp[j+1][k+b[j]] = true;
      // b[j]を使わない
      dp[j+1][k] = true;
    }
  }
  int wa = 0;
  FOR(j,0,K+1) {
    if(dp[N-1][j]) {
      wa = a[i] + j;
      if(wa >= K) break;
    }
  }
  return (wa < K) || (wa - a[i] >= K);
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> K;
  a.resize(N);
  FOR(i,0,N) {
    int in; cin >> in;
    in = min(in, K);
    a[i] = in;
  }
  sort(a.begin(), a.end());
  int l = -1, r = N + 1;
  while(r - l > 1) {
    int m = (r + l) / 2;
    if(calc(m)) l = m;
    else r = m;
  }
  cout << min(r, N) << endl;
  return 0;
}

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

int main() {
  string d;
  cin >> d ;
 if(d== "SUN"){
  cout << 7 <<endl;
 }
 else if(d== "MON"){
    cout << 6 << endl;
  }
  else if(d== "TUE"){
    cout << 5 << endl;
  }
  else if(d== "WED"){
    cout << 4 << endl;
  }
  else if(d== "THU"){
    cout << 3 << endl;
  }
  else if(d== "FRI"){
    cout << 2 << endl;
  }
  else{
	cout << 1 <<endl;
  }
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int h,w,n;
int a[100005],b[100005],c[100005],d[100005];
vector<P>M[4];
int main(){
	cin >> h >> w >> n;
	for(int i=1;i<=n;i++){
		scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
		if(a[i] == 0 || a[i] == h || b[i] == 0 || b[i] == w){
			if(c[i] == 0 || c[i] == h || d[i] == 0 || d[i] == w){
				if(a[i] == 0) M[0].pb(mp(b[i],i));
				else if(b[i] == w) M[1].pb(mp(a[i],i));
				else if(a[i] == h) M[2].pb(mp(-b[i],i));
				else M[3].pb(mp(-a[i],i));
				
				if(c[i] == 0) M[0].pb(mp(d[i],i));
				else if(d[i] == w) M[1].pb(mp(c[i],i));
				else if(c[i] == h) M[2].pb(mp(-d[i],i));
				else M[3].pb(mp(-c[i],i));
			}
		}
	}
	rep(i,4) sort(M[i].begin(),M[i].end());
	stack<int>S;
	rep(i,4){
	for(int ii=0;ii<M[i].size();ii++){
		int x = M[i][ii].sc;
		{
			if(S.empty()) S.push(x);
			else{
				if(S.top() == x) S.pop();
				else S.push(x);
			}
		}
	}}

	puts(S.empty()?"YES":"NO");
}

Measured memory_bytes: 4056
#include<iostream>

using namespace std;

int conv(int h, int m, int s)
{
	return s+m*60+h*60*60;
}

void reconv(int time, int *h, int *m, int *s)
{
	*h=time/(60*60);
	time%=60*60;
	*m=time/60;
	*s=time%60;
}

void print(int n)
{
	if(n<10){
		cout<<0<<n;
	}
	else{
		cout<<n;
	}
}

int main()
{
	int max=conv(0,120,0);
	while(1)
	{
		int h,m,s;
		cin>>h>>m>>s;
		if(h==-1&&m==-1&&s==-1)break;
		int ans1=max-conv(h,m,s);
		int ans2=ans1*3;
		reconv(ans1,&h,&m,&s);
		print(h); cout<<":"; print(m); cout<<":"; print(s); cout<<endl;
		reconv(ans2,&h,&m,&s);
		print(h); cout<<":"; print(m); cout<<":"; print(s); cout<<endl;
	}
}

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

using namespace std;


int main() {
  int y, m, d;
  char c1, c2;
  cin >> y >> c1 >> m >> c2 >> d;
  string ans = (m<=4) ? "Heisei" : "TBD";

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 256
cn500 = int(input())
cn100 = int(input())
cn50 = int(input())
g_amount = int(input())

counter = 0

for i in range(cn500+1):
    for j in range(cn100+1):
        for n in range(cn50+1):
            if g_amount == (500 * i + 100 * j + 50 * n):
                counter += 1
                break
            elif g_amount < (500 * i + 100 * j + 50 * n):
                break

print(counter)

Measured memory_bytes: 3064
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long N, Y; cin >> N >> Y;

	long man = -1, gos = -1, sen = -1;

	for (int i = 0; i <= N; i++) {
		for(int j = 0; j <= N - i; j++){
			if (i * 10000 + j * 5000 + (N - i - j) * 1000 == Y) {man = i; gos = j; sen = N - i - j; goto koko;}
		}
	}
koko:;
	cout << man << " " << gos << " " << sen << endl;
}

Measured memory_bytes: 256
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
T=int(input())
 
Query=[]
for i in range(T):
  Query.append(list(map(int,input().split())))
 
for i in range(T):
  while(True):
    if Query[i][0]%Query[i][1]>Query[i][2] or Query[i][0]<Query[i][1] or Query[i][1]>Query[i][3]:
      print('No')
      break;
    G=gcd(Query[i][1],Query[i][3]) #この倍数分の増減のみ考えれば良い
    '''
    A,B,C,DがQuery[i]の0,1,2,3に対応
    BmodG,DmodGは0(GはB,Dの約数であるため)よりmodGの世界で個数の増減はない。昼の購入で0個減少。夜の仕入れで0個増加。
    つまり、初期個数をAmodGとすると、個数は一定
    出現する可能性のあるBは買う個数であり、B-Gを考えると、買いきれない個数で出現しうる最大の個数が求まる。
    但し、初期個数を考える必要がある。
    初期個数によってループする幅が一緒でも取りうる値は異なる。
    
    例：
    B=24,C=19,D=36 この時,G=12
    
    A=31の場合 AmodG(本来の個数)
    7(31)→7(7)→7(43)→7(19)→7(31)→...
    A=30の場合 AmodG(本来の個数)
    6(30)→6(6)→6(42)→6(18)→6(30)→...
    
    Bを超えない最大数について、初期個数を考慮すると、B-G+AmodGとなる。
    G>AmodGであるため、この数が購入数Bを超えることはない
    つまり、B-G+AmodG>CならばNo,そうでなければYes
    '''
    if Query[i][1]-G+Query[i][0]%G>Query[i][2]:
      print('No')
      break;
    else:
      print('Yes')
      break;

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

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

    cout << max(c-a+b, 0) << endl;
    return 0;
}

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

using namespace std;

int main(void) {
    int q, n;
    cin >> q;
    n = 100010;
    vector<int> p(n, 1);
    p[0] = p[1] = 0;
    for(int i = 2; i < n; i++) {
        if(p[i]) {
            for(int j = i + i; j < n; j += i)
                p[j] = 0;
        }
    }

    vector<int> pref(n, 0);
    for(int i = 2; i < n; i++) {
        pref[i] += pref[i - 1];
        if(p[i] && p[(i + 1) / 2])
            pref[i] += 1;
    }

    while(q--) {
        int l, r;
        cin >> l >> r;
        cout << pref[r] - pref[l - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  long  double a,b,c; cin >> a >> b >> c;
  if((c - a -b) * (c - a - b) > 4 * a * b and c - a -b > 0)
    cout << "Yes";
  else
    cout << "No";
}
        
  

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

//floating numberを比較する場合、精度の問題で答えが正確でない場合がある
//->最も安全な方法は比較式を同値変形して整数同士の比較にする。
int main() {
  ll a, b, c;
  cin >> a >> b >> c;

  if (c-a-b < 0) {
    cout << "No" << endl;
    return 0;
  }
  if (4*a*b < (c-a-b)*(c-a-b)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << 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++ )
typedef long long ll ;

vector<ll> divisor(ll n){
vector<ll> ret;
for (ll i = 1 ; i*i <= n ; i++){
	if(n%i == 0 ){
	ret.push_back(i);
	if(i!=1&&i*i!=n){
		ret.push_back(n/i);
		}
	}
}
	sort(ret.begin(),ret.end());
	return ret;
}
int main() {

  int N ;
  cin >> N ;
  for(int i = N ; i <= 100003 ; i++){
    auto P = divisor(i) ;
    if( P.size() == 1 ){
      cout << i << endl;
      return 0 ;
    }
  }
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<ll> A(N);
    rep (i, N) {
        cin >> A[i];
    }

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

    ll index = -1;
    ll sum = 0;
    rep (i, N-1) {
        sum += A[i];
        if (A[i+1] > 2*sum) {
            index = i;
        }
    }

    cout << N-index-1 << endl;
    return 0;
}

Measured memory_bytes: 1024
n,a,b,k = map(int,input().split())
mod = 998244353


def factorial(N, MOD, r=True):
    fact = [1] * (N + 1)
    rfact = [1] * (N + 1)
    r = 1
    for i in range(1, N + 1):
        fact[i] = r = r * i % MOD
    rfact[N] = r = pow(fact[N], MOD - 2, MOD)
    for i in range(N, 0, -1):
        rfact[i - 1] = r = r * i % MOD
    if r:
        return fact, rfact
    else:
        return fact, rfact

fact,rfact = factorial(n,mod)


def comb(n, k):  # 上のfactorialと併用
    return fact[n] * rfact[k] * rfact[n - k] % mod

ans = 0
for x in range(n+1):
    if k-a*x >= 0 and (k-a*x)%b == 0:
        y = (k-a*x)//b
        if y <= n:
            ans += comb(n,x) * comb(n,y)
            ans %= mod

print(ans)

Measured memory_bytes: 46060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
#define F first
#define S second
constexpr auto INF = 1000000000;
constexpr auto LLINF = 9223372036854775807;
constexpr auto mod = 1000000007;
int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	FOR(i, n)cin >> s[i];
	int ab = 0, b = 0, a = 0;
	int ans = 0;
	FOR(i, n) {
		if (s[i][0] == 'B' && s[i][s[i].length() - 1] == 'A')ab++;
		if (s[i][0] == 'B' && s[i][s[i].length() - 1] != 'A')b++;
		if (s[i][0] != 'B' && s[i][s[i].length() - 1] == 'A')a++;
		FOR(j, s[i].length() - 1) {
			if (s[i][j] == 'A' && s[i][j + 1] == 'B')ans++;
		}
	}
	if (ab > 0) {
		ans += ab - 1;
		ab = 1;
		if (a > 0 && b > 0) {
			ab = 0;
			ans += 2;
			a--; b--;
		}
		else if (a > 0) {
			ab = 0;
			ans++; a--;
		}
		else if (b > 0) {
			ab = 0;
			ans++; b--;
		}
		if (ab > 0) {
			if (a > b)b++;
			else a++;
		}
	}

	cout << ans + min(a, b) << endl;
	
	return 0;
}


Measured memory_bytes: 768