akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll z=1000000000+7;
ll f[10000001]={0};
void nod(ll n)
{
  for(ll i=1;i<=n;i++)
  {
    f[i]=2;
  }
  f[1]=1;
  for(ll i=2;i<=n;i++)
  {
    for(ll j=2*i;j<=n;j+=i)
    {
      f[j]=f[j]+1;
    }
  }
}

int main()
{
  IOS;
  ll t=1;
  //cin>>t;
  while(t--)
  {
    ll i,n,k,sum=0,x,p=0,l,r,ans=0,cnt=0,m,j;
    cin>>n;
    nod(n);
    ans=0;
    for(i=1;i<=n;i++)
    {
      ans+=i*f[i];
    }
    cout<<ans;
  }
    return 0;
}


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

int judge(string sn, vector<string> s, vector<string> t);

int judge(string sn, vector<string> s, vector<string> t){
    int count = 0;

    for(int i = 0; i < s.size(); i++){
        if(sn == s[i]){
            count++;
        }
    }
    for(int j = 0; j < t.size(); j++){
        if(sn == t[j]){
            count--;
        }
    }
    
    return count;
}

int main(){
    int n, m;

    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    
    cin >> m;
    vector<string> t(m);
    for(int i = 0; i < m; i++){
        cin >> t[i];
    }

    int ans = 0;
    int count = 0;
    
    for(int i = 0; i < n; i++){
        count = judge(s[i], s, t);
        ans = max(count, ans);
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
const ll mod = 998244353;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, x = 0;
int g(int a) {
	if(a==1) return n+2;
	if(a==2) return n+3;
	return a&1?n+1+a:a;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	if(n<3||(n&-n)==n) return cout << "No", 0;
	cout << "Yes\n";
	cout << 3 << " " << n+1 << "\n";
	for(int i = 1; i < 3; i++) {
		cout << i << " " << i+1 << "\n";
		cout << n+i << " " << n+i+1 << "\n";
	}
	if(n==3) return 0;
	int a = 3;
	for(int i = a+1; i < n; i+=2) {
		cout << n+1 << " " << i << "\n";
		cout << i << " " << i+1 << "\n";
		cout << n+1 << " " << n+i+1 << "\n";
		cout << n+i+1 << " " << n+i << "\n";
	}
	if(!(n&1)) {
		int x = n&-n, on = n;
		n-=x;
		x^=1;
		if(((x&1)&&x!=3)||x==2)x+=on;
		if(((n&1)&&n!=3)||n==2)n+=on;
		cout << on << " " << x << "\n";
		cout << 2*on << " " << n << "\n";
	}
	return 0;
}


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

int main(){
 	int x,y,ans=0;
 	cin >> x >> y;
 	ans=2*x-y/2;
 	
 	if(y==2 || y==4){
 	    cout << "Yes" << endl;
 	} else if(y%2!=0){
 	    cout << "No" << endl;  
 	} else if(2*x > y){
 	    cout << "No" << endl;  
 	} else if(4*x < y){
 	    cout << "No" << endl;
 	} else if(ans>=0) {
 	    cout << "Yes" << endl;
 	} else {
 	    cout << "No" << endl;
 	}
}


Measured memory_bytes: 3604
-- Your code here!

import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
 
readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main=do
    [a,b]<-getIntList
    print $ ((a+b)*(a+b-1))`div`2-a*b
    

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

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

int main(){
    int h, w; cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    vector<string> t = s;
    rep(i,h)rep(j,w){
        int cnt = 0;
        if(s[i][j] == '#') continue;
        for(int k = 0; k < 8; k++){
            int nx = i + dx[k];
            int ny = j + dy[k];
            if(nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
            if(s[nx][ny] == '#') cnt++;
        }
        t[i][j] = cnt + '0';
    }
    rep(i,h) cout << t[i] << endl;
}

Measured memory_bytes: 256
def get(text,n):
    ans = [""]*n
    i = 0
    for x in text:
        if x==" ":
            i = i + 1
        ans[i] = ans[i]+x
    return ans

text = input()

if int(get(text,2)[0]) == int(get(text,2)[1]):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

#define REP(i,n) for(int i=0;i<n;i++)
#define EPS (1e-9)
#define INF (1e9 + 1)
#define PI (acos(-1))

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

ll lcm(ll a, ll b) {
	ll c = (b / gcd(a, b));
	return c * a;
}

int N, M, C;
int B[100];
int A[100][100];
int ans = 0;

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

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

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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

void MAIN() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  h = (h * 60.0 + m) / 720.0 * atan(1.0) * 8.0;
  m = m / 60.0 * atan(1.0) * 8.0;
  cout << fixed << setprecision(10);
  double ans = sqrt(a * a + b * b - 2 * a * b * cos(h - m));
  cout << ans << '\n';
}  

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
// #define mod 998244353
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int s, w;
	cin>>s>>w;
	if(w >= s){
		cout<<"unsafe";
	}
	else{
		cout<<"safe";
	}
	return 0;
}

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

using namespace std;

// T字にカットしたとき
int cutT(int h, int w){
	long long int p,q,s1,s2,s3,res1,res2,res3;
	p = h / 3;
	q = w / 2;
	s1 = p * w;
	s2 = (h-p) * q;
	s3 = (h-p) * (w-q);
	res1 = max(max(s1,s2),s3) - min(min(s1,s2),s3);
	p = p+1;
	s1 = p * w;
	s2 = (h-p) * q;
	s3 = (h-p) * (w-q);
	res2 = max(max(s1,s2),s3) - min(min(s1,s2),s3);
	p = p+1;
	s1 = p * w;
	s2 = (h-p) * q;
	s3 = (h-p) * (w-q);
	res3 = max(max(s1,s2),s3) - min(min(s1,s2),s3);
	return min(res1,min(res2,res3));
}


int main(int argc, char const *argv[]) {
	int h,w,temp;
	std::cin >> h >> w;

	if (h % 3 == 0 || w % 3 == 0) {
		std::cout << 0 << '\n';
		return 0;
	}

	// T字カットと３つに縦割りしたときの比較
	std::cout << min(min(w,cutT(h,w)), min(h,cutT(w,h))) << '\n';
	return 0;
}


Measured memory_bytes: 384
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)

