akhauriyash/Code-Regression huggingface dataset:
#ifndef __cplusplus
    cat << EOF
#endif
#include <bits/stdc++.h>
using namespace std;

#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()

template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if(lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if(lhs > rhs) { lhs = rhs; return 1; } return 0; }

int main() {

    int N;
    cin >> N;
    pair<int, int> ans(1 << 30, 1 << 30);
    rep(i, N) {
        int a;
        cin >> a;
        chmin(ans, make_pair(a, i + 1));
    }

    cout << ans.second << '\n';
    

}



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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    lint d[40];
    d[0] = 1;
    d[1] = 1;
    d[2] = 2;
    REP(p, 3, 40){
        d[p] = d[p-3] + d[p-2] + d[p-1];
    }
    int n;
    while(cin >> n, n){
        lint day = (d[n] - 1) / 10 + 1;
        lint year = (day - 1) / 365 + 1;
        cout << year << endl;
    }
    return 0;
}


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

bool IsPrime(int num)
{
    if (num < 2) return true;
    else if (num == 2) return false;
    else if (num % 2 == 0) return true;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return true;
        }
    }
    return false;
}

int main() {
  int X;
  cin>>X;
  while(IsPrime(X)){X++;}
  cout<<X<<endl;
}

Measured memory_bytes: 3656
MAX_A = 100_001
N = int(input())
A = list(map(int, input().split()))
_A = [0] * MAX_A
for a in A:
    _A[a] += 1
    if a - 1 >= 0:
        _A[a - 1] += 1
    if a + 1 < MAX_A:
        _A[a + 1] += 1
print(max(_A))


Measured memory_bytes: 20744
#include<stdio.h>
int main()
{
  int min, max;
  double sum;
  int n, i, q;

  scanf("%d", &n);
  min = max = sum = 0;

  for(i = 0; i < n; i++){
    scanf(" %d", &q);
    if(i == 0){
      min = max = q;
    }

    if(q < min){
      min = q;
    }
    if(max < q){
      max = q;
    }
    sum += q;
  }
   printf("%d %d %.0lf\n", min, max, sum);

  return(0);
}

Measured memory_bytes: 632
using System;
using System.Linq;

namespace abc098_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] ret = new int[] { x[0] + x[1], x[0] - x[1], x[0] * x[1] };
            Console.WriteLine(ret.Max());
        }
    }
}


Measured memory_bytes: 13396
x,y,z,k = map(int,input().split())

a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

def judge(p):
    cnt = 0
    for i in range(x):
        for j in range(y):
            for kk in range(z):
                if a[i]+b[j]+c[kk] < p : break
                cnt += 1
                if (cnt >= k):return True
    return False

ll,rr = 0,a[0]+b[0]+c[0]
while(rr- ll > 1):
    md = (ll+rr) // 2
    if(judge(md)) : ll = md
    else : rr = md

ans = []
cnt=0
for i in range(x):
    if(cnt >= k):break
    for j in range(y):
        if(cnt >= k):break
        for kk in range(z):
            if(cnt >= k):break
            if a[i]+b[j]+c[kk] < rr : break
            cnt += 1
            ans.append(a[i]+b[j]+c[kk])

if len(ans) <k:
    for i in range(k-len(ans)):
        ans.append(ll)

ans.sort(reverse=True)

