akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 1e18;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
// priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
// #define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
 
ll mod = 998244353;
//ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,a,b,c,d,e,h,r,l,q;
ll k;
ll x[500005], y[500005], z[500005];
// char s[500005];
string s, t, u;

int main(){
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if(s == u){
        pe(a-1);p(b);
    }else{
        pe(a);p(b-1);
    }
    return 0;
}


















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;



signed main(){
    ll n;
    cin>>n;

    vector<tuple<string,int,int>> v(n);

    for(int i=0;i < n;i++)
    {
        cin>>get<0>(v.at(i))>>get<1>(v.at(i));
        get<1>(v.at(i))*=(-1);
        get<2>(v.at(i))=i+1;
    }
    sort(v.begin(),v.end());

    for(int i=0;i < n;i++)
    {
        cout << get<2>(v.at(i)) << endl;
    }
}

Measured memory_bytes: 256
from collections import deque
H, W = map(int, input().split())
G = [list(input()) for i in range(H)]
directions = [[0, 1], [1, 0], [0, -1], [-1, 0]]

ans = 0
for sh in range(H):
    for sw in range(W):
        # 通れないマスはスタートになり得ない
        if G[sh][sw] == '#':
            continue

        # BFS
        dist = [[-1] * W for i in range(H)]
        dist[sh][sw] = 0
        que = deque([[sh, sw]])

        while que:
            nh, nw = que.pop()
            for dh, dw in directions:
                # 迷路からはみ出す
                if not ((0 <= nh + dh < H) and (0 <= nw + dw < W)):
                    continue

                # 移動先が通れないマス
                if G[nh + dh][nw + dw] == '#':
                    continue

                # 探索済み
                if dist[nh + dh][nw + dw] != -1:
                    continue

                dist[nh + dh][nw + dw] = dist[nh][nw] + 1
                que.appendleft([nh + dh, nw + dw])

        ans = max(ans, max([max(d) for d in dist]))

print(ans)


Measured memory_bytes: 3316
k, n = map(int, input().split())
A = list(map(int, input().split()))
s = A[0]
c = [0]*n 
for i in range(n):
  c[i] = k + A[i]
b = A + c 
ans = float('inf')
for i in range(n):
  ans = min(ans, b[i+n-1]-b[i])
print(ans)


Measured memory_bytes: 81356
use std::cmp;

const INF: i64 = 1 << 50;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let a: Vec<i64> = sc.vec(n);
    let mut dp = [INF; 5];
    dp[0] = 0;
    for i in 0..n {
        let a = a[i];
        let mut next = [INF; 5];
        for i in 0..5 {
            for j in i..5 {
                let cost = match j {
                    0 => a,
                    1 if a == 0 => 2,
                    1 => a % 2,
                    2 => (a + 1) % 2,
                    3 if a == 0 => 2,
                    3 => a % 2,
                    4 => a,
                    _ => unreachable!(),
                };
                next[j] = cmp::min(next[j], dp[i] + cost);
            }
        }
        dp = next;
    }

    let ans = dp.iter().min().unwrap();
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 6396
import itertools
n,m=map(int,input().split())
s=list(input().split() for i in range(n))
l=[]
c=0
for j in range(n):
    l.append(s[j][1:])
l=list(itertools.chain.from_iterable(l))    

for i in range(1,m+1):
    if l.count(str(i))==n:
        c+=1
print(c)        
        

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProCon
{

    class Program
    {
        static long[] Nums;
        static void Main(string[] args)
        {
            Console.ReadLine();
            string[] input = Console.ReadLine().Split(' ');
            Nums = new long[input.Count()];
            int i = 0;
            long All = 0;
            foreach ( string str in input)
            {
                Nums[i] = long.Parse(str);
                All += Nums[i];
                ++i;
            }
            long Sum1 = 0;
            long Sum2 = All;
            long LastResult = long.MaxValue;
            for(int j = 0; j < input.Count() - 1; ++j)
            {
                Sum1 += Nums[j];
                Sum2 -= Nums[j];
                if(LastResult > Math.Abs(Sum2 - Sum1)) {
                    LastResult = Math.Abs(Sum2 - Sum1);
                }
            }
            Console.WriteLine(LastResult);
        }
    }
 
}


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