## a, bを無向辺として，隣接リストを作成
n, m = list(map(int, input().split()))
al = [[] for i in range(n)]

for i in range(m):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1

    al[a].append(b)

@functools.lru_cache(None)
def depth(u):
    if len(al[u]) == 0:
        return 0
    else:
        max_d = 0
        for v in al[u]:
            max_d = max(max_d, depth(v) + 1)
        return max_d

ans = 0
for i in range(n):
    ans = max(ans, depth(i))
print(ans)


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

int a[2000010];
int b[2000010];
int main() {
  int n,m;
  cin>>n>>m;
  int k=0;
  for(int i=0;i<m;i++){
    int t1,t2;
    cin>>t1>>t2;
    if(t1>t2)swap(t1,t2);
    if(t1==1)b[k++]=t2;
    if(t2==n)a[t1]=1;
  }
  for(int i=0;i<k;i++){
	  if(a[b[i]]){
		  cout<<"POSSIBLE"<<endl;return 0;
		  }
	  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
 
  }

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

int main(){
  long long n,cnt=0;
  cin >> n;
  map<string,int> mp;
  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  for(auto s:mp){
    long long p = s.second;
    cnt += (p-1)*p/2;
  }
  cout << cnt << endl;
}


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

int main()
{
  int n,k,x,y;
  int i,sum;
  sum = 0;
  cin >> n >> k >> x >> y;
  for(i = 1; i  <= n; i++)
  {
    if(i <= k)
    {
      sum += x;
    }
    else
    {
      sum += y;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
class Main
{
    public static int[] prime = new int[100001];
    public static int[] like = new int[100001];
    public static int index1 = 0;
    public static int index2 = 0;
 
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
 
        int Q = sc.nextInt();
 
        int[] L = new int[Q];
        int[] R = new int[Q];
 
        for(int i = 0; i < Q; i++){
            L[i] = sc.nextInt();
            R[i] = sc.nextInt();
        }
 
        Prime();
        LikeMake();
 
        for(int i = 0; i < Q; i++){
            int L_index = Arrays.binarySearch(like, L[i]);
 
            if(L_index < 0){
                L_index = (-1) * L_index - 1; 
            }
 
            int R_index = Arrays.binarySearch(like, R[i]);
 
            if(R_index < 0){
                R_index = (-1) * R_index  - 2;
            }
            System.out.println( R_index - L_index + 1);
        }
    }
    static void Prime() // 素数生成
    {
        boolean bl = true;
    
        prime[0] = 2;
 
        for(int i = 1; i < prime.length; i++){
            prime[i] = 10000007;
        }
 
        for(int num = 3; num < prime.length; num += 2){
            bl = true;;
            for(int j = 0; Math.pow(prime[j], 2) <= num; j++){
                if( num % prime[j] == 0){
                    bl = false;
                    break;
                }
            }
            if(bl == true){
                prime[++index1] = num;
            }
        }
    }
    static boolean LikeJudge(int p)
    {
        boolean ans = false;            
        if( Arrays.binarySearch(prime, (p + 1) / 2) >= 0){
            ans = true;
        }
        return ans;
    }
    
    static void LikeMake()
    {
        for(int i = 0; i < like.length; i++){
            like[i] = 100001;
        }
        for(int i = 1; i < prime.length; i++){
            if(LikeJudge(prime[i]) == true){
                like[index2] = prime[i];
                index2++;
            }
        }
    }
}

Measured memory_bytes: 93496
n=int(input())
x=[]
w=[]

tot=0.0
for i in range (n):
	ip=input()
	ip=ip.split()
	x.append(float(ip[0]))
	w.append(ip[1])
#print(x)
for i in range (n):
	if(w[i]=="JPY"):
		tot+=x[i]
	else:
		tot+=(x[i]*380000.0)

print(tot)

Measured memory_bytes: 38256
import java.awt.Point;
import java.util.Iterator;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		TreeSet<KUSO> ts = new TreeSet<>();
		for(int i = 0; i < n; i++) {
			ts.add(new KUSO(new Point(sc.nextInt(),sc.nextInt()), true));
		}
		for(int i = 0; i < n; i++) {
			ts.add(new KUSO(new Point(sc.nextInt(),sc.nextInt()), false));
		}
		Iterator<KUSO> itr = ts.iterator();
		TreeSet<Integer> treeone = new TreeSet<>();
		long count = 0;
		while(itr.hasNext()) {
			KUSO k = itr.next();
			if(k.isRed) {
				treeone.add(k.p.y);
			} else {
				Integer i = treeone.floor(k.p.y);
				if(i!=null) {
					count++;
					treeone.remove(i);
				}
			}
		}
		System.out.println(count);
	}
}
class KUSO implements Comparable<KUSO>{
	Point p;
	boolean isRed;
	KUSO(Point p, boolean b) {
		this.p = p;
		this.isRed = b;
	}
	@Override
	public int compareTo(KUSO o) {
		return Integer.compare(this.p.x, o.p.x);
	}
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof KUSO) {
			KUSO kuso = (KUSO) obj;
			if(kuso.p.equals(this.p)&&kuso.isRed==this.isRed) {
				return true;
			}
		}
		return false;
	}
}