for i in ans:
    print(i)

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

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

    int sum=0;
    if(K>A){
        sum += A;
        //cout << "end A:" << sum << endl; 
        K -= A;
        K -= B;
        //cout << "end B:" << sum << endl; 
        if(K>0){
            sum-=K;
            //cout << "end C:" << sum << endl; 
        }
    }else{
        sum += K;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
N, M, X = map(int, input().split())
aa_list = list()

for _ in range(N):
    aa_list.append(list(map(int, input().split())) )

over_set = list()
for ii in range(2 ** N):
    a_sum = [0 for _ in range(M)]
    for j in range(N):
        if (ii >> j) & 1:
            for k in range(1, M+1):
                a_sum[k-1] += aa_list[j][k]
    
    flag = True
    for k in range(M):
        if a_sum[k] < X:
            flag = False
    if flag:
        over_set.append(ii)

if len(over_set) == 0:
    print(-1)
else:
    min_val = 10**5 * N +3
    for ii in over_set:
        # print(bin(ii))
        sum_val = 0
        for j in range(N):
            if (ii >> j) & 1:
                sum_val += aa_list[j][0]
        min_val = min(min_val, sum_val)

    print(min_val)


Measured memory_bytes: 9300
#include <cstdio>
#include <algorithm>

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

using namespace std;

int n, k, x, y;

int main(){
	scanf("%d%d%d%d", &n, &k, &x, &y);
	int a = min(n, k);
	int b = max(n - k, 0);
	int z = x * a + y * b;
	printf("%d\n", z);
	return 0;
}

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


void change(string s) 
{ 


	int n = s.length(); 

	
	int cc = 0; 

	for(int i=0;i<n/2;i++) 
	{ 

		
		if(s[i]== s[n-i-1]) 
			continue; 

		
		cc+= 1; 

		
		if(s[i]<s[n-i-1]) 
			s[n-i-1]= s[i] ; 
		else
			s[i]= s[n-i-1] ; 
	} 
	printf(" %d\n", (cc)) ; 
	
} 
int main() 
{ 
string s ;
cin>>s;
change((s)); 
return 0; 
} 

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,a,b,x[100000],ans;

signed main() {
    cin >> n >> a >> b >> x[0];
    rep1(i,n-1) {
        cin >> x[i];
        if ((x[i]-x[i-1])*a > b) ans += b;
        else ans += (x[i]-x[i-1])*a;
    }
    cout << ans << endl;
}

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

using namespace std;

using int64 = long long;
// const int mod = 1e9 + 7;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


int main() {
  int64 N, X, M;
  cin >> N >> X >> M;
  vector< int > pre(M, -1);
  pre[X] = 0;
  int64 sum = X, cur = 1;
  bool used = false;
  while(cur < N) {
    X = X * X % M;
    if(pre[X] == -1 || used) {
      pre[X] = cur;
      sum += X;
      cur++;
    } else {
      int64 length = (cur - pre[X]);
      int64 sub = 0;
      for(int64 i = 0, V = X; i < length; i++) {
        sub += V;
        V = V * V % M;
      }
      sum += (N - cur) / length * sub;
      cur += (N - cur) / length * length;
      while(cur < N) {
        sum += X;
        cur++;
        X = X * X % M;
      }
    }
  }
  cout << sum << "\n";
}



Measured memory_bytes: 3720
#include "bits/stdc++.h"
using namespace std;

int N, K, Dis[2000], INF = 1145141919;
vector<int> V[2000];
pair<int, int> P[2000];

void DFS(int p, int r) {
	for (int x : V[p]) {
		if (Dis[x] == INF) {
			Dis[x] = r + 1;
			DFS(x, r + 1);
		}
	}
}

int main() {
	cin >> N >> K;
	for (int i = 0; i < N - 1; i++) {
		int A, B;
		cin >> A >> B;
		A--, B--;
		P[i] = { A, B };
		V[A].push_back(B);
		V[B].push_back(A);
	}
	if (K % 2 == 0) {
		int ANS = N;
		for (int i = 0; i < N; i++) {
			int COUNT = 0;
			for (int j = 0; j < N; j++) Dis[j] = INF;
			Dis[i] = 0;
			DFS(i, 0);
			for (int j = 0; j < N; j++) {
				if (Dis[j] * 2 > K) COUNT++;
			}
			ANS = min(ANS, COUNT);
		}
		cout << ANS;
		return 0;
	}
	else {
		int ANS = N;
		for (int i = 0; i < N - 1; i++) {
			int COUNT = 0;
			for (int j = 0; j < N; j++) Dis[j] = INF;
			Dis[P[i].first] = 0;
			Dis[P[i].second] = 0;
			DFS(P[i].first, 0);
			DFS(P[i].second, 0);
			for (int j = 0; j < N; j++) {
				if (Dis[j] * 2 > K - 1) COUNT++;
			}
			ANS = min(ANS, COUNT);
		}
		cout << ANS;
		return 0;
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

#define __m int mid=(l+r)>>1
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1

template<class T>
inline bool rd(T &num) {
    char in;
    bool IsN = false;
    while(in = getchar(), in != '-' && (in < '0' || in > '9'))if(in == EOF)return false;
    in == '-' ? (IsN = true, num = 0) : num = in - '0';
    while(in = getchar(), in >= '0' && in <= '9')num = num * 10 + in - '0';
    return IsN ? num = -num : num, true;
}

#define rep(i,a,b) for(register int i = (a); i< (b); i++)
#define per(i,a,b) for(register int i = (a); i> (b); i--)
#define clr(a) memset(a,0,sizeof(a));
#define inf(a) memset(a,0x3f,sizeof(a));
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rd2(a,b) rd(a)&&rd(b)
#define rd3(a,b,c) rd(a)&&rd(b)&&rd(c)
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))

string nico;
#ifdef LOCAL
#define bug(x) cout<<#x<<" : "<<x<<endl
#define infile(x) freopen(x,"r",stdin)
#define outfile(x) freopen(x,"w",stdout)
#else
#define bug(x)
#define infile(x)
#define outfile(x)
#endif

const int maxn = 2e5 + 7;
const int inf  = 0x3f3f3f3f;
const LL linf  = (LL)inf << 32 | inf;
const int mod  = 1e9 + 7;

int main() {
    IO;
    string in;
    int w;
    cin>>in>>w;
    for(int i=0;i<in.size();i+=w)
        cout<<in[i];
    cout<<endl;
    return 0;
}


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

int main() {
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(),a.end());
    for(int i=0; i<3; i++) {
        cout << a[i];
        if(i != 2) cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 3148
N = int(input())
if N==1:
    print(0)
    exit()

from collections import Counter
def factorize(n):
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m += 1
    if n > 1:
        d[n] += 1
    return d

fac = factorize(N)
if len(fac)==1 and N in fac:
    print(1)
    exit()

ans = 0
for v in fac.values():
    n = 1
    while v >= n:
        v -= n
        ans += 1
        n += 1
print(ans)

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

using namespace std;

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


int main() {
    long long a, b;
    cin >> a >> b;
    cout << a*b/gcd(a, b);
}




Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,c,d,p,x,y;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&p);
	x = a*p;
	y = (c<p)?b+(p-c)*d:b;
	printf("%d\n",(x<y)?x:y);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
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)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,K;cin>>N>>K;
    vector<int> L(N);
    REP(i,N) cin >> L[i];
    sort(L.rbegin(),L.rend());
    int ans = 0;
    REP(i,K) ans += L[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n,b,f,r,v,room[4][3][10]={};
    int i,j,k,judge = 0;
    scanf("%d", &n);
    for(i = 0;i < n;i++){
        scanf(" %d %d %d %d", &b, &f, &r, &v);
        room[b-1][f-1][r-1] += v;
    }
    for(i = 0;i < 4; i++){
       if(judge) printf("####################\n");
        for(j = 0;j < 3; j++){
            for(k = 0;k < 10; k++){
                printf(" %d",room[i][j][k]);
            }
            printf("\n");
            judge = 1;
        }
    }
    return 0;
}


