akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<array>
#include<cassert>
#include<list>

using namespace std;

#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);

#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)

#define DEB(X) if(mode==1)cout<< #X <<": "<<X<<" ";
#define DEB2(X) if(mode==1)cout<<X<<" ";
#define ARDEB(i,X) if(mode==1)cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define FORDEB(n,X) if(mode==1)for(int i=0;i<(n);i++)ARDEB(i,X)
#define END if(mode==1)cout<<endl;

typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
struct P2{int x,y;};
//struct edge{int from,cost,to;};
#define MAX_V 11

const int MOD7=1000000007;
const int INF=100000000;
int mode=0;

int d[MAX_V][MAX_V];

void Warshall_Floyd(int n){
	REP(i,n)REP(j,n)REP(k,n){
		d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
	}
}

int main(){
	int h,w,ans=0;
	cin>>h>>w;
	REP(i,10)REP(j,10){
		cin>>d[i][j];
		if(d[i][j]==0){
			d[i][j]=INF;
		}
	}
	Warshall_Floyd(10);
	REP(i,h)REP(j,w){
		int a;
		cin>>a;
		if(a!=-1 && a!=1){
			ans+=d[a][1];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt
import math

import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


def main():
    n,m,k = mi()
    a = li()
    b = li()
    arui = [0]
    brui = [0]
    tmp = 0
    ans = 0

    for i in range(n):
        tmp+=a[i]
        arui.append(tmp)
    tmp = 0
    for i in range(m):
        tmp+=b[i]
        brui.append(tmp)
    anstmp = 0
    for i in range(n+1):
        if arui[i]>k:
            break
        anstmp = i
        anstmp+=bisect.bisect_right(brui,k-arui[i])
        anstmp-=1
        ans = max(ans,anstmp)
    print(ans)



main()




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

string s;
int cnt[2], ans;

int main() {
	cin >> s;
	for (char c: s) {
		if (c == 'g') {
			if (cnt[0] + 1 <= cnt[1]) {
				cnt[0]++; ans++;
			} else cnt[1]++;
		} else {
			if (cnt[0] + 1 <= cnt[1]) cnt[0]++;
			else {
				cnt[1]++; ans--;
			}
		}
	}	
	cout << ans;
}


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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i, 0, n)
    cin >> a[i];
  
  sort(a.begin(), a.end());
  
  ll ans = 0;
  
  rep(i, 1, n){
    int j = n-(i/2);
    j--;
    ans += a[j];
  }
  
  cout << ans << endl;
  
  return 0;
  
}

Measured memory_bytes: 4108
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let mut v: Vec<usize> = (0..n).map(|_| read::<usize>()).collect();
    v.sort();

    let mut ans: f64 = v[0] as f64;
    for i in 1..n {
        ans += v[i] as f64;
        ans /= 2.0;
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main(){
	int n=0,h,w;
	int a[501][501];
	vl x,y;
	cin>>h>>w;
	rep(i,0,h)rep(j,0,w)cin>>a[i][j];

	rep(i,0,h)rep(j,0,w-1){
		if(a[i][j]%2){
			n++;
			a[i][j]--,a[i][j+1]++;
			x.push_back(j+1),x.push_back(j+2);
			y.push_back(i+1),y.push_back(i+1);
		}
	}
	rep(i,0,h-1){
		if(a[i][w-1]%2){
			n++;
			a[i][w-1]--,a[i+1][w-1]++;
			x.push_back(w),x.push_back(w);
			y.push_back(i+1),y.push_back(i+2);
		}
	}
	print(n);
	int z=0;
	rep(i,0,x.size()){
		if(z==2)cout<<endl,z=0;
		cout<<y[i]<<" "<<x[i];
		z++;
		if(z==1)cout<<" ";
	}
	
}


Measured memory_bytes: 8164
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, m;
	cin >> n >> m;

	if (n >= m) {
		cout << "0\n";
	} else {
		vector<int> coordinates(m);
		for (int i = 0; i < m; ++i) {
			cin >> coordinates[i];
		}

		sort(coordinates.begin(), coordinates.end());

		vector<int> diff(m - 1);
		for (int i = 1; i < m; ++i) {
			diff[i - 1] = coordinates[i] - coordinates[i - 1];
		}

		sort(diff.begin(), diff.end());
		
		long long ans = 0;
		for (int i = 0; i < m - n; ++i) {
			ans += diff[i];
		}

		cout << ans << "\n";
	}

	return 0;

}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] arg){
        Scanner sc=new Scanner(System.in);
        int H=sc.nextInt();
        int W=sc.nextInt();
        int N=sc.nextInt();
        int Sr=sc.nextInt()-1;
        int Sc=sc.nextInt()-1;
        char[] S=sc.next().toCharArray();
        char[] T=sc.next().toCharArray();

        int xs=0;
        int xe=W;
        int ys=0;
        int ye=H;
        for(int i=N-1;i>=0;i--){
            switch (T[i]){
                case 'D':
                    if(ys>0){
                        ys--;
                    }
                    break;
                case 'U':
                    if(ye<H){
                        ye++;
                    }
                    break;
                case 'R':
                    if(xs>0){
                        xs--;
                    }
                    break;
                case 'L':
                    if(xe<W){
                        xe++;
                    }
            }
            switch (S[i]){
                case 'D':
                        ye--;
                        if(ye==ys){
                            System.out.println("NO");
                            return;
                        }
                    break;
                case 'U':
                        ys++;
                    if(ye==ys){
                        System.out.println("NO");
                        return;
                    }
                    break;
                case 'R':
                        xe--;
                    if(xe==xs){
                        System.out.println("NO");
                        return;
                    }
                    break;
                case 'L':
                        xs++;
                    if(xe==xs){
                        System.out.println("NO");
                        return;
                    }
            }
        }
        if(xs<=Sc&&Sc<xe&&ys<=Sr&&Sr<ye){
            System.out.println("YES");
            return;
        }
        System.out.println("NO");
    }
}