Measured memory_bytes: 22100
def numba_compile(numba_config):
    import os, sys
    if sys.argv[-1] == "ONLINE_JUDGE":
        from numba import njit
        from numba.pycc import CC
        cc = CC("my_module")
        for func, signature in numba_config:
            vars()[func.__name__] = njit(signature)(func)
            cc.export(func.__name__, signature)(func)
        cc.compile()
        exit()
    elif os.name == "posix":
        exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
        for func, _ in numba_config:
            globals()[func.__name__] = vars()[func.__name__]
    else:
        from numba import njit
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature, cache=True)(func)
        print("compiled!", file=sys.stderr)


import numpy as np

def solve(H, N, AB):
    # dp[n][h] := n 番目の魔法まで見て体力を h 削ったときの最小魔力
    dp = np.empty(H+1, dtype=np.int64)
    dp[:] = 1<<60
    dp[0] = 0
    for n in range(1, N+1):
        a, b = AB[n-1]
        for h in range(H):
            dp[min(H, h+a)] = min(dp[min(H, h+a)], dp[h]+b)
    return dp[-1]

numba_compile([
    [solve, "i8(i8,i8,i8[:,:])"],
])

import sys
def main():
    H, N = map(int, input().split())
    AB = np.array(sys.stdin.read().split(), dtype=np.int64).reshape(N, 2)
    ans = solve(H, N, AB)
    print(ans)

main()


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

int main() {
  int n, s, r, o;
  string e;

  cin >> n;
  for (int i=0; i<n; i++) {
    s = r = o = 0;
    while (1) {
      cin >> e;
      if (e == "HIT") {
        if (++r >= 4) {
          ++s;
          --r;
        }
      } else if (e == "HOMERUN") {
        s += r+1;
        r = 0;
      } else if (e == "OUT") {
        o++;
        if (o >= 3) break;
      }
    }
    cout << s << endl;
  }

  return 0;
}

Measured memory_bytes: 1208
#pragma region Macros

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

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    string S;
    cin >> S;
    if (S == "ABC") {
        cout << "ARC";
        return;
    }
    cout << "ABC";
}

#pragma region main
main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3592
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;

#define F first 
#define S second 
#define PB push_back 
#define MP make_pair

int A, B, H, M;

int main() {
    cin >> A >> B >> H >> M;
    double mdeg = M * 6;
    double hdeg = H * 30 + (mdeg / 12.0);
    double degc = abs(hdeg - mdeg);
    degc *= (M_PI / 180.0);

    // c2 = a2 + b2 − 2ab cos(C)
    double csqr = (A*A) + (B*B) - (2*A*B*cos(degc));

    cout << fixed << showpoint;
    cout << setprecision(20);
    cout << sqrt(csqr) << endl;

}

Measured memory_bytes: 3644
import heapq
N,M = map(int,input().split())
LRC = [tuple(map(int,input().split())) for i in range(M)]

es = [[] for i in range(N)]
for l,r,c in LRC:
    l,r = l-1,r-1
    es[l].append((r,c))
for i in range(N-1):
    es[i+1].append((i,0))

INF = float('inf')
dist = [INF]*N
dist[0] = 0
hq = [(0,0)]
heapq.heapify(hq)