Measured memory_bytes: 1856
import math

pi = math.pi
n = int(input())
p1 = [0, 0]
p2 = [100, 0]

def koch(n, p1, p2):
    if n == 0:
        return 
    s = [(2*p1[0]+p2[0])/3, (2*p1[1]+p2[1])/3]
    t = [(p1[0]+2*p2[0])/3, (p1[1]+2*p2[1])/3]
    u = [(t[0]-s[0])*math.cos(pi/3)-(t[1]-s[1])*math.sin(pi/3)+s[0], 
         (t[0]-s[0])*math.sin(pi/3)+(t[1]-s[1])*math.cos(pi/3)+s[1]]

    koch(n-1, p1, s)
    print(*s)
    koch(n-1, s, u)
    print(*u)
    koch(n-1, u, t)
    print(*t)
    koch(n-1, t, p2)

print(*p1)
koch(n, p1, p2)
print(*p2)


Measured memory_bytes: 5792
//#define sort(nums) sort(nums.begin(),nums.end())
#include <bits/stdc++.h>
#define mod 1000000007
#define deb(x) cout<<#x<<" "<<x<<endl
using namespace std;
using ll = long long int;

void jets(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}



int main(){
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    jets();
    int n,k;
    cin>>n>>k;
    std::vector<int> vec(n,0);
    for(int i=0;i<n;i++)
    	cin>>vec[i];
    int dp[n]={0};
    dp[0]=0;
    dp[1]=abs(vec[1]-vec[0]);

    ll ans=0;
    for(int i=2;i<n;i++){
        dp[i]=INT_MAX;
        for(int j=max(0,i-k);j<i;j++){
            dp[i]=min(dp[i],abs(vec[j]-vec[i])+dp[j]);
        }
    }
    cout<<dp[n-1]<<endl;


    return 0;
}

Measured memory_bytes: 4032
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    W, H, x, y = LI()
    c_w, c_h = W/2, H/2
    way = 0 
    if x == c_w and y == c_h:
        way = 1
    print("{} {}".format(W*H/2, way))
main()



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

long long seg1[1<<18]={0},seg2[1<<18]={0};

void val(int k,int v1,long long v2)
{
  int p=k+(1<<17);
  seg1[p]=v1,seg2[p]=v2;
  while(p>1){
    p/=2;
    seg1[p]=seg1[2*p]+seg1[2*p+1];
    seg2[p]=seg2[2*p]+seg2[2*p+1];
  }
}

long long rag(int i,int X)
{
  if(X<=0){
    return 0;
  }
  if(seg1[i]<=X){
    return seg2[i];
  }
  return rag(2*i+1,X)+rag(2*i,X-seg1[2*i+1]);
}

int main()
{
  int X,Y,Z;
  scanf("%d%d%d",&X,&Y,&Z);
  int n=X+Y+Z;
  static long long x[100000],y[100000],z[100000];
  for(int i=0;i<n;i++){
    scanf("%lld%lld%lld",x+i,y+i,z+i);
  }
  long long ans=0ll;
  for(int i=0;i<n;i++){
    x[i]-=z[i];y[i]-=z[i];
    ans+=z[i];
  }
  pair<long long,int> px[100000],py[100000];
  for(int i=0;i<n;i++){
    px[i]=make_pair(x[i],i);
    py[i]=make_pair(y[i],i);
  }
  sort(px,px+n);
  sort(py,py+n);
  priority_queue<pair<long long,int> > Q;
  long long M=0ll;
  static bool b[100000]={0};
  for(int t=n-1;t>=n-Y;t--){
    int i=py[t].second;
    Q.push(make_pair(x[i]-y[i],i));
    M+=py[t].first;
    b[i]=1;
  }
  static int rx[100000];
  for(int i=0;i<n;i++){
    rx[px[i].second]=i;
  }
  for(int i=0;i<n;i++){
    if(!b[i]){
      val(rx[i],1,x[i]);
      //printf("%d %lld\n",rx[i],x[i]);
    }
  }
  long long MM=M+rag(1,X);
  for(int t=n-Y-1;t>=0;t--){
    //printf("%lld %lld\n",M,rag(1,X));
    int j=py[t].second;
    M+=y[j];
    val(rx[j],0,0ll);
    Q.push(make_pair(x[j]-y[j],j));
    int i=Q.top().second;
    Q.pop();
    M-=y[i];
    val(rx[i],1,x[i]);
    MM=max(MM,M+rag(1,X));
  }
  printf("%lld\n",ans+MM);
  return 0;
}


