akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define f first 
#define s second 
#define pb push_back               
#define mp make_pair 

using namespace std;                    

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

const int N = (int)1e5 + 123, mod = (int)1e9 + 7;

int n, m, q, ans[N];
vector< int > v[2];

int main(){    
	cin >> n >> m;
	if(m == 1){
		int x;
		cin >> x;
		if(x == 1)
			cout << x << endl << 1 << endl << 1;
        else
        	cout << x << endl << 2 << endl << x - 1 << " " << 1;
		return 0;
	}
	for(int i = 0; i < m; i++){
		int x;
		cin >> x;
		v[x&1].pb(x);
	}                             
	sort(v[0].begin(),v[0].end());
	sort(v[1].begin(),v[1].end());
	
	if(v[1].size() > 2){
		cout << "Impossible" ;
		return 0;
	}                          
	
	if(!v[1].empty())
       	cout << (ans[q++] = v[1][0]) << " ";
	for(int i = 0; i < v[0].size(); i++)
		cout << (ans[q++] = v[0][i]) << " ";
	for(int i = 1; i < v[1].size(); i++)
		cout << (ans[q++] = v[1][i]) << " ";
	cout << endl; 
	ans[0]--;
	ans[q - 1]++;
	if(ans[0] == 0){
		cout << q - 1 << endl;
		for(int i = 1; i < q; i++)
			cout << ans[i] << " ";
	}else{
		cout << q << endl;
		for(int i = 0; i < q; i++)
			cout << ans[i] << " ";
	}
	return 0;
}


Measured memory_bytes: 256
from sys import stdin


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = list(map(int, list(_in[0])))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = sum(N)
    ans = 'Yes' if cnt % 9 == 0 else 'No'
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 85992
coin = [int(input()) for i in range(3)]
X = int(input())
cnt = 0
for i in range(coin[0]+1):
    for j in range(coin[1]+1):
        for k in range(coin[2]+1):
            if X - ((500 * i) + (100 * j) + (50 * k)) == 0:
                cnt += 1

print(cnt)


Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <utility>
using namespace std;
using ll = long long int;
int main() {
  string s;
  cin>> s;
  int a=0;
  int b=0;
  int c=0;
  for (int i=0;i<3;i++){
    if(s.at(i)=='a') a++;
    else if(s.at(i)=='b') b++;
    else if(s.at(i)=='c') c++;
  }
  if (a==1&&b==1&&c==1)  cout <<"Yes";
  else cout <<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  set <ll> s;
  map <ll, ll> score;
  rep(i, n) {
    ll a;
    cin >> a;
    s.insert(a);
    if (score.count(a)) {
      score.at(a)++;
    } else {
      score[a] = 1;
    }
  }
  ll res = s.size(), tmp = 0;
  for (auto p : score) {
    if (p.second > 1) {
      if (p.second%2) {
        continue;
      } else {
        tmp++;
      }
    }
  }
  if (tmp%2) {
    cout << res-1 << endl;
  } else {
    cout << res << endl;
  }
}

Measured memory_bytes: 11136
#include<stdio.h>
int main()
{  long long k,a,b,c,s;
   scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
   if((a+b)>=k)
   {  if(a>=k) s=k;
      else s=a;
   }
   else
   s=a-(k-a-b);
   printf("%lld",s);
} 

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

#define ll long long
#define pb push_back
#define pr pair<ll, ll>
#define vct vector<ll>
#define vpt vector<pr>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define F(i, n) for (i = 0; i < (1LL*n); i++)
#define Fr(i, n) for (i = n - 1; i >= 0; i--)

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, int, custom_hash>
void prv(vct v)
{
    for (ll i = 0; i < v.size(); i++)
        cout << v[i] << " ";
    cout << "\n";
}
ll poww(ll x, ll y, ll m)
{
    ll res = 1;
    while (y)
    {
        if (y % 2 == 0)
        {
            x = (x * x) % m;
            y = y / 2;
        }
        else
        {
            res = (res * x) % m;
            y--;
        }
    }
    return res;
}
void deb(string s, ll n)
{
    cout << s << " : " << n << "\n";
}
void prn(ll n) { cout << n << "\n"; }
void prs(string n) { cout << n << "\n"; }

mat mt;
void setmtsize(ll m,ll n, ll ini=0){
    mt.resize(m,vector<ll>(n,ini));
}
void prmt(mat m){
    for(ll i=0;i<(1LL*m.size());i++)prv(m[i]);
}
vct divsors(ll n)
{
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++)
    {if(n%i==0){ans.push_back(i);if(i!=(n/i))ans.push_back(n/i);}}
    sort(ans.begin(),ans.end());
    return ans;
}
vct sieve(ll n){
    vct ans(n+1,-1);
    for(ll i=2;i<=n;i++){
        if(ans[i]==-1){
            for(ll j=i;j<=n;j+=i)if(ans[j]==-1)ans[j]=i;
        }
    }
    return ans;
}
ll n, k, m, l, r, x, y, z, ans=0;
ll t, t1, t2;
ll q;
ll i, j;
ll a, b, c;
ll mod = 1000000007;