typedef long long           ll;
typedef vector < int >      vi;
typedef vector < ll >       vll;
typedef pair < int, int >   pii;
typedef pair < ll, ll >     pll;
typedef set<int>            sset;
typedef multiset<ll>        mset;

#define gcd(a,b)            __gcd(a,b)
#define lcm(a,b)            a/gcd(a,b)*b
#define pb                  push_back
#define mp                  make_pair
#define endl                "\n"
#define optimize            ios::sync_with_stdio(0); cin.tie(0)

void solve(){
        int  n;cin>>n;
                map<string,int> m;
       while(n--){
            string s;cin>>s;
       m[s]++;
       }
            cout<<"AC "<<"x "<<m["AC"]<<endl;
            cout<<"WA "<<"x "<<m["WA"]<<endl;
            cout<<"TLE "<<"x "<<m["TLE"]<<endl;
            cout<<"RE "<<"x "<<m["RE"]<<endl;

}

int main() {
   //int t;cin>>t;
   //while()
   solve();

    return 0;
}




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

using namespace std;

const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
struct Node{
	int c,w;
}a[maxn];
int n,X,Y;
int sum;
vector<int>bu[maxn];
int p[maxn];
int Min[maxn];
int ans[maxn];
int fac[maxn];
int inv[maxn];
int Mul(int x,int y){return 1LL * x * y % mod;}
int Pow(int x,int k,int re = 1){
	for(; k; k >>= 1,x = Mul(x,x))
		if(k & 1)re = Mul(re,x);
	return re;
}
int Read(char c = 0,int re = 0){
	while(!isdigit(c = getchar()));
	re = c - '0';
	while(isdigit(c = getchar()))
		re = ((re << 2) + re << 1) + c - '0';
	return re;
}
bool Cmp(const int& A,const int& B){
	return (Min[A] == Min[B]) ? (A < B) : (Min[A] < Min[B]);
}
int main(){
	n = Read(),X = Read(),Y = Read();
	memset(Min,0x3f,sizeof Min);
	for(int i = 1; i <= n; ++i){
		a[i].c = Read(),a[i].w = Read();
		bu[a[i].c].push_back(i);
		if(Min[a[i].c] > a[i].w)
			Min[a[i].c] = a[i].w;
	}
	for(int i = 1; i <= n; ++i)p[i] = i;
	sort(p + 1,p + n + 1,Cmp);
	for(int i = 1; i <= n; ++i)if(bu[p[i]].size()){
		int id = p[i];
		if(i != 1 && Min[id] + Min[p[1]] > Y)continue;
		for(int x : bu[id]){
			if(a[x].w + Min[id] <= X || (i != 1 && a[x].w + Min[p[1]] <= Y))
				sum++,ans[id]++/*,printf("join %d\n",x)*/;
			else if(i != 2 && Min[p[1]] + Min[p[2]] <= Y && a[x].w + Min[p[2]] <= Y)
				sum++,ans[id]++/*,printf("join %d\n",x)*/;
		}
	}
	fac[0] = inv[0] = 1;
	for(int i = 1; i <= n; ++i)fac[i] = Mul(fac[i - 1],i);
	inv[n] = Pow(fac[n],mod - 2);
	for(int i = n - 1; i; --i)inv[i] = Mul(inv[i + 1],i + 1);
	int Ans = fac[sum];
	//printf("%d\n",sum);
	for(int i = 1; i <= n; ++i)
		Ans = Mul(Ans,inv[ans[i]]);
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 14720
# include <bits/stdc++.h>
using namespace std;
double p,n,k,k1,ans,w,t;
string s;
int main()
{			double d=0.5;

	cin>>n>>k;
	for (int i=1; i<=n; i++)
	{
		w=0;
		p=0;
		if (i>=k)
		{
			ans++;
		}
		else
		{
			 t=i;
			while (true)
			{
				w++;
				if (t>=k) break;			
				t*=2;
			}
			w--;
			//cout<<w<<" ";
			k1=1;
			for (int j=1; j<=w; j++)
			{
				k1*=d;
			}
			ans+=k1;
		}
	}
	double ans1=1/n;
	std::cout << std::setprecision(10) << ans*ans1;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  static int[] l;
  static int min = 1000000000;
  static int N, A, B, C;

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    N = sc.nextInt();
    A = sc.nextInt();
    B = sc.nextInt();
    C = sc.nextInt();
    l = new int[N];
    for (int i = 0; i < N; i++) {
      l[i] = sc.nextInt();
    }
    sc.close();
    dfs(0, 0, 0, 0, 0);
    System.out.println(min);
  }

  static void dfs(int n, int a, int b, int c, int d) {
    if (n == N) {
      if (a == 0 || b == 0 || c == 0) {
        return;
      }
      int cost = Math.abs(A - a) + Math.abs(B - b) + Math.abs(C - c);
      cost += d - 30;
      min = Math.min(min, cost);
      return;
    }
    dfs(n + 1, a, b, c, d);
    dfs(n + 1, a + l[n], b, c, d + 10);
    dfs(n + 1, a, b + l[n], c, d + 10);
    dfs(n + 1, a, b, c + l[n], d + 10);
  }
}