while(hq):
    d,v = heapq.heappop(hq)
    if v==N-1:
        print(d)
        exit()
    for to,c in es[v]:
        if d+c >= dist[to]: continue
        dist[to] = d+c
        heapq.heappush(hq, (d+c, to))
print(-1)

Measured memory_bytes: 57500
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static void Main (string[] args) {
        var inp = Console.ReadLine().Split(' ');
        long n = long.Parse(inp[0]);

        int year = 0;
        long money = 100;
        while(true) {
            money = (long)(money * 1.01d);
            year++;
            if(money >= n) {
                break;
            }
        }

        Console.WriteLine(year);
    }
}

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

vector<long long> v,v2;

bool isOK(int index, int key){
  /*indexが条件を満たすかどうかを判定(今回はkeyよりおおきいか)*/
  if(v2[index]<=key) return true;
  else return false;
}

int binary_search(int key){
  int ng = (int)v2.size();
  int ok = -1;
  //okとngの初期値によって最大値だけでなく最小値も求められる.
  //ng=-1の時はkey以上の数値の最小値

  while(abs(ok - ng) > 1){
    int mid = (ok + ng) / 2;

    if(isOK(mid,key)) ok = mid;
    else ng = mid;
  }

  return ok;
}


int main(){
  long long n,m;
  while(cin >> n >> m){
    if(n==0)break;
    v.clear();
    v.resize(n+1);
    v[0]=0;
    long long i,j;
    for (i = 1; i < n+1; i++) {
      cin >> v[i];
    }
    v2.clear();
    v2.resize((n+1)*(n+2)/2);
    for(i=0;i<n+1;i++){
      for(j=i;j<n+1;j++){
        v2.emplace_back(v[i]+v[j]);
      }
    }
    sort(v2.begin(),v2.end());
    long long ret=0;
    for(i=0;i<v2.size();i++){
      if(v2[i]>m)break;
      int key=binary_search(m-v2[i]);
      if(key!=-1)ret=max(ret,v2[i]+v2[key]);
    }
    cout << ret << endl;
  }
  return 0;
}



Measured memory_bytes: 10760
#include<stdio.h>
int main(void){
  int a,b,c,d,n,r;
  while(scanf("%d",&n)!=EOF){
    r=0;
    for(a=0;a<10;a++){
      for(b=0;b<10;b++){
	for(c=0;c<10;c++){
	  for(d=0;d<10;d++){
	    if(a+b+c+d==n)
	      r++;
	  }
	}
      }
    }
    printf("%d\n",r);
  }
  return(0);
}

Measured memory_bytes: 0
N=int(input())
S=input()
DP=[0]*N
l=0
for i,x in enumerate(S):
  DP[i]+=l
  if S[i]=="W":
      l+=1
r=0
for j,y in enumerate(S[::-1]):
  DP[N-1-j]+=r
  if S[N-1-j]=="E":
      r+=1
print(min(DP))

Measured memory_bytes: 15456
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define all(v) v.begin(), v.end() // sort(all(array))
#define INF 1000000000
#define LINF 1LL << 60
#define mod 1000000007
#define EPS 0.0001
using namespace std;
using ll = long long;
using vi = vector<int>; //vi array(要素数, 初期値)
using vll = vector<ll>; 
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>; //vvi table(行数, vi(列数, 初期値))
using vvc = vector<vc>;
using vvs = vector<vs>;
using vvb = vector<vb>;

int main() {
    string s, ans; cin >> s;
    int l = s.size();
    if (s[l - 1] == 's') {
        ans = s + "es";
    } else {
        ans = s + 's';
    }
    
    cout << ans << endl;
}

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

using namespace std;

bool pali(string s)
{
    int i=0;
    int j = s.size()-1;

    while (i<j)
    {
        if (s[i]!=s[j]) return false;
        ++i;
        --j;
    }

    return true;
}

