akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    string s;
    cin >> n >> s;
    vector<int> westCum(n + 1);
    rep(i, n)
    {
        int add = s.at(i) == 'W' ? 1 : 0;
        westCum[i + 1] = add + westCum[i];
    }

    // view(westCum);
    vector<int> flips(n);
    rep(i, n)
    {
        int d = n - i - 1;
        int easts = d - (westCum[n] - westCum[i + 1]);
        flips[i] = westCum[i] + easts;
    }
    int ans = INT32_MAX;
    rep(i, n)
    {
        ans = min(ans, flips[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3076
use std::io;
fn main(){
    let mut s=String::new();
    let mut t=String::new();
    io::stdin().read_line(&mut s).ok();
    io::stdin().read_line(&mut t).ok();
    let vs:Vec<char>=s.as_str().chars().collect();
    let vt:Vec<char>=t.as_str().chars().collect();
    let mut cnt:i32=0;
    for i in 0..vs.len(){
        if vs[i]!=vt[i]{cnt+=1;}
    }
    println!("{}",cnt);
    }


Measured memory_bytes: 4008
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL =LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

ll bn[105][105];
void bin_prep(){int i,j;for(i=0;i<105;i++){for(j=0;j<=i;j++){if(j==0)bn[i][j]=1LL;else bn[i][j]=bn[i-1][j-1]+bn[i-1][j];}}}



int main() {
    ll n,p;cin>>n>>p;
    vLL A(n);cin>>A;
    
    ll even = 0;
    ll odd = 0;
    rep(i,n){
        if(A[i]%2==0)even++;
        else odd++;
    }
    
    bin_prep();
    
    ll ans = 0;
    if(p==0){
        for(auto i = 0; i<=odd; i+=2){//偶数個選ぶ
            ans += bn[odd][i];
        }
        ll temp = 0;
        for(auto i = 0; i<=even; i+=1){//偶数個選ぶ
           temp += bn[even][i];
        }
        ans *= temp;
    }
    
    if(p==1){
        for(auto i = 1; i<=odd; i+=2){
            ans += bn[odd][i];
        }
        ll temp = 0;
        for(auto i = 0; i<=even; i+=1){
            temp += bn[even][i];
        }
        ans *= temp;
    }
    
    cout<<ans<<endl;
    
    return 0;
}








Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main(){

	//match[i]:数iを作るのに必要なマッチの本数
	int match[11] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

	int N, M;
	vector<int> A;

	cin >> N >> M;
	for(int i = 0; i < M; i ++){
		int a;
		cin >> a;
		A.pb(a);
	}
	sort(A.begin(), A.end(), greater<int>());

	//dp[i]:マッチi本で作ることができる数の最大桁数
	int dp[10005];
	dp[0] = 0;
	for(int i = 1; i <= N; i ++){
		int dmax = -1000000;
		for(int j = 0; j < M; j ++){
			if(i >= match[A[j]]){
				if(dp[i - match[A[j]]] >= 0){
					dmax = max(dmax, dp[i - match[A[j]]] + 1);
				}
			}
		}
		dp[i] = dmax;
	}
	int availableMatch = N;
	string ANS = "";
	while(true){
		//cout << endl << availableMatch << endl;
		for(int i = 0; i < M; i ++){
			if(availableMatch - match[A[i]] >= 0){
				if(dp[availableMatch - match[A[i]]] == dp[availableMatch] - 1){
					ANS.pb(A[i] + '0');
					availableMatch = availableMatch - match[A[i]];
					break;
				}
			}
		}
		if(availableMatch <= 0){
			//cout << endl << availableMatch << endl;
			break;
		}
	}
	cout << ANS << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

/*

*/

ll n,k,h[100010],ans=1e12;

int main(void){
	cin>>n>>k;
	rep(i,n)cin>>h[i];
	sort(h,h+n);
	rep(i,n){
		if(i+k-1>=n)break;
		ans=min(ans,h[i+k-1]-h[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(void){
  int n,m,x;scanf("%d %d %d",&n,&m,&x);
  vector<ll> a(m);for(int i = 0;i < m;i++)scanf("%lld",&a[i]);
  int cnt = 0;
  for (int i = 0; i < m; ++i)
  {
    if(a[i] < x)cnt++;
  }
  cout << min(cnt,m-cnt) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i,j;
	for(i = 1;i <= 9;i++)
	{
		for(j = 1;j <= 9;j++)
		{
			printf("%dx%d=%d\n",i,j,i*j);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define        ll          long long int
#define        sz          200010
#define        fast        ios_base :: sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define        sc1(a)      scanf("%lld",&a)
#define        sc2(a,b)    scanf("%lld %lld",&a,&b)
#define        pb          push_back
#define        pn          printf("No\n")
#define        py          printf("Yes\n")
#define        op(a)       printf("%lld\n",a)

using namespace std;


ll num[sz];
map<ll,ll>mp;

int main()
{
    ll n,m,i,j,x,a,b,d,y,p,q;

    cin>>x;

    for(i=0; i<=200; i++)
    {
        for(j=0; j<=200; j++)
        {
            a=pow(i,5);
            b=pow(j,5);
            if(a-b==x)
            {
                cout<<i<<" "<<j<<endl;
                return 0;
            }

            a=pow(-i,5);
            b=pow(j,5);
            if(a-b==x)
            {
                cout<<-i<<" "<<j<<endl;
                return 0;
            }


            a=pow(i,5);
            b=pow(-j,5);
            if(a-b==x)
            {
                cout<<i<<" "<<-j<<endl;
                return 0;
            }



            a=pow(-i,5);
            b=pow(-j,5);
            if(a-b==x)
            {
                cout<<-i<<" "<<-j<<endl;
                return 0;
            }


        }
    }


    return 0;
}



Measured memory_bytes: 4060
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string S;
	cin >> S;

	int ai = INF, zi = 0;
	rep(i, 0, SZ(S))
	{
		if (S[i] == 'A')
		{
			chmin(ai, i);
		}
		else if (S[i] == 'Z')
		{
			chmax(zi, i);
		}
	}

	cout << zi - ai + 1 << endl;

	return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
cout.tie(0);
cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    long h[n];
    long sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    sort(h,h+n);
    if(k>=n)
    {
    cout<<0;
    return 0;
    }
    for(int i=n-1-k;i>=0;i--)
    {
        sum+=h[i];
    }
    cout<<sum;
}


Measured memory_bytes: 1792
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll mod = 1000000000+7;
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
      if (n & 1) res = res * a % mod;
      a = a * a % mod;
      n >>= 1;
  }
  return res;
}

int main() {
    ll n,b[110];
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> b[i];
    }
    vector<ll> result;
    bool used[110];
    Fill(used,false);
    
    for (int i = 0; i < n; i++) {
        // nowはn-iまで
        ll now = 1;
        ll now_index = 0;
        ll kesu_koho = -1;
        while(now_index<n && now <= n-i){
            if(used[now_index]){
                now_index++;
            }else{
                if( b[now_index] == now ){
                    kesu_koho = now_index;
                }
                now++;
                now_index++;
            }
        }
        if(kesu_koho != -1){
            used[kesu_koho] = true;
            result.push_back(b[kesu_koho]);
        }else{
            std::cout << -1 << std::endl;
            return 0;
        }
    }
    
    for (int i = 0; i < result.size(); i++) {
        std::cout << result[result.size()-1-i] << std::endl;
    }
}


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

int main()
{
	int N, A, B;
	cin >> N >> A >> B;

	int count = 0;
	for (int i = 1; i <= N; i++) {
		int n = i;
		int nn = 0;
		while (n > 0) {
			nn += n % 10;
			n = n / 10;
		}
		if (nn >= A && nn <= B) {
			count += i;
		}
	}
	cout << count << endl;
	return 0;
}


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

int main()
{
  while (true)
  {
    int n, y;
    cin >> n;
    if (!n)
    {
      return 0;
    }
    cin >> y;

    int mb = 0;
    double mr = 0;
    for (int i=0; i<n; i++)
    {
      int b, r, t;
      cin >> b >> r >> t;

      double rate;
      if (t == 1)
      {
	rate = 1 + y*r/100.0;
      }
      else
      {
	rate = pow((1+r/100.0), y);
      }

      if (rate > mr)
      {
	mr = rate;
	mb = b;
      }
    }

    cout << mb << endl;
  }
}

Measured memory_bytes: 1164
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll i,t,x;
    string s;
    //set + string Lexi_sort succesfully
    pair<pair<string,ll>,ll>restu[150];
    cin>>t;
    for(i=0;i<t;i++){
    cin>>s>>x;
    restu[i]=make_pair(make_pair(s,-x),i+1);
    }
    sort(restu,restu+t);
    for(i=0;i<t;i++){

        cout<<restu[i].second<<endl;

    }


    return 0;
}





Measured memory_bytes: 3616
import java.util.*;

class Main{
   public static void main(String[] args)
   {
      Scanner scan = new Scanner(System.in);
      int     N    = scan.nextInt();
      long    X    = scan.nextLong();
      long    Y    = scan.nextLong();

      long[] A = new long[N];

      for(int i = 0; i < N; i++){
          A[i] = scan.nextLong();
          }
      long max = A[0];
      if(A.length != 1){
         for(int i = 1; i < N; i++){
             max = Math.max(A[i - 1], A[i]);
             }
         }
      max = Math.max(max, Y);
      long score = 0;
      if(A.length == 1){
         score = Math.abs(A[0] - Y);
         }
      else{
          score = Math.max(Math.abs(Y - A[N - 1]), Math.abs(A[N - 2] - A[N - 1]));
          }
      System.out.println(score);
   }
}


Measured memory_bytes: 27240
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>
#define inf 0x3f3f3f3f
#define MN 200005
using namespace std;
inline int in(){
    int x=0;bool f=0; char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
struct st{
	int x,y,c;
}a[MN];
struct edge{
	int to,nxt,col;
}e[MN<<1];
int q[MN<<1],h[MN],dis[MN],pos[MN],clr[MN];
int n,m,cnt=1,col,hd,tl,tot;
vector<int> vc[MN],vc2[MN];
bool vis[MN],vic[MN];
set<int> sc[MN];
inline bool cmp(st x,st y){return x.c<y.c;} 
inline void ins(int x,int y,int c){
	e[++cnt].to=y;e[cnt].nxt=h[x];h[x]=cnt;e[cnt].col=c;
}
inline void dfs(int u,int c){
	vc2[c].push_back(u); 
	for (int i=h[u];i;i=e[i].nxt){
		int v=e[i].to;clr[(i>>1)+hd-1]=c;
		if (!vis[v]) vis[v]=1,dfs(v,c);
	}
}
inline void bfs(int s){
	memset(dis,0x3f,sizeof(dis));
	memset(vis,0,sizeof(vis));
	int H=1,T=0,sz=0;
	dis[s]=0;vis[s]=1;q[++T]=s;
	while (H<=T){
		int u=q[H];H++;
		for (int i=h[u];i;i=e[i].nxt){
			int v=e[i].to,cl=e[i].col;
			if (vic[cl]) continue;
			vic[cl]=1;sz=vc2[cl].size();
			for (int j=0;j<sz;++j)
			if (!vis[vc2[cl][j]]){
				vis[vc2[cl][j]]=1;
				dis[vc2[cl][j]]=dis[u]+1;q[++T]=vc2[cl][j];
			}
		}
	}
}
int main()
{
	n=in();m=in();
	for (int i=1;i<=m;++i){
		a[i].x=in();a[i].y=in();a[i].c=in();
		if (!pos[a[i].c]) pos[a[i].c]=(++tot);a[i].c=pos[a[i].c]; 
		if (!sc[a[i].c].count(a[i].x))
		sc[a[i].c].insert(a[i].x),vc[a[i].c].push_back(a[i].x);
		if (!sc[a[i].c].count(a[i].y))
		sc[a[i].c].insert(a[i].y),vc[a[i].c].push_back(a[i].y); 
	}sort(a+1,a+m+1,cmp);hd=1,tl=0;
	while (hd<=m){
		if (hd>tl||a[tl+1].c==a[tl].c){
			++tl;ins(a[tl].x,a[tl].y,a[tl].c);ins(a[tl].y,a[tl].x,a[tl].c);
		}else{
			int siz=vc[a[tl].c].size();
			for (int j=0;j<siz;++j) if (!vis[vc[a[tl].c][j]]){
				vis[vc[a[tl].c][j]]=1;dfs(vc[a[tl].c][j],(++col));
			}cnt=1;
			for (int j=0;j<siz;++j) h[vc[a[tl].c][j]]=0,vis[vc[a[tl].c][j]]=0;
			hd=tl+1;
		}
	}cnt=1;memset(e,0,sizeof(e));
	for (int i=1;i<=m;++i) ins(a[i].y,a[i].x,clr[i]),ins(a[i].x,a[i].y,clr[i]);
	bfs(1);printf("%d",(dis[n]==inf)?-1:dis[n]);return 0;
}

Measured memory_bytes: 61824
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  
  vector<vector<char>> grid(H, vector<char>(W));
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> grid.at(i).at(j);
    }
  }
  
  // 残す行，列
  vector<bool> leave_row(H, false);
  vector<bool> leave_col(W, false);
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (grid.at(i).at(j) == '#') {
        leave_row.at(i) = true;
        leave_col.at(j) = true;
      }
    }
  }
  
  for (int i = 0; i < H; i++) {
    if (leave_row.at(i)) {
      for (int j = 0; j < W; j++) {
        if (leave_col.at(j)) {
          cout << grid.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
}

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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 1e2 + 5;
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (fopen("VLJUM.INP", "r")){
                freopen("VLJUM.INP", "r", stdin);
                freopen("VLJUM.OUT", "w", stdout);
        }
        ll n, cnt = 0;
        cin >> n;
        queue<ll> pq;
        for (int i = 1; i <= 9; i++){
                pq.push(i);
        }
        while (true){
                ll now = pq.front();
                pq.pop();
                cnt++;
                if (cnt == n) {
                        cout << now;
                        return 0;
                }
                for (int i = 0; i < 10; i++){
                        if (abs((now % 10) - i) <= 1){
                                pq.push(now * 10 + i);
                        }
                }
        }
}
/*
*/


Measured memory_bytes: 1792
S = input()

def check() :
    if S[0] != 'A' or S[2:-1].count('C') != 1 :
        return 'WA'
    
    ret = 0
    for s in S :
        if ord(s) < 97 or 122 < ord(s) :
            ret += 1
            
    if ret != 2 :
        return 'WA'
        
    return 'AC'
    
print(check())

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

int main(void)
{
    string x;
    cin>>x;
    int cnt=0;
    for(int i=0;i<3;++i)
    {
        if(x[i]=='1')
        {
            cnt++;
        }
    }
    cout <<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

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

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

template <class T>
ostream& operator << (ostream& out, vector<vector<T>> &v)
{
	for (vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, vector<T> &v)
{
	for (T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
#define per(i,b,a) for (int i = b; i > a; i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

int k;

ll f(vector<string> g)
{
	ll ans = INT_MAX;
	rep(mask, 0, (1 << (g.size() - 1)))
	{
		ll cur_ans = bitset<20>(mask).count();
		vi v(g.size()), pre(g.size());
		bool found_ans = true;
		rep(l,0,g[0].size())
		{
			int index = 0;
			rep(i,0,g.size())
			{
				if(i and ((mask >> (i - 1)) & 1))
					index++;
				v[index] += (g[i][l] == '1');
			}
			bool cut = false;
			for(int x : v)
				if(x > k)
					cut = true;
			if(cut)
			{
				rep(i,0,v.size())
					v[i] -= pre[i];
				cur_ans++;
			}
			for(int x : v)
				if(x > k)
				{
					found_ans = false;
					break;
				}
			if(!found_ans)
				break;
			pre = v;
		}
		if(!found_ans)
			continue;
		// cerr << cur_ans << '\n';
		ans = min(ans, cur_ans);
	}
	return ans;
}

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	ll h, w;
	cin >> h >> w >> k;
	vector<string> v(h);
	cin >> v;
	cout << f(v);
}


Measured memory_bytes: 256
def main():
  n, m = map(int, input().split())
  s = input()
  mem = set()
  base = ord("a") - 1
  mod1 = 1000000007
  mod2 = 2147483647
  h1 = [0]
  h2 = [0]
  for c in s:
    h1.append((h1[-1] * 27 + ord(c) - base) % mod1)
    h2.append((h2[-1] * 27 + ord(c) - base) % mod2)
  pow_mem1 = {0:1}
  pow_mem2 = {0:1}
  def my_pow1(x):
    if x in pow_mem1:return pow_mem1[x]
    pow_mem1[x] = my_pow1(x - 1) * 27 % mod1
    return pow_mem1[x]

  def my_pow2(x):
    if x in pow_mem2:return pow_mem2[x]
    pow_mem2[x] = my_pow2(x - 1) * 27 % mod2
    return pow_mem2[x]
  
  left = right = 1
  for _ in range(m):
    com = input()
    if com == "L++":
      left += 1
    if com == "L--":
      left -= 1
    if com == "R++":
      right += 1
    if com == "R--":
      right -= 1
    x = (h1[right] - h1[left - 1] * my_pow1(right - left + 1)) % mod1
    y = (h2[right] - h2[left - 1] * my_pow2(right - left + 1)) % mod2
    mem.add((x, y))

  print(len(mem))

main()


Measured memory_bytes: 135012
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Poll
 */

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

/* constant */

const int MAX_N = 200000;

/* typedef */

typedef map<string,int> msi;

/* global variables */

msi smap;
string ss[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    char s[16];
    scanf("%s", s);
    smap[string(s)]++;
  }

  int m = 0, maxc = 0;
  for (msi::iterator mit = smap.begin(); mit != smap.end(); mit++) {
    int c = mit->second;
    if (maxc < c) maxc = c, m = 0, ss[m++] = mit->first;
    else if (maxc == c) ss[m++] = mit->first;
  }

  for (int i = 0; i < m; i++) puts(ss[i].c_str());
  return 0;
}


Measured memory_bytes: 25344
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct pair{
    int x, y;
    struct pair *next;
};

int board[51][51];
int check[51][51];
int w, h;
int ans;
int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int dy[8] = {1, 1, 1, 0, 0, -1, -1, -1};

struct pair *top, *bot;

void push(int a, int b);
void bfs();
int check_board(int a, int b);

int main(void)
{
    int i, j;
    scanf("%d %d",&w, &h);
    while (w != 0 && h != 0) {
        ans = 0;
        top = NULL;
        bot = NULL;
        for (i = 0; i < h; i++) {
            for (j = 0; j < w; j++) {
                scanf("%d",&board[i][j]);
                check[i][j] = 0;
            }
        }

        /*for (i = 0; i < h; i++) {
          for (j = 0; j < w; j++) {
          printf("%d",board[i][j]);
          }
          puts("");
          } */

        for (i = 0; i < h; i++) {
            for (j = 0; j < w; j++) {
                if (check[i][j] == 0 && board[i][j] == 1) {
                    check[i][j] = 1;
                    push(i, j);
                    bfs();
                    ans++;
                }
            }
        }
        printf("%d\n",ans);
        scanf("%d %d",&w, &h);
    }
    return 0;
}

void bfs() 
{
    struct pair *now;
    int i;
    now = bot;
    while (now != NULL) {
        //printf("%d %d\n",now->x, now->y);
        for (i = 0; i < 8; i++) {
            if (check_board(now->x+dx[i], h) && 
                    check_board(now->y+dy[i], w) ) {
                if (board[now->x+dx[i]][now->y+dy[i]] == 1 && 
                        check[now->x+dx[i]][now->y+dy[i]] == 0) {
                    check[now->x+dx[i]][now->y+dy[i]] = 1;
                    push(now->x+dx[i], now->y+dy[i]);
                }
            }
        }
        now = now->next;
    }
}

void push(int a, int b)
{
    struct pair *new;
    new = (struct pair *)malloc(sizeof(struct pair));
    new->x = a;
    new->y = b;
    new->next = NULL;
    if (bot == NULL) {
        bot = new;
        top = new;
    } else {
        top->next = new;
        top = new;
    }
}

int check_board(int a, int b)
{
    if (a < 0 || b <= a) {
        return 0;
    } else {
        return 1;
    }
}

Measured memory_bytes: 860
n,x=map(int,input().split())
a=list(map(int,input().split()))
count=0
a.sort()
for i in range(n):
    x-=a[i]
    if x>0:
        count+=1
    elif x==0:
        count+=1
        print(count)
        exit()
    else:
        print(count)
        exit()
print(count-1)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(){

  int n,y;
  int i,j,k;
  int cnt = 0;
  int flag = 0;

  scanf("%d %d", &n, &y);

  for(i = 0;i <= n;i++){
    for(j = 0;j <= n - i;j++){
      for(k = 0;k <= n - i - j;k++){
        if((k*10000 + j*5000 + i*1000) == y && (i + j + k) == n){
          printf("%d %d %d\n", k, j, i);
          flag = 1;
          break;
        }
      }
        if(flag == 1) break;
    }
    if(flag == 1) break;
  }

  if(flag == 0) printf("-1 -1 -1\n");

  return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int P[10010];

void init(int N)
{
    for (int i = 0; i < N; i++) P[i] = i;
}

int root(int a)
{
    if (P[a] == a)  return a;
    return (P[a] = root(P[a]));
}

bool is_same_set(int a, int b)
{
    return root(a) == root(b);
}

void unite(int a, int b)
{
    P[root(a)] = root(b);
}

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

    vector<tuple<int, int, int>> pr;
    int a;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a;
            if (a != -1 && i <= j) {
                pr.push_back(make_tuple(a, i, j));
            }
        }
    }

    sort(pr.begin(), pr.end());
    init(n);
    int cost = 0;

    for (int i = 0; i < pr.size(); i++) {
        int& a = get<1>(pr[i]);
        int& b = get<2>(pr[i]);

        if (!is_same_set(a, b)) {
            unite(a, b);
            cost += get<0>(pr[i]);
        }
    }
    cout << cost << endl;
}



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

public class Prime{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
         
        var primeFactors = PrimeFactors(n);
        //primeFactors.Dump();
         
        string output = primeFactors.Count() == 0 
                        ? n.ToString() 
                        : string.Join(" ", primeFactors.Select (f => f.ToString()).ToArray()); //AOJ??¨
                        //:string.Join(" ", primeFactors);
        Console.WriteLine("{0}: {1}", n, output);
    }
     
    public static IEnumerable<int> PrimeFactors(int n)
    {
        int i = 2;
        int tmp = n;
         
        while (i <= n)
        {
            if(n % i == 0){
                n /= i;
                yield return i;
            }else{
                i++;
            }
             
            if(i > Math.Sqrt(tmp)){
                i = int.MaxValue; //???????????????
                yield return n;
            }
        }
    }
}

Measured memory_bytes: 20324
def inpl(): return [int(i) for i in input().split()]
import numpy as np
N, x = inpl()
a = np.array(inpl())
b = np.copy(a)
ans = float('inf') 
for i in range(N):
    c = np.roll(a,i)
    b = np.minimum(b,c)
    ans = min(ans, sum(b)+i*x)
print(ans)

Measured memory_bytes: 12508
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  ll x, k, d; cin >> x >> k >> d;
  if (x < 0) x = -x;
  ll need = min(x / d, k);
  x -= need * d;
  k -= need;
  cout << (k % 2 == 0 ? x : d - x) << '\n';
  return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  rep(i,M){
    int A;
    cin >> A;
    N -= A;
  }
  if(N >= 0) cout << N << endl;
  else cout << -1 << endl;
}


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

int main() {

    int p, q, r;
    cin >> p >> q >> r;

    cout << p+q+r - max({p, q, r}) << endl;

    return 0;
}

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

int main () {
    string str;
    map<char,char> c;
    c[']'] = '[';
    c[')'] = '(';
    while (getline(cin,str), str != ".") {
        stack<char> s;
        bool flag = true;
        for (int i = 0; flag && i < str.size(); i++) {
            if (string("[()]").find(str[i]) == string::npos) continue;
            if (string("[(").find(str[i]) != string::npos) {
                s.push(str[i]);
            }
            else if (string("])").find(str[i] != string::npos)) {
                if (s.size() == 0) flag = false;
                else if (c.find(str[i]) != c.end() && c[str[i]] == s.top()) s.pop();
                else if (c.find(str[i]) != c.end() && c[str[i]] == s.top()) s.pop();
                else flag = false;
            }
        }

        cout << (flag && !s.size() ? "yes" : "no") << endl;
    }
}

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

int main()
{
	char c[4], a = 'A';

	while (cin >> c) {
		if (a == c[0])
			a = c[2];
		else if (a == c[2])
			a = c[0];
	}

	cout << a << endl;

	return 0;
}


Measured memory_bytes: 3056
/* AOJ0001 */
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
  int h, most[10];
  for(int i = 0 ; i < 10 ; i++ ){
    cin >> most[i];
  }
  sort(most,most + 10, greater<int>());
  for(int i = 0 ; i < 3 ; i++ ){
    cout << most[i] << endl;
  }
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main()
{
    int n;
    double d;
    cin>>n>>d;
    int cnt=0;
    double x,y;
    for(int i=0;i<n;i++) {
        cin>>x>>y;
        double p=sqrt(x*x+y*y);
        if(p<=d) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 3840
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	string s;
	int x=0,n;
	cin >> s;
	rep(i, s.size())
		x += s[i] - '0';
	n = stoi(s);
	if (n % x == 0)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1000000000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repM(i, n) for (int i = n; i > 0; i--)

int main() {
    string S;
    cin >> S;
    rep(i,3){
        if(S[i]=='7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(void) {
	// input integer
	int a, b, c;
	cin >> a >> b >> c;
	// judge small leage
	string result = "Yes";
	if (a >= b || b >= c) {
		result = "No";
	}
	// output
	cout << result << endl;
	return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cerr << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int maxn = 100010;
const int INF = TEN(9);

V<int> g[maxn];
int r;

int dfs(int v, int p, int l) {
	V<int> vec;
	for (int to : g[v]) if (to != p) {
		int res = dfs(to, v, l);
		if (res == -1 || res > l) {
			return -1;
		}
		vec.pb(res);
	}
	sort(ALL(vec));
	int sz = vec.size();

	if (sz % 2 == 0) {
		{
			//all
			int nl = 0, nr = sz - 1;
			bool f = 1;
			rep(i, sz / 2) {
				if (vec[nl] + vec[nr] > l) {
					f = 0;
				}
				++nl; --nr;
			}
			if (f) {
				return 1;
			}
		}
		vec.pop_back();
		--sz;		
	}

	//sz : odd

	auto valid = [&](int p) {
		int nl = 0, nr = sz - 1;
		bool f = 1;

		rep(i, sz / 2) {
			if (nl == p) ++nl;
			if (nr == p) --nr;
			if (vec[nl] + vec[nr] > l) {
				f = 0;
			}
			++nl; --nr;
		}
		return f;
	};

	int lo = 0, hi = sz - 1;
	if (valid(lo)) {
		hi = 0;
	}
	if (!valid(hi)) {
		return -1;
	}

	while (hi - lo > 1) {
		int m = (lo + hi) / 2;
		if (valid(m)) hi = m;
		else lo = m;
	}
	return vec[hi] + 1;
}

bool ok(int l) {
	int res = dfs(r, -1, l);
	return (res != -1);
}

int main() {
	int N; cin >> N;
	rep(i, N-1) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].pb(b); g[b].pb(a);
	}

	rep(i, N) if (g[i].size() == 1) {
		r = i;
		break;
	}

	int A = 0;
	rep(i, N) if (g[i].size() % 2 == 1) ++A;

	int lo = 0, hi = N;
	while (hi - lo > 1) {
		int m = (lo + hi) / 2;
		if (ok(m)) {
			hi = m;
		} else {
			lo = m;
		}
	}

	printf("%d %d\n", A / 2, hi);
	return 0;
}

Measured memory_bytes: 16768
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


string solve(string s,string t){
    int LCS[sz(s)+10][sz(t)+10];
    rep(i,sz(s)+10) rep(j,sz(t)+10) LCS[i][j] = 0;
    rep1(i,sz(s)) rep1(j,sz(t)){
        if(s[i-1]==t[j-1]) LCS[i][j] = max({LCS[i-1][j-1]+1, LCS[i][j-1], LCS[i-1][j]});
        else LCS[i][j] = max({LCS[i-1][j-1], LCS[i-1][j], LCS[i][j-1]});
    }
    string ans = "";
    int i = sz(s), j = sz(t);
    while(i && j){
        if(LCS[i][j] == LCS[i-1][j]) --i;
        else if(LCS[i][j] == LCS[i][j-1]) --j;
        else ans += s[i-1], --i, --j;
    }
    reverse(ALL(ans));
    return ans;
    
}

int main(){
    string s, t;
    cin >> s >> t;
    cout << solve(s,t) << endl;
}

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

using namespace std;
long long n,minn=1e15+1;
int main()
{
    //freopen("C.INP" ,"r",stdin);
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    //cout << ceil(1.3) << " " << floor(1.4) << "\n";
    cin >> n;
    for (int i=1;i<=5;i++)
    {
        long long t;
        cin >> t;
        minn=min(t,minn);

    }
    if (n<=minn) cout << 5;
    else cout << 5+ (long long)ceil((double)(n-minn)/(double)minn);

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int llu;
typedef long double ld;
typedef float fl;
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pair<int,int>>
#define pb push_back
#define pf push_front
#define mp map<ll,ll>
#define INF 1000000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
ll gcd(ll a,ll b)
{
    if(a==0)
    {
        return b;
    }
    else
    {
        return gcd(b%a,a);   
    }
}
ll lcm(ll a,ll b)
{
    return a*b/gcd(a,b);
}
int f(char c)
{
    return (int)c-96;
}
/**********************************************************************
***********************************************************************
*********************ACTUAL CODE BEGINS HERE***************************/
int main()
{   
    fast;
    ll i;
    ll n;
    cin>>n;
    ll x=0;
    for(i=1;i<=999999;i++)
    {
       x=((x%n)*(10%n)+(7%n))%n;
       if(x%n==0)
       {
           cout<<i;
           return 0;
       }
    }
    cout<<-1;
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

string s;
long a[15][15];
long longpow(long a, long b) {
	long ans = 1;
	for (int i = 0;i < b;i++) {
		ans *= a;
	}
	return ans;
}

int main() {
	cin >> s;
	a[0][0] =longpow((long)2, (long)s.size()-1);
	for (int i = 1;i < s.size();i++) {
		for (int j = 0;j <= i;j++) {
			if (i - j == 0)a[i][j] = a[i - 1][j - 1] / 2;
			else if (i - j == 1)a[i][j] = a[i - 1][j] / 2;
			else a[i][j] = a[i - 1][j];
		}
	}
	reverse(s.begin(), s.end());
	long ans = 0;
	for (int i = 0;i < s.size() ;i++) {
		for (long j = 0;j <= i;j++) {
			ans += (long)longpow((long)10, j)*a[i][j] * (long)(s[i] - '0');
		}
	}
	cout << ans << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>

namespace TokorotenLab
{
    /*
    Arguments:
        Search range: [begin, end)
        Target function: f(x)
    Requirement:
        f(x) => { false, ..., false, true, ..., true }
    Judge:
        true_bound == begin => All f(x) are true
        true_bound == end => All f(x) are false
    */
    std::pair<long long, long long> binary_search(long long begin, long long end, std::function<bool(long long)> f)
    {
        long long false_bound = begin - 1LL; // ( ..., false_bound] => false
        long long true_bound = end; // [true_bound, ... ) => true
        long long x;

        while(true_bound - false_bound > 1LL)
        {
            x = false_bound + (true_bound - false_bound) / 2LL;
            if(f(x))
            {
                true_bound = x;
            }
            else
            {
                false_bound = x;
            }
        }

        return std::make_pair(false_bound, true_bound);
    }
}

using namespace std;

#define int long long

signed main()
{
    int a, b;

    cin >> a >>  b;

    if((a + b) % 2 != 0) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    cout << (a + b) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.array;

void main()
{
    int N = readln.split[0].to!int;
    int[] H = readln.split.to!(int[]);

    int max = 0;
    int ans = 0;
    foreach (h; H){
        if (h >= max){
            ans++;
            max = h;
        }
    }

    writeln(ans);
}



Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    k = int(input())
    res = []

    def dfs(x):
        res.append(x)
        if len(str(x)) == 10:
            return

        for i in range(10):
            if abs(x % 10 - i) <= 1:
                dfs(x * 10 + i)

        return

    for i in range(1, 10):
        dfs(i)
    res.sort()
    print(res[k - 1])


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 12348
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,dp[100000];
	cin>>n;
	fill(dp,dp+n,1);
	for(int i=0;i<n;i++){
		cin>>a;
		*upper_bound(dp,dp+n,-a)=-a;
	}
	cout<<lower_bound(dp,dp+n,1)-dp<<endl;
}


Measured memory_bytes: 640
from collections import Counter,defaultdict,deque
import sys
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
    
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n=inp()
    ab=[]
    for _ in range(n):
        x,y=inpm()
        ab.append((x+y,x,y))
    ab.sort(reverse=True)
    pa=0
    pb=0
    for i in range(n):
        if i%2 == 0:
            pa+=ab[i][1]
        else:
            pb+=ab[i][2]
    print(pa-pb)

if __name__ == "__main__":
    main()

Measured memory_bytes: 63320
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int a,b,c; cin >> a >> b >> c;
    cout << min(a+b,min(b+c,c+a)) << endl; return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k,a,b,c;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            c=1;
            break;
        }else{ c=0;}
        
        }if(c==1){
            cout<<"OK";
            
        }else{
            cout<<"NG";
        }
       
    }


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

int main(void) {
   long long dp[10010];
   int n, m;
   int v, w, k=0, sum=0;
   cin >> n >> m;
   dp[0] = 0;
   for(int i=1; i<=10000; i++) dp[i] = 1000000010;
   
   for (int j = 0; j < n; j++){
       cin >> v >> w;
       sum += v;
       for(int i=sum; i>=1; i--) if( i-v >=0 ) {
       dp[i] = min(dp[i], dp[i-v]+w);
       }
   }
   
   for(int i=sum; i>=1; i--){
       if(dp[i] <= m){
           k = i;    break;
       }
   }
   
   cout << k << endl;

   return 0;
}



Measured memory_bytes: 3180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

int main(){
  vector<string> text(200);
  int line = 0;
  for(;line<11;line++){
    getline(cin,text[line],'\n');
    if (text[line]=="END_OF_TEXT")
      break;
  }
  string buf="";
  int cur[2];
  cur[0] = 0;//0s
  cur[1] = 0;//0¶Ú

  while(true){
    char com;
    cin >> com;
    if (com == '-')
      break;
    switch (com){
    case 'a':
      cur[1] = 0;
      break;
    case 'e':
      cur[1] = (int)text[cur[0]].size();
      break;
    case 'p':
      if (cur[0]>0)
	cur[0]--;
      cur[1]=0;
      break;
    case 'n':
      if (cur[0]<line-1)
	cur[0]++;
      cur[1]=0;
      break;
    case 'f':
      if (cur[1]<(int)text[cur[0]].size()){
	cur[1]++;
      }
      else{
	if (cur[0]<line-1){
	  cur[0]++;
	  cur[1]=0;	
	}
      }
      break;
    case 'b':
      if (cur[1]>0)
	cur[1]--;
      else{
	if (cur[0]>0){
	  cur[0]--;
	  cur[1]=(int)text[cur[0]].size();	
	}
      }
      break;
    case 'd':
      if (cur[1]<(int)text[cur[0]].size()){
	text[cur[0]] = text[cur[0]].substr(0,cur[1])+text[cur[0]].substr(cur[1]+1);
      }
      else{
	if (cur[0]<line-1){
	  text[cur[0]] = text[cur[0]]+text[cur[0]+1];
	  for(int i=cur[0]+1;i<line+1;i++)
	    text[i] = text[i+1];
	  line--;
	}
      }
      break;
    case 'k':
      if (cur[1]==(int)text[cur[0]].size()){
	if (cur[0]<line-1){
	  text[cur[0]] = text[cur[0]]+text[cur[0]+1];
	  for(int i=cur[0]+1;i<line+1;i++)
	    text[i] = text[i+1];
	  line--;
	  buf = "\n";
	}
      }
      else{
	buf = text[cur[0]].substr(cur[1]);
	text[cur[0]] = text[cur[0]].substr(0,cur[1]);
	cur[1] = (int)text[cur[0]].size();
      }
      break;
    case 'y':
      if (buf.empty())
	break;
      else{
	if (buf == "\n"){
	  for(int i=line+1;i>=cur[0]+1;i--)
	    text[i+1] = text[i];
	  line++;
	  text[cur[0]+1] = text[cur[0]].substr(cur[1]);
	  text[cur[0]] = text[cur[0]].substr(0,cur[1]);
	  cur[0]++;
	  cur[1]=0;
	}
	else{
	  text[cur[0]] = text[cur[0]].substr(0,cur[1])+buf+text[cur[0]].substr(cur[1]);
	  cur[1] += buf.size();
	}
      }
    default:
      break;
    }
    /*         for(int i=0;i<line;i++)
	cout << text[i] << endl;
	cout << "(" << cur[0] << "," << cur[1] << ")" << endl;
	cout << "#" << endl;*/
  }
  for(int i=0;i<line;i++)
    cout << text[i] << endl;
  return 0;
}  

Measured memory_bytes: 0
str = gets.chomp
q = gets.to_i
q.times do
    command = gets.chomp.split(" ")
    if command[0] == "print"
        puts str[command[1].to_i..command[2].to_i]
    elsif command[0] == "reverse"
        a = command[1].to_i
        b = command[2].to_i
        prefix = a==0 ? "" : str[0..(a-1)]
        surfix = b==str.length-1 ? "" : str[(b+1)..(str.length-1)]
        str = prefix + str[a..b].reverse + surfix
    elsif command[0] == "replace"
        a = command[1].to_i
        b = command[2].to_i
        prefix = a==0 ? "" : str[0..(a-1)]
        surfix = b==str.length-1 ? "" : str[(b+1)..(str.length-1)]
        str = prefix + command[3] + surfix
    end
end



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

int main(){

	int n, y=0;
	cin >> n;
	int x = n;
	while(n > 0){
		y += n % 10;
		n /= 10;
	}
	string ans = "No";
	if(x % y == 0) ans = "Yes";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256