Measured memory_bytes: 22612
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    vector<int> a(9);
    for(auto &x : a){
        cin >> x;
    }
    int d = a[3] - a[0];
    bool ok = true;
    for(int i = 0; i < 3; i++){
        ok &= (d == a[3 + i] - a[i]);
    }  
    d = a[6] - a[0];
    for(int i = 0; i < 3; i++){
        ok &= (d == a[6 + i] - a[i]);
    }
    d = a[6] - a[3];
    for(int i = 0; i < 3; i++){
        ok &= (d == a[i + 6] - a[3 + i]);
    }
    d = a[1] - a[0];
    for(int i = 0; i < 3; i++){
        ok &= (d == a[(3 * i) + 1] - a[3 * i]);
    }
    d = a[2] - a[1];
    for(int i = 0; i < 3; i++){
        ok &= (d == a[(3 * i + 1) + 1] - a[(3 * i + 1)]);
    }
    d = a[2] - a[0];
    for(int i = 0; i < 3; i++){
        ok &= (d == a[(3 * i + 1) + 1] - a[(3 * i)]);
    }
    if(ok){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

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

int main(void) {
	int N, K;
	bool D[] = {true, true, true, true, true, true, true, true, true, true};
	std::vector<int> digits;
	std::cin >> N >> K;
	for(int i = 0; i < K; ++i) {
		int t;
		std::cin >> t;
		D[t] = false;
	}
	for(int result = N; result < N * 10; ++result) {
		int t = result;
		bool flag = true;
		while(t != 0) {
			if(!D[t % 10]) {
				flag = false;
				break;
			}
			t /= 10;
		}
		if(!flag) continue;
		std::cout << result << '\n';
		return 0;
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

const int SIZE=100010;
struct edge{
    int to,cost;
};

vector<edge> G[SIZE];
int color[SIZE];

void dfs(int v,int c)
{
    color[v]=c;
    for(edge e:G[v]){
        if(color[e.to]==-1){
            if(e.cost==0) dfs(e.to,c);
            else dfs(e.to,c^1);
        }
    }
}


signed main()
{
    int N; cin>>N;
    for(int i=0;i<N-1;i++){
        int u,v,w; cin>>u>>v>>w;
        u--; v--; w%=2;
        G[v].push_back({u,w});
        G[u].push_back({v,w});
    }
    memset(color,-1,sizeof(color));
    dfs(0,0);
    for(int i=0;i<N;i++){
        cout<<color[i]<<endl;
    }
}


Measured memory_bytes: 12160
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [-int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    a = SI()
    if ord('A') <= ord(a) <= ord('Z'):
        print('A')
    else:
        print('a')


if __name__ == '__main__':
    main()

Measured memory_bytes: 68800
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll n, k;
    cin >> n >> k;

    ll ans = pow(n/k, 3);

    if(k % 2 == 0)ans += pow(n/(k/2) - n/k, 3);

    cout << ans << endl;
}

Measured memory_bytes: 4008
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
  
    vector<tuple<string, int, int>> list;
    for (int i=0; i<n; i++) {
        string s;
        int p;
        cin >> s >> p;
      
        list.push_back(make_tuple(s, p, i+1));
    }
  

    sort(list.begin(), 
         list.end(), 
         [](const tuple<string, int, int>& x, const tuple<string, int, int>& y) -> int {
              //printf("comp: %s:%d,   %s:%d \n", 
              //        get<0>(x).c_str(), get<1>(x), get<0>(y).c_str(), get<1>(y));
              
              if (get<0>(x) == get<0>(y)) {
                  auto r = get<1>(x) > get<1>(y);
                  //printf("ret1 %d \n", r);
                  return r;
              }

              auto r = get<0>(x) < get<0>(y);           
              //printf("ret2 %d \n", r);
              return r;
             
         } 
    );

    for (auto &it: list) {
        cout << get<2>(it) << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
using namespace std;
typedef long long ll;
ll mod = 1000000007;

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

	ll a[100000];
	int x = 0;
	int y = 0;
	int z = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];

		if (a[i] % 2 == 0)
		{
			if (a[i] % 4 == 0)
			{
				x++;
			}
			else {
				y++;
			}
		}
		else {
			z++;
		}
	}

	if (y > 0) {
		z++;
	}

	cout << ((x + 1 >= z) ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 1024
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	int n, m, l, r;
	cin >> n >> m;
	int left = 1, right = n;
	for (int i = 0; i < m; ++i) {
		cin >> l >> r;
		left = max(left, l);
		right = min(right, r);
	}
	int ans = max(0, right - left + 1);
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> Pair;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll N;

VL divisor(ll n) {
    VL res;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            if(i != (n / i) && i + 1 < (n / i)) res.push_back(n / i);
        }
    }
    return res;
}

int main() {
    cin >> N;
    VL v = divisor(N);
    ll ans = 0;
    FOREACH(x, v) { ans += x - 1; }
    cout << ans << "\n";
}


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

using namespace std;

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

int main(){
  string s;
  cin >> s;
  
  int n = s.size();
  rep(i, 0, n) {
    if (i % 2 == 0) {
      if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
        cout << "No" << endl;
        return 0;
      }
    }
    else {
      if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	ints := []int{a, b, c}
	sort.Ints(ints)
	fmt.Println(ints[0] * ints[1] / 2)
}


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

  
int main() {
  int64_t A ,B,K;
  cin >> A >> B >> K;
  if(A >= K) cout << A-K << " "<<B <<endl;
  else if(B >= K-A) cout << 0 << " " <<B - (K-A)<<endl;
  else cout <<0<<" "<<0<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string O,E;
    cin>>O>>E;
    for(int i=0;i<E.size();i++) cout<<O[i]<<E[i];
    if(O.size()>E.size())cout<<O.back()<<"\n";
    else cout<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
const int MAX = 510000;
const int MOD = 1000000007;
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
    ll a,v,b,w,t;cin>>a>>v>>b>>w>>t;
    ll l=max(a-b,b-a);
    if(v<=w){
      cout<<"NO"<<endl;
      return 0;
    }
    if(l<=t*(v-w))cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}

Measured memory_bytes: 3632
import numpy as np

N = int(input())
S = input()
alpha = np.zeros(52)
Alp = [chr(i) for i in range(97, 97+52)]
for s in S:
  alpha[Alp.index(s)] += 1
alpha = alpha[np.nonzero(alpha)]
def func(alpha):
  Size = alpha.shape[0]
  ans = 0
  if Size>1:
    size=int(Size/2)
    m_ans = func(alpha[:size])
    u_ans = func(alpha[size:])
    ans = (m_ans+1)*(u_ans+1)-1
  else:
    ans = alpha[0]
  return int(ans)

print(func(alpha)%(10**9+7))

Measured memory_bytes: 12612
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll n, W;
ll w[100], v[100];
ll dp[101][100001];

int main() {
    cin >> n >> W;
    rep(i,n) cin >> w[i] >> v[i];
    rep(i,n+1) rep(j,100001) dp[i][j] = W+1;
    dp[0][0] = 0;
    rep(i,n) {
        for (int j = 0; j < v[i]; j++) dp[i+1][j] = dp[i][j];
        for (int j = v[i]; j <= 100000; j++) {
            dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]]+w[i]);
        }
    }
    ll ans = 0;
    rep(i,100001) if (dp[n][i] <= W) ans = max(ans, (ll)i);
    cout << ans << endl;
}



