akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<cmath>
#include<algorithm>
using namespace std;
const double EPS=1e-10;

double add(double a,double b)
{
	//if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0;
	return a+b;
}

typedef struct Vec{
	double x,y;
	Vec(){}
	Vec(double x,double y):x(x),y(y){}
	Vec operator +(Vec v){return Vec(add(x,v.x),add(y,v.y));}
	Vec operator -(Vec v){return Vec(add(x,-v.x),add(y,-v.y));}
	Vec operator *(double d){return Vec(x*d,y*d);}
}Vec;

double dot(Vec a,Vec b){return add(a.x*b.x,a.y*b.y);}
double det(Vec a,Vec b){return add(a.x*b.y,-a.y*b.x);}

typedef struct Cer{
	double r;
	Vec cp;
}Cer;

double vabs(Vec a)
{
	return hypot(a.x,a.y);
}

double ch(Vec a,Vec b,Cer c)
{
	if(dot(b-a,c.cp-a)<EPS)return vabs(c.cp-a);
	if(dot(a-b,c.cp-b)<EPS)return vabs(c.cp-b);
	return fabs(det(b-a,c.cp-a))/vabs(b-a);
}

int chC(Vec a,Cer c)
{
	return hypot(a.x-c.cp.x,a.y-c.cp.y)<=c.r?1:0;
}

int N,M,i,j,f;
double m,d;
Cer W[100];