void solve()
{
    cin>>n;
    setmtsize(n,3,0);
    F(i,n)cin>>mt[i][0]>>mt[i][1]>>mt[i][2];

    i=0;
    for(i=1;i<n;i++){
        mt[i][0]+=max(mt[i-1][1],mt[i-1][2]);
        mt[i][1]+=max(mt[i-1][0],mt[i-1][2]);
        mt[i][2]+=max(mt[i-1][1],mt[i-1][0]);
    }
    prn(max(mt[n-1][0],max(mt[n-1][1],mt[n-1][2])));

}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t = 1;
    // cin >> t;
    // stress();
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 8732
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
signed main(){
  int n,a,b;cin>>n>>a>>b;
  vector<int> x(n);
  rep(i,n)cin>>x[i];
  int res=0;
  rep1(i,n-1){
    res+=min(b,a*(x[i]-x[i-1]));
  }
  cout<<res<<endl;
  return 0;
}


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

int main(){
  string a;
  cin >> a;
  if (a[0] == a[1] && a[2] == a[3] && a[0] != a[2]){
    cout << "Yes" << endl;
  }
  else if (a[0] == a[2] && a[1] == a[3] && a[0] != a[1]){
    cout << "Yes" << endl;
  }
  else if (a[0] == a[3] && a[1] == a[2] && a[0] != a[1]){
  	cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////
#define mx 100000
int main(){

int n;
cin>>n;

set<int>st;
for(int i=1;i<=n;i++){
    int x;
    cin>>x;
    st.insert(x);
}

if(st.size()==n)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 9600
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
long long mod = 1e9+7;

int main(void) {
  int n, a, b; cin >> n >> a >> b;
  cout << min(b, a*n) << endl;

  return 0;
}

// EOF


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >>N;
  vector<int> A(N,0);
  for(int i=0; i<N; i++){
    int a;
    cin >>a;
    A[i]=a;
  }
  vector<int> B(N,0);
  B=A;
  long long s1=A[0], ans1=0, s2, ans2=0;
  if(A[0]==0){
    A[0]=1, ans1++, s1=A[0];
  }
  if(A[0]>0){
    s2=-1, ans2=abs(B[0])+1;
  }
  else{
    s2=1, ans2=abs(B[0])+1;
  }
  for(int i=1; i<N; i++){
//    cout<<"i:"<<i<<endl;
    if(s1>0){
      if(s1+A[i]>=0){
        ans1+=s1+A[i]+1;
        A[i]=-s1-1;
      }
    }
    if(s1<0){
      if(s1+A[i]<=0){
        ans1+=abs(s1+A[i])+1;
        A[i]=-s1+1;
      }
    }
    s1+=A[i];
//    cout<<"A[i]:"<<A[i]<<" s1:"<<s1<<" ans1:"<<ans1<<endl;
    if(s2>0){
      if(s2+B[i]>=0){
        ans2+=s2+B[i]+1;
        B[i]=-s2-1;
      }
    }
    if(s2<0){
      if(s2+B[i]<=0){
        ans2+=abs(s2+B[i])+1;
        B[i]=-s2+1;
      }
    }
    s2+=B[i];
//    cout<<"B[i]:"<<B[i]<<" s2:"<<s2<<" ans2:"<<ans2<<endl;    
  }
  ans1=min(ans1, ans2);
  cout<<ans1<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, A, B;
    cin >> N >> A >> B;
    if((B-A)&1){
        cout << "Borys" << endl;
    }
    else{
        cout << "Alice" << endl;
    }
}

Measured memory_bytes: 3572
#include<cstdio>
#include<cstring>
int main(){
    char s[201],t[101],p[101];
    
    scanf("%s %s",s,p);
    strcpy(t,s);
    strcat(s,t);
    if(strstr(s,p)==NULL) printf("No\n");
    else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 2744
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int max = 1;
		for(int i=0;i<N;i++) {
			max *=2;
		}
		max--;
		List<List<People>> list = new ArrayList<List<People>>();
		Main main = new Main ();
		for(int i=0;i<N;i++) {
			int q = sc.nextInt();
			List<People> l = new ArrayList<People>();
			for (int j=0;j<q;j++) {
				People p = main.new People();
				p.p = sc.nextInt();
				p.b = sc.nextInt();
				l.add(p);
			}
			list.add(l);
		}
		int re = 0;
		while (max>0) {
			int a[] = new int[N];
			int i=0;
			int t = max;
			int count =0;
			while (t>0) {
				if (t%2==1) {
					a[i]++;
					count ++;
				}
				t = t/2;
				i++;
			}
			boolean b =true;
			for(int j=0;j<N;j++) {
				if (a[j]==1) {
					List<People> l = list.get(j);
					for (int k =0;k<l.size();k++) {
						if (l.get(k).b!=a[l.get(k).p-1]) {
							b = false;
							break;
						}
					}
					if (b==false) {
						break;
					}
				}
			}
			if (b) {
				if (count>re) {
					re = count;
				}
			}
			max--;
		}
		System.out.println(re);
	}
	public class People {
		int p;
		int b;

	}
}

Measured memory_bytes: 40660
import sys
import copy
from collections import deque

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = [deque(lr()) for _ in range(N)]

match = 0
candidate = []
used = set()
for i in range(N):    
    bool = False
    if len(A[i]) == 0:
        continue
    op = A[i][0] - 1
    if op in used or i in used:
        continue
    if A[op][0]-1 == i:
        used.add(i)
        used.add(op)
        candidate.extend([i, op])
        match += 1
        bool = True
        A[i].popleft()
        A[op].popleft()
answer = 1

while True:
    used = set()
    bool = False
    c = []
    for i in candidate:
        if len(A[i]) == 0:
            continue
        op = A[i][0] - 1
        if op in used or i in used:
            continue
        if A[op][0]-1 == i:
            used.add(i)
            used.add(op)
            match += 1
            c.extend([i, op])
            bool = True
            A[i].popleft()
            A[op].popleft()
    
    answer += 1
    candidate = c
    if match == N * (N-1) // 2:
        break
    if not bool:
        print(-1)
        exit()

print(answer)


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

public class AtCoderA
{
    static void Main()
    {
        int n;
        int a;
        int b;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            n = int.Parse(words[0]);
            a = int.Parse(words[1]);
            b = int.Parse(words[2]);
        }

        Console.WriteLine(Math.Min(n * a, b));
    }
}