Measured memory_bytes: 10868
c=[list(map(int,input().split())) for _ in range(3)]

for j in range(2):
  for i in range(3):
    if i==0:
      d = c[i][j+1]-c[i][j]
    else:
      if c[i][j+1]-c[i][j] != d:
        print('No')
        exit()

for i in range(2):
  for j in range(3):
    if j==0:
      d = c[i+1][j]-c[i][j]
    else:
      if c[i+1][j]-c[i][j] != d:
        print('No')
        exit()
print('Yes')

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

int main(void){
    
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;
    
    cout << s.substr(0,k-1);
    if(s.substr(k-1,1)=="A") cout << "a";
    else if(s.substr(k-1,1)=="B") cout << "b";
    else if(s.substr(k-1,1)=="C") cout << "c";
    cout << s.substr(k) << endl;
    
    return 0;
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    string S;
    cin >> S;

    for (int i = 0; i < (int)S.size(); i++) {
        if (i % 2 == 0 && S[i] == 'L') {
            cout << "No" << endl;
            return;
        }
        if (i % 2 == 1 && S[i] == 'R') {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int N, flag ;
	scanf("%d", &N);
	if (65<=N &&N<=90) {
		flag = 1;
	}
	else if (97<=N && N<=122) {
		flag = 2;
	}
	else {
		flag = 0;
	}
	printf("%d\n", flag);
	return 0;
}


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

const int N = 1e5+5;
int n;
ll A[N],x,ans=0;

void red(ll &e, int i) {
	ll l = min(e,A[i]);
	e -= l, A[i] -= l;
	ans += l;
}

int main() {	
	scanf("%d%lld",&n,&x);
	for(int i = 0; i < n; ++i)
		scanf("%lld",A+i);
	for(int i = 1; i < n; ++i) {
		ll e = max(0LL,A[i-1] + A[i] - x);
		if(e) red(e,i);
		if(e) red(e,i-1);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1024
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww

import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        sc.close();
        if(n > k){
            System.out.println((n - k) * y + k * x);
        }else{
            System.out.println(n * x);
        }
    }
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, m, q;
vector<int> g[100000];
int col[100000];
int st[100000], d[100000], c[100000];
int mx[100000];

int curCol;

inline void dfs(int v, int rem) {
    if (mx[v] >= rem) {
        return;
    }
    if (col[v] == -1) {
        col[v] = curCol;
    }
    mx[v] = rem;
    if (rem > 0) {
        for (int to : g[v]) {
            dfs(to, rem - 1);
        }
    }
}

int main() {
    scanf("%d%d", &n, &m);
    forn(i, m) {
        int from, to;
        scanf("%d%d", &from, &to), --from, --to;
        g[from].pb(to);
        g[to].pb(from);
    }
    memset(col, -1, sizeof col);
    memset(mx, -1, sizeof mx);
    scanf("%d", &q);
    forn(i, q) {
        scanf("%d%d%d", st + i, d + i, c + i);
        --st[i];
    }
    for (int i = q - 1; i >= 0; --i) {
        curCol = c[i];
        dfs(st[i], d[i]);
    }
    forn(i, n) col[i] = max(col[i], 0);
    forn(i, n) printf("%d\n", col[i]);
    return 0;
}


Measured memory_bytes: 8440
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
ll M=1e9+7;

const int MAX_N = 100005;
int par[MAX_N];
int rank_[MAX_N];
 
// n要素で初期化
void init(int n) {
    rep(i,n) {
        par[i] = i;
        rank_[i] = 0;
    }
}
 
// 木の根を求める
int root(int x) {
    if (par[x] == x) return x;
    else return par[x] = root(par[x]);
}
 
// xとyが同じ根に属するかどうか
bool same(int x, int y) {
    return root(x) == root(y);
}
 
// xとyが属する集合を併合
void unit(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    par[x] = y;
    /*if (rank_[x] < rank_[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rank_[x] == rank_[y]) rank_[x]++;
    }*/
}
 
 
int main() {
    int n, m, k;
    cin >> n >> m >> k;
 
    init(n);
 
    vector<pair<ll,ll>> fbNum(n);
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if (!same(a, b)) unit(a, b);
        fbNum[a].first++;
        fbNum[b].first++;
    }
 
    rep(i,k) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if (same(a, b)) {
            fbNum[a].second++;
            fbNum[b].second++;
        }
    }
    vector<int> gNum(n);
    rep(i,n) gNum[root(i)]++;
    rep(i,n) {
        int ans = gNum[root(i)] - 1 - fbNum[i].second - fbNum[i].first;
        cout << ans << " ";
    }
    return 0;
}

Measured memory_bytes: 4224
package main

import (
	"bufio"
	"fmt"
	"os"
)

var N, M, K int
var As, Bs, sumA, sumB []int

func main() {
	N, M, K = ReadInt(), ReadInt(), ReadInt()
	As = ReadInts(N)
	Bs = ReadInts(M)

	sumA = []int{0}
	sumB = []int{0}

	for i := 0; i < len(As); i++ {
		s := sumA[i] + As[i]
		sumA = append(sumA, s)
	}
	for i := 0; i < len(Bs); i++ {
		s := sumB[i] + Bs[i]
		sumB = append(sumB, s)
	}

	left := 0
	right := N + M + 1
	for right-left > 1 {
		mid := (right + left) / 2
		if isOK(mid) {
			left = mid
		} else {
			right = mid
		}
	}
	fmt.Println(left)
}

func isOK(n int) bool {
	for a := 0; a <= n; a++ {
		b := n - a
		if a > N {
			break
		}
		if b > M {
			continue
		}
		total := sumA[a] + sumB[b]
		if total <= K {
			return true
		}
	}
	return false
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }

func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 16300
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

int64_t X;

void solve()
{
    std::cin >> X;

	// (x^5)' = 5x^4
	// 5*(150)^4~2.5*10^9
	for (int64_t A = -150; A <= 150; A++)
	{
		for (int64_t B = -150; B <= 150; B++)
		{
			if (pow(A, 5) - pow(B, 5) == X)
			{
				std::cout << A << " " << B << std::endl;
				return;
			}
		}
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 4132
#include <iostream>
#include <string>
#include <utility>
#include <map>
#define ll long long
using namespace std;

int main() {
	int N;
	string S;
	cin >> N >> S;
	map<pair<string, string>, int> mp;
	for(int i=0; i<(1<<N); ++i){
		string x="", y="";
		for(int d=0; d<N; ++d){
			if(i&(1<<d)) x += S[d];
			else y += S[d];
		}
		++mp[make_pair(x, y)];
	}
	ll ans=0;
	for(int i=0; i<(1<<N); ++i){
		string x="", y="";
		for(int d=0; d<N; ++d){
			if(i&(1<<d)) x += S[2*N-1-d];
			else y += S[2*N-1-d];
		}
		ans += mp[make_pair(x, y)];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 91904
#include<iostream> 
#include<string>
#include<algorithm>
#include <math.h>

using namespace std;

#define No 55555
int arr[No];

void Eratosthenes(){
	for(int i = 0; i < No; i++){
		arr[i] = 1;
	}
	for(int i = 2; i < sqrt(No); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < No; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}
    int sosu[100000];
    int k=0;
	for(int i = 2; i < No; i++){
		if(arr[i]){
			//cout << i << endl;
		}
	}
}

int main(){
    int N;
    int ans[60];
    int sosu[100000];
    cin>>N;
    Eratosthenes();

    //出力
    int k=0;
    for(int i=2;i<No;i++){
        if(arr[i] && k<N){
            if((i-1)%5 == 0){
                cout<<i<<' ';
                k++;
            }
        }
    }
    cout<<endl;
}

Measured memory_bytes: 512
#include<stdio.h>
using namespace std;
int main(){
  int h,w,n;
  while(scanf("%d%d%d",&h,&w,&n)&&h){
    int c[1001][1001]={},a;
    c[0][0]=n-1;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	scanf("%d",&a);
	c[i+1][j]+=c[i][j]/2;
	c[i][j+1]+=c[i][j]/2;
	if(c[i][j]%2){
	  if(a)c[i][j+1]++;
	  else c[i+1][j]++;
	}
	c[i][j]+=a;
      }
    int x=0,y=0;
    while(x!=w&&y!=h){
      if(c[y][x]%2)x++;
      else y++;
    }
    printf("%d %d\n",y+1,x+1);
  }
  return 0;
}

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

public class Main {

	public static void main(String[] args) {


		//文字の個数
		int quantity = 0;
		//１文字の長さ
		int length = 0;
		String anser = "";

		Scanner scan = new Scanner(System.in);

        quantity = scan.nextInt();
        length = scan.nextInt();

		//入力された文字を入れる配列
		String[] str = new String[quantity];

		for(int i = 0;i<quantity;i++) {
			str[i] = scan.next();
		}

		Arrays.sort(str);
		for(String s:str) {
			anser = anser + s;
		}

		System.out.println(anser);
	}

}


Measured memory_bytes: 28500
import heapq
N,K = map(int, input().split())

I = []
for _ in range(N):
  t,d = map(int, input().split())
  I.append((d,t))
  
I.sort(reverse=True)

# heap_can_delete
h_d = []
# heap_can_add
h_a = []

wk = 0
kind = 0
# 出現したことのあるネタ
ap = set()
for i in range(K):
  d,t = I[i]
  wk += d
  if t not in ap:
    ap.add(t)
    kind += 1
  else:
    heapq.heappush(h_d, (d,t))

for i in range(K,N):
  d,t = I[i]
  if t not in ap:
    ap.add(t)
    # maxをpopさせるために、価値を-1かけておく
    heapq.heappush(h_a, ((-1) * d, t))
  
ans = wk + kind ** 2
while len(h_d) > 0 and len(h_a) > 0:
  d1,t1 = heapq.heappop(h_d)
  d2,t2 = heapq.heappop(h_a)
  d2 = (-1) * d2
  wk = wk - d1 + d2
  kind += 1
  ans = max(ans, wk + kind ** 2)
  
print(ans)
  
  

Measured memory_bytes: 99184
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll=long long;
const ll mod = 1e9 + 7;


template<class T>
T gcd(T a, T b)
{
  if(a && b) {
    return gcd(min(a, b), max(a, b) % min(a, b));
  } else {
    return a;
  }
}

template<class T>
T lcm(T a, T b)
{
  return a / gcd(a, b) * b;
}

ll power(ll base, ll exponent, ll module)
{
  if(exponent % 2) {
    return power(base, exponent - 1, module) * base % module;
  } else if(exponent) {
    ll root_ans = power(base, exponent / 2, module);
    return root_ans * root_ans % module;
  } else {
    return 1;
  }
}

struct combination
{
  vector<ll> fact, inv;
  combination(int sz) : fact(sz + 1), inv(sz + 1)
  {
    fact[0] = 1;
    for(int i = 1; i <= sz; i++) {
      fact[i] = fact[i - 1] * i % mod;
    }
    inv[sz] = power(fact[sz], mod - 2, mod);
    for(int i = sz - 1; i >= 0; i--) {
      inv[i] = inv[i + 1] * (i + 1) % mod;
    }
  }
  ll P(int n, int r)
  {
    if(r < 0 || n < r) return 0;
    return (fact[n] * inv[n - r] % mod);
  }
  ll C(int p, int q)
  {
    if(q < 0 || p < q) return 0;
    return (fact[p] * inv[q] % mod * inv[p - q] % mod);
  }
};

template<typename T>
void print_vec(vector<T>& v)
{
  for(const auto& e: v) {
    cout << e << " ";
  }
  cout << endl;
}
template<typename T>
void print_2dvec(vector<vector<T>>& m)
{
  for(const auto& v: m) {
    for(const auto& e: v) {
      cout << e << " ";
    }
    cout << endl;
  }
}


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

  vector<int> ps;

  for (int i = 0; i < n; i++) {
    cin >> p;
    ps.push_back(p);
  }

  int p_min = 2e5 + 1, ans = 0;

  for (int i = 0; i < n; i++) {
    if (p_min >= ps.at(i)) {
      ans++;
      p_min = min(p_min, ps.at(i));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1400
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;

ll func(ll x){
	return (x>0)?x:-x;
}

ll max(ll a,ll b){
	return (a>b)?a:b;
}

ll kodo(ll x,ll y,ll cx,ll cy,ll H){
	return max(H-func(x-cx)-func(y-cy),0);
}

int main(){
	int n;
	cin>>n;
	ll x[n],y[n],h[n];
	ll tmp,cx,cy,H;
	rep(i,n){
		cin>>x[i]>>y[i]>>h[i];
		tmp=max(tmp,h[i]);
	}
	rep(i,n){
		for(int j=n-2;j>=0;j--){
			if(h[j]<h[j+1]){
				ll a;
				a=x[j];x[j]=x[j+1];x[j+1]=a;
				a=y[j];y[j]=y[j+1];y[j+1]=a;
				a=h[j];h[j]=h[j+1];h[j+1]=a;
			}
		}
	}
	bool alt=false;
	rep(i,101){
		rep(j,101){
			bool check=true;
			H=-1;
			rep(l,n){
				if(H==-1)H=h[l]+abs(x[l]-i)+abs(y[l]-j);
				else{
					if(kodo(x[l],y[l],i,j,H)!=h[l]){
						check=false;
						break;
					}
				}
			}
			if(check){
				cx=i;
				cy=j;
				alt=true;
				break;
			}
			if(alt)break;
		}
		if(alt)break;
	}
	cout<<cx<<" "<<cy<<" "<<H<<endl;
	return 0;
}

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


def resolve():
    N, M = [int(i) for i in input().split()]
    ss = []
    cc = []
    for _ in range(M):
        s, c = [int(i) for i in input().split()]
        ss.append(s)
        cc.append(c)

    start = 10**(N - 1)
    if N == 1:
        start = 0
    end = 10**N
    for answer in range(start, end):
        for i in range(M):
            if str(answer)[ss[i] - 1] != str(cc[i]):
                break
        else:
            print(answer)
            return
    else:
        print(-1)


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 = """3 3
1 7
3 2
1 7"""
        output = """702"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 2
2 1
2 3"""
        output = """-1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """3 1
1 0"""
        output = """-1"""
        self.assertIO(input, output)


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


Measured memory_bytes: 5696
N,M,X = map(int,input().split(' '))

C=[]
A=[]
for i in range(N):
    tCA=list(map(int,input().split(' ')))
    C.append(tCA[0])
    A.append(tCA[1:M+1])
maxCost=10**8
minCost=maxCost

#print(A)
for i in range(2**N):
    binstr=format(i,'0'+str(N)+'b')
    #print(binstr)
    tmpM=[]
    for t in range(M):
        tmpM.append(0)
    tmpCost=0
    for n in range(N):
        if binstr[n]=='1':
            tmpCost+=C[n]
            for m in range(M):
                #print(n,m)
                tmpM[m]+=A[n][m]
    #print(tmpM)
    #print(tmpCost)
    #check X
    flg = True
    for m in range(M):
        if tmpM[m] < X:
            flg=False
    if flg:
        minCost=min(minCost,tmpCost)

if minCost==maxCost:
    print(-1)
else:
    print(minCost)


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

int main()
{
	int a,b,c,x,s=0;
	
	cin>>a>>b>>c>>x;
	
	for(int i=0;i<=a;i++)
	{
		for(int j=0;j<=b;j++)
		{
			for(int k=0;k<=c;k++)
			{
				if(i*500+j*100+k*50==x){
					s++;
				}
			}
		}
	}
	
	cout<<s<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
int main(){
  string s;
  cin>>s;
  int n=s.length();
  cout<<s[0];
  cout<<n-2;
  cout<<s[n-1]<<endl;
}

Measured memory_bytes: 3596
import sys
input = sys.stdin.readline
def print_ans(A,B):
    """Test Case
    >>> print_ans(3, 1)
    2
    >>> print_ans(1, 2)
    3
    """
    ans = [1, 2, 3]
    lists = [A, B]
    for a in ans:
        flg = True
        for b in lists:
            if a == b:
                flg = False
                break
        if flg:
            print(a)

if __name__ == '__main__':
    A = int(input().rstrip())
    B = int(input().rstrip())
    print_ans(A,B)




Measured memory_bytes: 3064
import std.string,
       std.stdio,
       std.conv;


void main() {
  int n = readln.chomp.to!int;
  int[] inputs = readln.chomp.split.to!(int[]);

  int[] colors;
  colors.length = 8;
  int   pro;


  foreach (e; inputs) {
    if (1 <= e && e <= 399) {
      colors[0]++;
    } else if (400 <= e && e <= 799) {
      colors[1]++;
    } else if (800 <= e && e <= 1199) {
      colors[2]++;
    } else if (1200 <= e && e <= 1599) {
      colors[3]++;
    } else if (1600 <= e && e <= 1999) {
      colors[4]++;
    } else if (2000 <= e && e <= 2399) {
      colors[5]++;
    } else if (2400 <= e && e <= 2799) {
      colors[6]++;
    } else if (2800 <= e && e <= 3199) {
      colors[7]++;
    } else {
      pro++;
    }
  }

  int kinds;
  int max, min;

  foreach (color; colors) {
    if (color) { kinds++; }
  }

  if (kinds == 0) {
    min = 1;
    max = pro;
  } else {
    min = kinds;
    max = kinds + pro;
  }

  writefln("%d %d", min, max);
}


Measured memory_bytes: 256
def readinput():
    k=int(input())
    s=input()
    return k,s

def main(k,s):
    if(len(s)<=k):
        return s
    else:
        return s[0:k]+'...'

if __name__=='__main__':
    k,s=readinput()
    ans=main(k,s)
    print(ans)


Measured memory_bytes: 9112
import collections
N=int(input())
L=list(map(int,input().split()))
d = collections.deque([str(L[0])])
NN = N % 2
for i in range(1,N):
  if NN == 0:
    if i % 2 == 0:
      d.append(str(L[i]))
    else:
      d.appendleft(str(L[i]))
  else:
    if i % 2 == 0:
      d.appendleft(str(L[i]))
    else:
      d.append(str(L[i]))
print(' '.join(list(d)))
  

Measured memory_bytes: 33092
import math

n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
total = sum(B) - sum(A)
cnt1, cnt2 = 0,0

for i in range(n):
    if A[i] > B[i]:
        cnt1 += A[i] - B[i]
    elif A[i] < B[i]:
        cnt2 += math.ceil((B[i]-A[i])/2)

if max(cnt1, cnt2) <= total:
    print('Yes')
else:
    print('No')

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

int n, m, k;
vector<vector<int> > E(1 << 17);
vector<int> dis(1 << 17, -1);
queue<int> q;

void bfs() {
    while (!q.empty()) {
        int s = q.front();
        q.pop();
        for (int j = 0; j < E[s].size(); j++) {
            int next = E[s][j];
            if (dis[next] == -1) {
                q.push(next);
                dis[next] = dis[s] + 1;
                // cout << next << " " << dis[next] << endl;
            }
        }
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int i, j;
    cin >> n >> m >> k;
    int d[m];
    for (i = 0; i < m; i++) {
        cin >> d[i];
    }
    vector<vector<int> > w(n, vector<int>(k, -1));
    for (i = 0; i < n; i++) {
        for (j = 0; j < k; j++) {
            int v;
            cin >> v;
            for (int l = 0; l < m; l++) {
                if (v == d[l]) w[i][j] = (1 << l);
            }
        }
    }

    for (i = 0; i < (1 << m); i++) {
        for (int l = 0; l < k; l++) {
            int nex = 0;
            for (j = 0; j < m; j++) {
                if (((i >> j) & 1) == 0) continue;
                if (w[d[j] - 1][l] >= 0) nex |= w[d[j] - 1][l];
            }
            if (nex != i) {
                E[nex].push_back(i);
                // cout << nex << " " << i << endl;
            }
        }
    }

    q.push(0);
    dis[0] = 0;
    bfs();
    cout << dis[(1 << m) - 1] << endl;
}



Measured memory_bytes: 82896
#include <iostream>
#include <queue>
#define MAX_W 30
#define MAX_H 30
using namespace std;

typedef pair<int, int> P;

int a[MAX_H * 2][MAX_W];
int d[MAX_H][MAX_W];
bool visited[MAX_H][MAX_W];

void bfs(int w, int h) {
  P t;
  t.first = t.second = 0;
  d[0][0] = 1;
  visited[0][0] = true;
  queue<P> que;
  que.push(t);

  while (que.empty() == false) {
    t = que.front();
    que.pop();
    P s;
    s.first = t.first - 1;
    s.second = t.second;
    if (s.first >= 0 && a[s.first * 2 + 1][s.second] == 0
	&& visited[s.first][s.second] == false) {
      d[s.first][s.second] = d[t.first][t.second] + 1;
      visited[s.first][s.second] = true;
      que.push(s);
    }
    s.first = t.first + 1;
    s.second = t.second;
    if (s.first < h && a[t.first * 2 + 1][s.second] == 0
	&& visited[s.first][s.second] == false) {
      d[s.first][s.second] = d[t.first][t.second] + 1;
      visited[s.first][s.second] = true;
      que.push(s);
    }
    s.first = t.first;
    s.second = t.second - 1;
    if (s.second >= 0 && a[s.first * 2][t.second] == 0
	&& visited[s.first][s.second] == false) {
      d[s.first][s.second] = d[t.first][t.second] + 1;
      visited[s.first][s.second] = true;
      que.push(s);
    }
    s.first = t.first;
    s.second = t.second + 1;
    if (s.second < w && a[s.first * 2][s.second] == 0
	&& visited[s.first][s.second] == false) {
      d[s.first][s.second] = d[t.first][t.second] + 1;
      visited[s.first][s.second] = true;
      que.push(s);
    }
  }
}

void init() {
  for (int i = 0; i < MAX_H * 2 + 1; i++) {
    for (int j = 0; j < MAX_W; j++) {
      a[i][j] = 0;
    }
  }
  for (int i = 0; i < MAX_H; i++) {
    for (int j = 0; j < MAX_W; j++) {
      d[i][j] = 0;
      visited[i][j] = false;
    }
  }
}

int main() {
  while (true) {
    int w, h;
    cin >> w >> h;
    if (w == 0 && h == 0) return 0;

    init();
    int flag = 0;
    for (int i = 0; i < h * 2 - 1; i++) {
      if (flag == 0) {
	for (int j = 1; j < w; j++) {
	  cin >> a[i][j];
	}
	flag = 1;
      } else {
	for (int j = 0; j < w; j++) {
	  cin >> a[i][j];
	}
	flag = 0;
      }
    }

    bfs(w, h);
    cout << d[h - 1][w - 1] << endl;
  }
}

Measured memory_bytes: 3024
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
 
 
 
 


ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}



int main()
{
    ll n,m;
    cin>>n>>m;
    ll mx=1LL;
    for(ll i=1;i<=sqrt(m);i++){
         if(m%i==0)
         {
              ll t=m/i;
              if(i>=n)mx=max(mx,t);
              if(t>=n)mx=max(mx,i);
         }
    }
    cout<<mx;
}















 














 
 

















Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
	int m, n;
	long long ans = 1;
	scanf("%d %d", &m, &n);
	long long beki[31], num[31];
	beki[0] = 1;
	num[0] = m;
	for (int i = 1; i < 31; i++) {
		beki[i] = 2 * beki[i - 1];
		num[i] = num[i - 1] * num[i - 1] % 1000000007;
	}
	for (int i = 30; i >= 0; i--) {
		if (n >= beki[i]) {
			ans *= num[i];
			ans %= 1000000007;
			n -= beki[i];
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 2724
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

bool get[100];
int gx[100];
int gy[100];
int dx[200];
int dy[200];

int main() {
  dx['W'] = -1;
  dx['S'] = 0;
  dx['N'] = 0;
  dx['E'] = 1;
  dy['W'] = 0;
  dy['S'] = -1;
  dy['N'] = 1;
  dy['E'] = 0;
  int n;
  while (scanf("%d", &n), n) {
    MEMSET(get, false);
    REP(i, n) {
      scanf("%d %d", &gx[i], &gy[i]);
    }
    int m;
    scanf("%d", &m);
    int total = 0;
    int x = 10;
    int y = 10;
    REP(i, m) {
      char c;
      int cnt;
      scanf(" %c %d", &c, &cnt);
      REP(j, cnt) {
        x += dx[(int)c];
        y += dy[(int)c];
        REP(k, n) {
          if (get[k]) { continue; }
          if (x == gx[k] && y == gy[k]) { get[k] = true; total++; }
        }
      }
    }
    if (n == total) { puts("Yes"); }
    else { puts("No"); }
  }
}

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

int main(){
  	int n;
  	int count=1;
  	int a[300000];
  	cin >> n;
  	for(int i=0;i<n;i++){
      	cin >> a[i];
    }
  
  	for(int i=0;i<n;i++){
      	if(a[i]==count){
          	count++;
       	}
    }
  	
  	if(count==1){
      	cout << -1 << endl;
    }else{
  		cout << n-count+1 << endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n, k;
    cin >> n >> k;
    deque<lint> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i]--;
        a[i] %= k;
    }
    for (int i = 1; i < n; ++i) {
        a[i] += a[i - 1];
        a[i] %= k;
    }
    map<int, int> cnt;
    a.push_front(0);
    lint ret = 0;
    for (int i = 0; i <= n; ++i) {
        ret += cnt[a[i]];
        cnt[a[i]]++;
        if (i >= k - 1)
            cnt[a[i - k + 1]]--;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
typedef long long llong;

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

  llong L, ans = N-1;
  L = sqrt(N)+1;
  
  llong b;
  for(llong a=1;a<=L;a++) {
      if(N%a==0) {
        b = N/a;
        ans = min(ans, a+b-2);
      } 
  }
  
  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 256