int main()
{
	for(;scanf("%d",&N),N;)
	{
		for(i=0;i<N;i++)
			scanf("%lf%lf%lf",&W[i].cp.x,&W[i].cp.y,&W[i].r);
		scanf("%d",&M);
		for(i=0;i<M;i++)
		{
			f=0;
			Vec t,s;
			scanf("%lf%lf%lf%lf",&t.x,&t.y,&s.x,&s.y);
			for(j=0;j<N;j++)
			{
				if(chC(s,W[j])&&chC(t,W[j]))continue;
				if(ch(t,s,W[j])<=W[j].r)
					f=1;
			}
			puts(f?"Safe":"Danger");
		}
	}
	return 0;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));
	int n;
	cin >> n;
	int a[n+5];
	rep(i,1,n)
	{
		cin >> a[i];
	}
	int ans=0;
	rep(i,1,n-1)
	{
		rep(j,i+1,n)
		{
			ans += a[i]*a[j];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import System.Environment
import Data.Maybe
import Data.List
import Control.Exception

main :: IO ()
main = do
  isTest <- getEnv "TEST" `catch` (\(SomeException _) -> return "")
  if isTest == "1"
    then do
      testFile <- readFile "tests"
      putStrLn $ tests testFile
    else do
      input <- getContents
      putStrLn $ trim (solve (trim input))

--処理
solve :: String -> String
solve s | b == c = show $ a
        | a == c = show $ b
        | a == b = show $ c
  where [a, b, c] = fmap read (words s) :: [Int]

tests :: String -> String
tests text = case testParse text of
  Right bodys -> unlines (fmap (\(i, body) -> test i body) (zip [1 ..] bodys))
  Left  msg   -> "Test file parse error:" ++ msg

test :: Int -> (String, String) -> String
test n (input, outputRight)
  | output == outputRight
  = header ++ "Passed"
  | otherwise
  = header
    ++ "Faild\n"
    ++ "Right:"
    ++ show outputRight
    ++ "\nOutput:"
    ++ show output
 where
  header = "test" ++ show n ++ ":"
  output = trim $ solve input

testParse :: String -> Either String [(String, String)]
testParse s = case lines s of
  (sp1:sp2:bodys) -> testBodysParse sp1 sp2 bodys
  _               -> Left "testParse"

testBodysParse
  :: String -> String -> [String] -> Either String [(String, String)]
testBodysParse sp1 sp2 = (traverse . testBodyParse) sp2 . (split sp1)

testBodyParse :: String -> [String] -> Either String (String, String)
testBodyParse sp body = case fmap (trim . unlines) (split sp body) of
  [input, output] -> Right (input, output)
  _               -> Left "testBodyParse"

split :: Eq a => a -> [a] -> [[a]]
split spratar = foldr f [[]]
 where
  f x (p:ps) | x == spratar = [] : p : ps
             | otherwise    = (x : p) : ps
  f _ _ = undefined

trimHead :: String -> String
trimHead = dropWhile (\s -> isJust (elemIndex s [' ', '\t', '\n', '\r']))

trim :: String -> String
trim = reverse . trimHead . reverse . trimHead

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int inf = 1<<30;
const ll mod = 1000000007;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int N, K;
  string S;
  cin >> N >> K >> S;

  int diff = 'a'-'A';
  S[K-1] += diff;
  cout << S << endl;
}

Measured memory_bytes: 256
M=10**9+7
N,A,B,C=map(int,input().split())
f=[1]
for i in range(1,2*N):
	f.append(f[-1]*i%M)
t=pow(A+B,M-2,M)
A*=t
B*=t
a=pow(A,N,M)
b=pow(B,N,M)
z=0
for i in range(N):
	z+=(N+i)*100*t*f[N+i-1]*pow(f[N-1]*f[i],M-2,M)*(a+b)
	z%=M
	a=a*B%M
	b=b*A%M
print(z)


Measured memory_bytes: 13076
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"I=input;n=int(I());s,t=I(),I();print(2*n-max(i*(s[-i:]==t[:i])for i in range(n+1)))\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3280
fun main(args : Array<String>) {
    val (a, b, c, k) = readLine()!!.split(" ").map { it.toLong() }
    val cardSum = a + b + c

    if (cardSum == 0L) {
        println(0)
        return
    }

    if (a >= k) {
        println(k)
    }
    else if (a + b >= k) {
        println(a)
    }
    else {
        println(a - (k - a - b))
    }
}

Measured memory_bytes: 36348
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入


int main(){
    int N;
    cin>>N;
    priority_queue<int> A;
    int a;
    REP(i,N){
        cin >> a;
        A.push(a);
    }
    int cur,before;
    cur=A.top();
    A.pop();
    int sum=0;
    int m=0;
    int num=INF;
    while(!A.empty()){
        before=cur;
        cur=A.top();
        A.pop();
        if(cur==before){
            if(cur==num){
                sum++;
            }else{
                sum+=2;
                num=cur;
                m++;
            }
        }else{
            num=cur;
        }
    }
    cout << N -(sum-m)- (sum-m)%2 << endl;
    
}

Measured memory_bytes: 892
#include <iostream>

int main()
{
  // 用意
  int d, i;
  std::string str;

  // 入力
  std::cin >> d;

  // 計算
  if ((d >= 22) && (d <= 25))
  {
    str = "Christmas";
    for (i = d; i < 25; i++)
    {
      str += " Eve";
    }
  }

  // 出力
  std::cout << str << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
int main() {
	string s;
	cin >> s;
	bool ok = false;
	for (int i = 0; i <= 7; ++i) {
		if (s.substr(0, i) == string("keyence").substr(0, i) && s.substr(s.size() - (7 - i)) == string("keyence").substr(i)) {
			ok = true;
		}
	}
	cout << (ok ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define rep(i,N) for(int i=0;i<N;i++)
#define MOD 1000000007

using namespace std;

int tt(const VVI &G,int v,VI &ck,VI &cnt){
    ck[v]=1;

    for(auto next:G[v]){
        if(ck[next]!=1){
            cnt[next]+=cnt[v];
            tt(G,next,ck,cnt);
        }
    }
}

int main(void){
    int N,Q;
    cin>>N>>Q;
    VVI G(N);
    VI cnt(N,0),ck(N,-1);
    rep(i,N-1){
        int a,b;
        cin>>a>>b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    rep(i,Q){
        int p,x;
        cin>>p>>x;
        cnt[p-1]+=x;
    }
    tt(G,0,ck,cnt);
    rep(i,N)cout<<cnt[i]<<" ";
    cout<<endl;
}



Measured memory_bytes: 27392
n=int(input())
a=list(map(int, input().split()))
i=0
odd=0
even=0
eveneven=0
while i<n:
    if a[i]%4==0:
        eveneven+=1
    elif a[i]%2==0:
        even+=1
    else:
        odd+=1
    i+=1    
if even==0 and eveneven>=(odd-1):
    print("Yes")
elif even!=0 and eveneven>=odd:
    print("Yes")
else:
    print("No")

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

int main(){
    int N;
    std::cin>>N;
    std::string ans = "No";
    for(int i=4;i<=N;i+=4){
        for(int j=7;j<=N+7;j+=7){
            if(!((N-i)%j) || !(N%i) || !(N%j)) ans = "Yes";  
        }
    }
    std::cout<<ans;
}

Measured memory_bytes: 256
h,w,a,b=map(int,input().split());m=10**9+7;f=[1]
for i in range(h+w):f+=[f[-1]*(i+1)%m]
def comb(a,b,m):return f[a]*pow(f[b],m-2,m)*pow(f[a-b],m-2,m)%m
x=0
for i in range(b,w):x+=comb(h-a+i-1,i,m)*comb(a+w-i-2,a-1,m)%m
print(x%m)

Measured memory_bytes: 11028
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
        // setw(6) << setfill('0')
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << "(" << v.first << ", " << v.second << ")";
    return ostr;
}

vector<string> split(const string &s, char delim) {
    vector<string> result;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
        if (!item.empty()) {
            result.push_back(item);
        }
    }
    return result;
}

int main() {
    int N; cin >> N;
    string ans = "";

    int p = -2;
    while (N != 0) {
        if (N % p == 0) {
            ans.push_back('0');
        } else {
            ans.push_back('1');
            N -= 1;
        }
        N = N / p;
    }

    reverse(all(ans));
    cout << (ans.size() == 0 ? "0" : ans) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
 
typedef long long ll;


#define double long double

const double EPS = 1e-9;

double sqr(double x) {
    return x * x;
}

struct Point
{
    double x, y;
    
    Point(double _x, double _y): x(_x), y(_y) {};
    Point() {};
    
    Point operator + (Point A) {
        return Point(x + A.x, y + A.y);
    }
    Point operator * (double k) {
        return Point(k * x, k * y);
    }
    double len() {
        return sqr(x) + sqr(y);
    }
    
    void show() {
        cout << x << ' ' << y << '\n';
    }
};

double dist(Point A, Point B) {
    return sqrt(sqr(A.x - B.x) + sqr(A.y - B.y));
}

bool check(vector<Point> p, double R, Point C) {
    int n = sz(p);
    for (int k = 0; k < n; ++k)
        if (dist(p[k], C) > R + EPS) return false;
    return true;
}

int main()
{
    cout.precision(20);
    
    int n;
    cin >> n;
    vector<Point> p(n);
    for (int i = 0; i < n; ++i)
        cin >> p[i].x >> p[i].y;

    double ans = 1e9;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            Point C0 = (p[i] + p[j]) * 0.5;
            double R0 = dist(p[i], C0);
            if (check(p, R0, C0)) {
                ans = min(ans, R0);
                continue;
            }
            for (int k = j + 1; k < n; ++k) {
                double D = 2 * (p[i].x * (p[j].y - p[k].y) + p[j].x * (p[k].y - p[i].y) + p[k].x * (p[i].y - p[j].y));
                if (fabs(D) < EPS) continue;
                double Ux = (p[i].len() * (p[j].y - p[k].y) + p[j].len() * (p[k].y - p[i].y) + p[k].len() * (p[i].y - p[j].y));
                double Uy = (p[i].len() * (-p[j].x + p[k].x) + p[j].len() * (-p[k].x + p[i].x) + p[k].len() * (-p[i].x + p[j].x));
                Point C = Point(Ux / D, Uy / D);
                double R = dist(C, p[i]);
                if (check(p, R, C)) {
                    ans = min(ans, R);
                }
            }
        }
    }
    
    cout << ans << '\n';
}



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

#define ll long long
#define ld long double
#define pb push_back
#define mod 1000000007
#define mk make_pair
#define sz size


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

    ll n,k,i,j;
    cin>>n>>k;
    vector<ll> v(n);
    for(i=0;i<n;i++)cin>>v[i];
    ll ans=0;
    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
            if(v[i]>v[j]){
                ans+=(k*(k+1)/2ll);
                ans%=mod;
            }else if(v[i]<v[j]){
                ans+=(k*(k-1)/2ll);
                ans%=mod;
            }
        }
    }
    cout<<ans<<endl;
    return 0;  
}

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