int main()
{
    string s;
    cin>>s;
    bool a = pali(s);
    int n = s.size();
    bool b = pali(string(s.begin(),s.begin()+(n-1)/2));
    bool c = pali(string(s.begin()+(n+3)/2-1,s.end()));

    if (a && b && c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18;
const int N = (int)1e5 + 100;
const int MAXA = (int)3e6;
ll a[N];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    int n;
    ll t;
    cin >> n >> t;
    for(int i = 1;i <= n;i++)cin >> a[i];
    ll mn = a[1];
    ll mx = -LLONG_MAX;
    set<int> s;
    for(int i = 2;i <= n;i++){
        if(a[i] - mn > mx){
            mx = a[i] - mn;
            s.clear();
            s.insert(mn);
        }else if(a[i] - mn == mx){
            s.insert(mn);
        }
        mn = min(mn, a[i]);
    }
    cout << (int)s.size();
    return 0;
}


Measured memory_bytes: 6712
S = input().strip()
T = input().strip()

listS = list(S)
f = False
for i in range(len(S) - len(T), -1, -1):
    for ji, j in enumerate(range(i, i + len(T))):
        if S[j] == T[ji] or S[j] == "?":
            continue
        else:
            break
    else:
        for ji, j in enumerate(range(i, i + len(T))):
            listS[j] = T[ji]
        f = True
        break

if f:
    for i in range(len(S)):
        if listS[i] == "?":
            listS[i] = 'a'

    print("".join(listS))
else:
    print("UNRESTORABLE")

Measured memory_bytes: 8996
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int G[35][35];
int A[35][35];
int B[35][35];

void bfs(pair<int,int> u){
  queue<pair<int,int>> q;
  G[u.first][u.second]=1;
  q.push(u);
  int ny,nx;
  while(!q.empty()){
    auto t=q.front(); q.pop();
    ny=t.first, nx=t.second;
    if(A[ny][nx]==0 && G[ny][nx-1]==0){
      G[ny][nx-1]=G[ny][nx]+1;
      q.push({ny,nx-1});
    }
    if(B[ny][nx]==0 && G[ny-1][nx]==0){
      G[ny-1][nx]=G[ny][nx]+1;
      q.push({ny-1,nx});
    }
    if(A[ny][nx+1]==0 && G[ny][nx+1]==0){
      G[ny][nx+1]=G[ny][nx]+1;
      q.push({ny,nx+1});
    }
    if(B[ny+1][nx]==0 && G[ny+1][nx]==0){
      G[ny+1][nx]=G[ny][nx]+1;
      q.push({ny+1,nx});
    }
  }
}

int main(){
  int w,h;
  while(cin>>w>>h){
    if(w==0 && h==0) return 0;
    
    rep(i,35){
      rep(j,35){
        G[i][j]=0;
        A[i][j]=0;
        B[i][j]=0;
      }
    }
  
    G[1][1]=1;
  
    for(int i=1;i<2*h;i++){
      if(i%2==1){
        for(int j=2;j<w+1;j++) cin>>A[(i+1)/2][j];
      }
      else{
        for(int j=1;j<=w;j++) cin>>B[i/2+1][j];
      }
    }
  
    for(int i=1;i<=w;i++){
      B[1][i]=1;
      B[h+1][i]=1;
    }
    for(int i=1;i<=h;i++){
      A[i][1]=1;
      A[i][w+1]=1;
    }
  
    bfs({1,1});  
    cout<<G[h][w]<<endl;
  }
}


Measured memory_bytes: 3044
import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
    static double pi=3.14285714;
    public static void process()throws IOException
    {
      long n=nl();
      long m=nl();
      long sum=0;
      while(m-->0)
      {
        long x=nl();
        sum+=x;
      }
      if(sum<=n)
      pn(n-sum);
      else
      pn(-1);
      
    }

 static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new AnotherReader();
        boolean oj = true;

    //  oj = System.getProperty("ONLINE_JUDGE") != null;
        if(!oj) sc=new AnotherReader(100);

        long s = System.currentTimeMillis();
        
         //int t=ni();
         //while(t-->0)
            process();
        out.flush();
        if(!oj)
            System.out.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static String nn()throws IOException{return sc.next();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static boolean multipleTC=false;

/////////////////////////////////////////////////////////////////////////////////////////////////////////
    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
    
    
    

    


Measured memory_bytes: 34096
x, y = map(int, input().split())

mon = [0, 300000, 200000, 100000]
add = 400000
s = 0
if x == y == 1:
    s += add


def f(x):
    if x <= 3:
        return mon[x]
    return 0


s += f(x) + f(y)
print(s)


Measured memory_bytes: 3060
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < (up); ++i)
#define repp(i, up) for (ll i = 0; i <= (up); ++i)
#define rrep(i, lo, up) for (ll i = (lo); i < (up); ++i)
#define rrepp(i, lo, up) for (ll i = (lo); i <= (up); ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))
#define feach(it, vec) for (auto it = (vec).begin(); it != (vec).end(); ++it)


ll gcd(ll a, ll b);

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

#endif  // end of use_templates


int main()
{
    ll n, x, t;
    cin >> n >> x >> t;
    cout << (n + x - 1) / x * t << endl;
    return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using M = map<int, int>;
ll INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  char x, y;
  cin >> x >> y;
  if (x < y) cout << "<" << endl;
  else if (x == y) cout << "=" << endl;
  else cout << ">" << endl;


  return 0;
}


Measured memory_bytes: 256
import java.util.*;
    
public class Main {
    public static void main(String[] args) throws Exception {
    Scanner sc = new Scanner(System.in);
     
    String s = sc.next();
    int cnt =0;
 
    if(s.length()>1){
        for(int i=1; i<s.length(); i++){
            if(s.charAt(i)!=s.charAt(i-1)){
                cnt++;
            }
        }
    }
    
    System.out.println(cnt);
	sc.close();
    }
}


Measured memory_bytes: 23508
// Author : Hardik Upadhyay
// college: SVNIT 
// slogan : Ab to phod dunga
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i = a ; i >= b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int MAXN = 100005;
ll mod=1000000007;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vi a(n);
	rep(i,0,n-1)cin>>a[i];
	map<int,int> cnt;
	ll ans = 0;
	// hi + hj == i - j
	// i - hi == hj + j              
	// i - hi ==  hj + j  i >= j           
	for(int i = 0; i < n; i++){
			ans+=cnt[i - a[i]];	
			cnt[i + a[i]]++;
	}
	cout<<ans<<nl;
	return 0;
}



