akhauriyash/Code-Regression huggingface dataset:
#include<cmath>
#include <bits/stdc++.h>
#include <atcoder/fenwicktree>
using ll = long long;
using namespace std;
using namespace atcoder;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ll n,q;
    cin >>n>>q;
    fenwick_tree<ll> tree(n);
    rep(i,n){
        ll a;
        cin >> a;
        tree.add(i,a);
    }
    rep(j,q){
        ll t,u,v;
        cin >> t>> u>> v;
        if(t==0){
            tree.add(u,v);
        }else{
            cout<<tree.sum(u,v)<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 8220
using System;    
     
class sample15{    
    static void Main(string[] args){
        while(true){
            int  result;
            int[] calc_number = new int[2];
            string[] str_flagment = Console.ReadLine().Split(' '); 
            calc_number[0] = int.Parse(str_flagment[0]);
            string op = str_flagment[1];
            calc_number[1] = int.Parse(str_flagment[2]);
        
             //バリデーション
            if ( op == "?"){
                break;
            }else if(calc_number[0] < 0 || calc_number[1] < 0 || calc_number[0] > 20000 || calc_number[1] > 20000  ){ 
                    Console.WriteLine("値が範囲外です。"); 
                    Environment.Exit(0);
            }
        
            //opの値によって操作を変更
            switch(op){
                case "+":
                    result = calc_number[0] + calc_number[1];
                    Console.WriteLine(result);    
                    break;
                case "-":
                    result =  calc_number[0] - calc_number[1];
                    Console.WriteLine(result);
                    break;
                case "*":
                    result =  calc_number[0]* calc_number[1];
                    Console.WriteLine(result);
                    break;
                case "/":
                    if(calc_number[1] == 0){
                        Console.WriteLine("0を含め割り算を行うことはこの計算機ではできません。"); 
                        Environment.Exit(0);
                    }
        
                    result =  calc_number[0]/ calc_number[1];
                    Console.WriteLine(result);
                    break;
            }            
        }
            
    }
}    




Measured memory_bytes: 17904
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;
using mat2d_t = std::vector<std::vector<int64_t>>;



int main(int argc, char **argv) {
    std::string s;
    cin >> s;
    bool ans{true};
    if (s.size() % 2) {
        cout << "No" << endl;
        return 0;
    }

    for (int i=0; i<s.size(); i += 2) {
        if (s[i]!='h' || s[i+1]!='i') {
            ans = false;
            break;
        }
    }
    cout << (ans ? "Yes": "No") <<endl;
    return 0;
}


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

int main()
{
  char s1[11]={},s2[11]={},s3[11]={};
  char t1,t2,t3;
  
  scanf("%s %s %s",s1,s2,s3);
  
  t1=s1[0]-('a'-'A');
  t2=s2[0]-('a'-'A');
  t3=s3[0]-('a'-'A');
  
  printf("%c%c%c\n",t1,t2,t3);
  
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int[] a = new int[7];
        int x,y,ans=1;
		for (int i = 1; i < 7; i++) {
			a[i] = scanner.nextInt();
		}
		int q = scanner.nextInt();
		for(int i=0;i<q;i++){
		    x=scanner.nextInt();
		    y=scanner.nextInt();
		    if(x==a[1]||x==a[6]){
		        if (y == a[2]){
					ans = 3;
				}else if (y == a[3]){
					ans = 5;
				}else if (y == a[4]){
					ans = 2;
				}else{
					ans = 4;
				}
		    }else if(x==a[2]||x==a[5]){
		        if (y == a[1]){
					ans = 4;
				}else if (y == a[3]){
					ans = 1;
				}else if (y == a[4]){
					ans = 6;
				}else{
					ans = 3;
				}
		    }else if(x==a[3]||x==a[4]){
		        if (y == a[1]){
					ans = 2;
				}else if (y == a[2]){
					ans = 6;
				}else if (y == a[5]){
					ans = 1;
				}else{
					ans = 5;
				}
		    }
		    if (x == a[4] || x == a[5] || x == a[6])
				ans = 7 - ans;
		    System.out.println(a[ans]);
		    }
	    }
	}


Measured memory_bytes: 26264
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    int n,c,k;
    vector<int> t;
    Problem(LL n):n(n),t(n){};

    void solve(){
        cin >> c >> k;
        for(int i=0; i<n; ++i){
            cin >> t[i];
        }
        sort(t.begin(),t.end());
        int ans=0,pos=0;
        for(; pos<(int)t.size();++ans){
            pos=min<int>(pos+c,upper_bound(t.begin(),t.end(),t[pos]+k)-t.begin());
        }
        cout <<ans <<"\n";
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0;
    cin >> n;
    Problem p(n);
    p.solve();
    return 0;
}



Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
  long long h,w;
  cin >> h >> w;
  int ans = 0,mode = 0;
  
  if(h == 1 || w == 1)
  {
    cout << 1 << endl;
  } 
  else if(h % 2 == 0)
  {
    if(w % 2 == 0)
    {
      cout << (h*w)/2 << endl;
    }
    else
    {
      cout << (h*w)/2 << endl;
    }
  }
  else
  {
    if(w % 2 ==0)
    {
      cout << (h*w)/2 << endl;
    }
    else
    {
      cout << ((h*w)-1)/2 + 1  << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int D  = keyboard.nextInt();
		
		int[][]X = new int[N][D];
		
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < D; j++) {
				X[i][j] = keyboard.nextInt();	
			}
		}
		
		int count = 0;
		double a = 0;

		for(int i = 0; i < N; i++) {
			for(int j = i+1; j < N; j++) {
				a = 0;
				for(int k = 0; k < D; k++) {
					a += Math.pow(X[i][k]-X[j][k],2);
				}
				if(Math.sqrt(a)%1.0 == 0.0) {
					count++;
				}
			}
		}
		
		System.out.println(count);
		keyboard.close();	
	}
}