Measured memory_bytes: 79104
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

void solve()
{
	string s;
	cin >> s;
	deque<char> D;
	for (int i = 0; i < s.length(); i++)
		D.push_back(s[i]);
	int q;
	cin >> q;
	int rev = 0;
	while (q--)
	{
		int t;
		cin >> t;
		if (t == 1)
			rev = 1 - rev;
		else
		{
			int f;
			char c;
			cin >> f >> c;
			if (f == 1)
			{
				if (rev)
					D.push_back(c);
				else
					D.push_front(c);
			}
			else
			{
				if (rev)
					D.push_front(c);
				else
					D.push_back(c);
			}
		}
	}
	if (rev)
		reverse(D.begin(), D.end());
	for (int i = 0; i < sz(D); i++)
		cout << D[i];
	cout << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 976
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int a,b,c,d,ans;
	cin>>a>>b>>c>>d;
	if(b<=c||a>=d) ans=0;
	if(c>=a&&d>=b&&b>=c) ans=b-c;
	if(c<=a&&b<=d) ans=b-a;
	if(c>=a&&b>=d) ans=d-c;
	if(a>=c&&b>=d&&d>=a) ans=d-a;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
    int n,count=0,i;
    string str,temp;
    cin >> n;
    cin >> str;
    for(i=0;i<n-2;i++)
    {
        temp=str.substr(i,3);
        //cout << temp << endl;
        if(temp=="ABC")
        {
            count++;
        }
    }
    cout << count;
}


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