Measured memory_bytes: 21032
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;

static const double EPS = 1e-8;

const int tx[] = {0,1,0,-1};
const int ty[] = {-1,0,1,0};

int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;

		int L_count=0;
		int L_ok=0;
		int D_count=0;
		int D_ok=0;
		int M_count=0;
		int M_ok=0;
		for(int i=0;i<n;i++){
			int h,m,d;
			scanf("%d:%d %d",&h,&m,&d);
			int time = (d-m >= 0 ? d-m : (60+d-m));
			bool isok = (time <= 8 ? true : false);

			int t = h*60+m;

			if(11*60 <= t && t <= 14*60 + 59){
				if(isok) L_ok++;
				L_count++;
			}
			else if(18*60 <= t && t <= 20*60 + 59){
				if(isok) D_ok++;
				D_count++;
			}
			else if((21*60 <= t && t <= 24*60)
				|| (0 <= t && t <= 1*60+59)){
					if(isok) M_ok++;
					M_count++;
			}
		}
		
		if(L_count==0){
			printf("lunch no guest\n");
		}
		else{
			printf("lunch %.0lf\n",floor(((L_ok)/(double)L_count + EPS) * 100.0));
		}

		if(D_count==0){
			printf("dinner no guest\n");
		}
		else{
			printf("dinner %.0lf\n",floor(((D_ok)/(double)D_count + EPS) * 100.0));
		}

		if(M_count==0){
			printf("midnight no guest\n");
		}
		else{
			printf("midnight %.0lf\n",floor(((M_ok)/(double)M_count + EPS) * 100.0));
		}
	}
}

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

int main() {
  	long long int N;
  	cin >> N;
  	long long A[N], B[N];
  	for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
  
  	sort(A, A + N);
  	sort(B, B + N);
  
  	if (N % 2 == 1){
      	cout << B[(N - 1) / 2] - A[(N - 1) / 2] + 1 << endl;
    }
  	else {
      	cout << B[N / 2] + B[N / 2 - 1] - A[N / 2] - A[N / 2 - 1] + 1 << endl;
    }
}

Measured memory_bytes: 6752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1e5 + 10;

int N;
char s[MAX];
int tot[3], pre[MAX][3];
map<char, int> mp;

int main() {
#ifdef ACM_LOCAL
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
#endif
    scanf("%d%s", &N, s + 1);
    mp['R'] = 0, mp['G'] = 1, mp['B'] = 2;
    for (int i = 1; i <= N; i++) {
        int id = mp[s[i]];
        tot[id]++, pre[i][id]++;
        pre[i][0] += pre[i - 1][0];
        pre[i][1] += pre[i - 1][1];
        pre[i][2] += pre[i - 1][2];
    }
    ll ans = 0;
    for (int i = 1; i <= N - 2; i++)
        for (int j = i + 1; j <= N - 1; j++) {
            if (s[j] == s[i]) continue;
            int id = 3 - mp[s[j]] - mp[s[i]];
            int cnt = tot[id] - pre[j][id] - (2 * j - i <= N && mp[s[2 * j - i]] == id);
            ans += cnt;
        }
    printf("%lld\n", ans);



    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);



signed main(){
  int h, w, n;cin >> h >> w >> n;
  int sh, sw;cin >> sh >> sw;
  string s1, s2;cin >> s1 >> s2;
  reverse(all(s1));
  reverse(all(s2));
  
  int u = 1, d = h, l = 1, r = w;
  rep(i,n){
    if(s2[i] == 'U')d = min(h, d+1);
    if(s2[i] == 'D')u = max(1LL, u-1);
    if(s2[i] == 'R')l = max(1LL, l-1);
    if(s2[i] == 'L')r = min(w, r+1);
    
    if(s1[i] == 'U')u = u+1;
    if(s1[i] == 'D')d = d-1;
    if(s1[i] == 'R')r = r-1;
    if(s1[i] == 'L')l = l+1;
    
    if(d < u or r < l){
      cout << "NO" << endl;
      return 0;
    }
  }
  if(u <= sh and sh <= d and l <= sw and sw <= r)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}






Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
/*
    By: Umang Srivastava
*/
#define lli long long int
#define ld long double
#define mod 1000000007
#define lp(var,start,end,inc) for (var = start; var <end ; var=var+inc)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<lli>
#define pll pair<lli,lli> 
#define vpll vector<plli>
#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b