Measured memory_bytes: 11092
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << "\n"

using mint = modint998244353;

typedef struct {
    mint val;
    mint len;
} S;

using F = ll;
ll ID = 0;
ll ten[200010] = {};
mint m9 = mint(9).inv();


S op(S a, S b){
    return {a.val * b.len + b.val, a.len * b.len};
}

S e(){
    return {0,1};
}

S mapping(F f, S x){
    if(f == ID){
        return x;
    }else{
        return {f * (x.len-1) * m9, x.len};
    }
}


F composition(F f, F g){
    if(f == ID){
        return g;
    }else{
        return f;
    }
}

F id(){
    return ID;
}




void solve(){
    ll N,Q;
    cin >> N >> Q;
    ten[0] = 1;
    rep(i,1,N){
        ten[i] = ten[i-1] * 10 % MOD;
    }
    vector<S> v(N);
    rep(i,0,N){
        v[i] = {1, 10};
    }

    lazy_segtree<S, op, e, F, mapping, composition, id> sg(v);
    // print(sg.all_prod().val);
    while(Q--){
        ll l,r,d;
        cin >> l >> r >> d;
        l--; r--;
        sg.apply(l, r+1, d);
        print(sg.all_prod().val.val());
    }

}

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

    solve();
}

Measured memory_bytes: 12412
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    x,t = map(int, input().split())

    print(max(0, x-t))


if __name__ == '__main__':
    main()


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define str(n) to_string(n)
#define int(w) stoi(w)
#define len(l) l.size()
#define append(l,i) l.push_back(i)
int main() {
    long n,x,n1;
    cin>>n>>x;
    vector<long> l1;
    rep(i,n){
        cin>>n1;
        append(l1,n1);
    }
    vector<long> l=l1;
    vector<long> l2=l1;
    long ans1=0;
    long ans2=0;
    if (l.at(0)>x){
        ans1+=l.at(0)-x;
        l.at(0)=x;
    }
    rep(i,n-1){
        if (l.at(i)+l.at(i+1)>x){
            ans1+=l.at(i)+l.at(i+1)-x;
            l.at(i+1)=x-l.at(i);
        }
    }
    if (l2.at(n-1)>x){
        ans2+=l2.at(n-1)-x;
        l2.at(n-1)=x;
    }
    rep(i,n-1){
        if (l2.at(n-1-i)+l2.at(n-i-2)>x){
            ans2+=l2.at(n-1-i)+l2.at(n-2-i)-x;
            l2.at(n-2-i)=x-l2.at(n-1-i);
        }
    }
    cout<<min(ans1,ans2)<<endl;

    return 0;
}