namespace ABC108
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] xy = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] sidexy1 = new int[2] { xy[2] - xy[0], xy[3] - xy[1] };
            int[] sidexy2 = new int[2] { -sidexy1[1], sidexy1[0] };
            int[] ans = new int[4] { xy[2] + sidexy2[0], xy[3] + sidexy2[1], xy[0] + sidexy2[0], xy[1] + sidexy2[1] };
            Console.WriteLine(ans[0]+" "+ans[1]+" "+ans[2]+" "+ans[3]);
        }
    }
}

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

int main() {
  string S;
  cin >> S;

  if(S == "SAT") cout << 1 << endl;
  if(S == "FRI") cout << 2 << endl;
  if(S == "THU") cout << 3 << endl;
  if(S == "WED") cout << 4 << endl;
  if(S == "TUE") cout << 5 << endl;
  if(S == "MON") cout << 6 << endl;
  if(S == "SUN") cout << 7 << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		String s = sc.next();
		int cntA = 0;
		for(int i = 0; i < 3; ++i) {
			if(s.charAt(i) == 'A') {
				cntA++;
			}
		}
		String ans = (cntA % 3 != 0) ? "Yes" : "No";
		System.out.println(ans);
	}

}


Measured memory_bytes: 21844
h,w=map(int, input().split())
s=[list(input()) for i in range(h)]
dp=[[0]*(w+2) for i in range(h+2)]
dp[0][1]=1

for i in range(h):
    for j in range(w):
        if s[i][j]=='.':
            dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j]
        else:
            pass
    
        
print(dp[h][w]%(10**9+7))

Measured memory_bytes: 165328
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=998244353;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

int dx[]={1, 0, -1, 0};
int dy[]={0, -1, 0, 1};

ll modpow(ll a, ll b){
    if(b == 0) return 1;
    else if(b % 2 == 0){
        ll d = modpow(a, b/2) % MOD;
        return (d * d) % MOD;
    }
    else{
        return (a * modpow(a, b-1)) % MOD;
    }
}