Measured memory_bytes: 21716
import math

intlist = list(map(int, input().split()))
n = intlist[0]
k = intlist[1]

sum = 0.0

for i in range(n):
  if (i+1)<k:
    x = math.log2(k/(i+1))
    y = math.ceil(x)
    sum += 1 / n / (2**y) 
    
  else:
    sum += 1/n
    
print(sum)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using lint=long long;
using namespace std;

int main()
{
	lint A,B,C;
	lint ans=0;
	
	cin >> A >> B >> C;
	
	for(;B>0 && C>0;)
	{
		C--;
		B--;
		ans+=2;
	}
	for(;A>0 && C>0;)
	{
		C--;
		A--;
		ans++;
	}
	ans+=B;
	if(C>0)ans++;
	cout  << ans << endl;
 	return 0;
}



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

using namespace std;

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

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        ans += __builtin_ctz(a);
    }

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


Measured memory_bytes: 256
import math
x = int(input())
if x == 1 or x== 2 or x==3:
  print(1)
  exit()

s = math.floor(math.sqrt(x))

def l(k,p):
  q = int(math.floor(math.log(p)/math.log(k)))
  if k ** (1+q) <= p:
    return(1+q)
  else:
    return(q)

ans = 0
for i in range(2,s+1):
  ans = max(ans, i ** l(i,x))
  if ans == x:
    print(x)
    exit()
  
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define MAXN 1000005
#define INF 1000000000
#define MOD 998244353
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,a[MAXN],inv[MAXN],coef[MAXN],s[MAXN];
int cnt[MAXN];
int sum[MAXN],res[MAXN];
void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;}
void dec(int &a,int b) {a-=b; if(a<0) a+=MOD;}
int pow_mod(int a,int i)
{
    int s=1;
    while(i)
    {
        if(i&1) s=1LL*s*a%MOD;
        a=1LL*a*a%MOD;
        i>>=1;
    }
    return s;
}
int main()
{
    inv[1]=1;
	for(int i=2;i<=1000000;i++) inv[i]=1LL*(MOD-MOD/i)*inv[MOD%i]%MOD;
    scanf("%d",&n);
    for(int i=1;i<=1000000;i++) coef[i]=inv[i];
    for(int i=1;i<=1000000;i++)
        for(int j=2*i;j<=1000000;j+=i)
            dec(coef[j],coef[i]);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        cnt[a[i]]++;
    }
    for(int i=1;i<=1000000;i++)
        for(int j=i;j<=1000000;j+=i)
            for(int k=1;k<=cnt[j];k++)
            {
                add(res[i],1LL*j*sum[i]%MOD);
                add(sum[i],j);
            }
    int ans=0;
    for(int i=1;i<=1000000;i++) add(ans,1LL*coef[i]*res[i]%MOD);
    printf("%d\n",ans);
    return 0;
}


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

namespace AtCoder
{
    static class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var str = IO.GetLongList();
            if (str[2] > str[0])
            {
                str[1] = Math.Max(str[1]-(str[2] - str[0]),0);
                str[0] = 0;
            }
            else
            {
                str[0] -= str[2];
            }