Measured memory_bytes: 2676
#include <iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int ans=0;
        if(a>=b){
            ans+=a;
            a--;
        }
        else{
            ans+=b;
            b--;
        }
    ans+=a>b?a:b;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
n,c=map(int,input().split())
A=[]
for i in range(n):
  s,t,c=map(int,input().split())
  A.append((s,t,c))
A.sort(key=lambda x:(x[2],x[0],x[1]))
B=[]
s,t,c=A[0]

for i in range(1,n):
  s2,t2,c2=A[i]
  if c==c2 and t==s2:
    t=t2
  else:
    B.append((s-1,t,c))
    s,t,c=s2,t2,c2
B.append((s-1,t,c))

T=[0]*(10**5+1)
for s,t,c, in B:
  T[s]+=1
  T[t]-=1
for i in range(10**5):
  T[i+1]+=T[i]
print(max(T))



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

#define ff first
#define ss second
#define endl '\n'
#define int ll

ll a[3];

// machineMove
// 0 -> rock
// 1 -> paper
// 2 -> scissor
ll playMove(int machine, int player) {
	if (player == 0 && machine == 2) {
		return a[0];
	} else if (player == 1 && machine == 0) {
		return a[1];
	} else if (player == 2 && machine == 1) {
		return a[2];
	}

	return 0;
}

const int MAX = 2e5;
int n, k;
ll dp[MAX][4];
int machineMove[MAX];

ll f (int i, int prev) {
	if (i >= n) {
		return 0ll;
	}

	if (dp[i][prev] != -1) {
		return dp[i][prev];
	}

	ll ans = -1000000000ll;
	for (int x = 0; x < 3; ++x) {
		if (x != prev) {
			ans = max(ans, playMove(machineMove[i], x) + f(i+k, x));
		}
	}

	return dp[i][prev] = ans;
}

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

	cin >> n >> k;
	cin >> a[0] >> a[2] >> a[1];

	string s;
	cin >> s;
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'r') {
			machineMove[i] = 0;
		} else if (s[i] == 'p') {
			machineMove[i] = 1;
		} else {
			machineMove[i] = 2;
		}
	}

	memset(dp, -1, sizeof(dp));
	ll ans = 0ll;
	for (int i = 0; i < k; ++i) {
		ans += f(i, 3);
	}

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

Measured memory_bytes: 12112
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define PII pair<int,int>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
#define maxn 150
using namespace std;
const double PI=acos(-1.0);
const double eps=1e-6;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int a[maxn],b[maxn];
int main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int n;
    while(cin>>n){
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        rep(i,1,n-1) cin>>b[i];
        a[n]=b[n-1];
        a[n-1]=a[n];
        for(int i=n-2;i>=1;i--){
            if(b[i]<a[i+1]){
                a[i]=b[i];
                a[i+1]=b[i];
            }
            else a[i]=b[i];
        }
        int sum=0;
        rep(i,1,n) sum+=a[i];
        cout<<sum<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd_int(void){
  int x;
  rd(x);
  return x;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int i;
  int N = rd_int();
  long long res = 0;
  for(i=(1);i<(N+1);i++){
    if(i%3 && i%5){
      res += i;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200418-1

// --- original code ---
// {
//   int N = rd_int();
//   ll res = 0;
//   rep(i,1,N+1) if(i%3 && i%5) res += i;
//   wt(res);
// }


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s,s1,s2;
    cin>>n;
    cin>>s;
    if(n%2)cout<<"No"<<endl;
    else
    {
        s1.assign(s, 0, n/2);
        s2.assign(s, n/2,n);

        //s1.append(s2);

        if(s1==s2)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;

    }

    return 0;
}


Measured memory_bytes: 256
import sys

a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
d = [int(input()) for f in range(n)]

for k in range(3):
  if a[k][0] in d and a[k][1] in d and a[k][2] in d:
    print("Yes")
    sys.exit()
  elif a[0][k] in d and a[1][k] in d and a[2][k] in d:
    print("Yes")
    sys.exit()
if a[0][0] in d and a[1][1] in d and a[2][2] in d:
  print("Yes")
  sys.exit()
elif a[0][2] in d and a[1][1] in d and a[2][0] in d:
  print("Yes")
  sys.exit()
else:
  print("No")

Measured memory_bytes: 9168
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 1e9 + 7;
const long long inf = 1e18;
 
using namespace std;
 

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 
ll binomialCoeff(ll n, ll k) 
{ 
	ll C[n + 1][k + 1]; 
	ll i, j; 


	for (i = 0; i <= n; i++) 
	{ 
		for (j = 0; j <= min(i, k); j++) 
		{ 
			
			if (j == 0 || j == i) 
				C[i][j] = 1; 

			else
				C[i][j] = (C[i - 1][j - 1] + 
										C[i - 1][j])%MOD; 
		} 
	} 

	return C[n][k]; 
}
bool compare(const string &a , const string&b){
	
}
 
void solve()
{
	int  n  ,  k  
	;
	cin>>n>>k ;

    string s ; 
    cin>>s ;
    rep(i , n){
    	if(k==i+1){
    		char c = s[i] - 'A' + 'a' ;
    		cout<<c;
    	}
    	else{
    		cout<<s[i] ;
    	}
    }

}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3792
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<map>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 110000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)


int main(){
    int H,W;
    cin>>H>>W;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            string s;
            cin>>s;
            if(s=="snuke"){
                cout<<char(j-1+'A')<<i<<endl;
            }
        }
    }
}



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