// lli findgcd(lli a, lli b, lli *x , lli *y)
// {
//     if(a==0)
//     {
//         *x=0,*y=1;
//         return b;
//     }
//     lli x1,y1;
//     lli gcd = findgcd(b%a,a,&x1,&y1);
//     *x=y1-(b/a)*x1;
//     *y=x1;
//     return gcd;
// }
 
// lli modInv(lli b)
// {
//     lli x,y;
//     lli g = findgcd(b,mod,&x,&y);
//     if(g!=1)
//         return -1;
//     return (x%mod + mod)%mod;
// }


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n,i,j;
    cin>>n;
    lli ar[n];
    lli prime[1000001]={0};
    lli maxval=-1;
    for(i=0;i<n;i++)
    {
        cin>>ar[i];
        prime[ar[i]]++;
        maxval=max(maxval,ar[i]);
    }
    lli c=0;
    for(i=2;i<=maxval;i++)
    {
      c=0;
      for(j=i;j<=maxval;j+=i)
      {
        c+=prime[j];
        if(c>1)
          break;
      }
      if(c>1)
      {
        break;
      }
    }
    if(c<2)
    {
      cout<<"pairwise coprime";
      return 0;
    }
    lli result=ar[0];
    for(i=1;i<n;i++)
    {
      result = gcd(result,ar[i]);
    }
    if(result==1)
    {
      cout<<"setwise coprime";
    }
    else
      cout<<"not coprime";
}

Measured memory_bytes: 19244
from operator import itemgetter

H, W, M = map(int, input().split())
h_count = [[i, 0] for i in range(H)]
w_count = [[i, 0] for i in range(W)]
exist = dict()
for _ in range(M):
    h, w = map(lambda x: int(x)-1, input().split())
    h_count[h][1] += 1
    w_count[w][1] += 1
    exist[(h, w)] = True

h_count.sort(key=itemgetter(1), reverse=True)
w_count.sort(key=itemgetter(1), reverse=True)
h_max = h_count[0][1]
w_max = w_count[0][1]
res = 0
is_dup = True
for h in h_count:
    if h[1] != h_max or not is_dup:
        break
    for w in w_count:
        if w[1] != w_max or not is_dup:
            break
        val = h[1] + w[1]
        if exist.get((h[0], w[0]), False):
            val -= 1
        else:
            is_dup = False
        res = max(res, val)
print(res)


Measured memory_bytes: 132376
#include <stdio.h>
#include <string.h>
int	main()
{
	long long int  a, b;
	char s[11];
	char t[11];
	char u[11];

	scanf("%s %s",s, t);
	scanf("%lld %lld",&a, &b);
	scanf("%s", u);

	if(strcmp(s,u) == 0)
		printf("%lld %lld", a-1, b);
	else
		printf("%lld %lld", a, b-1);
	return(0);
}