            Console.WriteLine(str[0]+" "+str[1]);
        }

        static public Dictionary<int,int> Factoring(int num)
        {
            Dictionary<int, int> vs = new Dictionary<int, int>();
            if(num == 1) { vs.Add(1,1);return vs; }
            while (num % 2 == 0)
            {
                if (vs.ContainsKey(2) == false) { vs.Add(2, 0); }
                vs[2]++;
                num /= 2;

            }
            if (num == 1)
            {
                return vs;
            }
            int i = 3;
            while (i <= Math.Sqrt(num))
            {
                if (num % i == 0)
                {
                    if (vs.ContainsKey(i) == false) { vs.Add(i, 0); }
                    vs[i]++;
                    num /= i;
                }
                else
                {
                    i += 2;
                }
            }
            if (vs.ContainsKey(num) == false) { vs.Add(num, 1); }
            else { vs[num]++; }

            return vs;
        }

        //aの逆元を取得
        //1/A (mod)
        static long GetInv(long a, long mod)
        {
            return ModPow(a, mod - 2, mod);
        }

        //a^n modを求める
        //O(N)=logN
        static long ModPow(long a, long n, long mod)
        {
            long res = 1;
            while (n > 0)
            {
                if ((n & 1) == 1) { res = res * a % mod; }
                a = a * a % mod; ;
                n >>= 1;
            }
            return res;
        }

    }

    static class IO
    {
        static public string GetString() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> GetStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> GetIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> GetLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteStrings<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
    }
}

Measured memory_bytes: 11348
# Aizu Problem ITP_1_10_B: Triangle
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


a, b, C = [int(_) for _ in input().split()]
C *= math.pi / 180
S = a * b * math.sin(C) / 2
c = math.sqrt(a**2 - 2 * a * b * math.cos(C) + b**2)
L = a + b + c
h = 2 * S / a
print("%.8f\n%.8f\n%.8f" % (S, L, h))

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

bool isA(string s){

  if(s.size() < 6 || s.size() % 2 == 1) return false;
  if(s.substr(0,2) != ">\'") return false;
  if(s[s.size() - 1] != '~') return false;

  int a, b;
  for( a = 2, b = s.size() - 2 ; a != b ; a++, b--){
    if(s[a] != '=' || s[b] != '=') return false;
  }

  return s[a] == '#';
}
bool isB(string s){

  if(s.size() < 6 || s.size() % 2 == 1) return false;
  if(s.substr(0,2) != ">^") return false;

  if(s.substr(s.size() - 2) != "~~") return false;

  for(int i = 2 ; i < s.size() - 2 ; i += 2){
    if(s.substr( i, 2) != "Q=") return false;
  }
  return true;
}