int main() {
    int q;
    std::cin >> q;

    std::unordered_map<std::string, int> M;
    for (int i = 0; i < q; i++) {
        int op;
        std::string key;
        std::cin >> op >> key;
        if (op == 0) {
            int x;
            std::cin >> x;
            M[key] = x;
        } else if (op == 1) {
            std::cout << M[key] << std::endl;
        }
    }
}



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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define TASKNAME somethinghere

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

	//freopen(TASKNAME".inp", "r", stdin);
	//freopen(TASKNAME".out", "w", stdout);

    ll n;
    string s;
    cin >> n >> s;
	ll i = 0;
	while(i < n) {
		if(s[i] == s[i+1]) {
			s.erase(i+1, 1);
			i--;
			n--;
		}
		i++;
	}

	cout << s.size();
	cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}

// g++ .cpp -o .exe -DEVAL -std=c++11 -pipe -O2 -s -static -Wall -Wshadow
/* stuff you should look for
	* array bounds
	* special cases (n=1?), set tle
	* do sth instead of nothing and stay organized
	* check for variables with close names
*/


Measured memory_bytes: 512
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    string s; cin >> s;
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3] || s[3] == s[4]) cout << "Bad" << endl;
    else cout << "Good" << endl;
}


Measured memory_bytes: 256
from __future__ import print_function

import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# import math
# import string
# import fractions
# from fractions import Fraction
# from fractions import gcd

# def lcm(n,m):
#     return int(n*m/gcd(n,m))

# import re
# import array
# import copy
# import functools
# import operator

# import collections
# import itertools
# import bisect
# import heapq


# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace

# from queue import PriorityQueue as pq

# def reduce(p, q):
#     common = fractions.gcd(p, q)
#     return (p//common , q//common )
# # from itertools import accumulate
# # from collections import deque

# from operator import mul
# from functools import reduce

# def combinations_count(n, r):
#     r = min(r, n - r)
#     numer = reduce(mul, range(n, n - r, -1), 1)
#     denom = reduce(mul, range(1, r + 1), 1)
#     return numer // denom

# import random