Measured memory_bytes: 28984
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  ll N, X, T, count, tmp1, tmp2;
  count = tmp1 = tmp2 = 0;
  cin >> N >> X >> T;
  tmp1 = N / X;
  tmp2 = N % X;
  if (tmp2 == 0) {
    count = tmp1 * T;
  } else {
    count = (tmp1 + 1) * T;
  }
  printf("%lld\n", count);
  return 0;
}

Measured memory_bytes: 3748
#include<iostream>
#include<map>
using namespace std;
int n;
string st;
map<string,int> mp;
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        cin>>st,mp[st]++;
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",mp["AC"],mp["WA"],mp["TLE"],mp["RE"]);
}

Measured memory_bytes: 3316
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

int n,k;
int dp[100005][3];
int A[100005][3];

int f( int pos, int c ){
	if ( pos == n ) return 0;
	int &ans = dp[pos][c];
	if ( ans != -1 ) return ans;
	ans = 0;
	for ( int i = 0; i < 3 ; i++ ){
		if ( c != i ) ans = max( ans, f(pos+1,i) + A[pos][i] );
	}
	return ans;
}

int main(){

	scanf("%d",&n);
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < 3; j++ ) scanf("%d",&A[i][j]);
	}

	memset(dp,-1,sizeof(dp));

	int ans = 0;
	for ( int i = 0; i < 3; i++ ){
		ans = max( f(1,i) + A[0][i], ans );
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    int H, N;
    cin >> H >> N;
    int sum = 0;
    int A;
    for (int i = 0; i < N; i++) {
        cin >> A;
        sum += A;
    }
    if (H <= sum) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
return 0;
}

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