int main(){
    int n; cin>>n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];

    int sum = accumulate(a.begin(), a.end(), 0); 

    vector<vector<ll>> dp(n+10, vector<ll>(sum+10, 0));
    dp[0][0] = 1;
    auto dp2 = dp;
    for(int i=0; i<n; i++){
        for(int j=0; j<=sum+5; j++){
            // Red
            if(j - a[i] >= 0) (dp[i+1][j] += dp[i][j-a[i]]) %= MOD;
            // Blue or Green
            (dp[i+1][j] += dp[i][j] * 2) %= MOD;

            if(j - a[i] >= 0) (dp2[i+1][j] += dp2[i][j-a[i]]) %= MOD;
            (dp2[i+1][j] += dp2[i][j]) %= MOD;
        }
    }

    ll whole = modpow(3, n);
    ll lengthLarge=0;
    if(sum % 2){
        for(int i=sum/2+1; i<=sum; i++){
            (lengthLarge += dp[n][i] * 3) %= MOD;
        }

        cout << (whole - lengthLarge + MOD) % MOD << endl;
    }
    else{
        for(int i=sum/2; i<=sum; i++){
            (lengthLarge += dp[n][i] * 3) %= MOD;
        }

        ll halfSum = dp2[n][sum/2] * 3;

        cout << (whole - lengthLarge + halfSum + MOD) % MOD << endl;
    }
}

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

using namespace std;
typedef long long ll;

int main() {
   ll n;
   cin >> n;
   ll count = 0;
   vector<ll> a(n);
   for(auto &it : a) cin >> it;
   for(ll i = 0; i < n; i++){
       for(ll j = 0; j < n; j++){
           for(ll k = 0; k < n; k++){
               if(i < j && j < k){
                   if(a[i] == a[j]) continue;
                   if(a[j] == a[k]) continue;
                   if(a[k] == a[i]) continue;
                   if(a[i] + a[j] + a[k] <= max({a[i], a[j], a[k]})*2) continue;
                   count++;
               }
           }
       }
   }
   cout << count << endl;
   



}



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

#define REP(i, t) for(int i=0;i<t;i++)

int main () {
    string s;
    int a,i,t,x,W,H,N,num[2]={1,1};
    cin >> s;
    a=abs(int(s.find('A')-s.rfind('Z')))+1;
    cout << a << endl;

    return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <stdio.h>
#include<math.h>
int main(void){
    // Your code here!
    double r,S,C;
    scanf("%lf",&r);

    S=3.14159265358979*r*r;
    C=2*3.14159265358979*r;
    printf("%f %f",S,C); 
    
    return 0;
}


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

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

    int res = -1;
    for (int i=0; i<=a; i++) {
        if ((i * 108) / 100 == a) {
            res = i;
        }
    }

    if (res != -1) {
        printf("%d\n", res);
    } else {
        puts(":(");
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	string row;
	while(1){
		int sum=0;
		cin>>row;
		if(row=="0")break;
		for(int i=0;i<row.size();i++){
			sum+=row[i]-'0';
		}
		cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
typedef pair<int,int> pii;
int n,ls[30],mx1,mx2,x;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        mx1=0;
        for(int j=1;j<=26;j++)
        {
            scanf("%d",&x);
            if(mx1<(i-ls[j])*x)mx1=(i-ls[j])*x,mx2=j;
            else if(mx1==(i-ls[j])*x)if(ls[j]<ls[mx2])mx2=j;
        }
        ls[mx2]=i;
        printf("%d\n",mx2);
    }
}


Measured memory_bytes: 3804
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  map<string, string> dic;

  dic["Sunny"] = "Cloudy";
  dic["Cloudy"] = "Rainy";
  dic["Rainy"] = "Sunny";

  string in;

  cin >> in;
  cout << dic[in] << endl;

  return 0;
}


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