def main():
    x = int(input().strip())
    d10 = x%100
    
    a=0
    b=0
    c=0
    d=0
    e=0
    
    f = d10//5
    
    if d10%5==0:
        pass
    elif d10%5==1:
        b=1
    elif d10%5==2:
        c=1
    elif d10%5==3:
        d=1
    elif d10%5==4:
        e=1
    else:
        try:
            raise ValueError("error!")
        except ValueError as e:
            eprint(e)

    if (b+c+d+e+f)*100<=x:
        print(1)
    else:
        print(0)
    return

if __name__ == '__main__':
    main()


'''
for given X (1<=X<=10**5).
exits (a,b,c,d,e,f \in [0...10**6]).
100*a + 101*b + 102*c + 103*d + 104*e + 105*f == X



100*(a+b+c+d+e+f) + (b + 2*c + 3*d + 4*e + 5*f) == X
(b + 2*c + 3*d + 4*e + 5*f) == X - 100*(a+b+c+d+e+f)

Xの下二桁をみると，
(b + 2*c + 3*d + 4*e + 5*f) % 100 =  (Xの下二桁) ---(1)
かつ
X >= 

100*(a+b+c+d+e+f) 
が成立．


このとき
(1)を満たす中で
b+c+d+e+fが最小の場合を考えると
let d0 and  d1 (0 <= d0,d1 <= 9) such that
	10*d1 + 1*d0  = (Xの下二桁)

(10*d1 + 1*d0) // 5 -> f
(10*d1 + 1*d0) % 5 -> 
(if 1 then b else b ->0
 if 2 then c else c ->0
 if 3 then d else d ->0
 if 4 then e else e ->0
)
の場合であることが分かる．(後述)
このとき
Xが小さすぎなければ，
乃ち
100*(b+c+d+e+f) <= X 
のとき，乃ち
  ( (100*(b+c+d+e+f) <= X) and ((b + 2*c + 3*d + 4*e + 5*f) % 100 == (Xの下二桁)) )

such that 
 (但し b,c,d,e は
  (10*d1 + 1*d0) // 5 -> f
  (10*d1 + 1*d0) % 5 -> 
  (if 1 then b else b ->0
   if 2 then c else c ->0
   if 3 then d else d ->0
   if 4 then e else e ->0
  )
 )

のとき，
for given X (1<=X<=10**5).
exits (a,b,c,d,e,f \in [0...10**6]).
100*a + 101*b + 102*c + 103*d + 104*e + 105*f == X
は必ず成立する

'''


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string t;
int n, w, s, e;

int main() {
	cin >> t;
	rep(i,t.length()) {
		if (t[i]=='N') n++;
		else if (t[i]=='W') w++;
		else if (t[i]=='S') s++;
		else e++;
	}
	if ((n+s && !(n*s)) || (w+e && !(w*e))) cout << "No" << ln;
	else cout << "Yes" << ln;
}

Measured memory_bytes: 256
use itertools::Itertools;
use proconio::input;

fn main() {
  input! {
    _: i64,
    c: String
  }
  let cs = c.chars().sorted();
  let r = c.chars().zip(cs).filter(|(a, b)| (*a == 'W') && (*b == 'R')).count();
  
  println!("{}", r);
}