int main() {
  int n; cin >> n;
  int c = -1, cnt;
  vector<int> x[100009];
  for(int i = 1; i <= 1000; i++) {
    if(i * (i-1) / 2 == n) {
      c = i;
      break;
    }
  }

  if(c == -1) {
    cout << "No" << endl;
    return 0;
  }

  for(int i = 0; i < c; i++) {
    for(int j = i + 1; j < c; j++) {
      x[i].push_back(cnt + 1);
      x[j].push_back(cnt + 1);
      cnt++;
    }
  }

  cout << "Yes" << endl;
  cout << c << endl;
  for(int i = 0; i < c; i++) {
    cout << x[i].size() << " ";
    for(int j = 0; j < x[i].size(); j++) {
      if(j) cout << " ";
      cout << x[i][j];
    }
    cout << endl;
  }
  return 0;
}


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

#define MAX_V 105
#define INF 1e9

struct Edge{
    int from, to, cost;
};

// d[u][v]は辺e=(u,v)のコスト(存在しない場合はINF、ただしd[i][i]=0とする)
int d[MAX_V][MAX_V];
int V; // 頂点数

void warshall_floyd() {
    for (int k = 0; k < V; k++)
        for (int i = 0; i < V; i++)
            for (int j = 0; j < V; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int main(){
    int m;
    cin >> V >> m;
    for(int i=0;i<V;++i){
        for(int j=0;j<V;++j){
            if(i != j)d[i][j] = INF;
            else d[i][j] = 0;
        }
    }
    vector<Edge> edges;
    for(int i=0;i<m;++i){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        d[a][b] = c;
        d[b][a] = c;
        edges.push_back((Edge){a, b, c});
    }
    warshall_floyd();

    int ans = 0;
    for(Edge edge : edges){
        if(d[edge.from][edge.to] < edge.cost)ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

s = list(map(int,list(input())))

d = [-1]
ans = 0
for i in s:
  if d[-1]+i==1:
    del d[-1]
    ans+=1
  else:
    d.append(i)
print(ans*2)

Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using vl = long long;
using P = pair<long long,long long>;

int main(){
	ll n,a,b; cin >> n >> a >> b;
	ll p = n/(a + b);
	ll q = n%(a + b);
	if(q >= a)cout << a * p + a << endl;
	else cout << a * p + q << endl; 

}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]

ans = 0
for i in range(N)[::-1]:
  if A[i] > i or (i > 0 and A[i] - A[i-1] > 1):
    print(-1)
    exit()

  if A[i] - A[i-1] == 1:
    ans += 1
  else:
    ans += A[i]

print(ans)

Measured memory_bytes: 11052
s = input()
n = int(s)
m = len(s)
ans = 0
i = 1
while(True):
    if i == m:
        ans += n - 10 ** (i - 1) + 1
        break
    elif i > m:
        break
    ans += 10 ** i - 10 ** (i - 1)
    i += 2
print(ans)


Measured memory_bytes: 2940
#include<stdio.h>
typedef unsigned u;
int main()
{
	u a,b;
	scanf("%u%u",&a,&b);
	a=(a+11)%13;
	b=(b+11)%13;
	printf(a>=b?a==b?"Draw\n":"Alice\n":"Bob\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll a,b;
    cin >> a >> b;
    cout << max((ll)0,a-2*b);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int n;
long long ans=0;
int main()
{
	scanf("%d",&n);
	for(int i=1,x;i<=n;i++)
	{
		scanf("%d",&x);
		ans+=x-1;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int x = fs.nextInt();
        int y = fs.nextInt();

        if(y % 2 != 0 || 4*x < y || 2*x > y) {
            System.out.println("No");
            return;
        }
        System.out.println("Yes");
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


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

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


int main()
{
	int n; 
	while(cin>>n)
	{
		int ans=0;

		REP(i,10) REP(j,10) REP(k,10)
		{
			if( (i+j+k)<=n && (i+j+k)+9>=n ) ++ans;
		}

		cout<<ans<<endl;
	}

	return 0;
}

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

int main() 
{
    int n;
    cin>>n;
    int a[n];
    int dp[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    
    cout<<dp[n-1]<<endl;
    
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=100005;
int a[N],b[N],c[N],cnt[N];
signed main(){
	int n,q;
	long long sum=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		cnt[a[i]]++;
		sum+=a[i];
	}
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>b[i]>>c[i];
		int x=cnt[b[i]];
		sum-=x*b[i];
		sum+=x*c[i];
		cnt[b[i]]=0;
		cnt[c[i]]+=x;
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 6756
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> x(n), y(n);
    rep(i,n)cin >> x[i] >> y[i];
    vector<ll> cx, cy;
    cx = x, cy = y;
    sort(ALL(cx));
    sort(ALL(cy));

    ll res = 1000000000000000010*4;
    rep(xi, n)for(ll xj = xi+1; xj < n; ++xj){
        rep(yi, n)for(ll yj = yi+1; yj < n; ++yj){
            ll lx = cx[xi], rx = cx[xj];
            ll ly = cy[yi], ry = cy[yj];
            ll cnt = 0;
            rep(i, n)if(x[i] >= lx && x[i] <= rx && y[i] >= ly && y[i] <= ry)cnt++;
            if(cnt >= k)res = min(res, abs(lx-rx)*abs(ly-ry));
        }
    }
    cout <<  res << endl;
}

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

int pre[100001], n, q;
bool book[100001];

int find(int x){
	while (!book[pre[x]]) x = pre[x];
	return pre[x];
}

int main()
{
	while (~scanf("%d%d", &n, &q)){
		if (!n && !q)return 0;
		long long sum = 0;
		memset(book, 0, sizeof book);
		book[1] = true;
		for (int i = 2; i <= n; ++i)scanf("%d", &pre[i]);
		while (q--){
			char ch;
			int num;
			cin >> ch;
			scanf("%d", &num);
			if (ch == 'Q'){
				if (book[num])sum += num;
				else sum += find(num);
			}
			else book[num] = true;
		}
		printf("%lld\n", sum);
	}
}


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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); ++i)
#define REP(i,start,end) for(int i=(start);i<=(end);++i)
#define all(n) begin(n),end(n)

#define DEBUG

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

	if(s[3] == '7') s[3] = '8';

	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int main()
{
	int n;
	int amax;
	int C[200000];
	int cmin;

	scanf("%d", &n);
	for (int t = 0; t < n; t++)
	{
		scanf("%d", &C[t]);
	}

	amax = C[1] - C[0];
	cmin = C[0];
	
	for (int j = 0; j < n-1 ; j++)
	{

		if (C[j] <= cmin)
		{
			cmin = C[j];

		
		for (int i = j + 1; i < n; i++)
		{
			int comp = C[i] - cmin;
			if (amax < comp)
			{
				amax = comp;
			}
		}
	   }
	}
		printf("%d\n", amax);	
			

	return 0;
}

Measured memory_bytes: 2516
import math
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

def int_input():
    return map(int, input().split())

m, k = int_input()
if k == 0:
    l = []
    for i in range(2 ** m):
        l.append(i)
    m = l[:]
    m.reverse()
    ans = m + l
    print(*ans)
else:
    v = 0
    l = []
    for i in range(2 ** m):
        if i != k:
            l.append(i)
            v ^= i
    m = l[:]
    m.reverse()
    ans = m + [k] + l + [k]
    if v == k: print(*ans)
    else: print(-1)



Measured memory_bytes: 26360
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int n; long double sx[16], sy[16], tx[16], ty[16], dp[1 << 15][15][2];
long double dst(long double ax, long double ay, long double bx, long double by) {
	return sqrt((ax - bx)*(ax - bx) + (ay - by)*(ay - by));
}
int main() {
	int d = 0;
	while (true) {
		cin >> n; if (n == 0)break; long double ret = 0; d++;
		for (int i = 0; i < n; i++) {
			cin >> sx[i] >> sy[i] >> tx[i] >> ty[i];
			ret += dst(sx[i], sy[i], tx[i], ty[i]);
		}
		for (int i = 0; i < (1 << n); i++) {
			for (int j = 0; j < n; j++) { dp[i][j][0] = 1e10; dp[i][j][1] = 1e10; }
		}
		for (int i = 0; i < n; i++) { dp[(1 << i)][i][0] = 0; dp[(1 << i)][i][1] = 0; }
		for (int i = 0; i < (1 << n); i++) {
			for (int j = 0; j < n; j++) {
				if (dp[i][j][0] <= 1e9) {
					for (int k = 0; k < n; k++) {
						if ((i&(1 << k)) != 0)continue;
						dp[i + (1 << k)][k][0] = min(dp[i + (1 << k)][k][0], dp[i][j][0] + dst(tx[j], ty[j], sx[k], sy[k]));
						dp[i + (1 << k)][k][1] = min(dp[i + (1 << k)][k][1], dp[i][j][0] + dst(tx[j], ty[j], tx[k], ty[k]));
					}
				}
				if (dp[i][j][1] <= 1e9) {
					for (int k = 0; k < n; k++) {
						if ((i&(1 << k)) != 0)continue;
						dp[i + (1 << k)][k][0] = min(dp[i + (1 << k)][k][0], dp[i][j][1] + dst(sx[j], sy[j], sx[k], sy[k]));
						dp[i + (1 << k)][k][1] = min(dp[i + (1 << k)][k][1], dp[i][j][1] + dst(sx[j], sy[j], tx[k], ty[k]));
					}
				}
			}
		}
		long double minx = 1e10;
		for (int i = 0; i < n; i++) {
			minx = min(minx, min(dp[(1 << n) - 1][i][0], dp[(1 << n) - 1][i][1]));
		}
		cout << "Case " << d << ": "; printf("%.9Lf\n", minx + ret);
	}
	return 0;
}

Measured memory_bytes: 10760
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[6] = {0,1,0,-1,1,-1};
const int vy[6] = {1,0,-1,0,1,1};




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

    ll n;
    cin >> n;
    ll ans = 1e18;
    for(ll i = 1;i * i <= n;++i){
        if(n%i == 0){
            ans = min(ans,i+(n/i)-2);
        }
    }
    cout << ans << endl;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
 
X, Y = map(int, input().split())
def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

if 2*Y < X or 2*X < Y or (X+Y)%3 != 0:
  print(0)
  sys.exit()
  
n1 = (2*Y-X)//3
n2 = (2*X-Y)//3

print(combination(n1+n2, min(n1, n2), 10**9+7))

Measured memory_bytes: 3064
l, r = [int(e) for e in input().split()]
m = 2019
for i in range(l, r):
  for j in range(i + 1, r + 1):
    t = (i * j) % 2019
    if t < m:
      m = t
    if m == 0:
      break
  if m == 0:
    break
print(m)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
   int k=0,i,n;
   char s[101];
   cin.getline(s,101); ///citirea unui sir de caractere
   n=strlen(s); ///retin lungimea sirului de caractere
   for(i=0;i<=n/2-1;i++){
     ///  cout<<s[i]<<" "<<s[n-i-1]<<endl;
       if(s[i]!=s[n-i-1]){
           
           k++;
       }
   }  
   cout<<k;
   
    return 0;
}

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

typedef long long ll;
int n;
vector<ll> a;
ll sum = 0;

bool f(ll x){
    for(int i = 1; i <= n; i++){
        auto first = lower_bound(a.begin(), a.end(), a[i-1]+x);
        if(first == a.end())    continue;
        ll s = *first-a[i-1];
        auto second = lower_bound(a.begin(), a.end(), *first+x);
        if(second == a.end())   continue;
        ll t = *second-*first;
        if(sum-s-t >= x)    return true;
    }
    return false;
}

int main(){
    cin >> n;

    a.resize(n+1);
    a[0] = 0;
    for(int i = 0; i < n; i++)  cin >> a[i+1];

    sum = accumulate(a.begin(), a.end(), 0ll);
    ll l = 1, r = sum;

    for(int i = 0; i < n; i++)  a[i+1] += a[i];

    while(r-l > 1){
        ll mid = (l+r)/2;
        if(f(mid))  l = mid;
        else        r = mid;
    }

    cout << l << endl;

    return 0;
}


Measured memory_bytes: 3636
n, m = map(int, input().split())
x = [list(map(int, input().split())) for i in range(m)]
for i in range(10**(n-1) if n>1 else 0, 10**n):
    i = str(i)
    for s, c in x:
        if i[s-1] != str(c):
            break
    else:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 38384
#include<iostream>
using namespace std;
int main(){
	
	int n,a[10000],min,max;
	long sum;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	min=a[0];
	max=a[0];
	sum=a[0];
	for(int b=1;b<n;b++){
		if(min>a[b]){
			min=a[b];
		}
	}
	for(int c=1;c<n;c++){
		if(max<a[c]){
			max=a[c];
		}
	}
	for(int d=1;d<n;d++){
		sum=sum+a[d];
	}
	cout<<min<<" "<<max<<" "<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3092
n,m=list(map(int,input().split(" ")))
py=[]
for i in range(m):
    py.append(list(map(int,input().split(" ")))+[i])
py.sort()
ids = []
c=1
p=1
for j in py:
    if j[0] != p:
        c=1
        p=j[0]
    ids.append([j[2],"{:0>6}{:0>6}".format(j[0],c)])
    c+=1
ids.sort()
for i in ids:
    print(i[1])


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

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  rep(i, n + 1) {
    int sum = findSumOfDigits(i);
    if (sum >= a && sum <= b) {
      ans += i;
    }
  }
  cout << ans << endl;
}

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

int main() {
	int a,b;
	cin >> a >> b;
	int c = 0;
	for(int i = 0;i < max(a,b);i++)
	{
		c += min(a,b) * pow(10,i);
	}
	cout << c <<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <array>
#include <stack>
#define NUM 100010
#define NIL -1

using namespace std;

stack<int> S;
vector<pair<int,int>> w[NUM];
array<long long, NUM> d;

void init(){
    for(int i = 0; i < NUM; i++){
        d[i] = NIL;
    }
}

int main(void){
    init();
    int N;
    scanf("%d\n", &N);

    for(int i = 1; i <= N-1; i++){
        int u_, v_, w_;
        scanf("%d %d %d", &u_, &v_, &w_);
        w[u_].push_back(make_pair(v_, w_));
        w[v_].push_back(make_pair(u_, w_));
    }

    d[1] = 0;
    S.push(1);
    while(S.size()){
        int num = S.top(); S.pop();
        //printf("num: %d\n", num);
        for(int i = 0; i < w[num].size(); i++){
            if(d[w[num][i].first] == NIL){
                S.push(w[num][i].first);
                d[w[num][i].first] = d[num] + w[num][i].second;
            }
        }
    }

    for(int i = 1; i <= N; i++){
        //printf("%d\n", d[i]);
        if(d[i] % 2 == 0){
            printf("0\n");
        }else{
            printf("1\n");
        }
    }

}


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

char ss[1010];

int main(){
	scanf("%s",ss);
	if(ss[0]=='Y'&&ss[1]=='A'&&ss[2]=='K'&&ss[3]=='I')
		printf("Yes");
	else printf("No");
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int d;
    cin >> d;
    if(d == 25) cout << "Christmas"<<endl;
    if(d == 24) cout << "Christmas Eve"<<endl;
    if(d == 23) cout << "Christmas Eve Eve"<<endl;
    if(d == 22) cout << "Christmas Eve Eve Eve" <<endl;

    return 0;
}

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

ll A[100002];
ll B[100001];

int main()
{
	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int n;
	cin>>n;

	ll ans=0LL;	

	for(int i=1; i<=n+1; i++)
	{
		cin>>A[i];
	}

	for(int i=1; i<=n; i++)
	{
		cin>>B[i];
	}

	for(int i=1; i<=n; i++)
	{
		ll cur = min(A[i],B[i]);
		ans += cur;
		A[i] -= cur;
		B[i] -= cur;

		ll cur2=min(B[i],A[i+1]);
		ans += cur2;
		A[i+1] -= cur2;
		B[i] -= cur2;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, 0, n) {
        cin >> a[i];
    }
    int ans = 1;
    int flag = 0;
    rep(i, 0, n - 1) {
        if (flag == 0) {
            if (a[i] < a[i + 1]) {
                flag = 1;
            }
            if (a[i] > a[i + 1]) {
                flag = -1;
            }
        }
        if (flag == 1) {
            if (a[i] > a[i + 1]) {
                ans++;
                flag = 0;
            }
        }
        if (flag == -1) {
            if (a[i] < a[i + 1]) {
                ans++;
                flag = 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	int N;
	int ans = 0;
	int l, r;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		for (int i=0; i<values.length; i++) {
			values[i] = i+1;
		}
		for (int i=0; i<n; i++) {
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;
			int tmp = values[a];
			values[a] = values[b];
			values[b] = tmp;
		}
		for (int i=0; i<w; i++) {
			System.out.println(values[i]);
		}
	}
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  vector<int> v{a,b,c};
  sort(v.begin(), v.end());
  cout << v[0] + v[1] << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(raw_input())
if n > 1:
    s = map(int, raw_input().split())
else:
    s = int(raw_input())
    
q = int(raw_input())
if q > 1:
    t = map(int, raw_input().split())
else:
    t = int(raw_input())

count = 0
for i in range(q):
    try:
        a = s.index(t[i])
        count += 1
    except:
        pass

print count

Measured memory_bytes: 6848