int main()
{
    int n;
    cin >> n;
    int D1[n], D2[n];
    int count = 0;

    for(int i = 0; i < n; ++i ) {
        cin >> D1[i] >> D2[i];
        if( D1[i] == D2[i]) count++;
        else if ( D1[i] != D2[i] && count < 3) count = 0;
        else break;
    }

    if ( count >= 3 ) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N = Integer.parseInt(sc.next());
	static int[] A = new int[N];
	static {
		Arrays.setAll(A, i -> Integer.parseInt(sc.next()));
	}
	public static void main(String[] args) {
		int ans = gcd(A[0], A[1]);
		for (int i = 2; i < N; i++) {
			ans = gcd(ans, A[i]);
		}
		System.out.println(ans);
	}
    private static int gcd(int m, int n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
}

Measured memory_bytes: 51228
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

int N;
int finalAns;

int main()
{

	scanf("%d", &N);
	finalAns  = N  / 3;

	printf("%d\n", finalAns);
	
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll n, k;
    cin >> n >> k;

    ll a[n];
    rep(i,n)cin >> a[i];
    sort(a,a+n);

    ll ans = 0;

    ll l = 0, r = 1001001;

    while(l + 1 < r){
        ll m = (l + r) / 2;
        ll cnt = 0;
        rep(i,n){
            auto ite = lower_bound(a, a+n, m - a[i]);
            cnt += a + n - ite;
        }

        if(cnt >= k){
            l = m;
        }else{
            r = m;
        }
    }

    ll b[n];
    rep(i,n)b[i] = a[i];
    sort(b,b+n,greater<ll>());
    ll sum[n+1] = {};
    srep(i,1,n+1){
        sum[i] = sum[i-1] + b[i-1];
    }


    ll cc = 0;
    rep(i,n){
        auto ite = lower_bound(a, a+n, l - a[i]);
        ll cnt = a + n - ite;
        cc += cnt;
        // cout << i << ' ' << cnt << endl;
        ans += cnt * a[i];
        ans += sum[cnt];
    }

    if(cc > k){
        ans -= (cc - k) * l;
    }

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


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

int main(){
    int D;cin >> D;
    if(D == 25){
        cout << "Christmas" << endl;
    }else if(D == 24){
        cout << "Christmas Eve" << endl;
    }else if(D == 23){
        cout << "Christmas Eve Eve" << endl;
    }else{
        cout << "Christmas Eve Eve Eve" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
int main() {
  int N;
  int T[100000];
  cin >> N;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> T[i];  
    sum += T[i];
  }
  int M;
  cin >> M;
  int P[M], X[M];
  for (int i = 0; i < M; i++) {
    cin >> P[i] >> X[i];
  }
  for (int i = 0; i < M; i++) {
    cout << sum + (X[i] - T[P[i] - 1]) << endl;
  }
}

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

int main(void){
	int N, Y;
	cin >> N >> Y;

	for(int i = 0; i < N + 1; i++){
		for(int j = 0; j < N + 1 - i; j++){
			int k = N - i - j;
			if(10*i + 5*j + k == Y/1000){
				cout << i << " " << j << " " << k << endl;
				return 0; 
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
         int w = sc.nextInt();
         int h = sc.nextInt();
         int x = sc.nextInt();
         int y = sc.nextInt();
         int r = sc.nextInt();
         
         boolean isH = y+r<=h&&y-r>=0;
         boolean isW = x+r<=w&&x-r>=0;

        System.out.println(isH&&isW?"Yes":"No");
    }
}


Measured memory_bytes: 26340
#include<stdio.h>

int main(void) {
    int i, j;
    int S;
    int x[3000] = {};
    int y[3000] = {};
    
    for(i = 0; i < 3000; i++) {
        
        scanf("%d %d", &x[i], &y[i]);
        
        if(x[i] == 0 && y[i] == 0) {
            break;
        }
    }
    
    for(j = 0; j < i; j++) {
        
        if(x[j] > y[j]) {
            S = x[j];
            x[j] = y[j];
            y[j] = S;
        }
        
        printf("%d %d\n", x[j], y[j]);
    }
    
    return 0;
    
}


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

int main(){
  string s;
  cin >>s;
  if(s[1]=='B') cout << "ARC" << endl;
  else cout << "ABC" << endl;
  return 0;
}

Measured memory_bytes: 3624
// https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll A, B, C, K;
  cin >> A >> B >> C >> K;

  ll necessary = 0;

  while (B <= A) {
    necessary++;
    B *= 2;
  }

  while (C <= B) {
    necessary++;
    C *= 2;
  }

  string res = necessary <= K ? "Yes" : "No";
  cout << res << "\n";
}


Measured memory_bytes: 3584
// Original macro is in https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = || -> String {
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// for adhoc read (ex. https://atcoder.jp/contests/abc112/tasks/abc112_a)
#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    input!{
        h: usize,
        w: usize,
        b: [chars; h],
    }
    let mut rows = vec![false; h];
    let mut columns = vec![false; w];
    for (i, r) in b.iter().enumerate() {
        for (j, &c) in r.iter().enumerate() {
            if c == '#' { 
                rows[i] = true; 
                columns[j] = true; 
            }
        }
    }
    for i in 0..h {
        for j in 0..w {
            if rows[i] && columns[j] { print!("{}", b[i][j]); }
        }
        println!();
    }
}

Measured memory_bytes: 4352
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

int main() {
  ll X, Y, Z;

  cin >> X >> Y >> Z;

  cout << (X-Z)/(Y+Z) << endl;

  return 0;
}


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

int main(){
	int n;
	int dice[5];
	string s;
	while(cin >> n && n){
		int ans = 1;
		dice[0] = 1; dice[1] = 5; dice[2] = 2; dice[3] = 3; dice[4] = 4;
		for(int i = 0; i < n; i++){
			cin >> s;
			if(s[0] == 'S'){
				int temp = dice[0];
				dice[0] = dice[1];
				dice[1] = 7 - temp;
				dice[2] = temp; 
			}
			if(s[0] == 'N'){
				int temp = dice[0];
				dice[0] = dice[2];
				dice[2] = 7 - temp;
				dice[1] = temp;
			}
			if(s[0] == 'W'){
				int temp = dice[0];
				dice[0] = dice[3];
				dice[3] = 7 - temp;
				dice[4] = temp;
			}
			if(s[0] == 'E'){
				int temp = dice[0];
				dice[0] = dice[4];
				dice[4] = 7 - temp;
				dice[3] = temp;	
			}
			if(s[0] == 'L'){
				int temp;
				temp = dice[2];
				dice[2] = dice[4];
				dice[4] = dice[1];
				dice[1] = dice[3];
				dice[3] = temp;
			}
			if(s[0] == 'R'){
				int temp = dice[3];
				dice[3] = dice[1];
				dice[1] = dice[4];
				dice[4] = dice[2];
				dice[2] = temp;
			}
			ans += dice[0];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1200
#include <iostream>
using namespace std;
int main(){
	int N,L[110],X,D[110],ans=1;
	cin>>N>>X;
	for (int i=0;i<N;i++)
		cin>>L[i];
	D[0]=0;
	for (int i=1;i<=N;i++){
		D[i]=D[i-1]+L[i-1];
		if (D[i]<=X)
			ans++;
	}
	cout<<ans;
	return 0;
}

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


ll powr(ll a,ll b, ll mod)
{
	if(b<=0)
		return 1;
	else if(b%2==0)
	{
		ll x = powr(a,b/2,mod);
		return (x*x)%mod;
	}
	else
		return (a*powr(a,b-1,mod))%mod;
}

// ll power(ll x, ll y, ll p) 
// { 
//     ll res = 1;      // Initialize result 
  
//     x = x % p;  // Update x if it is more than or 
//                 // equal to p 
  
//     while (y > 0) 
//     { 
//         // If y is odd, multiply x with result 
//         if (y & 1) 
//             res = (res*x) % p; 
  
//         // y must be even now 
//         y = y>>1; // y = y/2 
//         x = (x*x) % p; 
//     } 
//     return res; 
// } 
  
// Returns n^(-1) mod p 
ll modInverse(ll n, ll p) 
{ 
    return powr(n, p-2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
ll fac[(ll)2e6+1]; 
ll nCrModPFermat(ll n, ll r, ll p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}
void solve()
{
	ll k;
	cin>>k;
	string s;
	cin>>s;
	ll n = s.length();
	ll mod = 1e9+7;
    fac[0] = 1; 
    for (ll i=1 ; i<=n+k; i++) 
        fac[i] = fac[i-1]*i%mod; 
	ll ans = 0;
	for (ll i = 0; i <= k; ++i)
	{
		// cout<<i<<endl;
		ans = (ans+powr(25,i,mod)*(nCrModPFermat(n+k,n+k-i,mod)))%mod;
	}
	cout<<ans<<endl;
}

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

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

if K % 2 == 0:
    if A - B > 10e18:
        print('Unfair')
    else:
        print(A - B)
else:
    if B - A > 10e18:
        print('Unfair')
    else:
        print(B - A)

Measured memory_bytes: 2940