akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define REPI(i, a, n)	for(ll (i)=(a);(i)<(int)(n);(i++))
#define REP(i,n) REPI(i,0,n)
#define REP1(i,n) for(ll (i)=1;(i)<=(n);(i++))
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
 
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;
 
	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
 
template<typename T>
int contains(std::vector<T> vec, int number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll fact(ll n) {
	ll m;
	if (n == 0) {
		return 1;
	}
	m = fact(n - 1);
	return n * m;
}
 
ll Combination(unsigned long long n, unsigned long long r) {
	if (r * 2 > n) r = n - r;
	uintmax_t dividend = 1;
	uintmax_t divisor = 1;
	for (unsigned int i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
 
struct vec {
	ll x, y;
 
	bool operator == (const vec &v) const{
		return x == v.x && y == v.y;
	}
 
};
 
namespace std {
	template<>
	class hash<vec> {
	public:
		size_t operator () (const vec& p) const { return p.x%SIZE_MAX; }
	};
}
 
int main() {
	int a,b,c,d;
	cin>>a>>b;
	cin>>c>>d;
	cout << (a!=c?(1):(0)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int n;
		set<int> s;
		cin >> n;
		rep(i,0,n){
			int t;
			cin >> t;
			s.insert(t);
		}
		if(sz(s)==n) cout<<"YES";
		else cout<<"NO";
	}
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

void solve()
{
    double a, b, h, m, ans;
    cin >> a >> b >> h >> m;
    h = (60*h + m) * (pi / 360);
    m *=  (pi / 30);
    double ang = abs(h - m); 
    ans = sqrt(a*a + b*b - 2*a*b*cos(ang));
    cout << fixed << setprecision(21);
    cout << ans << "\n";
}   

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 4288
import java.io.PrintWriter;
import java.util.*;

public class Main {

    private static Scanner in = new Scanner(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int k = in.nextInt();
        int x = in.nextInt();

        int MIN = -1000000;
        int MAX = 1000000;

        for (int i=Math.max(x - k + 1, MIN); i < Math.min(x + k - 1, MAX); i++)
            out.print(i + " ");
        out.println(Math.min(x + k - 1, MAX));
    }

}


Measured memory_bytes: 23764
import itertools


N, M = map(int, input().split())
edge = [[0] * (N+1) for _ in range(N+1)]
for i in range(M):
    a, b = map(int, input().split())
    edge[a][b] = 1
    edge[b][a] = 1

ans = 0
node = list(range(1, N+1))
for x in itertools.permutations(node):
    if x[0] == 1:
        for i in range(N-1):
            if not edge[x[i]][x[i+1]]:
                break
        else:
            ans += 1

print(ans)

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

int main() {
	int n;
	cin >> n;
	vector<long> b(n-1,0);
	for(int i = 0;i<n-1;i++)
	{
		cin >> b.at(i);
	}
	vector<long> a(n,0);
	long ss = 0;
	a.at(0) = b.at(0);
	for(int i = 1;i<n-1;i++)
	{
		a.at(i) = min(b.at(i),b.at(i-1));
	}
	a.at(n-1) = b.at(n-2);
	for(int i = 0;i<n;i++)
	{
		ss += a.at(i);
	}
  cout << ss << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin >> a;
  if ((a[0]==a[1]&&a[2]==a[3]&&a[0]!=a[2])||(a[0]==a[2]&&a[1]==a[3]&&a[0]!=a[1])||(a[0]==a[3]&&a[1]==a[2]&&a[0]!=a[1])){
    cout << "Yes" << endl;
  }
      else {
        cout << "No" << endl;
      }
      }

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    int n ;
    cin >> n ;

    vi v ( n ) ;
    int x = 0 ;

    for ( int i=0 ; i < n ; i ++ )
    {
        cin >> v[i] ;
        x ^= v[i] ;
    }

    for ( int i=0 ; i < n ; i ++ )
        cout << (x ^ v[i]) << " " ;

    line ;

}

int main()
{fast
    int t = 1;
    // cin >> t;

    for ( int i = 1 ; i <= t ; i ++ )
    {
        solve ( i ) ;
    }

    return 0;
}


Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
int main(){
    long a,b;
    cin >> a >> b;
    int s = a + b;
    if(s % 2 != 0){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    cout << s/2 << endl;
    return 0;
}

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

int main()
{
int a,b;
cin >> a >> b;
if(a>b)
{
cout << "a > b\n";
}
else if(a<b)
{
cout << "a < b\n";
}
else
{
cout << "a == b\n";
}

return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<vector<int>> A(2, vector<int>(N));
    rep(i, 2) rep(j, N) cin >> A[i][j];
    int ans, s = A[1][N - 1];
    rep(j, N) s += A[0][j];
    ans = s;
    rep(j, N - 1) {
        s = s - A[0][N - 1 - j] + A[1][N - 1 - j - 1];
        ans = max(ans, s);
    }
    cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> vec(n);
  
  for(int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int alice = 0, bob = 0;
  for(int i = 0; i < n; i++) {
    if(i % 2 == 0) {
      alice += vec.at(i);
    } else {
      bob += vec.at(i);
    }
  }
  cout << alice - bob << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int a, b;
  cin >> a >> b;
  if (a <= b) dump(a);
  else dump(a-1);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  static int flag=0,i,j,N,A[110],temp,cnt=0;

  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&A[i]);

  flag = 1;
  while(flag>0)
  {
    flag = 0;
    for(i=N-1;i>=0;i--)
    {
      if(A[i]<A[i-1])
      {
        temp=A[i];
        A[i]=A[i-1];
        A[i-1]=temp;
        flag = 1;
        cnt++;
      }
    }
  }
  for(i=0;i<N;i++)
  {
   printf("%d",A[i]);
   if(i!=N-1)printf(" ");
  }
  printf("\n");
  printf("%d\n",cnt);
  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi   = vector<int>;
using vll  = vector<ll>;
using vc   = vector<char>;
using vvll  = vector<vll>;
using vvi  = vector<vi>;
using vvc  = vector<vc>;
using vb   = vector<bool>;
using vvb  = vector<vb>;
using pii  = pair<int,int>;
using vpii = vector<pii>;
using posteriority_queue = priority_queue<int, vi, greater<int>>;

int main() {
    int N; cin >> N;
    ll ans = 0, add = floor(sqrt(N-1));
    for (int i = 1; i <= N-1; i++) {
        for(int j = 1; j < sqrt(i); j++) {
            if(i%j==0) {
                ans = ans + 2;
            }
        }
    }
    cout << ans + add;
}


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

typedef long long ll;
using namespace std;
int main()
{
  string s;
  cin>>s;
  ll max=0;

  if(s=="A"||s=="G"||s=="T"||s=="C"){
    cout<<1<<endl;
    return 0;
  }


  rep(i,s.length()-1){
    ll start=i;
    ll tmp=0;

    if(s[start]=='A'||s[start]=='T'||s[start]=='G'||s[start]=='C'){
      tmp++;
      while((s[start+1]=='A'||s[start+1]=='T'||s[start+1]=='G'||s[start+1]=='C')&&start<s.length()){
        start++;
        tmp++;
      }
    }
    if(tmp>max)max=tmp;
  }

  cout<<max<<endl;
  return 0;
}


Measured memory_bytes: 3648
import math

def nyu():
    N,K= map(int,(input().split()))
    return K,N


def check(K,N ):
    min = 0
    abs_num = 0

    N = N%K

    OLD_ABS =N
    NEW_ABS = abs(K-N)

    while NEW_ABS < OLD_ABS:
        OLD_ABS = N #OK
        N = NEW_ABS ##OK
        NEW_ABS =abs(K-N)
    #    print("N_NEW",NEW_ABS,"OLS_ABS",OLD_ABS,"N",N)
    print(N)     
            
K,N = nyu()
check(K,N)
#print(S)



Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)

ans = A[0]
N -= 2

n = N // 2
ans += 2 * sum(A[1: n + 1])
if N % 2 == 1:
    ans += A[n + 1]

print (ans)

Measured memory_bytes: 31524
import sys
from io import StringIO
import unittest

def resolve():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))

    print(sum([1 for hh in h if hh >= k]))

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4 150
150 140 100 200"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """1 500
499"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """5 1
100 200 300 400 500"""
        output = """5"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 14712
import bisect
import os

import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


X = int(sys.stdin.buffer.readline())

hist = []
for a in range(100000):
    hist.append(a ** 5)
    i = bisect.bisect_left(hist, a ** 5 - X)
    if i < len(hist) and hist[i] == a ** 5 - X:
        print(a, i)
        break
    i = bisect.bisect_left(hist, X - a ** 5)
    if i < len(hist) and hist[i] == X - a ** 5:
        print(a, -i)
        break

# while a ** 5 < 10 ** 18:
#     a += 1
# print(a)
# for _ in range(200):
#     hist.append(a ** 5)
#     a += 1
# print(hist)


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

struct CSF {
  ll C, S, F;
};

int main() {
  int N;
  cin >> N;
  vector<CSF> V(N + 1);
  for (int i = 1; i < N; ++i) {
    cin >> V[i].C >> V[i].S >> V[i].F;
  }
  
  // vector<ll> dp(N, 0);
  
  for (int i = 1; i <= N; ++i) {
    if (i == N) {
      cout << 0 << endl;
    } else {
      ll result = V[i].S + V[i].C;
      for (int j = i + 1; j <= N - 1; ++j) {
        if (V[j].S < result) {
          ll start = (result - V[j].S + (V[j].F - 1)) / V[j].F;
          result += (V[j].S + start * V[j].F - result) + V[j].C;
        } else {
          result += (V[j].S - result) + V[j].C;
        }
      }
      cout << result << endl;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#define ll int64_t
#define REP(i, n) for (ll i=0; i<n; i++)
using namespace std;

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

    int A, P;
    cin >> A >> P;
    cout << ((P+3*A)/2) << "\n";
}

Measured memory_bytes: 256
//0321 部活動調査
//UF木
#include<bits/stdc++.h>
#define LL long long int
using namespace std;
LL bol[200010],r1[200010],r2[200010],club[100010],node[100010],size[100010];
int root(int x){
	if(x!=node[x]){
		node[x] = root(node[x]);
		return node[x];
	}
	else return x;
}
int main(void)
{
	LL i,j,n,m,k;
	cin>>n>>m>>k;
	for(i=0;i<k;i++) cin>>bol[i]>>r1[i]>>r2[i];
	for(i=0;i<n;i++) club[i]=0,node[i]=i,size[i]=1;
	for(i=0;i<k;i++) {
		int x,y,c,s;
		if(bol[i]==1) {
			x=r1[i],y=r2[i];
			//while(x!=node[x]) x=node[x];
			//while(y!=node[y]) y=node[y];
			x=root(x);
			y=root(y);
			if(club[x]!=0&&club[y]!=0&&club[x]!=club[y]) {
				cout<<i+1<<endl;
				break;
			}
			else if(club[x]!=0&&club[y]==0) club[y]=club[x];
			else if(club[x]==0&&club[y]!=0) club[x]=club[y];
			if(x!=y) {
				if(size[x]>size[y]) node[y]=x;
				else if(size[y]>size[x]) node[x]=y;
				else node[y]=x,size[x]++;
			}
		}
		else {
			s=r1[i],c=r2[i];
			while(s!=node[s]) s=node[s];
			if(club[s]==0) club[s]=c;
			else if(club[s]!=c) {
				cout<<i+1<<endl;
				break;
			}
		}
	}
	if(i==k) cout<<"0"<<endl;
}

Measured memory_bytes: 10132
s=gets.chomp!
t=false
t=true if s[0]!="A"
g=0
for i in 2..s.size-2 do
    if s[i]=="C"
        g+=1
    else     
        t=true if s[i].codepoints[0]<97||s[i].codepoints[0]>123
    end
end
t=true if s[1].codepoints[0]<97||s[1].codepoints[0]>123
t=true if s[s.size-1].codepoints[0]<97||s[s.size-1].codepoints[0]>123
t=true if g!=1
puts "AC" if !t
puts "WA" if t

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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(){
    ll n,m; cin>>n>>m;
    vector<ll> x(n), y(n), z(n);
    rep(i,n) cin>>x[i]>>y[i]>>z[i];

    ll res=0;
    rep(i,8){
        ll tmp=0;
        vector<bool> ifinc(3);
        rep(j,3){
            if(i>>j & 1) ifinc[j]=true;
            else ifinc[j]=false;
        }

        vector<ll> w(n, 0);

        if(ifinc[0]){
            rep(j,n) w[j]+=(-1)*x[j];
        }else{
            rep(j,n) w[j]+=x[j];
        }

        if(ifinc[1]){
            rep(j,n) w[j]+=(-1)*y[j];
        }else{
            rep(j,n) w[j]+=y[j];
        }

        if(ifinc[2]){
            rep(j,n) w[j]+=(-1)*z[j];
        }else{
            rep(j,n) w[j]+=z[j];
        }

        sort(w.begin(), w.end(), greater<ll>());
        rep(j,m) tmp+=w[j];

        chmax(res, tmp);
        
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    a, b, c = list(map(int, readline().split()))
    if a == b == c:
        if a == b == c == 1:
            print(0)
        else:
            print(-1)
    else:
        cnt = 0
        while True:
            if a % 2 == b % 2 == c % 2 == 0:
                cnt += 1
                a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
            else:
                print(cnt)
                exit()


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
int main () {

  int n;
  int k;
  std::cin >> n;
  std::cin >> k;
  
  std::vector<int> ls;
  
	for(int i=0; i< n;++i) {
      int l;
      std::cin >> l;
      ls.push_back(l);
    }
  
  int count;
  for(auto&& l : ls) {
    if(k <= l)
      	++count;
  }
  std::cout << count;
}

Measured memory_bytes: 892
from typing import Iterable


def multply(nums: Iterable[int]) -> int:
    if 0 in nums:
        return 0

    result = 1

    for i in nums:
        result *= i
        if result > 10**18:
            return -1

    return result

count_num = int(input())
nums = map(int, input().split())
print(multply(list(nums)))


Measured memory_bytes: 23680
n, a, b = map(int, input().split())

from operator import mul
from functools import reduce
import math

flg = (a == n-b)
rep = math.ceil(n/2)
MOD = 10**9+7
memo = 0

def modpow(a: int, p: int, mod: int) -> int:
    # return a**p (mod MOD) O(log p)
    if p == 0:
        return 1
    if p % 2 == 0:
        half = modpow(a, p//2, mod)
        return half*half % mod
    else:
        return a * modpow(a, p-1, mod) % mod


from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mod_mul, range(n, n - r, -1), 1)
    denom = reduce(mod_mul, range(1, r + 1), 1)
    return numer*pow(denom, MOD-2, MOD)%MOD
  
def mod_mul(a, b):
  return mul(a%MOD, b%MOD)%MOD

s = 0
ans = modpow(2, n, MOD)-1
if flg:
  ans = ans - 2*combinations_count(n, a)%MOD
else:
  ans = (ans - combinations_count(n,a))%MOD - combinations_count(n,b)
print(ans%MOD)

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

int main(){
    ll N;
    cin >> N;
    int ans = 0;
    vector<string> S(N);
    rep(i, N) cin >> S[i];
    sort(all(S));
    for(int i=1; i<=N; ++i){
        if(S[i-1]!=S[i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
 }


Measured memory_bytes: 9600
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def s_list(): return list(input())
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def grid(n): return [s_list() for _ in range(n)]


if __name__ == '__main__':
    n, a, b = wi()
    s = s()
    acnt = 0
    bcnt = 0
    for i in range(n):
        if s[i] == "a":
            if acnt + bcnt < a + b:
                print("Yes")
                acnt += 1
            else:
                print("No")
        elif s[i] == "b":
            if acnt + bcnt < a + b:
                if bcnt < b:
                    print("Yes")
                    bcnt += 1
                else:
                    print("No")
            else:
                print("No")
        else:
            print("No")

Measured memory_bytes: 7792
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <climits>

using namespace std;


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

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

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

	map<string, int> u;

	for (int i = 0; i < m; i++) {
		u[s[i]]++;
	}

	for (int i = 0; i < n; i++) {
		u[t[i]]--;
	}

	int count = 0;
	for (auto b : u) {

		if (count < b.second)count = b.second;
	}
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
int main() {
	int res = 99999999;
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < 3; ++k) {
				if (i == j || j == k || k == i) continue;

				int x = 0;
				x += abs(a[j] - a[i]);
				x += abs(a[k] - a[j]);
				res = min(res, x);
			}
		}
	}
	PRI(res);
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define dd double
using namespace std;
const ll MOD = 1e9 + 7; 
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  string s;
  cin>>s;
  ll i;
  ll sum=0;
  for(i=0;i<s.size();i++){
  	sum=sum+s[i]-'0';
  }
  
  if(sum%9==0){
  	cout<<"Yes"<<endl;
  }
  else{
  	cout<<"No"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;

int main() {
	rep(i, 5) {
		int a;
		cin >> a;
		if (a == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <regex>
#include <math.h>
typedef long long ll;
using namespace std;


int main(void){
  ll n, yen;
  vector<ll> v = {10000,5000,1000};
  cin >> n >> yen;
  for(ll i = 0;i <= n;i++){
    ll y = 0;
    for(ll j = 0;j <= n - i;j++){
      y = v[0]*i + v[1]*j + v[2]*(n - i - j);
      if(y == yen){
        cout << i << " " << j << " " << (n - i - j) << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;

}

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

int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b)
		if(a!=c){
			printf("Yes");
			return 0;
		}
	if(a==c)
		if(a!=b){
			printf("Yes");
			return 0;
		}
	if(b==c)
		if(a!=b){
			printf("Yes");
			return 0;
		}
	printf("No");
	return 0;
 } 

Measured memory_bytes: 256
import sys
n,m=map(int,input().split())
sc=sorted([list(map(int,input().split())) for i in range(m)])

if n==1:
  a=0
else:
  a=10**(n-1)
for i in range(a,10**n):
  ans=str(i)
  flg=0
  for j in range(m):
    if sc[j][0]>len(ans):
      flg=1
      break
    if int(ans[sc[j][0]-1])!=sc[j][1]:
      flg=1
      break
  if flg==0:
    print(ans)
    sys.exit()
print(-1)

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

int main() {
  int N;
  cin >> N;
  int c;
  int A=0, B=0;
  vector<int> vec(N);
  for (int i=0; i<N; i++) {
    cin >> c;
    vec.at(i)=c;
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  for (int i=0; i<(N+1)/2; i++) {
    A += vec.at(2*i);
  }
  for (int i=0; i<N/2; i++) {
    B += vec.at(2*i+1);
  }
  cout << A-B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	long double a, b, x;
	cin >> a >> b >> x;
	long double t;
	if(x <= (a*a*b)/2.0){
		t = (a*b*b)/(2.0*x);
	}else{
		t = (2.0*b)/a - (2.0*x)/(a*a*a);
	}
	long double ans = (atan(t)*180.0)/M_PI;
	cout << setprecision(12) << ans  << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  int ans = c - (a - b);
  if(ans < 0) ans = 0;
  cout << ans << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb(t) push_back(t)
#define pt(num) cout << num << "\n"
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;


int main(void) {
    ll N;
    cin >> N;
    ll a[MAX/10], b[MAX/10];
    ll i;
    
    for(i=0; i<N; i++) cin >> a[i];
    for(i=0; i<N; i++) cin >> b[i];
    
    ll p=0, m=0;
    for(i=0; i<N; i++) {
        ll c=a[i]-b[i];
        
        if(c>0) p+=c;
        else m+=-c/2;
    }
    
    if(p<=m) pt("Yes");
    else pt("No");
    
    
}




Measured memory_bytes: 384
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)
for i in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x - 1] + b[y - 1] - c)
print(ans)

Measured memory_bytes: 18612
#include<bits/stdc++.h>
using namespace std;
  
 
int main(){
  std::vector<tuple<string,int,int>> v;
  int N;
  cin >> N;
  for(int i=0;i<N;i+=1){
     int b,c;
     string a;
     cin >> a >> b;
     v.push_back(make_tuple(a,-b,i+1)); 
  }
  
  sort(v.begin(),v.end());
//   sort(v.begin(),v.end());
  for(auto x:v){
     cout << get<2>(x) <<endl ;
  }
}

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

public class Main {

	public static void main(String[] args) {

		//		ABC115_A();
		ABC115_B();
		// ABC115_C();
		// ABC115_D();
	}

	private static void ABC115_A() {
		Scanner scanner = null;
		int date = 0;

		try {
			scanner = new Scanner(System.in);
			date = scanner.nextInt();

			switch (date) {
			case 22:
				System.out.println("Christmas Eve Eve Eve");
				break;
			case 23:
				System.out.println("Christmas Eve Eve");
				break;
			case 24:
				System.out.println("Christmas Eve");
				break;
			case 25:
				System.out.println("Christmas");
				break;
			default:
				System.out.println("fail!");
				break;
			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static void ABC115_B() {
		Scanner scanner = null;
		int numItem = 0;
		int priceItem = 0;

		try {
			scanner = new Scanner(System.in);
			numItem = scanner.nextInt();
			int[] priceArray = new int[numItem];

			for (int i = 0; i < numItem; i++) {
				priceArray[i] = scanner.nextInt();
			}

			Arrays.sort(priceArray);

			int prices = 0;
			for (int i = 0; i < priceArray.length; i++) {
				if (i != numItem - 1) {
					prices += priceArray[i];
				} else {
					prices += priceArray[i] / 2;
				}

			}

			System.out.println(prices);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static void ABC115_C() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static void ABC115_D() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 22868
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        if (k % 2 == 0) {
            long count1 = 0;
            for (int i = 1; i <= n; i++) {
                if (i % k == k / 2) count1++;
            }
            long count2 = 0;
            for (int i = 1; i <= n; i++) {
                if (i % k == 0) count2++;
            }
            
            long ans = count1 * count1 * count1 + count2 * count2 * count2;
            System.out.println(ans);
        } else {
            long count2 = 0;
            for (int i = 1; i <= n; i++) {
                if (i % k == 0) count2++;
            }
            
            long ans = count2 * count2 * count2;
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 23764
while(True):
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    fr = ''
    for i in range(W):
        fr += '#'
    fr += '\n'
    for i in range(H-2):
        fr += '#'
        for j in range(W-2):
            fr += '.'
        fr += '#\n'
    for i in range(W):
        fr += '#'
    fr += '\n'
    print(fr)

Measured memory_bytes: 7596
N = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(N-2):
    p1, p2, p3 = P[i:i+3]
    if (p1 < p2 and p2 < p3) or (p1 > p2 and p2 > p3):
        ans += 1
print(ans)

Measured memory_bytes: 3060
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd


def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    s=list(input())
    t=set(s)
    if len(t)==2:
        print('Yes')
    else:
        print('No')


if  __name__=='__main__':
    main()


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

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

  vector<int> A(N, K);      //得点配布
  vector<int> QN(N);       //正解した問題数

  for(int i = 0; i < Q; i++){
    int q;
    cin >> q;
    QN[q-1]++;
  }

  for(int i = 0; i < N; i++)
    A[i] -= (Q - QN[i]);            //正解できなかった問題数

  for(int i = 0; i < N; i++){
    if(A[i] > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;

}

Measured memory_bytes: 1408
#include <cstdio>

int main()
{
	unsigned long long x;
	scanf("%lld", &x);
	long long a = 100;
	long long ans = 0;
	while (a < x)
	{
		a += a / 100;
		ans += 1;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1700
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N,P,g=0,n=0,m=0;
  cin>>N>>P;
  vector<int> A(N);
  for(int &i:A){
    cin>>i;
    if(i%2==1){
      cout<<(int)pow(2,N-1)<<endl;
      return 0;
    }
  }
  if(P==1)
    cout<<0<<endl;
  else
    cout<<(int)pow(2,N)<<endl;
}

Measured memory_bytes: 3960
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	static class Tuple {
		int i;
		int C, S, F;

		Tuple(int i, String[] tokens) {
			this.i = i;
			this.C = Integer.parseInt(tokens[0]);
			this.S = Integer.parseInt(tokens[1]);
			this.F = Integer.parseInt(tokens[2]);
		}
	}

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);

		int N = Integer.parseInt(in.readLine());
		Tuple[] stations = new Tuple[N - 1];
		for (int i = 0; i + 1 < N; ++i) {
			stations[i] = new Tuple(i, in.readLine().split(" "));
		}
		for (int i = 0; i + 1 < N; ++i) {
			System.out.println(getArriveTime(stations, i));
		}
		System.out.println(0);

	}

	static long getArriveTime(Tuple[] stations, int startStation) {
		long time = 0;
		for (int i = startStation; i < stations.length; ++i) {
			Tuple station = stations[i];
			if (time < station.S) {
				time = station.S;
			} else if (time % station.F != 0) {
				time += station.F - (time % station.F);
			}
			time += station.C;
		}

		return time;
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N;
  cin >> N;
  vector<ll> X(1010, 0);
  for (ll i = 0; i < N; i++)
  {
    ll L;
    cin >> L;
    X.at(L)++;
  }

  ll ans = 0;
  for (ll a = 1; a <= 1000; a++)
  {
    for (ll b = a; b <= 1000; b++)
    {
      for (ll c = b; c <= 1000; c++)
      {
        if (c >= a + b)
          break;

        if (a == b && b == c)
          ans += X.at(a) * (X.at(b) - 1) * (X.at(c) - 2) / 6;
        else if (a == b)
          ans += X.at(a) * (X.at(b) - 1) * X.at(c) / 2;
        else if (b == c)
          ans += X.at(a) * X.at(b) * (X.at(c) - 1) / 2;
        else
          ans += X.at(a) * X.at(b) * X.at(c);
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
	int a, b, c;
	bool flag=false;

	cin >> a >> b >> c;

	for (int i = 1; i <= b; i++) {
		if ((a*i)%b == c)flag = true;
	}
	if (flag)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
n, a, b = i2()

if a == 0:
    print(0)
elif b == 0:
    print(n)
else:
    cnt = n // (a+b)
    c = n % (a+b)
    if c <= a:
        print(a*cnt+c)
    else:
        print(a*cnt+c-(c-a))

Measured memory_bytes: 3064
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> 
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
 

 int dfs(string s,int same){
     //string sがsameより小さいかdfsする?

 }
 int main(){
     string N;cin>>N;
    int head = N[0] - '0';
    int tmp = head * 111;
    if(tmp<stoi(N)){
        tmp += 111;
    }
    cout<<tmp;
 }

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int W,a,b;
    cin>>W>>a>>b;
    if(a+W<=b){
        cout<<b-(a+W)<<endl;
    }
    else if(b+W<=a){
        cout<<a-(b+W)<<endl;
    }
    else if(a<=b && b+W<=a+W){
        if(a+W-b<=b+W-a){
            cout<<0<<endl;
        }
        else
            cout<<0<<endl;
    }
    else if(b<=a+W && a+W<=b+W){
        cout<<0<<endl;
    }
    else if(b<=a && a<=b+W){
        cout<<0<<endl;
    }}

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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359;
#define inf (1 << 21);
#define mod 1000000007;

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    ll ans = 1;
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        if (A.at(i) == 0) {
            ans = 0;
        }
    }
    ld Max = 1000000000000000000;
    if (ans != 0) {
        for (int i = 0; i < N; i++) {
            if (Max / (ld)A.at(i) >= 1) {
                ans *= A.at(i);
                Max /= (ld)A.at(i);
            }
            else {
                ans = -1;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3996
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;

int n,m,k,mod,c[111][111];
inline void add(int&x,int y){x+=y;if(x>=mod)x-=mod;}

int f[111][111][111],g[111][111][111];
int qpow(int x,int y)
{
	int ret=1;
	while(y)
	{
		if(y&1)ret=(LL)ret*x%mod;
		x=(LL)x*x%mod;
		y>>=1;
	}
	return ret;
}

int main()
{
	scanf("%d%d%d%d",&n,&m,&k,&mod);
	for(int i=0;i<111;i++)
	{
		c[i][0]=1;
		for(int j=1;j<=i;j++)
		{
			c[i][j]=c[i-1][j]+c[i-1][j-1];
			if(c[i][j]>=mod)c[i][j]-=mod;
		}
	}
	
	f[1][0][0]=1;
	for(int v=1;v<=k;v++)
	{
		for(int i=0;i<=n;i++)for(int j=0;j<=m;j++)if(f[v][i][j])
		{
			int row=qpow(v,m-j)-qpow(v-1,m-j);if(row<0)row+=mod;
			int col=qpow(k-v+1,j),p=1;
			for(int ni=0;ni<=n-i;ni++)
			{
				add(g[v][i+ni][j],(LL)f[v][i][j]*c[n-i][ni]%mod*p%mod);
				p=(LL)p*row%mod*col%mod;
			}
		}
		for(int i=0;i<=n;i++)for(int j=0;j<=m;j++)if(g[v][i][j])
		{
			int row=qpow(v,n-i),p=1;
			int col=qpow(k-v+1,i)-qpow(k-v,i);if(col<0)col+=mod;
			for(int nj=0;nj<=m-j;nj++)
			{
				add(f[v+1][i][j+nj],(LL)g[v][i][j]*c[m-j][nj]%mod*p%mod);
				p=(LL)p*row%mod*col%mod;
			}
		}
	}
	printf("%d\n",f[k+1][n][m]);
	return 0;
}

Measured memory_bytes: 10496
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long ll;
#define N 200005

int n;
ll s[N],ans=1e18;

int main()
{
	scanf("%d",&n);
	for (int i=1,a;i<=n;i++) scanf("%d",&a),s[i]=s[i-1]+a;
	for (int mid=2,L=1,R=3;mid<n-1;mid++)
	{
		while(abs(s[mid]-2*s[L])>abs(s[mid]-2*s[L+1])) L++;
		while(abs(s[n]-2*s[R]+s[mid])>abs(s[n]-2*s[R+1]+s[mid])) R++;
		ans=min(ans,max(max(s[n]-s[R],s[R]-s[mid]),max(s[mid]-s[L],s[L]))-min(min(s[n]-s[R],s[R]-s[mid]),min(s[mid]-s[L],s[L])));
	}
	printf("%lld\n",ans);
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a<=2*b) cout << 0 << endl;
    else cout << a-2*b << endl;
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

string S;
LL K;

LL ans = 0;

void solve(){
	int N = S.size();
	//dp[i][j][k]:
	//Sを上からi桁目まで見た時、
	//未満フラグをjとして
	//0でない数字がちょうどk個あるような数の個数
	vector<vector<vector<LL>>> dp(N+1,vector<vector<LL>>(2,vector<LL>(4,0)));
	dp[0][0][0] = 1;
	//ばらまくイメージのDP
	for(int i=0;i<N;i++){
		for(int k=0;k<=3;k++){
			LL num = S[i] - '0';
			if(dp[i][0][k]){
				if(num==0){
					//0を選択
					dp[i+1][0][k] += dp[i][0][k];
				}
				if(num>=1){
					//0を選択
					dp[i+1][1][k] += dp[i][0][k];
					//1~num-1を選択
					if(k+1<=3) dp[i+1][1][k+1] += dp[i][0][k]*(num-1LL);
					if(k+1<=3) dp[i+1][0][k+1] += dp[i][0][k];
				}
			}
			if(dp[i][1][k]){
				//0を選択
				dp[i+1][1][k] += dp[i][1][k];
				//1~9を選択
				if(k+1<=3) dp[i+1][1][k+1] += dp[i][1][k]*9LL;
			}
		}
	}
	ans = dp[N][0][K] + dp[N][1][K];
}

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

    solve();

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

Measured memory_bytes: 256
N = input()
cnt = 0

for i in range(1, int(N)+1):
    
    if i % 10 == 0:
        continue
    
    if i % 10 < int(N[0]):
        for j in range(len(N)-1):
            cnt += 10 ** j
    
    elif i % 10 == int(N[0]):
        if len(N) >= 3:
            for j in range(len(N)-2):
                cnt += 10 ** j
            cnt += int(N[1:-1])+1
        
        if len(N) == 2:
            cnt += 1
        
        if int(str(i)[0]) > int(N[-1]):
            cnt -= 1
    
    else:
        for j in range(len(N)-2):
            cnt += 10 ** j
        
    if str(i)[0] == str(i)[-1]:
        cnt += 1
    
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int N, M;
int target[100];
int score[100];
int main() {
  cin >> N >> M;
  for (int i=0; i<M; i++) cin >> target[i];
  for (int i=0; i<M; i++) {
    int f = 0;
    for (int j=0; j<N; j++) {
      int x;
      cin >> x;
      if (x != target[i]) f++;
      score[j] += (x == target[i]) ? 1 : 0;
    }
    score[target[i]-1] += f;
  }
  for (int i=0; i<N; i++) cout << score[i] << "\n";
  return 0;
}

Measured memory_bytes: 3064
#include <iostream>
int main(){
    int a, b;
    std::cin >> a >> b;
    if(a > b){
        std::cout << "a > b" << std::endl;
    }else if(a == b){
        std::cout << "a == b" << std::endl;
    }else{
        std::cout << "a < b" << std::endl;
    }
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
int INF = 1e9+5;

int main() {
    long H, N;
    cin >> H >> N;
    vector<int> A(N), B(N);
    for(int i=0; i<N; i++) cin >> A[i] >> B[i];
    
    int max_A = 0;
    for(int i=0; i<N; i++) if(max_A < A[i]) max_A = A[i];
    int max_H = H + max_A + 1;
    vector<int> dp(max_H, INF); // dp[h]は体力をh減らすのに必要な魔力の最小値
    dp[0] = 0;
    for(int i=0; i<N; i++) dp[A[i]] = B[i];

    // 計算　O(NH)
    for(int h=0; h<max_H; h++) {
        for(int i=0; i<N; i++) {
            int j = h-A[i];
            if(j >= 0) {
                if(dp[h] > dp[j] + B[i]) {
                    dp[h] = dp[j] + B[i];
                }
            }
        }
    }

    int ans = INF;
    for(int h=H; h<max_H; h++) {
        if(ans > dp[h]) ans = dp[h];
    }

    cout << ans << endl;
}


Measured memory_bytes: 256