Measured memory_bytes: 128
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n, m;
  cin >> n >> m;
  int l[m], r[m];
  for(int i = 0; i < m; i++) cin >> l[i] >> r[i];

  int lmax = l[0], rmin = r[0];
  for(int i = 1; i < m; i++){
    lmax = max(lmax, l[i]);
    rmin = min(rmin, r[i]);
  }

  int ans = max(0, rmin - lmax + 1);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h,n;
  cin >> h >> n;
  vector<int> damage(n);
  for(int i = 0; i < n; i++) {
    cin >> damage.at(i);
  }
  int sum = 0;
  for(int i = 0; i < n; i++) {
    sum += damage.at(i);
  }
  if(sum >= h) {
    cout << "Yes" << endl;
  }
  else{ 
    cout << "No" << endl;
  }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	unsigned long long n,m;
	cin>>n>>m;
	long a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	unsigned long long sum=0;
	long long ans=n-m;
	if(ans<=0){
		ans=0;
	}
	for(int i=0;i<ans;i++){
		sum+=a[i+1];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1792
// Ball Coloring
// * frank_c1
// * 2017 / 09 / 30

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

const int maxn = (int)(1e6) + 5;
pii a[maxn];
int c[maxn];

int main() {
	int n, tot = 0;
	scanf("%d", &n);
	int mi = (int)(1e9), mx = 0, Mi = (int)(1e9), Mx = 0;
	for (int i = 1; i <= n; ++i) {
		int x, y; scanf("%d%d", &x, &y);
		if (x > y) swap(x, y); 
		a[++tot] = make_pair(x, i); a[++tot] = make_pair(y, i); 
		mi = min(mi, x); mi = min(mi, y); 
		mx = max(mx, x); mx = max(mx, y);
		Mi = min(Mi, y); Mx = max(Mx, x);
	} LL ret = 1LL * (Mx - mi) * (mx - Mi);
	sort(a + 1, a + tot + 1); 
	int ps = 1, cnt = 0;
	for (int i = 1; i <= tot; ++i) {
		int u = a[i].second; if (!c[u]) ++cnt; ++c[u];
		while (c[a[ps].second] > 1) --c[a[ps++].second]; if (cnt == n) ret = min(ret, 1LL * (mx - mi) * (a[i].first - a[ps].first));
	}
	return printf("%lld\n", ret), 0;
}

Measured memory_bytes: 7168
#include <iostream>
#include <vector>
#include <iterator>

using namespace std;

int main(int argc, const char * argv[]) {
    int n;
    cin>>n;
    
    vector<int> vec[n];
    

    int q;
    cin>>q;
    
    
    
    for(int i=0;i!=q;++i){
        int query;
        cin>>query;
        int t;
        cin>>t;
        
        switch(query){
                
            case 0:
        
                int x;
                cin>>x;
                
                vec[t].push_back(x);
                
                break;
                
            case 1:
                
                for(int i=0;i!=vec[t].size();++i){
                    cout<<vec[t].at(i);
                    if(i!=vec[t].size()-1){
                        cout<<" ";
                    }
                }
                cout<<endl;
                
                
                break;
            case 2:
                vec[t].clear();
                
                break;
                
        }
        
    }
    
    return 0;
}




Measured memory_bytes: 5936
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <map>
#include <cmath>
#include <bitset>
#include <string>

using namespace std;

#define int long long

signed main() {
    int n, m;
    cin >> n >> m;
    int sum = 0;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }

    int cnt = 0;
    for(int i = 0; i < n; i++) {
        if(a[i] / (sum * 1.0) >= 1 / (4.0 * m)) cnt++;
        if(cnt == m) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define INF 2000000000
#define min(a,b) ((a)<(b)?(a):(b))

int sisu(long a){
	int i=0;
	while(a%2==0){
		a=a/2;
		i++;
	}
	return i;
}

int main(){
	int n,i,ans=INF;
	scanf("%d",&n);
	long a;
	for(i=0;i<n;i++){
		scanf("%ld",&a);
		ans=min(ans,sisu(a));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;

typedef long long int lli;
#define int lli
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OrderedSet;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define endl "\n"
#define error(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }
int mul(int a, int b, int c){lli res=(lli)a*b;return (int)(res>=c?res%c:res);}
template<typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}




signed main(){
    #ifdef DEBUG
		freopen("test", "r", stdin);
	#endif
    fastio;
    
    int N, M;
    cin >> N >> M;
    vector<vi> vert(N);
    int x, y;
    rep(i, M){
        cin >> x >> y;
        vert[x-1].push_back(y-1);
        vert[y-1].push_back(x-1);
    }

    queue<int> q;
    vi visited(N, -1);

    q.push(0);

    visited[0] = 0;
    while(!q.empty()){
        int top = q.front();
        q.pop();
        for(auto it : vert[top]){
            if(visited[it] == -1){
                q.push(it);
                visited[it] = top + 1;
            }
        }
    }

    bool ans = true;
    rep(i, N){
        if(visited[i] == -1){
            ans = false;
            break;
        }
    }

    if(!ans){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
        repA(i, 1, N - 1){
            cout << visited[i] << endl;
        }
    }


    return 0;
}


Measured memory_bytes: 12932
import math
A, B, H, M = map(int, input().split())

if 30 * H + (30 * M / 60) == 6 * M:
    kakudo = 0
elif 30 * H + (30 * M / 60) > 6 * M:
    kakudo = 30 * H - 6 * M + (30 * M / 60) 
elif 30 * H + (30 * M / 60) < 6 * M:
    kakudo = 6 * M - 30 * H - (30 * M / 60)

if kakudo > 180:
    kakudo = 360 - kakudo

ans = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(kakudo))

print(ans ** (1/2))

Measured memory_bytes: 9564
main :: IO ()
main = interact $ unlines . map (board . strToIntList) . takeWhile (/="0 0") . lines

strToIntList :: String -> (Int, Int)
strToIntList s = (x, y) where x:y:_ = map read . words $ s

board :: (Int, Int) -> String
board (height, width) = unlines $ map (line width) [1 .. height]

line :: Int -> Int -> String
line width r = take width . concat . repeat $ if odd r then "#." else ".#"

Measured memory_bytes: 5032
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

ll N;
ll r=20;
ll digit(ll a)
{
	ll i,b=a;
	for(i=0;b>0;i++,b/=10);
	return i;
}

int main()
{
	scanf("%lld",&N);
	for(int i=1;i<=100000;i++)
	{
		if(N%i==0)
		{
			r=min(r,max(digit(i),digit(N/i)));
		}
	}
	printf("%lld\n",r);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N; string a,b,c;
	cin>>N>>a>>b>>c;
	int ans = 0;
	rep(i,N){
		set<char> cnt;
		cnt.insert(a[i]);
		cnt.insert(b[i]);
		cnt.insert(c[i]);
		ans += cnt.size()-1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3568