int main(){
  int n;
  cin >> n;
  while(n--){
    string s;
    cin >> s;
    if(isA(s)) cout << "A\n";
    else if(isB(s)) cout << "B\n";
    else cout << "NA\n";
  }
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int n, t;
int d[100010];

int main()
{
	cin >> n >> t;
	for (int i = 0; i < n; i++){
		cin >> d[i];
	}
	sort(d, d + n);
	
	long long res = 1;
	for (int i = 0; i < n; i++){
		int l = i - (lower_bound(d, d + i, d[i] - t) - d);
		res = res * (l + 1) % MOD;		
	}

	cout << res << endl;
}

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

int main() {
    int A,B;
    cin >> A >> B;
    vector<int> list(B);
    for(int i = 0; i<B; i++) {
        cin >> list[i];
    }
    list.push_back(list[0] + A);
    int l = 0;
    for(int i = 0; i<B; i++) {
        l = max (l, list[i+1] - list[i]);
    }
    int ans = A - l;
    cout << ans << endl;
}

Measured memory_bytes: 1792
import bisect


def solve(n, k, xxx):
    i0 = bisect.bisect(xxx, 0)
    if i0 == 0:
        return xxx[k - 1]
    if i0 == n:
        return -xxx[-k]

    xxx.insert(i0, 0)
    # print(xxx)
    ans = float('inf')
    for p in range(k + 1):
        li = i0 - k + p
        ri = i0 + p
        # print(p, li, ri, -xxx[li] * 2 + xxx[ri], -xxx[li] + xxx[ri] * 2)
        if li < 0 or ri > n:
            continue
        ans = min(ans, -xxx[li] * 2 + xxx[ri], -xxx[li] + xxx[ri] * 2)
    return ans


n, k = map(int, input().split())
xxx = list(map(int, input().split()))
print(solve(n, k, xxx))


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/12  Problem: ABC 082 C / Link: http://abc082.contest.atcoder.jp/tasks/abc082_c  ----- */


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

	LL N; 
	cin >> N;
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	map<LL, LL>M;
	FOR(i, 0, N) {
		M[a[i]]++;
	}

	LL ans = 0LL;
	for (auto it : M) {
		if (it.first <= it.second) {
			ans += it.second - it.first;
		}
		else {
			ans += it.second;
		}
	}
	
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 7040
import math  # noqa: F401
from collections import deque  # noqa: F401
from typing import Deque, Dict, List, Optional, Tuple, Union  # noqa: F401


def main(N: int):
    x = 1000 - N % 1000
    if x == 1000:
        print(0)
    else:
        print(x)


if __name__ == "__main__":
    N = int(input())
    main(N)


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

#define ll long long
#define pi acos(-1)
#define valid(a , b) a >= 0 && a < r && b >= 0 && b < c && arr[a][b] == '.'

int main()
{
    //ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    /*
    #ifndef ONLINE_JUDGE
    freopen("input.cpp", "r" , stdin);
    //freopen("output.cpp" , "w" , stdout);
    #endif // ONLINE_JUDGE
    //*/
    ll n , k;cin >> n >>k;
    int arr[n+3];
    for(ll i = 0 ; i < n ; i++){
        cin >> arr[i];
    }
    sort(arr , arr+n);
    ll ans = 0;
    for(int i = 0 ; i < (n-k) ; i++){
        ans += arr[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;

int H,W,K;
char s[300][300];
int ans[300][300];
int num=0;

int ball(int l, int t, int r, int b){
    int cnt=0;
    for(int i=t;i<=b;i++){
        for(int j=l;j<=r;j++){
            if(s[i][j]=='#') cnt++;
        }
    }
    return cnt;
}

void dfs(int l, int t, int r, int b){
    //cout<<"("<<l<<","<<t<<")~("<<r<<","<<b<<")"<<endl;
    int sum=ball(l,t,r,b);
    //cout<<"  "<<sum<<endl;
    if(sum==1){
        num++;
        for(int i=t;i<=b;i++){
            for(int j=l;j<=r;j++){
                ans[i][j]=num;
            }
        }
        return;
    }

    int cnt=0;
    for(int i=t;i<=b;i++){
        for(int j=l;j<=r;j++){
            if(s[i][j]=='#') cnt++;
        }
        if(0<cnt && cnt<sum){
            dfs(l,t,r,i);
            dfs(l,i+1,r,b);
            return;
        }
    }
    
    cnt=0;
    for(int j=l;j<=r;j++){
        for(int i=t;i<=b;i++){
            if(s[i][j]=='#') cnt++;
        }
        if(0<cnt && cnt<sum){
            dfs(l,t,j,b);
            dfs(j+1,t,r,b);
            return;
        }
    }
}

int main(){
    cin>>H>>W>>K;
    rep(i,H) rep(j,W) cin>>s[i][j];
   
    dfs(0,0,W-1,H-1);

    rep(i,H){
        rep(j,W){
            cout<<ans[i][j]<<' ';
        }
        cout<<endl;
    }
}

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

int main() {
	int n,m,p;
	while(cin >> n >> m >> p,n||m||p){
		int x[1000],sum=0;
		for(int i=0;i<n;i++){
			cin >> x[i];
			sum+=x[i];
		}
		if(x[m-1] == 0) cout << 0 << endl;
		else cout << (sum*100 - sum*p)/x[m-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
n = int(input())
h = list(map(int, input().split()))

dp = [float("inf")] * (n + 1)
dp[0] = 0
dp[1] = abs(h[0]-h[1])

for i in range(2, n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 13980
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int A, B;
	char OP;
	cin >> A >> OP >> B;
	cout << (OP == '+' ? A + B : A - B) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T *)array, (T *)(array + N), val);
}
ll dp[1010][20010];
const ll inf = 1e9;
int main() {
  Fill(dp, inf);
  int h, n;
  cin >> h >> n;
  vl a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  rep(i, n+1) dp[i][0] = 0;
  rep(i, n) {
    rep(j, h + 1) {
      if (j < a[i]){
        dp[i + 1][j] = min(dp[i][j], b[i]);
        dp[i + 1][j] = min(dp[i + 1][j], b[i]);
      }
      else{
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - a[i]] + b[i]);
        dp[i + 1][j] = min(dp[i + 1][j], dp[i + 1][j - a[i]] + b[i]);
      }
    }
  }
  // rep(i, n + 1) {
  //   rep(j, h + 1) cout << dp[i][j] << " ";
  //   cout << endl;
  // }
  ll ans = inf;
  rep(i, n+1) mins(ans, dp[i][h]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 161508
#include <bits/stdc++.h>
#include <unordered_set>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

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

	int n; cin >> n;
	ll money = 1000;

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

	for (int i = 1; i < n; i++) {
		if (v[i - 1] < v[i]) {
			ll stock = money / v[i - 1];
			money -= money / v[i - 1] * v[i - 1];
			money += stock * v[i];
		}
	}
	cout << money << '\n';
	return 0;
}

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

class MyClass
{
    public static void Main(string[] args)
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var a = input[0];
        var b = input[1];
        var N = int.Parse(Console.ReadLine());
        var s = new int[N];
        var f = new int[N];
        for (int i = 0; i < N; i++)
        {
            input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            s[i] = input[0];
            f[i] = input[1];
        }
        var ans = 0;
        for (int i = 0; i < N; i++)
        {
            if (a < f[i] && s[i] < b)
            {
                ans = 1;
                break;
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 20348
n = int(input())
a, b = map(int, input().split())
p = [int(s) for s in input().split()]

count = [0, 0, 0]
for i in range(n):
    if p[i] <= a:
        count[0] += 1
    elif a < p[i] <= b:
        count[1] += 1
    else:
        count[2] += 1
print(min(count))


Measured memory_bytes: 9188
/// You just can't beat the person who never gives up
/// ICPC next year

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std ;
const int N = 2e5+5 ;

string str ;
int main(){
    cin >> str ;
    if(str.size()%2) return cout << "No",0;
    for(int i=0;i<str.size();i+=2){
        if(str[i]=='h' && str[i+1]=='i') continue ;
        return cout << "No",0;
    }
    return cout << "Yes",0;
    return 0;
}


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

int main() {
  
  int n;
  cin >> n;
  
  int num,cnt=1;
  
  vector<pair<int,int>> a;
  for ( int i = 0; i < n; i++){
    cin >> num;
    a.push_back(make_pair(num,cnt));
    cnt++;
  }
  
  sort(a.begin(),a.end());
  
  for ( int i = 0; i < n; i++){
    int x,y;
    tie(x,y) = a[i];
    cout << y << ' ';
  }
  
  cout << endl;
  
}

Measured memory_bytes: 1780
N = int(input())
A = []
for i in range(N):
    a = int(input())
    A.append(a)
check = 0
count = 0
botton = 1
for i in range(N):
    count += 1
    if A[botton - 1] == 2:
        check = 1
        break
    botton = A[botton - 1]

if check == 0:
    print(-1)
else:
    print(count)

Measured memory_bytes: 7084
#include <iostream>
#include <string>
//#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int N;
    cin >> N;
    string S[N];
    vector<string> M,A,R,C,H;
    for(int i=0; i<N; i++){
        cin >> S[i];
        char c = S[i][0];
        if (c == 'M'){
            M.push_back(S[i]);
        }else if(c == 'A'){
            A.push_back(S[i]);
        }else if(c == 'R'){
            R.push_back(S[i]);
        }else if(c == 'C'){
            C.push_back(S[i]);
        }else if(c == 'H'){
            H.push_back(S[i]);
        }
    }
    size_t Ms = M.size();
    size_t As = A.size();
    size_t Rs = R.size();
    size_t Cs = C.size();
    size_t Hs = H.size();
    //printf("%d,%d,%d,%d,%d",Ms,As,Rs,Cs,Hs);
    long result = 0;

    result = result + Ms*As*Rs + Ms*As*Cs + Ms*As*Hs + Ms*Rs*Cs + Ms*Rs*Hs + Ms*Cs*Hs + As*Rs*Cs + As*Rs*Hs + As*Cs*Hs + Rs*Cs*Hs;
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 11636
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <string>
#include <queue>

size_t H = 19;
size_t W = 15;

constexpr size_t m1 = -1;
constexpr size_t di[] = {m1, m1, m1, 0, 0, 1, 1, 1};
constexpr size_t dj[] = {m1, 0, 1, m1, 1, m1, 0, 1};

template <class Tp>
constexpr Tp inf = Tp(1) << (8*sizeof(Tp)-3);

int dfs(std::vector<std::string>& s, size_t i, size_t j) {
  // char tmp = s[i][j];
  // s[i][j] = '@';
  // for (const auto& si: s)
  //   fprintf(stderr, "%s\n", si.c_str());
  // fprintf(stderr, "---\n");
  // s[i][j] = tmp;

  int res = inf<int>;
  for (int k = 0; k < 8; ++k) {
    size_t ni = i + di[k];
    size_t nj = j + dj[k];
    if (!(ni < H && nj < W && s[ni][nj] == 'X')) continue;

    std::vector<std::pair<size_t, size_t>> jmp;
    do {
      jmp.emplace_back(ni, nj);
      ni += di[k];
      nj += dj[k];
      if (ni == H) return 1;
      if (ni+1 == H && nj < W) return 1;
      if (!(ni < H && nj < W)) break;  // cannot jump
      if (s[ni][nj] != 'X') {
        for (const auto& p: jmp) {
          size_t ji, jj;
          std::tie(ji, jj) = p;
          s[ji][jj] = '.';
        }
        res = std::min(res, 1 + dfs(s, ni, nj));
        for (const auto& p: jmp) {
          size_t ji, jj;
          std::tie(ji, jj) = p;
          s[ji][jj] = 'X';
        }
        break;
      }
    } while (true);
  }
  return res;
}

int main() {
  std::vector<std::string> s(H);
  size_t si = -1;
  size_t sj = -1;
  for (size_t i = 0; i < H; ++i) {
    char buf[16];
    scanf("%s", buf);
    s[i] = buf;
    for (size_t j = 0; j < W; ++j) {
      if (s[i][j] == 'O') {
        si = i;
        sj = j;
      }
    }
  }
  // s.insert(s.begin(), std::string(W, '.'));
  // ++H;
  // ++si;

  int res = dfs(s, si, sj);
  if (res == inf<int>) return puts("-1"), 0;
  printf("%d\n", res);
}



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

int main()
{
  int K,i,Size;
  char S[102];

  scanf("%d",&K);
  scanf("%s",S);

  if(strlen(S) > K){
    for(i=0; i<K; i++)
      printf("%c",S[i]);
    printf("...");
    }
  else
    printf("%s", S);

  return 0;
}


Measured memory_bytes: 1732
S = list(input())

ans = 0
s_dict = {'0':0, '1':0}
for i in range(len(S)):
    if s_dict['0'] == 0 and s_dict['1'] == 0:
        s_dict[S[i]] += 1
    elif s_dict['0'] == 0:
        if S[i] == '0':
            s_dict['1'] -= 1
            ans += 2
        elif S[i] == '1':
            s_dict['1'] += 1
    elif s_dict['1'] == 0:
        if S[i] == '0':
            s_dict['0'] += 1
        elif S[i] == '1':
            s_dict['0'] -= 1
            ans += 2
print(ans)

Measured memory_bytes: 3956
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

map<ll, ll> prime_factor(ll n){
	map<ll, ll> res;
	for(ll i = 2; i*i <= n; i++){
		while(n%i == 0){
			res[i]++;
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	int ans = 0;
	for(auto p : prime_factor(n)){
		ll div = p.first;
		while(n%div == 0){
			n /= div;
			div *= p.first;
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define maxn 10005
using namespace std;
typedef long long ll;
inline int getint(){
  char c; int res = 0;
  for(c = getchar();c < '0' || c > '9';c = getchar());
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return res;
}
const int num[] = {0,2,5,5,4,5,6,3,7,6};
int n,m,a[15];
int f[maxn],g[maxn];
int main(){
	n = getint(), m = getint();
	for(int i = 1;i <= m;i++) a[i] = getint();
	sort(a + 1,a + m + 1);
	memset(f,-1,sizeof(f));
	f[0] = 0;
	for(int i = 1;i <= n;i++){
		for(int j = m;j >= 1;j--){
	 		if(i >= num[a[j]] && f[i - num[a[j]]] >= 0){
				f[i] = max(f[i],f[i - num[a[j]]] + 1);
			}
		}
	}
//	
//	for(int i = 1;i <= n;i++){
//		cout << f[i] << " ";
//	}
//	cout << endl;
//	system("pause");
	
	for(int i = 1;i <= n;i++){
		for(int j = m;j >= 1;j--){
	 		if(i >= num[a[j]] && f[i - num[a[j]]] == f[i] - 1){
				g[i] = a[j];
				break;
			}
		}
	}
	for(int i = n;i;i = i - num[g[i]]){
		printf("%d",g[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 384
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
#

import sys


# 回文判定
def is_palindrome(s: str) -> bool:
    """decide if s is palindrome or not.

    example:
        >>> s = "akasaka"
        >>> is_palindrome(s)
        # return nothing
        >>> s = "tokyo"
        >>> is_palindrome(s)
        No

    """
    for i in range(int(len(s) / 2)):
        if s[i] != s[-(i + 1)]:
            print("No")
            sys.exit()


s = str(input())
s_firsthalf = s[:int((len(s) - 1) / 2)]
s_secondhalf = s[int((len(s) + 3) / 2)-1:]

is_palindrome(s)
is_palindrome(s_firsthalf)
is_palindrome(s_secondhalf)

print("Yes")


Measured memory_bytes: 3064
import sys

stdin = sys.stdin


def na(): return map(int, stdin.readline().split())


def ns(): return stdin.readline().strip()


n,m=na()
abss = []
for i in range(n):
    abss.append(list(na()))
cds = []
for i in range(m):
    cds.append(list(na()))

for ab in abss:
    mind = 999999999
    argmin = -1
    import math
    for j in range(m):
        v = abs(cds[j][0]-ab[0])+abs(cds[j][1]-ab[1])
        if v < mind:
            mind = v
            argmin = j
    print(argmin+1)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int i;
  int j;
  int flag = 0;
  for(i=0;i<41;i++){
    for(j=0;j<16;j++){
      if((i*4+j*7)==N){
        flag = 1;
      }
    }
  }
  if(flag == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void trace(int A[],int N) {
    int i;
    for(i=0;i<N;i++) {
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}

void insertionSort(int A[], int N) {
    int i,j,v;
    for(i=1;i<N;i++) {
        v=A[i];
        j=i-1;
        while(j>=0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1]=v;
        trace(A,N);
    }
}

int main(void)
{
    int N, i;
    int A[100];
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);
    
    trace(A,N);
    insertionSort(A,N);
    return 0;
}


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

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

    int n,a,b;
    cin>>n>>a>>b;

    int ans=0;

    for(int i=1;i<=n;i++)
    {
        int m=i;
        int sum=0;
        while(m/10)
        {
            sum+=m%10;
            m/=10;
        }
        sum+=m%10;

        if(a<=sum&&sum<=b)ans+=i;
    }

    cout<<ans<<"\n";

    return 0;
}


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int n;
	cin >> n;
	map<string, int> res;
	res.insert(make_pair("AC", 0));
	res.insert(make_pair("WA", 0));
	res.insert(make_pair("TLE", 0));
	res.insert(make_pair("RE", 0));
	REP(i, n) {
		string tmp;
		cin >> tmp;
		res[tmp]++;
	}

	cout << "AC x " <<  res["AC"] << '\n';
	cout << "WA x " <<  res["WA"] << '\n';
	cout << "TLE x " <<  res["TLE"] << '\n';
	cout << "RE x " <<  res["RE"] << '\n';
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
 
int main() {
  int N;
  while(cin >>N && N){
    string s; cin >>s;
    vector<int> v(N, 0);
    int f = 0, t = 0;
    while(s != ""){
      if(s[0] == 'M') v[t]++;
      else if(s[0] == 'S'){
        f += 1 + v[t];
        v[t] = 0;
      } else{
        v[t] += 1 + f;
        f = 0;
      }
      s = s.substr(1);
      t = (t + 1) % N;
    }
    SORT(v);
    REP(i, v.size()) cout <<v[i] <<" ";
    cout <<f <<endl;
  }
  return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int a, b;
    cin >> a >> b;
    int mul = a * b;
    if (mul % 2 == 0) puts("Even");
    else puts("Odd");
}


Measured memory_bytes: 3660
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def bs(ar,eq,n) en=(eq==1 ? :>= : :>); ar.bsearch_index{|x|x.send(en,n)} end
def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
x,y=gsmi

n = x
cnt = 1
while n<y do
  n = n<<1
  cnt+=1 if n<=y
end

puts cnt


Measured memory_bytes: 1788
<?php
  $n = trim(fgets(STDIN));
  $count = [];
  $march=["M","A","R","C","H"];
  for($i=0; $i<$n; $i++){
      $s = trim(fgets(STDIN));
      if(in_array($s[0],$march)){
          $count[$s[0]]++;
      }
  }
  
  $ans = 0;
  for($i=0; $i<3; $i++){
      for($j=$i+1; $j<4; $j++){
          for($k=$j+1; $k<5; $k++){
              $ans += $count[$march[$i]]*$count[$march[$j]]*$count[$march[$k]];
          }
      }
  }
  
  echo $ans;

Measured memory_bytes: 4604
user_input = list(map(int,input().split()))
x1,y1 = user_input[0],user_input[1]
x2,y2 = user_input[2],user_input[3]

x_diff=x2-x1
y_diff=y2-y1

x3,y3 = x2-y_diff, y2+x_diff
x4,y4 = x1-y_diff, y1+x_diff

print(x3,y3,x4,y4)

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

int main() {
    int X;
    cin >> X;
    for(int i = -120; i < 121; i++) {
        for(int j = -120; j < 121; j++) {
            if(i*i*i*i*i-j*j*j*j*j == X) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}                 



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

class Program {
    static Scanner cin = new Scanner();
    static int N = cin.Int();
    static int K = cin.Int();
    static int[] D = cin.ArrayInt(K);
    static List<int> list = new List<int>() { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    static List<int> ANS = new List<int>();
    static void Main() {
        foreach (var x in D) {
            list.Remove(x);
        }
        foreach (var x in list) {
            if(x != 0) hoge(x);
        }

        ANS = ANS.Where(x => x >= N).ToList();
        Console.WriteLine(ANS.Min());
        Console.ReadLine();
    }

    static void hoge(int n) {
        ANS.Add(n);
        if (n >= 450 * N) return;
        foreach (var x in list) {
            hoge(10 * n + x);
        }
    }
}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 246828
def area(x1, y1, x2, y2, x3, y3)
  a = Math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
  b = Math.sqrt((x2 - x3)**2 + (y2 - y3)**2)
  c = Math.sqrt((x3 - x1)**2 + (y3 - y1)**2)
  s = (a + b + c)/2.0
  Math.sqrt(s*(s - a)*(s - b)*(s - c))
end

while gets do
  x1, y1, x2, y2, x3, y3, xp, yp = $_.chomp.split(' ').map(&:to_f)
  s_all = area(x1, y1, x2, y2, x3, y3)
  s_1 = area(x1, y1, x2, y2, xp, yp)
  s_2 = area(x2, y2, x3, y3, xp, yp)
  s_3 = area(x1, y1, x3, y3, xp, yp)
  puts (s_all - s_1 - s_2 - s_3).abs <= 0.00001 ? 'YES' : 'NO'
end

Measured memory_bytes: 6148
def c_welcome_to_atcoder():
    N, M = [int(i) for i in input().split()]

    count_wa = [0] * (N + 1)
    is_already_ac = [False] * (N + 1)

    for _ in range(M):
        p, s = input().split()
        p = int(p)
        if is_already_ac[p]:
            continue
        if s == 'AC':
            is_already_ac[p] = True
        elif s == 'WA':
            count_wa[p] += 1

    accepted, wrong = 0, 0
    for ac, wa in zip(is_already_ac, count_wa):
        if ac:
            accepted += 1
            wrong += wa
    return '{} {}'.format(accepted, wrong)

print(c_welcome_to_atcoder())

Measured memory_bytes: 4596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		String S = sc.next();

		String[] resultArray = S.split("");//[2]

		for (int i = 0; i < K - 1; i++) {

			System.out.print(resultArray[i]);
		}

		System.out.print(resultArray[K-1].toLowerCase());

		for (int i = K ; i < N; i++) {

			System.out.print(resultArray[i]);
		}

		sc.close();
	}

}

Measured memory_bytes: 23636
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons;
import std.math, std.numeric;


void main() {
    int k, t; scan(k, t);
    auto a = readln.split.to!(int[]);
    auto amax = a.reduce!max;
    auto ans = max(0, amax - (k - amax) - 1);
    writeln(ans);
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = 1e18;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    int K, A, B;
    cin >> K >> A >> B;

    if (A % K == 0){
        if (A <= B){
            cout << "OK" << endl;
        } else{
            cout << "NG" << endl;
        }
    } else{
        if ((A / K + 1) * K <= B){
            cout << "OK" << endl;
        } else{
            cout << "NG" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3636
/**Bismillahir Rahmanir Rahim.**/

/**
 *    author:  nasimnoob
**/

#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<cstring>
#include<cstdio>

using namespace std;

//----------------------------------------------------------//

typedef long long int                        ll;
typedef unsigned long long int              ull;
typedef long double                          ld;

//-----------------------------------------------------------//
#define      test                       int t; cin>>t;  while(t--)

#define      cube(x)                    (x*x*x)
#define      sqr(x)                     (x*x)

#define      INPUT                      freopen("input.txt", "r", stdin)
#define      OUTPUT                     freopen("output.txt", "w", stdout)

#define      srev                       reverse(s.begin(),s.end())
#define      sortstr                    sort(s.begin(), s.end());
#define      gtl(x)                     getline(cin, (x))
#define      dot(x)                     fixed << setprecision(x)

#define      Case                       cout << "Case " << ++tt << ": " ;

#define      PI                         acos(-1) // 3.1415926535897932
#define      MIN                        9999999
#define      EPS                        (1e-7)

#define      Faster                     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);




//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);


//--------------------------------------Solution------------------------------//

int main()
{

    #ifndef ONLINE_JUDGE
    clock_t tStart = clock();
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    //Faster;


    int tt = 0 ;
    int n ;

    cin >> n ;

    for (int i = 1 ; i <= n ; i++)
        cout <<"ACL";
    cout << endl;

    #ifndef ONLINE_JUDGE
    fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif


    return 0 ;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int n;
    cin >> n;
    int a[n];
    REP(i,n) cin >> a[i];
    int ans=0;
    {
    int tmp=0;
    REP(i,n-1){
        if(a[i]>=a[i+1])tmp++;
        else{
            chmax(ans,tmp);
            tmp=0;
        }
    }
    chmax(ans,tmp);
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3944
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long ll;
#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);

const int MAXN=2e5+5;
const int MOD=10000000;
 
int a[MAXN];
int n,k;

int main(){
	cin >> n >> k;
	int maxn=-1;
	for(int i=0;i<n;i++){
		cin >> a[i];
		maxn = max(maxn,a[i]);
	}
	sort(a,a+n);
	if(k == 0){
		cout << maxn<<endl;
	}
	else {
	int l = 0,r = maxn;
	ll ans =0;
	int p;
	while(r-l > 1){
		ans = 0;
		int mid = l + ((r-l) >> 1);
		for(int i=0;i<n;i++){
		ans += (a[i] / mid);
		 if(a[i] % mid != 0){
		 	ans++;
		 }
		 ans--;
		}
		
		if(ans > k){
			l=mid;
		}
		else{
		r = mid;
		}
		 
	}	
	cout << r << endl;
	}
	return 0;
}


Measured memory_bytes: 4320
from collections import Counter
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    A = list(map(int, input().split()))

    cnt = Counter(A)
    n = N
    if N % 2:
        if cnt[0] != 1:
            print(0)
            return
        n = N - 1
    for i in range(1, n, 2):
        if cnt[N-i] != 2:
            print(0)
            return
    print(pow(2, n // 2, 1000000007))


main()


Measured memory_bytes: 14820