int main()
{
	int i = 1;
	int n;
	cin >> n;
	for (i=1; i<=n; i++)
	{
		int x = i;
		if (x % 3 == 0)
		{
			cout << " " << i;
		}
		else
		{
			while (x != 0)
			{
				if (x % 10 == 3)
				{
					cout << " " << i;
					break;
				}
				x = x / 10;
			}
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3088
#include <stdio.h>

int quicksort( int x[], int left, int right ) {
	
	int i, j, pivot, temp;
	
	i = left;
	j = right;
	
	pivot = x[(left+right)/2];
	
	while (1) {
	
		while ( x[i] < pivot ) { i++; }
		
		while ( pivot < x[j] ) { j--; }
		
		if ( i >= j ) { break; }
		
		temp = x[i];
		x[i] = x[j];
		x[j] = temp;
		
		i++;
		j--;
		
	}
	
	if ( left < i - 1 ) { quicksort( x, left, i - 1 ); }
	if ( j + 1 < right ) { quicksort( x, j + 1, right ); }
	
	return 0;
		
}

int main( void ) {

	int t, n, k, x[1000000], i, j, sum;
	
	scanf( "%d", &t );
	
	for ( i = 0; i < t; i++ ) {
	
		scanf( "%d %d", &n, &k );
		
		sum = 0;
	
		for ( j = 0; j < n; j++ ) { scanf( "%d", &x[j] ); }
		for ( j = 0; j < n - 1; j++ ) { x[j] = x[j+1] - x[j]; }
	
		quicksort( x, 0, n - 2 );
		
		for ( j = 0; j < n - k; j++ ) { sum += x[j]; }
		
		printf( "%d\n", sum );
		
	}
	
	return 0;

}

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

typedef long long int ll;
ll powk(ll a, ll n = 2){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}


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

    ll ans = 0;
    for(ll i = 0;i < n - 1;i++){
        if(a[i] > a[i + 1]){
            ans += a[i] - a[i + 1];
            a[i + 1] = a[i];
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 4832
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"
#include "cmath"
#include "set"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll> > mat;

int main()
{
  ll n;
  cin >> n;
  ll x = 1;
  while (n > 0)
  {
    n /= 2;
    x += x;
  }
  cout << x - 1 << "\n";
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  1000000007
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    map <int,int> oc;
    int n; cin>>n; 
    for (int i=2;i<=n;i++){
        int j=i;
        for ( int k=2;k*k<=j;k++){
            while (j%k==0){
                j/=k;
                oc[k]++;
            }
        }
        if (j>1) oc[j]++;
    }
    int ans=1;
    for (auto &it: oc)
        ans = (ans*(it.ss+1))%mod;
    cout << ans << endl;
    
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3600
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
//orz yht
using namespace std;
int ans=INF;
char s[105];
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>s;
	for(int i='a';i<='z';i++){
		int la=-1,sol=0,j;
		for(j=0;s[j];j++)
		if(s[j]==i){
			if(sol<j-la-1)
			sol=j-la-1;
			la=j;
		}
		if(sol<j-la-1)
		sol=j-la-1;
		if(ans>sol)
		ans=sol;
	}
	cout<<ans;
	//system("pause");
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    ll n;
    ll a[3002];
    cin >> n;
    REP(i, n){
        cin >> a[i];
    }
    ll ans = 0;
    REP(i, n){
        ans += a[i] - 1;
    }
    print(ans);
}


Measured memory_bytes: 256
n = int(input())
H = list(map(int, input().split()))
mh = 0
cnt = 0
for i in range(n - 1):
    mh = max(mh, H[i])
    if H[i] <= H[i + 1] and mh < H[i + 1]:
        continue
    else:
        cnt += mh - H[i + 1]
print(cnt)


Measured memory_bytes: 32148
#include<stdio.h>
int main (void){
	char b ;
	scanf("%c", &b);
  	if (b=='A'){
    	printf("T");
    }
	if (b=='T'){
    	printf("A");
    }
	if (b=='C'){
    	printf("G");
    }
	if (b=='G'){
    	printf("C");
    }
	return 0;
}

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

using namespace std;

using int64 = long long;

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {
    if (x > P || x < 0) { cerr << "Invalied FiniteField!" << endl; exit(1); }
  }
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

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

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

  FiniteField ans = 0;
  for (int i = 0; i < n; i++) {
    int64 a = 0;
    int64 b = 0;
    for (int j = i + 1; j < n; j++) {
      if (xs[j] < xs[i]) a++;
    }
    for (int j = 0; j < n; j++) {
      if (xs[j] < xs[i]) b++;
    }

    ans += FiniteField(a) * k;
    ans += FiniteField(b) * k * (k - 1) / 2;
  }
  cout << ans.Value() << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//マスの数(N+1)
		int N = sc.nextInt();
		//コストのかかるマスの数
		int M = sc.nextInt();
		//初期位置
		int X = sc.nextInt();

		int[] costMasu = new int[M];

		for(int i = 0; i < M; i++){
		    costMasu[i] = sc.nextInt();
		}

		int cost2N = 0;
		int cost20 = 0;

		for(int j = X; j <= N; j++){
		    for(int k = 0; k < M; k++){
			if(costMasu[k] == j){
			    cost2N++;
			}
		    }
		}

		for(int l = X; l > 0; l--){
		    for(int m = 0; m < M; m++){
			if(costMasu[m] == l){
			    cost20++;
			}
		    }
		}

		if(cost2N <= cost20){
		    System.out.println(cost2N);
		}else{
		    System.out.println(cost20);
		}
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;
 
const int MAX_N = 1010;
using TYPE = ll; // 距離の型を入れる
vector<pair<int, TYPE> > G[MAX_N];
vector<TYPE> dijkstra(int start){
	vector<TYPE> dist(MAX_N, INFF);
	dist[start] = 0;//dist[i] :=　start->iまでの最短距離
	priority_queue<pair<TYPE, int>, vector<pair<TYPE, int> >, greater<pair<TYPE, int> > >  que;
	que.push(make_pair(0, start));
	while(!que.empty()){
		TYPE cost; int u;//今までにかかった時間 現在の頂点
		cost = que.top().first, u = que.top().second;
		que.pop();
		if(dist[u] < cost) continue;
		for (auto tmp : G[u]){
			int v = tmp.first; TYPE time = tmp.second;//隣接する頂点 その頂点まで行く時間
			if(dist[v] > dist[u] + time){//u->v
				dist[v] = dist[u] + time;
				que.push(make_pair(dist[v], v));
			}
		}
	}
	return dist;
}
 
ll memo[1100][1100];
ll N, M, R;
ll r[100];
ll A[100010], B[100010];
ll C[100010];
 
int main() {
	cin >> N >> M >> R;
	rep(i, R) cin >> r[i];
	rep(i, R) r[i]--;
	rep(i, M) cin >> A[i] >> B[i] >> C[i];
	rep(i, M) A[i]--, B[i]--;
	rep(i, M) G[A[i]].pb(mp(B[i], (ll)C[i])), G[B[i]].pb(mp(A[i], (ll)C[i]));
 
	rep(i, R)rep(j, R) {
		auto d = dijkstra(r[i]);
		memo[r[i]][r[j]] = d[r[j]];
	}
	/*
	rep(i, R){
		rep(j, R) printf("%d ", memo[r[i]][r[j]]);
		printf("\n");
	}
	*/
	ll ans = INFF;
	vector<ll> v;
	rep(i, R) v.pb(r[i]);
  	sort(all(v));
	do {
		// for(auto k : v) printf("%d ", k);
		// printf("\n");
		ll tmp = 0;
		rep(i, R - 1) {
			tmp += memo[v[i]][v[i + 1]];
		}
		// printf("%lld\n", tmp);
		chmin(ans, tmp);
	}while( next_permutation(v.begin(), v.end()) );
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3712
N, x = map(int, input().split())
child_list = list(map(int, input().split()))

count = 0
for i, child in enumerate(sorted(child_list)):
  x -= child
  if x < 0:
    break
  if (i == len(child_list) - 1) and x != 0:
    break
  count += 1

print(count)

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

typedef long long ll;
typedef std::pair<ll, ll> l_l;
typedef std::pair<int, int> i_i;
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;
}

using namespace std;

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

    vector<int> B(N);
    for (int i = 0; i < N-1; ++i) {
        cin >> B[i];
    }

    vector<ll> A(N);
    A[0] = B[0];
    A[1] = B[0];
    for (int i = 1; i < N-1; ++i) {
        if (A[i] < B[i]) {
            A[i + 1] = B[i];
        } else {
            A[i] = B[i];
            A[i + 1] = B[i];
        }

    }
    ll begin = 0;
    ll ans = accumulate(A.begin(), A.end(), begin);
    cout << ans << endl;
    return 0;
}


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

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

Measured memory_bytes: 3524
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int INF = 1e9+7;

int main() {
  int n, m; cin >> n >> m;
  vec s(m, 0), p(m);
  rep(i,m) {
    int k; cin >> k;
    rep(j, k) {
      int t; cin >> t; t--;
      s[i] += 1<<t;
    }
  }
  rep(i,m) {
    cin >> p[i];
  }

  int cnt = 0;
  for (int bit = 0; bit < (1<<n); bit++) {
    bool f = true;
    rep(i,m) {
      if ((__builtin_popcount(bit&s[i])&1) != p[i]) f = false;
    }
    if (f) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>                                                                          
using namespace std;
int main()
{
  int N,D;
  cin >> N >> D;
  vector<vector<int>> X(N,vector<int>(D));
  for(int i=0; i<N; i++){
    for(int j=0; j<D; j++){
      cin >> X.at(i).at(j);
    }
  }
  int d=0;
  int count=0;
  for(int i=0; i<N-1; i++){
    for(int j=i+1; j<N; j++){
      for(int k=0; k<D; k++){
        d+=(X.at(i).at(k)-X.at(j).at(k))*(X.at(i).at(k)-X.at(j).at(k));
      }
      for(int l=0; l<=d; l++){
        if(l*l==d){
          count++;
          break;
        }
      }
      d=0;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a,b;
	string s;
	cin>>s;
	a=s[0]-48;
	a=a*10+s[1]-48;
	b=s[2]-48;
	b=b*10+s[3]-48;
	if(a<=12&&a>0&&b>0&&b<=12)
	cout<<"AMBIGUOUS";
	else if(a>0&&a<=12)
	cout<<"MMYY";
	else if(b>0&&b<=12)
	cout<<"YYMM";
	else
	cout<<"NA";
	return 0;
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main()
{
  int N;
  cin >> N;
  
  int d[N];
  int i = 0;
  while(cin >> d[i]){
    i++;
  }
  
  long kaifuku;
  for(int j = 0; j < N; j++){
   for(int k = j+1; k < N; k++){
    kaifuku += d[j]*d[k];
   }
  }
  cout << kaifuku << endl;
  
  return 0;
}

Measured memory_bytes: 256
/*---------------Go Code GO---------------*/

#include<bits/stdc++.h>
using namespace std;

#define     PI              acos(-1.0)
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define     precision(a)    fixed<<setprecision(a)
#define     endl            '\n'
#define     Flush           cout<<flush
#define     LLMX            0x3fffffffffffffff
#define     PW2(a)          (long long)1<<a

long long arr[500005];

int main()
{
    long long i,j,k,l,m,n,o,p,q,r,tst,ans=0;
    cin>>n;
    bool pos=true;
    for(i=0; i<n; i++)
    {
        cin>>k;
        if(k%2==0)
        {
            if(k%3==0||k%5==0)
                continue;
            else
                pos=false;
        }
    }
    if(pos)
    cout<<"APPROVED"<<endl;
    else
        cout<<"DENIED"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <deque>
using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define EPS 0.0001

int N;
bool END = false;
deque<int> question;
void out(int ch, bool front_flg) {
	front_flg ? question.push_front(ch) : question.push_back(ch);
	REP(k, 0, 2) {
		REP(i, 0, question.size()) {
			cout << ((question[i] & (1 << k)) ? '#': '.');
		}
		cout << endl;
	}
	front_flg ? question.pop_front() : question.pop_back();
}

bool in() {
	string a;
	cin >> a;
	if (a == "end") END = true;
	return a[0] != 'F';
}

void query() {
	REP(front, 0, 2) {
		bool flg = true;
		while (flg) {
			flg = false;
			REP(ch, 0, 4) {
				out(ch, front);
				if (in()) {
					if (END) return;
					front ? question.push_front(ch) : question.push_back(ch);
					flg = true;
					break;
				}
			}
		}
	}
	return;
}

int main() {
	cin >> N;
	query();
	return 0;
}


Measured memory_bytes: 596
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
#define N 100000

char s[N]; int w;

int main(){
	scanf("%s",&s);
	scanf("%d",&w);
	for (int i=0; i<strlen(s); i+=w){
		printf("%c",s[i]);
	}
	printf("\n");
	return 0;
}

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

int main()
{
	int ans = 0;
	string A;
	cin >> A;

	for (int i = 0; i < 3; i++) {
		if (A.at(i) == A.at(i + 1)) {
			ans = 1;
		}
	}
	if (ans == 1) {
		cout << "Bad";
	}
	else
		cout << "Good";
}


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

using namespace std;

const int MAXN = 100005;

int dp[3][MAXN];

int main()
{
    int n, a, b, c;
    scanf("%i", &n);
    for (int x = 1; x <= n; x++)
    {
        scanf("%i%i%i", &a, &b, &c);
        dp[0][x] = max(dp[1][x-1], dp[2][x-1]) + a;
        dp[1][x] = max(dp[0][x-1], dp[2][x-1]) + b;
        dp[2][x] = max(dp[0][x-1], dp[1][x-1]) + c;
    }
    printf("%i\n", max(dp[0][n], max(dp[1][n], dp[2][n])));
}


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

using namespace std;

int main(){
	string s,t;
	
	cin >> s >> t;
	
	int ans = t.size();
	
	for (int start = 0; start <= s.size() - t.size();start++){
		int diff = 0;
		
		for (int i = 0;i < t.size();i++){
			if (t[i] != s[start+i]){
				diff++;
			}
		}
		ans = min(diff,ans);
	}
	cout << ans;
	
	return 0;
}
		


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,a,b) for(ll i=a;i<b;i++)
int main() {
	ll n;
	cin>>n;
	ll a[n],b[n],c[n];
	f(i,0,n)
	    cin>>a[i]>>b[i]>>c[i];
	
	ll dp[n+1][3];
	dp[1][0]=a[0];
	dp[1][1]=b[0];
	dp[1][2]=c[0];
	f(i,2,n+1)
	{
	    dp[i][0] = max(dp[i-1][1] , dp[i-1][2]) + a[i-1];
	    dp[i][1] = max(dp[i-1][0] , dp[i-1][2]) + b[i-1];
	    dp[i][2] = max(dp[i-1][0] , dp[i-1][1]) + c[i-1];
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
	return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<ll> s(n);
    for(int i=0;i<n;++i){
        cin >> s[i];
    }

    ll score = 0LL;
    for(int c=1;c<n/2;++c) {
        ll tmp_score = 0LL;
        if((n-1) % c) {
            for(int x=0;n-1-c*x>=c;++x) {
                tmp_score += s[c*x] + s[n-1-c*x];
                score = max(score, tmp_score);
            }
        } else {
            for(int x=0;c*x<n-1-c*x;++x) {
                tmp_score += s[c*x] + s[n-1-c*x];
                score = max(score, tmp_score);
            }
        }
        
    }

    cout << score << endl;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main{
	static Scanner s=new Scanner(System.in);
	static int gInt(){
		return Integer.parseInt(s.next());
	}
	public static void main(String[]$){
		String v=s.next();
		int x=gInt(),y=gInt();

		ArrayList<Integer> dx=new ArrayList<>(),dy=new ArrayList<>();

		boolean dir=true;
		int d=0;
		for(int i=0;i<v.length();i++){
			if(v.charAt(i)=='T'){
				(dir?dx:dy).add(d);
				d=0;
				dir^=true;
			}else{
				d++;
			}
		}
		(dir?dx:dy).add(d);

		x-=dx.remove(0);
		System.out.println(dp(dx,x)&&dp(dy,y)?"Yes":"No");
	}

	static boolean dp(List<Integer> list,int goal){
		Set<Integer> set=new HashSet<>(),buf=new HashSet<>();
		set.add(0);

		for(int v:list){
			buf.clear();
			for(int base:set){
				buf.add(base+v);
				buf.add(base-v);
			}
			set.clear();
			set.addAll(buf);
		}

		return set.contains(goal);
	}
}


Measured memory_bytes: 147992
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if((abs(a-b) <= d && abs(b-c) <=d) || abs(a-c) <= d) cout <<   "Yes";
    else cout << "No";
    cout << endl;

    return 0;
}


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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

vector<int>adj[M+3];
int ses=0;
int vis[M+5];
int n,k;
int dfs(int u)
{
     vis[u]=1;
     int mx=-1;
     for(auto v:adj[u])
     {
         if(vis[v])continue;
         int d=dfs(v);
         if(u!=1 && d==k-1)
         {
             ses++;
         }
         else
         {
             mx=max(mx,d);
         }
     }
     return (mx+1);
}
 main()

{
    fast
    cin>>n>>k;
    f(i,1,n)
     {
         int x;
         cin>>x;
         if(i==1)
         {
             if(x!=1)ses++;
             continue;
         }
         if(x==i)continue;
         adj[x].pb(i);
     }
     dfs(1);
     cout<<ses<<endl;
     return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Vertex {
    vector<ll> node;
};

Vertex V[2005];
ll C[2005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, X, Y;
    cin >> N >> X >> Y;
    REP(i, N - 1) {
        V[i].node.push_back(i + 1);
        V[i + 1].node.push_back(i);
    }
    X--;
    Y--;
    V[X].node.push_back(Y);
    V[Y].node.push_back(X);

    std::map<ll, ll> M;
    REP(i, N) {
        REP(j, N) {
            C[j] = INF;
        }
        C[i] = 0;
        queue<pll> q;
        q.push(pll(i, 0));
        while (!q.empty()) {
            pll t = q.front();
            q.pop();
            ll cost = t.second + 1;
            REP(j, V[t.first].node.size()) {
                ll n = V[t.first].node[j];
                if (C[n] <= cost)
                    continue;
                C[n] = cost;
                q.push(pll(n, cost));
                if (n > i)
                    M[cost]++;
            }
        }
    }

    REP(i, N - 1) {
        cout << M[i + 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#define eps 1e-8
#define zero(x) (((x)>0?(x):-(x))<eps)

#define pause cout << " press ansy key to continue...",  cin >> chh
#define file_r(x) freopen(x,  "r",  stdin)
#define file_w(x) freopen(x,  "w",  stdout)
#define lowbit(x) ((x) & (-x))
#define repit(i, c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repe(i, u) for (int i = head[u]; i != -1; i = nxt[i])
#define repd(i, n) for (int i = (n - 1); i >= 0; i--)
#define FOR(i, n, m) for (int i = (n); i <= (m); i++)
#define FORD(i, n, m) for (int i = (n); i >= (m); i--)
#define pb push_back
#define X first
#define Y second
#define ins insert
#define rb rbegin
#define be begin
#define er erase
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define SZ(c) (c).size()
#define ALL(c) (c).begin(), (c).end()
#define sqr(r) ((LL) (r) * (r))
#define dis(x1, y1, x2, y2) (((x1) - (x2)) * ((x1) - (x2)) + ((y1) - (y2)) * ((y1) - (y2)))
#define FASTIO ios::sync_with_stdio(false);cin.tie(0)

#define sc(x) cout << #x" = " << x << endl, system("pause")
#define sc2(x, y) cout << #x" = " << x << " " << #y" = " << y << endl, system("pause")
#define sc3(x, y, z) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << endl, system("pause")
#define sc4(x, y, z, w) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << " " << #w" = " << w << endl, system("pause")

#define in(n) scanf("%d", &n)
#define in2(n, m) scanf("%d %d", &n, &m)
#define in3(x, y, z) scanf("%d %d %d", &x, &y, &z)

using namespace std;
int chh;

typedef vector<int> vi;
typedef set<int> si;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<int, pii> pi3;
typedef vector< pair<int, int> > vpii;
typedef long long LL;

int main() {
    FASTIO;
    int n;
    string a, b;
    while (cin >> n >> a >> b) {
        for (int i = 0; i < n; i++) cout << a[i] << b[i];
        puts("");
    }
    return 0;
}


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

int main()
{
	int n; cin >> n;
	int a = n % 10;
	if (a == 2 || a == 4 || a == 5 || a == 7 || a == 9) {
		cout << "hon" << endl;
	}
	else if (a == 0 || a == 1 || a == 6 || a == 8) {
		cout << "pon" << endl;
	}
	else if (a == 3) {
		cout << "bon" << endl;
	}
}

Measured memory_bytes: 3632
//
//  abc112d.cpp
//  
//
//  Created by Yoshida Satoshi on 2018/10/22.
//

#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
    int N,M;
    
    cin>>N>>M;
    
    for(int i=N;i<=M;i++){
        if(M%i==0){
            cout<<M/i<<endl;
            break;
        }
      if(i>M/2){
        cout<<1<<endl;
        break;
      }
    }
    
    
    return 0;
}


Measured memory_bytes: 256
import bisect

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

S.sort()

cnt = 0
for t in T:
    b = bisect.bisect_left(S, t)
    if S[b] == t:
        cnt += 1

print(cnt)



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

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

  vector<int> A(M);
  for (int i = 0; i < M; i++) cin >> A[i];

  ll sum = 0;

  for (int i = 0; i < M; i++) sum += A[i];

  if (N - sum >= 0) cout << N - sum << endl;
  else cout << -1 << endl;

  return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    rep(i,N) cin >> p.at(i);
    bool first = 0;
    int ans = 0;
    rep(i,N) {
        if (first == 1) {
            first = 0;
        } else {
            if (p.at(i) == i + 1) {
                ++ans;
                first = 1;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
int power(int i,int j)
{
	int ans=1;
	for(int k=1;k<=j;k++)
	{
	    ans*=i;
	}
	return ans;
}
int main()
{	
	int x,maxv=0;
	cin>>x;
	if(x==1)
	{
		cout<<1;
		return 0;
    }
	for(int i=2;i<=int(sqrt(x));++i)
	{
		for(int j=2;j<=10;++j)
		{
			if(power(i,j)<=x&&power(i,j)>maxv)
			{
				maxv=power(i,j);
			}
		}
	}
	cout<<maxv;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iostream>
#include<cstring>
#define ll long long
#define maxn 5005
			 
#define p 1000000007
#define re(i,a,b) for(int i=a;i<=b;i++)
#define for_edge(x) for(int i=head[x];i;i=e[i].nxt)
using namespace std;
inline int read(){char c=getchar();int f=1;int ans = 0;while(c>'9'||c<'0'){if(c=='-')f=-f;c=getchar();}while(c<='9'&&c>='0'){ans =ans*10+c-'0';c=getchar();}return ans*f;}
//_____________________________________________________________________________________________________
ll _C[maxn][maxn];
inline ll C(int n,int m)
{
	return (n>=0 && m>=0) ? _C[n][m] : 0;
}
int main()
{
	int A = read() , B = read();;
	_C[0][0] = 1;
	re(i,0,5000)
		re(j,0,i)
		{
			_C[i][j] %= p;
			_C[i+1][j] += _C[i][j];
			_C[i+1][j+1] += _C[i][j];
		}
	ll ans = 0;
	re(i,1,B)
	{
		re(j,1,B-i)
				( ans += C(B-1,i-1)*C(B-i-1,j-1)%p * C( A-2*B+2*i+j+2,2 ) )%=p;
		//( ans += C(B-1,i-1) *  )
	}
	ans += A+1;
	printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 194048
n = map(int, input().split())
a, b = map(int, input().split())
p = sorted(list(map(int, input().split())))
ans1 = sum(map(lambda x: (1 if x <= a else 0), p))
ans2 = sum(map(lambda x: (1 if a+1 <= x <= b else 0), p))
ans3 = sum(map(lambda x: (1 if b+1 <= x else 0), p))
print(min(ans1, ans2, ans3))


Measured memory_bytes: 3060
N = gets.to_i
S = ?a * N
F = ->(i,j) {
  if i<N
    0.upto(j) {|k|
      S[i] = (?a.ord+k).chr
      j = k+1 if j <= k
      F[i+1,j]
    }
  else
    puts S
  end
}
F[0,0]

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

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

    ll i;
    for (i = 0; i < s.size(); i++) {
        if (s.at(i) != '1')
            break;
    }

    if (i == s.size() || i == k)
        cout << "1" << endl;
    else
        cout << s.at(i) << endl;    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

typedef long long ll;

using namespace std;
int main(){
    int h,w;cin >> h >> w;
    char b[102][102];
    for(int i=0;i<h+2;i++){
        for(int j=0;j<w+2;j++){
            b[i][j]='#';
        }
    }
    for(int i=1;i<h+1;i++){
        for(int j=1;j<w+1;j++){
            cin >> b[i][j];
        }
    }
    for(int i=0;i<h+2;i++){
        for(int j=0;j<w+2;j++){
            cout << b[i][j];
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a[10000],k,l;
    l =0; 
    while(1){
        scanf("%d",&k);

        if(k == 0){ 
            break;
        }   

        a[l]=k;
        l++;
    }   

    for(k=0;k<l;k++){
        printf("Case %d: %d\n",k+1,a[k]);
    }   
}

Measured memory_bytes: 2648
/*
    Created by Ezio112
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
ll inf(1e18);
#define mod ll(1e9+7)
//#define mod ll(998244353)
#define ff first
#define ss second
ll power(ll a,ll b)
{
	if(!b)
		return 1;
	ll dp=power(a,b/2)%mod;
	
	if(b&1) return (((dp*dp)%mod)*a)%mod;
	
	return (dp*dp)%mod;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll test=1;
    //cin>>test;

    while(test--)
    {
		ll n,prod(1);
		cin>>n;
		vector<ll> vec(n);
		for(ll &x:vec)
			cin>>x;
		bool zero=false;
		for(ll x:vec) 
		{
			if(!x)
			{
				zero=true;
				break;
			}
		}
		if(zero)
		{
			cout<<0;
			return 0;
		}
		
		for(ll i=0;i<n;++i)
		{
			if(prod>inf/vec[i])
			{
				cout<<-1;
				return 0;
			}
			else prod*=vec[i];
		}
		cout<<prod;
	}
	return 0;
}


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define in2(x, y) int x,y;cin>>x>>y
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 100002
#define lim9 1000000002

#define deg(rad) (((rad)/2/M_PI)*360)
#define pow(x) (x)*(x)

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

	rep(i, s.length()) {
		s[i] += n;
		if (s[i] > 'Z') s[i] -= 26;
	}

	out(s);

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            decimal L = decimal.Parse (Console.ReadLine ());

            Console.Write (L * L * L / 27);
        }
    }

    class MyLibrary
    {
        public static int GCD (int a, int b)
        {
            if (a % b == 0) return b;
            return GCD (b, a % b);
        }
    }
}

Measured memory_bytes: 27516
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

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

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


int main(void) {
	string a, s, b;

	cin >> a >> s >> b;

	cout << 'A'<<  s[0] << 'C' << endl;



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll ab[2];
  ll cd[2];
  rep(i, 2) cin >> ab[i];
  rep(i, 2) cin >> cd[i];
  ll maxval = -INF;

  rep(i, 2)
    rep(j, 2)
      chmax(maxval, ab[i] * cd[j]);

  cout << maxval << endl;

  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {

	int a,b;
	int c,d,e,max;

		cin >> a >> b;

		c=a+b;
		d=a-b;
		e=a*b;

		if(c<d && e<d)
			max=d;
		else if(d<c && e<c)
			max=c;
		else if(c<e && d<e)
		  max=e;
		
			
		cout << max << endl;
	
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>

int n;
double x;

int main() {
	scanf("%d", &n);
	for(int i=0;i<n;i++) {
		int a; scanf("%d", &a);
		x += 1./a;
	}
	
	printf("%.10lf\n", 1/x);
	
	return 0;
}

Measured memory_bytes: 128