akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main()
{
    int N;
    cin >> N;
    vector<int> a(N, 0);
    rep(i, N)
    {
        cin >> a[i];
    }

    int ans = 0;
    int count = 1;
    bool is_break = false;
    rep(i, N)
    {
        if (a[i] == count)
        {
            count++;
            is_break = true;
        }
        else
        {
            ans++;
        }
    }

    if (!is_break)
        ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#include <cassert>
#include <chrono>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

void solve() {
    int n;
    cin >> n;
    vll a(n);

    for (auto &x : a)
        cin >> x;
    a.resize(std::distance(a.begin(), std::unique(a.begin(), a.end()))); 
    n = sz(a);

    ll ans = 1000, s = 0;

    FOR (i, 0, n) {
        if ((i == 0 or a[i] < a[i-1]) and (i < (n-1) and a[i] < a[i+1])) {
            s += ans/a[i], ans %= a[i];
        }

        if ((i == 0 or a[i] > a[i-1]) and (i == (n-1) or a[i] > a[i+1])) {
            ans += a[i]*s, s = 0;
        }
    }
    assert(s == 0);
    cout << ans << "\n";
}

int main() {
    #ifdef LOCAL
    auto t1 = std::chrono::high_resolution_clock::now();
    #endif

    io;
    solve();

    #ifdef LOCAL
    auto t2 = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( t2 - t1 ).count();

    std::cout << "Time Taken: " << duration << "\n";
    #endif

}
// check for edge cases in limits
// printing double may print 1.223232e9 like values, beware of that
// carefully observe simulation of test cases


Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
using namespace std;
int main() {
	int q;
	scanf("%d", &q);
	for (int i = 0;i < q;++i) {
		int team = 0;
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		int ask = min(a, b);
		ask = min(ask, c);
		a -= ask;
		b -= ask;
		c -= ask;
		team += ask;
		if (a*2 < b) {
			while (true) {
				if (a <= 1||b == 0) break;
				a -= 2;
				b -= 1;
				team++;
			}
			goto printmode;
		}
		else {
			while (true) {
				if (b == 0||a <= 1) break;
				a -= 2;
				b -= 1;
				team++;
			}
			while (true) {
				if (a <= 2) break;
				a -= 3;
				team++;
			}
			goto printmode;
		}
	printmode:;
		printf("%d\n", team);
	}
}


Measured memory_bytes: 1028
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    string s; cin >> s;
    for(int i=0;i<s.size()-1;i++){
        if(s[i] == s[i+1]){
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
    }
    for(int i=0;i<s.size()-2;i++){
        if(s[i] == s[i+2]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }

    cout << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b;
    cin >> a >> b;
    if (a <= b) {
    	cout << a << endl;    
  	}
  	else {
    	cout << a-1 << endl;
  	}  
}


Measured memory_bytes: 3640
#include <stdio.h>


int main(void){
    
    int x,n;
    long int ans;
    scanf("%d %d",&x,&n);
    int p[n];
    int ans1 = x;
    int ans2 = x;
    int flag1=0;
    int flag2 = 0;
    for(int i=0;i<n;i++){
        scanf("%d",&p[i]);
    } 
    while(1){
        flag1 = 1;
        flag2 = 1;
        for(int i=0;i<n;i++){
            if(ans1 == p[i]) flag1 = 0;
            if(ans2 == p[i]) flag2 = 0;
        }
        if(flag1&&flag2){
            printf("%d",ans2);
            return 0;            
        }
        if(flag1){
            printf("%d",ans1);
            return 0;
        }
        if(flag2){
            printf("%d",ans2);
            return 0;
        }
        ans1+=1;
        ans2-=1;
    }

    return 0;
}

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

using namespace std;
 
int main()
{
    string s;
 
    while (cin >> s) {
	for (int i = 0; i < (int)s.size(); i++) {
	    if (s[i] == '@') {
		cout << string(s[i+1]-'0', s[i+2]);
		i += 2;
	    } else {
		cout << s[i];
	    }
	}
	cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3184
# -*- coding: utf-8 -*-
import sys
from operator import itemgetter
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy
from collections import Counter, deque, defaultdict
import heapq
from functools import reduce
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template

def main():
    r = ii()
    print(3 * r**2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5076
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cmath>
using namespace std;

int main()
{
 double r;
 cin >> r;  
 cout << std::fixed << std::setprecision(6) << r*r*M_PI << " " << 2*r*M_PI << endl;
 return 0;
}

Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int a,b;
  string s;
  cin >> a;
  if(a % 2 == 1){
    a++;
    cout << (a / 2) - 1;
  }
  else{
    cout << (a / 2) - 1;
  }
}

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

typedef long long lli;
lli A, B, C, D, P;

lli F1() {
  return A * P;
}

lli F2() {
  if(P <= C) return B;
  else return B + (P - C) * D;
}

int main() {
  while(cin >> A >> B >> C >> D >> P) {
    cout << min(F1(), F2()) << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	int l, r, ml = 1, mr = n;
	for (int i = 0; i < m; i++) {
		cin >> l >> r;
		ml = max(ml, l);
		mr = min(mr, r);
	}
	cout << max(0, mr - ml + 1);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<map>
using namespace std;
char str[2];
int main(){
	int a;
	while(scanf("%d",&a),a){
		map<pair<int,int> ,int> M;
		M[make_pair(0,1000000001)]=-1;
		for(int i=0;i<a;i++){
			scanf("%s",str);
			if(str[0]=='W'){
				int b,c;
				scanf("%d%d",&b,&c);
				for(map<pair<int,int>,int >::iterator it=M.begin();it!=M.end();it++){
					if(c<=0)break;
					pair<pair<int,int>,int> dat=*it;
					if(dat.second==-1){
						if(c>=dat.first.second-dat.first.first){
							c-=dat.first.second-dat.first.first;
							M[dat.first]=b;
						}else{
							M[make_pair(dat.first.first,dat.first.first+c)]=b;
							M[make_pair(dat.first.first+c,dat.first.second)]=-1;
							M.erase(dat.first);
							c=0;
							break;
							
						}
					}
				}
			}
			if(str[0]=='D'){
				int b;
				scanf("%d",&b);
				for(map<pair<int,int>,int>::iterator it=M.begin();it!=M.end();it++){
					if((*it).second==b){
						M[(*it).first]=-1;
					}
				}
			}
			if(str[0]=='R'){
				int b;
				scanf("%d",&b);
				bool found=false;
				for(map<pair<int,int> ,int >::iterator it=M.begin();it!=M.end();it++){
					pair<int,int> q=(*it).first;
					if(q.first<=b&&b<q.second){
						printf("%d\n",(*it).second);
						found=true;
						break;
					}
				}
			}
		}
		printf("\n");
	}
}

Measured memory_bytes: 1296
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;
const ll max_N = 9*pow(10,6)+1;

int main(){
  ll K;
  cin >> K;
  if(K%2==0 || K%5==0) cout << "-1" << endl;
  else{
    ll L=9*K;
    if(K%7==0) L /= 7;
    ll ans = 1;
    ll j = 0;
    bool fla = false;
    for(ll i=0;i<max_N;i++){
      ans = ans*10%(L);
      j++;
      if(ans==1){
	fla = true;
	break;
      }
    }
    if(fla) cout << j << endl;
    else cout << "-1" << endl;
  }
}


Measured memory_bytes: 3160
#include <iostream>
using namespace std;
int N;
int V[10];

int dfs(int a, int b, int d) {
    if(d==10) return 1;
    int atry = 0, btry = 0;
    if(a < V[d]) atry = dfs(V[d], b, d+1);
    if(b < V[d]) btry = dfs(a, V[d], d+1);
    if(atry == 0 && btry == 0) return 0;
}

int main() {
    cin >> N;
    for(int i=0; i<N; i++) {
        for(int j=0; j<10; j++) cin >> V[j];
        int res = dfs(0,0,0);
        if(res) cout << "YES" << endl;
        else cout << "NO" << endl; 
    }
}


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<list>
#include<cctype>
#include<utility>
#include<algorithm>
#include<cmath>
#include<cctype>
using namespace std;

///入力順はここで定義
enum FACE { TOP,BACK, RIGHT ,LEFT , FRONT,  BOTTOM};
template <class T>
class dice {
public:
  dice() {
    id[TOP] = 0; id[FRONT] = 1; id[LEFT] = 2;
    id[RIGHT] = 3; id[BACK] = 4; id[BOTTOM] = 5;
  }
  T& operator[] (int f) { return var[id[f]]; }
  const T& operator[] (int f) const { return var[id[f]]; }
  bool operator==(const dice<T>& b) const {
    const dice<T> &a = *this;
    return a[TOP] == b[TOP] && a[BOTTOM] == b[BOTTOM] &&
           a[FRONT] == b[FRONT] && a[BACK] == b[BACK] &&
           a[LEFT] == b[LEFT] && a[RIGHT] == b[RIGHT];
  }
  //回転はここで
  void roll_n() { roll(TOP, BACK, BOTTOM, FRONT); }
  void roll_s() { roll(TOP, FRONT, BOTTOM, BACK); }
  void roll_e() { roll(TOP, LEFT, BOTTOM, RIGHT); }
  void roll_w() { roll(TOP, RIGHT, BOTTOM, LEFT); }
  void roll_z() { roll(FRONT, RIGHT, BACK, LEFT); }
  vector<dice> all_rolls() {
    vector<dice> ret;
    for (int k = 0; k < 6; (k&1?roll_w():roll_s()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        ret.push_back(*this);
    return ret;
  }
  bool equivalent_to(const dice& di) {
    for (int k = 0; k < 6; (k&1?roll_w():roll_s()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        if (*this == di) return true;
    return false;
  }
private:
  void roll(FACE a, FACE b, FACE c, FACE d) {
    T tmp = id[a];
    id[a] = id[b]; id[b] = id[c];
    id[c] = id[d]; id[d] = tmp;
  }
  T var[6];
  int id[6];
};

int main()
{
	int n;cin >> n;
	vector<dice<int>> vd(n);
	for(int i=0;i<n;i++){
		for(int j=0;j<6;j++){
			int a;cin >> a;
			vd[i][j] = a;
		}
	}

	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(vd[i].equivalent_to(vd[j])){
				cout << "No" << endl;
				exit(0);
			}
		}
	}
	cout << "Yes" << endl;
	/*
	vector<dice<int>> d(2);
	for(int j=0;j<2;j++)
	for(int i=0;i<6;i++){
		int n; cin >>n;
		d[j][i] = n;
	}
	if(d[0].equivalent_to(d[1])){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	int n;cin >> n;
	for(int i=0;i<n;i++){
		int top,back;
		cin >> top >> back;
		for(int i=0;i<vd.size();i++){
			if(vd[i][TOP] == top && vd[i][BACK] == back){
				cout << vd[i][RIGHT] << endl;
				break;
			}
		}
	}*/
    return 0;
}

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

using namespace std;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

ull f(ull k,ull a){
switch(k){
  case 0:return a;
  case 1:return 1;
  case 2:return a+1;
  case 3:return 0;
  }
}

int main(){
const int n=65536;
bitset<n> bs;
ull s;
ull a,b,r,l,c,d;
cin>>a>>b;
r=(a-1)%4;
c=f(r,a-1);
l=b%4;
d=f(l,b);

bs=bitset<n>(c^d);
s=bs.to_ullong();
cout<<s<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;
    vector<int> L(N, 0), R(N, 0);
    int i = 0, cnt = 0;
    while (i < N) {
        while (S[i] == 'x') {
            i++;
        }
        cnt++;
        L[i] = cnt;
        i += C + 1;
    }
    i = N - 1; cnt = K + 1;
    while (i >= 0) {
        while (S[i] == 'x') {
            i--;
        }
        cnt--;
        R[i] = cnt;
        i -= C + 1;
    }

    rep(i, N) {
        if (L[i] != 0 && L[i] == R[i]) cout << (i + 1) << endl;
    }
    return 0;
}


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

int main(){
   
  int N;
  cin >> N;
  
  for(int i=0; i<N; i++){
    string S;
    cin >> S;
    if (S=="Y") {
      cout << "Four" << endl;
      break;
    }
    else if (i==(N-1)){
      cout <<"Three" << endl;
    } 
    
  } 


}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>//小数点以下表示
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<queue>
using Graph =vector<vector<int>>;

bool palindrome(string s){
    string t;
    t=s;
    reverse(t.begin(),t.end());
    if(s==t) return true;
    return false;
}

int main() {
    string s;
    cin>>s;
    int n=s.size();
    if(palindrome(s)&&palindrome(s.substr(0,(n-1)/2))&&palindrome(s.substr((n+1)/2))){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
typedef long long int ll;
using namespace std;
ll h[4][1000005];
ll dp[4][1000005];


ll go(ll p,ll q)
{
	if (q==1)
	return h[p][1];
	
	if (dp[p][q]!=0)
	return dp[p][q];
	else
	{
		ll x;
		if (p==1)
		{
			x=h[p][q]+max(go(2,q-1),go(3,q-1));
		}
		if (p==2)
		{
			x=h[p][q]+max(go(1,q-1),go(3,q-1));
		}
		if (p==3)
		{
			x=h[p][q]+max(go(2,q-1),go(1,q-1));
		}
		dp[p][q]=x;
		return x;
	}
}
	
	    
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    for (ll j=1;j<=n;j++)
    for (int i=1;i<=3;i++)
    cin>>h[i][j];
    memset(dp,0,sizeof(dp));
	ll m=0;
	for (int i=1;i<=3;i++)
	m=max(m,go(i,n));
	cout<<m;   
}


Measured memory_bytes: 48000
n,m=map(int,input().split())
mod=10**9+7


# コンビネーション、さらに高速。あらかじめO(N)の計算をすることでのちの計算が早くなる
def cmb(n,r,mod):
  if (r<0 or r>n):
    return 0
  r=min(r,n-r)
  return g1[n]*g2[r]*g2[n-r]%mod
g1=[1,1] # g1[i]=i! % mod　:階乗
g2=[1,1] # g2[i]=(i!)^(-1) % mod　:階乗の逆元
inverse=[0,1]
for i in range(2,min(2*10**5,n+m)+1):
  g1.append((g1[-1]*i)%mod)
  inverse.append((-inverse[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inverse[-1])%mod)

#heap

def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr
#factorization(24) 
## [[2, 3], [3, 1]] 
##  24 = 2^3 * 3^1

if m==1:
  print(1)
  exit()
ary=factorization(m)
ans=1
for x,y in ary:
  ans*=cmb(n-1+y,y,mod)
  ans%=mod
print(ans)

Measured memory_bytes: 110724
import math
N = int(input())
def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table
print(sum(num_divisors_table(N-1)))

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

int main() {
  int n, w, h;
  cin >> n >> w >> h;
  vector<pair<int, int>> x, y;
  for (int i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    x.push_back({a - c, a + c});
    y.push_back({b - c, b + c});
  }
  sort(begin(x), end(x));
  sort(begin(y), end(y));
  auto reduce = [](vector<pair<int, int>>& v) {
    for (int i = v.size() - 1; i >= 1; i--) {
      if (v[i].first <= v[i - 1].second) {
        v[i - 1].second = max(v[i - 1].second, v[i].second);
        v.erase(begin(v) + i);
        if (i < v.size()) {
          i++;
        }
      }
    }
  };
  reduce(x);
  reduce(y);
  // for (auto e : x) cerr << e.first << " " << e.second << endl;
  // for (auto e : y) cerr << e.first << " " << e.second << endl;
  bool rx = x.size() == 1 && x.front().first <= 0 && w <= x.front().second;
  bool ry = y.size() == 1 && y.front().first <= 0 && h <= y.front().second;
  cout << (rx || ry ? "Yes" : "No") << endl;
  return 0;
}



Measured memory_bytes: 4716
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int count =0;
	string s;
	cin>>s;
	if(s[0]==s[1]||s[0]==s[2]||s[0]==s[3])
	{
		count++;
	}
	if(s[1]==s[2]||s[1]==s[3])
	{
		count++;
	}
	if(s[2]==s[3])
	{
		count++;
	}
	count==2 ? cout<<"Yes" : cout<<"No" ;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdio>

void kock(int n,std::complex<double> p1,std::complex<double> p2){
	if(!n){
		printf("%.8f %.8f\n",p1.real(),p1.imag());
		return ;
	}
	std::complex<double> s,t,u;
	s.real((2*p1.real()+p2.real())/3);
	s.imag((2*p1.imag()+p2.imag())/3);
	t.real((p1.real()+2*p2.real())/3);
	t.imag((p1.imag()+2*p2.imag())/3);
	u.real(cos(M_PI/3)*(t.real()-s.real())-sin(M_PI/3)*(t.imag()-s.imag())+s.real());
	u.imag(sin(M_PI/3)*(t.real()-s.real())+cos(M_PI/3)*(t.imag()-s.imag())+s.imag());
	kock(n-1,p1,s);
	kock(n-1,s,u);
	kock(n-1,u,t);
	kock(n-1,t,p2);

}

int main(void){
	int n;
	const std::complex<double> LEFT(0,0);
	const std::complex<double> RIGHT(100,0);
	std::cin>>n;
	kock(n,LEFT,RIGHT);
	printf("%.8f %.8f\n",RIGHT.real(),RIGHT.imag());
	return 0;
}



Measured memory_bytes: 3180
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))

c = [0] * 3
for Pi in P:
    if Pi <= A:
        c[0] += 1
    elif Pi <= B:
        c[1] += 1
    else:
        c[2] += 1
print(min(c))


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
 
int main() {
    char ch;
    while(1){
        scanf("%c", &ch);
 
        if (islower(ch)) {
            printf("%c", toupper(ch));
        } else {
            printf("%c", tolower(ch));
        }
 
        if ( ch == '\n' ) break;
    }
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
int main(){
  char A,B,C;
  int X=700;
  cin >> A >> B >> C;
  if (A=='o'){
    X+=100;
  }
  if (B=='o'){
    X+=100;
  }
  if (C=='o'){
    X+=100;
  }
  cout << X;
}

Measured memory_bytes: 256
n, m, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

aa = [0]
bb = [0]
a.size.times{|i| aa << a[i] + aa.last}
b.size.times{|i| bb << b[i] + bb.last}

ans, j = 0, m
(0..n).each do |i|
  break if aa[i] > k
  while bb[j] > k-aa[i]
    j -= 1
  end
  ans = i+j if i+j > ans
end

print ans

Measured memory_bytes: 45096
#include <iostream>
#include <string>
using namespace std;
int k, n, a[210000], b[210000], mx;
int main()
{
  cin >> k >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  for (int i = 0; i < n - 1; i++)
  {
    b[i] = a[i + 1] - a[i];
  }
  b[n - 1] = a[0] + k - a[n - 1];
  for (int i = 0; i < n; i++)
  {
    mx = max(mx, b[i]);
  }
  cout << k - mx << endl;
  return 0;
}

Measured memory_bytes: 1792
//region Template
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "../debug_prettyprint.hpp"
#else
#define debug(...) 42
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#endif
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout<<fixed<<setprecision(12);
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
#define EXIT(answer) { cerr<<"EXIT #"<<__LINE__<<endl; cout<<answer<<endl; exit(0); }
#define sz(v) int(v.size())
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> istream& operator>>(istream& in, pair<T,U> &p) { in>>p.first>>p.second; return in; }
template<typename T> inline vector<T> READ(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
//endregion


int main() {
    FASTIO

    string s,t; cin>>s>>t;
    int ans=0;
    FOR(i,s.size())
    if(s[i]!=t[i]) ans++;
    cout<<ans<<endl;

    
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

class comb{
	vector<ll> f,fr;
	ll MOD;
	public:
	//a^(p-1) = 1 (mod p)(p->Prime numbers)
	//a^(p-2) = a^(-1)
	ll calc(ll a,ll b,ll p){//a^(b) mod p   
		if(b==0)return 1;
		ll y = calc(a,b/2,p);y=(y*y)%p;
		if(b & 1) y = (y * a) % p;
		return y;
	}
	void init(ll n,ll mod){//input max_n
		MOD = mod;
		f.resize(n+1);
		fr.resize(n+1);
		f[0]=fr[0]=1;
		for(ll i=1;i<n+1;i++){
			f[i] = (f[i-1] * i) % mod;
			fr[i] = calc(f[i],mod-2,mod);
		}
	}
	ll nCr(ll n,ll r){
		return f[n] * fr[r] % MOD * fr[n-r] % MOD;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N,M;
	cin >> N >> M;
	vector<ll> v;
	ll m = M;
	FOR(i,2,sqrt(m)+1){
		ll k=0;
		while(M%i==0){
			k++;
			M /= i;
		}
		if(k>0)v.push_back(k);
	}
	if(M!=1)v.push_back(1);
	ll ans = 1;
	comb ca;
	ca.init(200000,MOD);
	for(auto x:v){
		ans *= ca.nCr(N-1+x,N-1);
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
h, w = gets.split.map(&:to_i)
ch, cw = gets.split.map(&:to_i)
dh, dw = gets.split.map(&:to_i)

init = 1 << 30
d = Array.new(h+2) {Array.new(w+2, 0)}
h.times do |i|
    gets.each_char.with_index do |c,j|
        d[i][j] = init if c == ?.
    end
end

move = [[1,0], [-1,0], [0,1], [0,-1]]
warp = (-2..2).to_a.product((-2..2).to_a) - move - [[0,0]]

t = [[ch-1, cw-1]]
(0..).each do |k|
    break if t.empty? || d[dh-1][dw-1] < init
    u = []

    while (x, y = t.pop)
        next if d[x][y] <= k
        d[x][y] = k

        move.each do |i,j|
            t << [x+i, y+j] if d[x+i][y+j] > i
        end

        warp.each do |i,j|
            u << [x+i, y+j] if d[x+i][y+j] > i
        end
    end

    t = u
end

p d[dh-1][dw-1] == init ? -1 : d[dh-1][dw-1]

Measured memory_bytes: 51564
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, f, n) for (int i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;

int main() {
    ll N, K;
    cin >> N >> K;

    vector<ll> a(N);
    rep(i, N) cin >> a[i];

    vector<ll> sums;

    // rep(i, N) {
    //     reps(j, i + 1, N) {
    //         reps(k, j + 1, N) { sums.push_back(a[i] + a[j] + a[k]); }
    //     }
    // }

    sort(a.begin(), a.end(), greater<int>());
    // sums.erase(unique(a.begin(), a.end()), a.end());

    ll ans = 0;
    rep(i, K) ans += a[i];

    cout << ans << endl;
    // repv(sums) { cout << *it << " "; }
    // cout << sums[2] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	
	int T[50] = { 0 };
	int n, i;

	scanf("%d", &n);
	T[0] = 1;
	T[1] = 1;

	for (i = 2; i <= n; i++) {
		T[i] = T[i - 1] + T[i - 2];
	}

	printf("%d\n", T[i-1]);

	return 0;
}


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

int gcd(int x,int y){
  if(x%y==0)return y;
  return gcd(y,x%y);
}

int main() {
  int k;
  cin>>k;
  int sum=0;
  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int l=1;l<=k;l++){
        sum+=gcd(gcd(i,j),l);
      }
    }
  }
  
  cout<<sum<<endl;
}


Measured memory_bytes: 3628
N=int(input())
ans={}
cnt=0
for i in range(N):
  t=input()
  if not t in ans.keys():
    ans[t]=1
  else:
    ans[t]+=1
  if cnt<ans[t]:
    cnt=ans[t]
tmp =[]
for i in ans.keys():
  if ans[i]  == cnt:
    tmp.append(i)
tmp.sort()
for i in tmp:
  print(i)


Measured memory_bytes: 32096
#include<bits/stdc++.h>
using namespace std;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9	
#define MOD 1000000007
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

void solve() {
	string s, s1;
	cin >> s >> s1;
	int n = (int)(s.size());
	int m = (int)(s1.size());

	VVI dp(n+1,VI(m+1));
	int max_ = INT_MAX;

	for(int i = 0; i <= n-m; i++) {
		int c = 0;
		for(int j = 0; j < m; j++) {
			if(s[i+j] != s1[j]) c++;
		}
		max_ = min(c,max_);
	}
	cout << max_;
	

}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 7152
#include <iostream>

using namespace std;

void Sort(int p[],int n){
  int i,j;

  for(i=0;i<n-1;++i){
    for(j=i+1;j<n;++j){
      if(p[i]<p[j]){
	p[i]^=p[j]^=p[i]^=p[j];
      }
    }
  }
}

int main(){
  int n,p[101];
  cin >> n;
  for(int i=0;i<n;++i) cin >> p[i];
  //降順
  Sort(p,n);

  int num;
  for(int i=p[0];i>0;--i){
    num=0;
    for(;;){
      if(i<=p[num]){
	num++;
	if(num==i){
	  cout << num << endl;
	  return 0;
	}
      }else{
	break;
      }
    }
  }
  cout << num << endl;
  
  return 0;
}



Measured memory_bytes: 3108
#include<stdio.h>

int q, x_len[150] = {0}, y_len[150] = {0}, i, j, k, c[150][1001][1001];
char x[150][1001], y[150][1001];

int main(){
    
    scanf("%d", &q);
    for (i = 0; i < q; i++){
        scanf("%s %s", x[i], y[i]);
    }
    
    for(k = 0; k < q; k++){
    	while(x[k][x_len[k]] != 0){
            x_len[k]++;
        }
        while(y[k][y_len[k]] != 0){
            y_len[k]++;
        }
        
        for (i = 0; i < x_len[k]; i++){
            c[k][i][0] = 0;
        }
        for (i = 0; i < y_len[k]; i++){
            c[k][0][i] = 0;
        }
        for (i = 0; i < x_len[k]; i++){
            for (j = 0; j < y_len[k]; j++){
                if(x[k][i] == y[k][j]){
                	if(i - 1 < 0 || j - 1 < 0){
                		c[k][i][j] = 1;
                	} else {
                    	c[k][i][j] = c[k][i - 1][j - 1] + 1;
                	}
                } else if(c[k][i - 1][j] > c[k][i][j - 1]){
                	if(i - 1 < 0){
                		c[k][i][j] = 0;
                	} else {
                    	c[k][i][j] = c[k][i - 1][j];
                	}
                } else {
                	if(j - 1 < 0){
                		c[k][i][j] = 0;
                	} else{
                    	c[k][i][j] = c[k][i][j - 1];
                	}
                }
            }
        }
        
        printf("%d\n", c[k][x_len[k] - 1][y_len[k] - 1]);
    }
    return 0;
}


Measured memory_bytes: 80068
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main()
{
    string a;
    cin>>a;
    int n=a.length();
    int dp[n+1][13]={};

    int mod=1e9+7;

    dp[0][0]=1;

    for(int i=1;i<=n;i++)
    {
        for (int j = 0; j <13 ; ++j) {
            if(a[i-1]!='?')
            {
                dp[i][(a[i-1]-'0'+10*j)%13]=(dp[i-1][j]+dp[i][(a[i-1]-'0'+10*j)%13])%mod;
            }
            else
            {
                for (int k = 0; k <=9 ; ++k) {
                    dp[i][(k+10*j)%13]=(dp[i-1][j]+dp[i][(k+10*j)%13])%mod;
                }
            }
        }
    }

    cout<<dp[n][5];
}

Measured memory_bytes: 10624
from sys import stdin
mod = 10**9+7
N,K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]

maxn = 2*10**6

fac  = [0 for _ in range(maxn)]
finv = [0 for _ in range(maxn)]
inv  = [0 for _ in range(maxn)]

fac[0]  = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1

for i in range(2,maxn):
    fac[i] = fac[i-1] * i % mod
    inv[i] = mod - inv[mod%i] * (mod // i) % mod
    finv[i] = finv[i-1] * inv[i] % mod

def combinations(n,k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

ans = 0
A.sort()
for ind,a in enumerate(A):
    ans -= a*combinations(N-ind-1,K-1) % mod
    ans %= mod
    
A.reverse()
for ind,a in enumerate(A):
    ans += a*combinations(N-ind-1,K-1) % mod
    ans %= mod
    
print(ans%mod)

Measured memory_bytes: 149388
import Control.Monad

type Path = (Int, Int)

main :: IO ()
main = do
  (n, t) <- readPair
  pathes <- replicateM n readPair
  putStrLn $ maybe "TLE" show $ solve t pathes

readPair :: IO (Int, Int)
readPair = do
  [a, b] <- map read . words <$> getLine
  return (a, b)

solve :: Int -> [Path] -> Maybe Int
solve t pathes = case [ cost path | path <- pathes, time path <= t ] of
  [] -> Nothing
  xs -> Just $ minimum xs

cost :: Path -> Int
cost = fst

time :: Path -> Int
time = snd


Measured memory_bytes: 1020
#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 yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll a[10001];
ll r=1000000001;
int main() {

	int n;
	ll total=0;

	cin>>n;

	rep(i,n){
		cin>>a[i];
		rep(j,r){
			if(a[i]%2==0){
				total++;
				a[i]=a[i]/2;
			}else{
				break;
			}
		}
	}
	cout<<total<<endl;
	return 0;

}


Measured memory_bytes: 384
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

namespace ModFunctions {
	const int F = 2e5 + 10;

	int fact[F], inv_fact[F];

	inline void add(int &a, int b) {
		a += b;
		if (a >= MOD) {
			a -= MOD;
		}
	}

	inline void sub(int &a, int b) {
		a -= b;
		if (a < 0) {
			a += MOD;
		}
	}

	inline int mul(int a, int b) {
		return int((1ll * a * b) % MOD);
	}

	inline int power(int a, ll b) {
		int res = 1;
		while (b > 0) {
			if (b & 1) {
				res = mul(res, a);
			}
			a = mul(a, a);
			b >>= 1;
		}
		return res;
	}

	inline int inv(int a) {
		a %= MOD;
		if (a < 0) {
			a += MOD;
		}
		int b = MOD, u = 0, v = 1;
		while (a) {
			int t = b / a;
			b -= t * a;
			swap(a, b);
			u -= t * v;
			swap(u, v);
		}
		assert(b == 1);
		if (u < 0) {
			u += MOD;	
		}
		return u;
	}

	void pre_build() {
		fact[0] = 1;
		for (int i = 1; i < F; ++i) {
			fact[i] = mul(fact[i - 1], i);
		}
		inv_fact[F - 1] = inv(fact[F - 1]);
		for (int i = F - 2; i >= 0; --i) {
			inv_fact[i] = mul(inv_fact[i + 1], i + 1);
		}
	}

	int choose(int x, int y) {
		if (x < y) {
			return 0;
		}
		return mul(fact[x], mul(inv_fact[y], inv_fact[x - y]));
	}
}

using namespace ModFunctions;

void test_case();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	test_case();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void test_case() {
	string s;
	cin >> s;
	int res = 0, to_add = 1;
	for (int i = 0, rem = s.size() - 1; i < s.size(); ++i, --rem) {
		if (s[i] == '0') {
		} else {
			add(res, mul(to_add, power(3, rem)));
			to_add = mul(to_add, 2);
		}
	}
	add(res, to_add);
	cout << res << "\n";
}

Measured memory_bytes: 512
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Snuke's favorite YAKINIKU
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  if (s.size() >= 4 &&
      s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')
    puts("Yes");
  else
    puts("No");

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
const ll inf = 1e9;
int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    int q; cin >> q;
    rep(i,q){
        ll k;
        cin >> k;
        vector<ll>::iterator lw = lower_bound(all(a), k), up = upper_bound(all(a), k);
        cout << lw - a.begin() << " " << up - a.begin() << endl;
    }
    return 0;
}


Measured memory_bytes: 3544
import numpy
N, M, X = map(int, input().split())
status = []
for n in range(N):
    li = list(map(int, input().split()))
    status.append(li)
minimum = 10**12
def dp(depth, money, oklist):
    global minimum
    ok = oklist
    if depth == N:
        tf = True
        for m in range(M):
            if ok[m] < X:
                tf = False
        if tf:
            if money < minimum:
                minimum = money
        ok = [0]*M
        return
    dp(depth+1, money, ok)
#     for m in range(M):
#         ok[m] += status[depth][m+1]
    dp(depth+1, money+status[depth][0],ok+numpy.array([status[depth][m+1] for m in range(M)]))
oklist = numpy.array([0]*M)
dp(0, 0, oklist)
if minimum == 10**12:
  print(-1)
else:
  print(minimum)

Measured memory_bytes: 27156
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

main :: IO ()
main = do
	[n, a, b] <- readIntToList <$> BS.getLine
	print $ a * (n `div` (a + b)) + min a (n `mod` (a + b))


Measured memory_bytes: 380
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<cstdlib>
#include<list>
#include<set>
#include<numeric>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int field[1002][1002],h[1002][1002];
int x[1000001], y[1000001];
int dx[] = { 1,0,-1,0 }, dy[] = {0,1,0,-1};

int main() {
	int H, W;
	cin >> H >> W;

	for (int i = 0; i < H + 2; i++) {
		for (int j = 0; j < W + 2; j++) {
			field[i][j] = 100000000;
			h[i][j] = 0;
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) 
			cin >> field[i+1][j+1];
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			x[field[i][j]] = i;
			y[field[i][j]] = j;
		}
	}
	int ans = 0;
	for (int i = 1; i <= H*W; i++) {
		int a = 0;
		for (int j = 0; j < 4; j++) {
			int ddx = dx[j] + x[i], ddy = dy[j] + y[i];
			if (field[ddx][ddy] < i) {
				if (a == 0) a = h[ddx][ddy];
				else if (a != h[ddx][ddy])a = -1;
			}
		}
		if (a == 0)h[x[i]][y[i]] = i;
		else h[x[i]][y[i]] = a;
		if (a == -1)ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N, M, mx=0, my= INT_MAX, l, r;
	cin >> N >> M;
	REP(i, 0, M){
		cin >> l >> r;
		mx = max(l, mx);
		my = min(r, my);
	}
	cout << (my-mx >= 0 ?my - mx+1:0);

}


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (ll)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

ll digsum(ll n){
    ll sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

int main()
{
    ll n;
    cin >> n;
    vll h(n);
    rep(i,n)cin >> h[i];
    
    vll ans;
    ll cnt = 0;
    REP(i,1,n){
        if(h[i-1] >= h[i])cnt++;
        else{
            //cout << i << " ";
            ans.pb(cnt);
            cnt = 0;
        }
    }
    ans.pb(cnt);

    sort(rall(ans));

    /*rep(i,SIZE(ans))cout << ans[i] << " ";
    cout << endl;*/

    cout << ans[0] << endl;

    return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
  ll n,k,ans=0;cin>>n>>k;
  ll a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for(int i=0;i<k;i++){
    ans+=a[i];
  }
  cout << ans<<endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
int main() {
    int t,i;
    int a[10000],temp;
    double m=1,l,sum=0;
    cin>>t;
    for(i=0;i<t;i++) {
        cin >> a[i];
        sum = sum + (1.0 / a[i]);
    }
    cout<<(1.0/sum)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<n; i++)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
using namespace std;
using ll = long long;
using Graph = vector<vector<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;
}

int main() {
    int X, N;
    cin >> X >> N;
    int p[N];
    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
    }
    int dmin = 1000;
    int ans  = -1;
    for (int i = -1; i <= 101; i++)
    {
        bool flag = true;
        for (int j = 0; j < N; j++)
        {
            if(i==p[j]) flag = false;
        }
        if(flag){
            int d = max(X,i)-min(X,i);
            if(d<dmin){
                dmin = d;
                ans = i;
            }
        }   
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3592
import math


def resolve():
    a, b, c = map(int, input().split())
    if a == b == c:
        if a % 2:
            print(0)
        else:
            print(-1)
        return 0
    for i in range(int(math.log2(10 ** 9)) + 1):
        if a % 2 or b % 2 or c % 2:
            print(i)
            return 0
        a_new, b_new, c_new = (b + c) // 2, (a + c) // 2, (a + b) // 2,
        a, b, c = a_new, b_new, c_new
    print(-1)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3188
m = 0
x = 0
y = 0

list=[15,15*2,15*3,15*4,15*5,15*6]

n = input()
n = int(n)

while m < n:
    x = x + 800
    m = m + 1
    if m in list:
        y = y + 200

print(x-y)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace AtCoder
{
    class ABC177B
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            int mincount = 1001;
            for(int i = 0; i <= (s.Length - t.Length); i++)
            {
                int count = 0;
                for(int j = 0; j < t.Length; j++)
                {
                    if(s[i+j] != t[j])
                    {
                        count++;
                    }
                }
                //Console.WriteLine(count);
                if(count < mincount)
                {
                    mincount = count;
                }
            }
            Console.WriteLine(mincount);
        }
    }
}

Measured memory_bytes: 25908
#include <stdio.h>
int main(void){
    // Your code here!
    int n;
    float ans;
    scanf("%d",&n);
    if(n%2==0){
        ans = 0.5;
        printf("%f",ans);
    }else{
        ans = (float)(n+1)/(2*n);
        printf("%f",ans);
    }
    return 0;
}


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

namespace A {
	class main {
		public main() { }
		public static int Main() {
			new main().run();
			return 0;
		}
		void run() {
			Scanner cin = new Scanner();
			int[] a= new int[6]{1,5,10,50,100,500};
			int sum=0;
			for(int i=0; i<6; i++) { 
				int d=cin.nextInt();
				sum+=d*a[i];
			}
			if(sum>=1000) Console.WriteLine(1);
			else Console.WriteLine(0);
		}
	}

	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++];
			s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 0;
			return s[i++];
		}
		public int nextInt() {
			return int.Parse(next());
		}
		public long nextLong() {
			return long.Parse(next());
		}
		public double nextDouble() {
			return double.Parse(next());
		}
	}
}


Measured memory_bytes: 5620