Measured memory_bytes: 3456
#include <bits//stdc++.h>
using namespace std;
typedef long long int ll;
int main(void) {
    ll t1, t2, a1, a2, b1, b2; cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    ll p = (a1 - b1) * t1, q = (a2 - b2) * t2;
    if (p >= 0) p *= -1, q *= -1;
    if (p + q < 0) cout << 0 << endl;
    else if (p + q == 0) cout << "infinity" << endl;
    else {
        ll s = -p / (p + q), t = -p % (p + q);
        if (t != 0) cout << s * 2 + 1 << endl;
        else cout << s * 2 << endl;
    }
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



string s;
int a[202020];
i64 cnt[2020];
void solve(){
	cin >> s;
	int n = s.size();
	
	for(int i = 0; i < n; i++){
		a[i] = s[i]-'0';
	}
	
	int d = 0, c = 1;
	cnt[0]++;
	for(int i = n-1; i >= 0; i--){
		d += a[i]*c;
		d %= 2019;
		c *= 10;
		c %= 2019;
		cnt[d]++;
		//cout << d << endl;
	}
	i64 ans = 0;
	for(int i = 0; i < 2019; i++){
		ans += cnt[i]*(cnt[i]-1)/2;
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 4592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)

#define Rep(j,n) for(int j=i+1;j<(int)(n);++j)

#define int long long

using namespace std;

signed main()
{
    bool maxtrue=true;
    string a;
    cin>>a;
    if(a=="A"){
    a="T";
    }else if(a=="T"){
    a="A";
    }else if(a=="G"){
    a="C";
    }else{
    a="G";
    }
    cout<<a;
    return 0;
}



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

int main(){

	int a, b;
	cin >> a >> b;
	int ans;
	if((a+b)%2 == 0) ans = (a+b)/2;
	else ans = (a+b+1)/2;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100005],n;
int v[100005];
int main()
{
	while(~scanf("%d",&n))
	{
		bool flag=0;int mi=1e9,ma=0;
		for(int i=1;i<=n;++i)
		{
			scanf("%d",&a[i]);
			mi=min(mi,a[i]);
			ma=max(ma,a[i]);
			v[a[i]]++;
			if(i>1&&a[i]!=a[i-1])flag=1;
		}
		if(ma-mi>1)puts("No");
		else if(!flag)
		{
			if(ma==n-1)puts("Yes");
			else
			{
				if(n/2>=mi)puts("Yes");
				else puts("No");
			}
		}
		else
		{
			if(v[mi]+v[ma]/2==ma&&v[ma]>1)puts("Yes");
			else puts("No");
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long

int n;

struct Term
{
    int index;
    lin l;
    lin r;
};

vector<Term> termsL, termsR;

Term make_Term(int index, lin l, lin r)
{
    Term t;
    t.index = index;
    t.l = l;
    t.r = r;
    return t;
}

lin move(lin current, Term term)
{
    if(term.l < current && current < term.r)
        return 0;

    if(term.l >= current)
        return term.l - current;

    return term.r - current;
}

lin solve(lin current, int pl, int pr)
{
    unordered_set<int> deleted;
    rep(i, pl)
    {
        deleted.insert(termsL[i].index);
    }
    rep(i, pr)
    {
        deleted.insert(termsR[i].index);
    }

    lin res = abs(current);

    while(deleted.size() < n)
    {
        while(deleted.find(termsL[pl].index) != deleted.end())
            pl++;
        while(deleted.find(termsR[pr].index) != deleted.end())
            pr++;
            
        lin moveL = move(current, termsL[pl]);
        lin moveR = move(current, termsR[pr]);

        if(abs(moveL) > abs(moveR))
        {
            current += moveL;
            res += abs(moveL);
            deleted.insert(termsL[pl].index);            
        }
        else
        {
            current += moveR;
            res += abs(moveR);
            deleted.insert(termsR[pr].index);            
        }

        //cout << current << " " << moveL << " " << moveR << " " << termsL[pl].index << termsR[pr].index << endl;
    }

    res += abs(current);

    return res;
}

int main(void)
{
    cin >> n;
    rep(i, n)
    {
        lin l, r;
        cin >> l >> r;
        termsL.push_back(make_Term(i, l, r));
        termsR.push_back(make_Term(i, l, r));
    }

    sort(termsL.begin(), termsL.end(), [](Term t1, Term t2) -> int { return t1.l > t2.l || (t1.l == t2.l && t1.r > t2.r); });
    sort(termsR.begin(), termsR.end(), [](Term t1, Term t2) -> int { return t1.r < t2.r || (t1.r == t2.r && t1.l < t2.l); });

    lin res = max(
        solve(move(0, termsL[0]), 1, 0), 
        solve(move(0, termsR[0]), 0, 1));

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 9764
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 998244353

//つねに10億7などの剰余をとる構造体
//参考: https://www.youtube.com/watch?v=L8grWxBlIZ4&t=9858
//参考: https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#4-%E7%B4%AF%E4%B9%97-an
int mod  = MODA;
struct modint {
	ll x;
	modint (ll x):x(x%mod){}
	modint& operator+=(const modint a){
		(x += a.x ) %= mod;
		return *this;
	}
	modint& operator-=(const modint a){
		(x -= a.x ) %= mod;
		if (x < 0) x += mod;
		return *this;
	}
	modint& operator*=(const modint a){
		(x *= a.x ) %= mod;
		return *this;
	}
	modint& operator/=(modint a){
		ll exp = mod - 2;
		while(exp > 0){
			if(exp & 1) *this *= a.x;
			a *= a.x;
			exp >>= 1;
		}
		return *this;
	}
	modint operator+(const modint a) const{
		modint res(*this);
		return res+=a;
	}
	modint operator-(const modint a) const{
		modint res(*this);
		return res-=a;
	}
	modint operator*(const modint a) const{
		modint res(*this);
		return res*=a;
	}
	modint operator/(const modint a) const{
		modint res(*this);
		return res/=a;
	}
};
modint modpow(modint x, ll n){
	modint res=1;
	while(n > 0){
		if(n & 1) res = res * x.x;
		x = x * x;
		n >>= 1;
	}
	return res;
}

ll fac[200001], inv[200001], finv[200001];
void facinit(){
	fac[0] = 1; fac[1] = 1;
	finv[0] = 1; finv[1] = 1;
	inv[1] = 1;
	for(int i = 2; i <= 200000; i++){
		fac[i] = fac[i-1] * i % MODA;
		inv[i] = MODA - inv[MODA%i] * (MODA / i) % MODA;
		finv[i] = finv[i-1] * inv[i] % MODA;
	}
}

int main() {
	modint ans = 0;
	modint tmp = 0;
	facinit();
	int n, k;
	modint m = 0;
	cin >> n >> m.x >> k;
	REP(i, k+1){
		tmp = 1;
		tmp *= m;
		tmp *= modpow(m-1, (ll)(n - 1 - i));
		tmp *= fac[n-1];
		tmp *= finv[i];
		tmp *= finv[n-1-i];
		ans += tmp;
	}
	cout << ans.x << endl;
}

Measured memory_bytes: 8324
#include <stdio.h>
int main()
{
  int n,l=0,k=0;
  char x[10000000];
 
  scanf("%s",x);
  
  while(1){
    if(x[l] == '\0')
      break;
    l++;
  }

 
   for(n=0;n<l;n++){
     if(x[n-1]==x[n]){
       k++;
       if(x[n-1]=='0')
          x[n]='1';
         else 
          x[n]='0';
     }
    }
   printf("%d",k);
  return 0;
}

Measured memory_bytes: 2304
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class BRingosFavoriteNumbers {
public:
    void solve(std::istream &in, std::ostream &out) {
        int d, n;
        in >> d >> n;
        int res = n == 100 ? 101 : n;
        FOR(i, 0, d) {
            res *= 100;
        }
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    BRingosFavoriteNumbers solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node *NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;

  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;

  while(1){
    if(cur == nil) break;
    if(isf == 0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
    isf = 0;
  }
  
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;

  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;

  if(t == nil) return;

  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;

  if(t == nil) return;

  deleteNode(t);
}

void delete(int key){
  NodePointer t = listSearch(key);

  if(t == nil) return;

  deleteNode(t);
}

void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key,n,i;
  int size = 0;
  char com[20];
  int np = 0,nd = 0;

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

  for(i = 0;i < n;i++){
    scanf("%s%d",com,&key);

    if(!(0 <= key && key <= 2000000000)){
      printf("error\n");
    }

    if(com[0] == 'i'){
      insert(key);
      np++;
      size++;
    }
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
	if(com[6] == 'F'){
	  deleteFirst();
	}
	else if(com[6] == 'L'){
	  deleteLast();
	}
      }
      else{
	delete(key);
	nd++;
      }
      size--;
    }

    if(size > 1000000){
      printf("error\n");
    }
  }

  if(!(np + nd <= 2000000)){
    printf("error\n");
  }

  if(!(nd <= 20)){
    printf("error\n");
  }

  printList();

  return 0;
}



Measured memory_bytes: 33040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dbg(x) cerr << #x << " : " << x << endl;
#define endl '\n'
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll ans=n*(n-1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main() {
  int n; cin >> n;
  int f = 1;
  for (int i=0;i<n;i++) {int a;cin >> a;f&=1-(a&1);}
  if(f)cout << "second" << endl;
  else cout << "first" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <utility>
#include <tuple>
using namespace std;

constexpr int mod = 1000000007;

int pow2(int n) {
    // fprintf(stderr, "pow2(%d) = ", n);
    long ans = 1, x = 2;
    for (; n; n >>= 1, x = x * x % mod)
        if (n & 1)
            ans = ans * x % mod;
    // fprintf(stderr, "%d\n", (int) ans);
    return ans;
}

pair<int, int> solve(int *bg, int *ed) {
    int m = *min_element(bg, ed);
    for_each(bg, ed, [m](int &x) { x -= m; });

    long f = 1, s = 2;
    int n = 0;
    for (int *p = bg; p != ed;) {
        if (*p) {
            int *q = find(p, ed, 0);
            auto pa = solve(p, q);
            f = f * (pa.first + pa.second) % mod;
            s = s * pa.second % mod;
            p = q;
        } else {
            n++;
            p++;
        }
    }
    f = f * pow2(n) % mod;

    f = (f - s + mod) % mod;
    s = s * pow2(m - 1) % mod;
    f = (f + s) % mod;

    return make_pair(f, s);
}

int h[100];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", h + i);
    
    printf("%d\n", solve(h, h + n).first);
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>
#include <cmath>
#include <time.h>
#include <functional>
#include <cstdio>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define MOD1 1000000007;
#define MOD2 1000007
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/* ここからが本編 */
/*  */
int dic[10000000];
ull pow(ull x,ull n) {
  ull res = 1;
  while(n > 0) {
    if(n&1) res = res * x;
    x = x * x;
    n >>= 1;
  }
  return res;
}
int dic_op(char str[14],int& key)
{
  int j;
  int f = 1;
  int g = 0;
  for(j = 0;j<10;j++) {
    if(str[j] == 'A')
      g += f * 1;
    else if(str[j] == 'C')
      g += f * 2;
    else if(str[j] == 'G')
      g += f * 3;
    else if(str[j] == 'T')
      g += f * 4;
    else break;
    f *= 5;
  }
  key = 0;
  if(j == 10) {
    f = 1;
    for(;j<10;j++) {
      if(str[j] == 'A')
        key += f * 1;
      else if(str[j] == 'C')
        key += f * 2;
      else if(str[j] == 'G')
        key += f * 3;
      else if(str[j] == 'T')
        key += f * 4;
      else break;
        f *= 5;
    }
  }
  return g;
}
int main()
{
  int i,j,k,l;
  long n;
  long ans = 0;
  char opstr[7];
  char str[13];
  int key;
  int a = 1;
  cin >> n;
  for (i = 0; i < n; i++) {
    scanf("%s %s",opstr,str);
    if(opstr[0] == 'i') {
      int tmp = dic_op(str,key);
      if( (dic[tmp] >> key) % 2 == 0) {
        dic[tmp] += 1 << key;
      }
    }
    else if(opstr[0] == 'f') {
      int tmp = dic_op(str,key);
      /*
      printf("tmp = %d\n",tmp);
      printf("key = %d\n",key);
      printf("dic[tmp] = %d\n",dic[tmp]);
      */
      if( (dic[tmp] >> key) % 2 == 1) {
        puts("yes");
      }
      else {
        puts("no");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 39168
// D - Derangement
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int solve(int N, vi &P){
	int ans = 0;
	rp(i, 1, N+1){//1 origin
		if(P[i] == i){//X
			swap(P[i], P[i + (i==N? -1:1) ]);//LR swap
			ans++;
			i++;
		}
	}
	return ans;
}

int main(){
	int N; cin>>N;
	vi P(N+1); rp(i, 1, N+1) cin>>P[i];//1 origin
	cout<< solve(N, P) <<endl;
}

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

int main(){
  int N,i,j;
  bool ok=true;
  cin>>N;
  vector<vector<int>> time(N,vector<int>(3,0));
  for(i=0;i<N;i++){
    for(j=0;j<3;j++){
    cin>>time.at(i).at(j);
    }
  }

  int s_x=0;
  int s_y=0;
  int s_tt=0;
  for (int k=0;k<N;k++){
    
  int x=time.at(k).at(1);
  int y=time.at(k).at(2);
  int t=time.at(k).at(0);
  if((abs(x-s_x)+abs(y-s_y))%2==abs(t-s_tt)%2 && (abs(x-s_x)+abs(y-s_y))<=(t-s_tt)){
    s_x=x;
    s_y=y;
    s_tt=t;
  }else{
    ok=false;
   break;
  }
  
  }
if(ok==false){
 cout<<"No"<<endl; 
}else{
 cout<<"Yes"<<endl; 
}
}

Measured memory_bytes: 5760
import java.util.*; 
import java.lang.*; 

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int N = scan.nextInt();
		int M = scan.nextInt();
		
		System.out.println((N*(N-1)/2)+(M*(M-1)/2));
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b+c){
        cout << "Yes" << endl;
    }else if(b==c+a){
        cout << "Yes" << endl;
    }else if(c==a+b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}




Measured memory_bytes: 256
A,B,C = map(int,input().split())
maxi = max(A,B,C)
mini = min(A,B,C)
mid = sum([A,B,C]) - (maxi+mini)
i,j,k,l = 0,0,0,0
if mini%2 != mid%2:
    #midだけ偶奇が違うとき
    if maxi%2 == mini%2 and maxi%2 != mid%2:
        if mid - maxi != 1:
            i = (maxi+1-mid)//2
            mid = maxi + 1
    #miniだけ偶奇が違うとき
    if maxi%2 != mini%2 and maxi%2 == mid%2:
        if mini - maxi != 1:
            j = (maxi+1-mini)//2
            mini = maxi + 1
while maxi - mini > 1:
    mini += 2
    k += 1
while maxi - mid > 1:
    mid += 2
    l += 1
if maxi == mini and maxi == mid:
    print(i+j+k+l)
else:
    print(i+j+k+l+1)

Measured memory_bytes: 3064
#pragma region Include
#include <bits/stdc++.h>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define newl "\n"
#define out(x) cout << (x) << newl
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << newl
template <class T>
using VV = vector<vector<T>>;
#define Uni(v) (v).erase(unique((v).begin(), (v).end()), (v).end());

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;

string tostring(int i, int digit) {
  auto cur = cout.flags();
  stringstream ss;
  ss << setw(digit) << setfill('0') << i;
  string ret = ss.str();
  cout.flags(cur);
  return ret;
}

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

#pragma endregion

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string A, B;
  cin >> A >> B;
  int l = A.length();
  bool flag = true;
  rep(i, l) {
    if (A[i] != B[i]) {
      flag = false;
      break;
    }
  }
  if (flag) {
    out("Yes");
  } else {
    out("No");
  }

  return 0;
}

Measured memory_bytes: 3612
#include<cstdio>
#include<algorithm>
#define MN 110001
#define ll long long
using namespace std;

ll read_p,read_ca;
inline ll read(){
	read_p=0;read_ca=getchar();
	while (read_ca<'0'||read_ca>'9') read_ca=getchar();
	while (read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
	return read_p;
}
ll n,m,x;
int main(){
	n=read();m=read();
	if (m>n*2) x=(m-n*2)/4,n+=x,m-=2*x;
	m/=2;
	printf("%lld\n",n>m?m:n);
}

Measured memory_bytes: 128
N, M = map(int, input().split())

def solve() :
    ret = 1
    i = 1
    while i * i <= M :
        if M % i == 0 :
            if i >= N :
                ret = max(ret, M // i)
            if M // i >= N :
                ret = max(ret, i)
        i += 1
    
    return ret

print(solve())

Measured memory_bytes: 40156
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
    string str;
    char ch[3];
    int count = 0;

    cin >> str;
    str.copy(ch, str.size());

    FOR(i,0,3)if(ch[i] == 'o')count++;

    cout << 700 + count * 100;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,a[100000],h,n,ans;
  scanf("%d %d",&h,&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    ans+=a[i];
    if(ans>=h){
      printf("Yes");
      break;
    }
  }
  if(ans<h)
    printf("No");
  return 0;
}

Measured memory_bytes: 512
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"

using namespace std;
typedef long long ll;

int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  int p[110];
  for (int i = 0; i < n; i++)
  {
    cin >> p[i];
  }
  int x = 0;
  int y = 0;
  int z = 0;
  for (int i = 0; i < n; i++)
  {
    if (p[i] <= a)
    {
      x++;
    }
    else
    if (p[i] <= b)
    {
      y++;
    }
    else
    {
      z++;
    }
  }
  cout << min({x, y, z}) << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        while(true){
 
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
 
            if(op.equals("?"))break;
 
            int ans = 0;
 
            switch(op){
            case "+":
                ans = a+b;
                break;
            case "-":
                ans = a-b;
                break;
            case "*":
                ans = a*b;
                break;
            case "/":
                ans = a/b;
                break;
            }
 
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 26400
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S,T;cin>>S>>T;
  int A,B;cin>>A>>B;
  string U; cin>>U;
  if (U==S){
    cout << A-1 << " " << B;
  }
  else{
    cout << A << " " << B-1;
  }
}

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

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

    vector<int> A;
    int tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        A.push_back(tmp);
    }

    long long sum = 0;
    for (int i = 1; i < N; i++)
    {
        if (A.at(i - 1) > A.at(i))
        {
            sum += A.at(i - 1) - A.at(i);
            A.at(i) = A.at(i - 1);
        }
    }

    cout << sum << endl;

    return 0;
}

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



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    string s;
    cin>>s;
    ll n = s.size();
    ll mod = 1e9+7;
    ll dp[n+1][2]={};
    dp[0][0]=1;
    
    for(int i=0;i<n;i++){
        if(s[i]=='1') dp[i+1][0] = 2*dp[i][0];
        else dp[i+1][0] = dp[i][0];
        dp[i+1][1] = dp[i][1] * 3;
        if(s[i]=='1') dp[i+1][1] += dp[i][0];
        dp[i+1][0] %= mod;
        dp[i+1][1] %= mod;
    }
    ll ans = dp[n][1] + dp[n][0];
    ans %= mod;
    cout << ans << endl;
}

Measured memory_bytes: 2000
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

int main(void) {
    int n, m;
    cin >> n >> m;

    int a;
    int sum = 0;
    rep(i, 0, m) {
        cin >> a;
        sum += a;
    }

    int ans = -1;
    if (sum == n) ans = 0;
    if (sum < n) ans = n - sum;
    cout << ans << endl;

    return 0;
}


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

namespace IO
{
    const int S=(1<<20)+5;
    char buf[S],*H,*T;
    inline char Get()
    {
        if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
        if(H==T) return -1;return *H++;
    }
    inline void reads(char *s)
    {
        char c=Get();int tot=0;
        while(c!='#'&&c!='.') c=Get();
        while(c=='#'||c=='.') s[++tot]=c,c=Get();
        s[++tot]='\0';
    }
    char obuf[S],*oS=obuf,*oT=oS+S-1,c,qu[55];int qr;
    inline void flush(){fwrite(obuf,1,oS-obuf,stdout);oS=obuf;}
    inline void putc(char x){*oS++ =x;if(oS==oT) flush();}
    inline void prints(const char *s)
    {
        int len=strlen(s);
        for(int i=0;i<len;i++) putc(s[i]);
        putc('\n');
    }
}

using namespace IO;
const int N=510;
char A[N][N],B[N][N],C[N][N];
int n,m;

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            B[i][j]=C[i][j]='.';
    for(int i=1;i<=n;i++)
    {
        reads(A[i]);
        for(int j=1;j<=m;j++)
            if(A[i][j]=='#') B[i][j]=C[i][j]='#';
    }
    for(int i=2;i<n;i++)
        for(int j=1;j<=m;j+=2)
            B[i][j]='#';
    for(int i=2;i<n;i++)
        for(int j=2;j<=m;j+=2)
            C[i][j]='#';
    for(int i=1;i<=m;i++)
        B[1][i]=C[n][i]='#';
    for(int i=1;i<=n;i++)
        B[i][m+1]='\0',prints(B[i]+1);
    putchar('\n');
    for(int i=1;i<=n;i++)
        C[i][m+1]='\0',prints(C[i]+1);
    flush();
    return 0;
}

Measured memory_bytes: 2176