akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstring>
using namespace std;

int main(void){
  int w,h;
  while(cin>>h>>w,h){
    string f[h];
    for(int i=0;i<h;i++){
      cin>>f[i];
    }	
    int x,y;
    x=y=0;
    while(true){
      if(f[y][x]=='p'){
	cout<<"LOOP"<<endl;
	break;
      }
      if(f[y][x]=='.'){
	cout<<x<<" "<<y<<endl;
	break;
      }
      if(f[y][x]=='>') {
	f[y][x]='p';x+=1;}
      if(f[y][x]=='<') {
	f[y][x]='p'; x-=1;}
      if(f[y][x]=='^') {
	f[y][x]='p'; y-=1;}
      if(f[y][x]=='v') {
	f[y][x]='p'; y+=1;}
    }
	
    	
  }
	
}

Measured memory_bytes: 1232
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

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;
}

int main(){
    int h,n;
    cin >> h >> n;
    rep(i,n){
        int k;
        cin >> k;
        h-=k;
    }
    if(h<=0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll maxn=2e5+1;
ll a[maxn];
ll c[maxn]={0};
void solve()
{
	ll N;
	cin>>N;
	for(ll i=2;i<=N;i++)
	{
		cin>>a[i];
		c[a[i]]++;
	}
	for(ll i=1;i<=N;i++)
	{
		cout<<c[i]<<"\n";
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1,p=0;
	//cin>>T;
	do
	{
		solve();
		p++;
	}while(p<T);
	return 0;
}



Measured memory_bytes: 6784
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

struct HopcroftKarp {
  vector< vector< int > > graph;
  vector< int > dist, match;
  vector< bool > used, vv;

  HopcroftKarp(int n, int m) : graph(n), match(m, -1), used(n) {}

  void add_edge(int u, int v) {
    graph[u].push_back(v);
  }

  void bfs() {
    dist.assign(graph.size(), -1);
    queue< int > que;
    for(int i = 0; i < graph.size(); i++) {
      if(!used[i]) {
        que.emplace(i);
        dist[i] = 0;
      }
    }

    while(!que.empty()) {
      int a = que.front();
      que.pop();
      for(auto &b : graph[a]) {
        int c = match[b];
        if(c >= 0 && dist[c] == -1) {
          dist[c] = dist[a] + 1;
          que.emplace(c);
        }
      }
    }
  }

  bool dfs(int a) {
    vv[a] = true;
    for(auto &b : graph[a]) {
      int c = match[b];
      if(c < 0 || (!vv[c] && dist[c] == dist[a] + 1 && dfs(c))) {
        match[b] = a;
        used[a] = true;
        return (true);
      }
    }
    return (false);
  }

  int bipartite_matching() {
    int ret = 0;
    while(true) {
      bfs();
      vv.assign(graph.size(), false);
      int flow = 0;
      for(int i = 0; i < graph.size(); i++) {
        if(!used[i] && dfs(i)) ++flow;
      }
      if(flow == 0) return (ret);
      ret += flow;
    }
  }

  void output() {
    for(int i = 0; i < match.size(); i++) {
      if(~match[i]) {
        cout << match[i] << "-" << i << endl;
      }
    }
  }
};

void solve(){
    ll n;cin>>n;
    vl a(n),b(n),c(n),d(n);
    rep(i,n)cin>>a[i]>>b[i];
    rep(i,n)cin>>c[i]>>d[i];

    HopcroftKarp bm(n,n);
    rep(i,n)rep(j,n){
        if(a[i]<c[j]&&b[i]<d[j])bm.add_edge(i,j);
    }
    cout<<bm.bipartite_matching()<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}

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

    int N; cin >> N;
    int A[N];
    rep(i,N) cin >> A[i];
    int pos[N];
    rep(i,N) {
        pos[A[i]-1]=i;
    }
    set<int> s;
    int ans=0;
    rep(i,N) {
        s.insert(pos[i]);
        auto it=s.find(pos[i]);
        int a,b;
        if(it==s.begin()) a=pos[i]+1;
        else {
            it--;
            a=pos[i]-*it;
            it++;
        }
        it++;
        if(it==s.end()) b=N-pos[i];
        else {
            b=*it-pos[i];
            it--;
        }
        ans+=a*b*(i+1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 13304
#include<stdio.h>
#include<ctype.h>

int main(){
    char ch;
    
    while(1) {
        scanf("%c", &ch);
        if(ch=='\n'){
          break;
        }
        if(islower(ch)){
            printf("%c", toupper(ch));  //chが小文字なら大文字を返す
        }
        else if(isupper(ch)){
             printf("%c", tolower(ch));  //chhが大文字なら小文字を返す
        }
        else printf("%c", ch);   //それ以外の文字はそのまま印字
        
    }
    printf("\n");
    return 0;
}




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

//#define debug(...)   printf( __VA_ARGS__ )
#define debug(...)   /****nothing****/

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mem(arr,val)    memset(arr,val,sizeof(arr))
#define mp make_pair
#define pii pair<int,int>
#define F first
#define S second
#define sz(x) (int)(x).size()
#define nopos string::npos
#define fr(i,a,b) for(i=a;i<=b;i++)
#define frn(i,a,b) for(i=a;i>=b;i--)
#define MX 200007
int ans[MX],leftt[MX],rightt[MX],i,j,k,n,ar[MX],t;

int main()
{
    while(scanf("%d",&n)==1)
    {
        stack<int> stk;

        ll sum=0;

        fr(i,0,n-1)
         scanf("%d",ar+i) ,  rightt[i]=n , leftt[i]=-1 , ans[i+1]=0;

        fr(i,0,n-1)
         {
             while(!stk.empty() && ar[stk.top()]>ar[i])
                rightt[stk.top()]=i , stk.pop();

             stk.push(i);
         }

         while(!stk.empty())
            stk.pop();

        fr(i,0,n-1)
         debug("%d ",rightt[i]);

        debug("\n");

        frn(i,n-1,0)
         {
             while(!stk.empty() && ar[stk.top()]>ar[i])
                leftt[stk.top()]=i , stk.pop();

             stk.push(i);
         }

        while(!stk.empty())
            stk.pop();

        fr(i,0,n-1)
         debug("%d ",leftt[i]);

        debug("\n");

        fr(i,0,n-1)
             sum+=1LL*(i-leftt[i])*(rightt[i]-i)*ar[i];

        printf("%lld\n",sum);

    }



    return 0;
}







Measured memory_bytes: 4224
S = input()
if len(S) == 2:
    print([2,1][S[0] == S[1]])
    exit()
i = 1
ans = [S[0]]
hoge = ""
while i < len(S):
    hoge += S[i]
    if ans[-1] != hoge:
        ans.append(hoge)
        hoge = ""
    i += 1
print(len(ans))

Measured memory_bytes: 53600
c=input()
if c=='a':
    print('b')
elif c=='b':
    print('c')
elif c=='c':
    print('d')
elif c=='d':
    print('e')
elif c=='e':
    print('f')
elif c=='f':
    print('g')
elif c=='g':
    print('h')
elif c=='h':
    print('i')
elif c=='i':
    print('j')
elif c=='j':
    print('k')
elif c=='k':
    print('l')
elif c=='l':
    print('m')
elif c=='m':
    print('n')
elif c=='n':
    print('o')
elif c=='o':
    print('p')
elif c=='p':
    print('q')
elif c=='q':
    print('r')
elif c=='r':
    print('s')
elif c=='s':
    print('t')
elif c=='t':
    print('u')
elif c=='u':
    print('v')
elif c=='v':
    print('w')
elif c=='w':
    print('x')
elif c=='x':
    print('y')
elif c=='y':
    print('z')

Measured memory_bytes: 3064
a,b,c,d = map(int,input().split())
# 高橋君の倒すまでの攻撃回数
takahashi_turn = 0
# 青木君の倒すまでの攻撃回数
aoki_turn = 0
# 攻撃するたびに回数カウントして体力を減らす
while c - b > 0:
    takahashi_turn += 1
    c -= b
while a - d > 0:
    aoki_turn += 1
    a -= d
# 高橋くんが早く倒すときはYes
if takahashi_turn <= aoki_turn:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9100
#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;

int main(){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		string str;
		cin >> str;
		set<string> s;
		for(int i=1;i<(signed)str.size();i++){
			string s1 = str.substr(0,i);
			string s2 = str.substr(i);
			string s3 = string(s1.rbegin(),s1.rend());
			string s4 = string(s2.rbegin(),s2.rend());
			s.insert(s1+s2);
			s.insert(s3+s4);
			s.insert(s1+s4);
			s.insert(s3+s2);
			s.insert(s2+s1);
			s.insert(s4+s3);
			s.insert(s4+s1);
			s.insert(s2+s3);
		}
		cout << s.size() << endl;
	}
}

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

using namespace std ;

const int N = 1e5 + 10 ;
int n , a[N] , mem[N] ;


int go(int i){

    if(i == n - 1)
        return 0 ;

    else if(i > n - 1)
        return 2e9 ;

    if(mem[i] != -1)
        return mem[i] ;

    return mem[i] = min( go(i + 1) + abs(a[i] - a[i + 1]) , go(i + 2) + abs(a[i] - a[i + 2]) ) ;
}




int main(){
    scanf("%d" , &n) ;
    for(int i = 0 ; i < n ; i++){

        scanf("%d" , &a[i]) ;
        mem[i] = -1 ;
    }

    printf( "%d\n" , go(0) ) ;

}


Measured memory_bytes: 2560
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()
p = list(map(int, input().split()))

p = set(p)

if x in p:
  i = 1
  while True:
    if not (x - i in p):
      print(x-i)
      exit()
    if not (x + i in p):
      print(x+i)
      exit()
    i += 1
print(x)

Measured memory_bytes: 61656
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int ans = 0;
    int a[31][31] = {};
    rep(i, 0, n){
        int k;
        cin >> k;
        rep(j, 0, k){
            int b;
            cin >> b;
            b--;
            a[i][b] = 1;
        }
    }
    rep(i, 0, m){
        int cnt = 0;
        rep(j, 0, n){
            cnt += a[j][i];
        }
        if(cnt == n) ans++;
    }
    cout << ans << endl;
}

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

#define fi first
#define se second

const int N = 3030;
const long long mod = 1e9 + 9;

using namespace std;

string s, t;
int d[N][N];
int p[N][N];

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        cin >> s >> t;
        for(int i = 1; i <= s.size(); i++){
                for(int j = 1; j <= t.size(); j++){
                        if(s[i - 1] == t[j - 1]){
                                d[i][j] = d[i - 1][j - 1] + 1;
                                p[i][j] = 3;
                        }
                        else if(d[i - 1][j] > d[i][j - 1]){
                                d[i][j] = d[i - 1][j];
                                p[i][j] = 1;
                        }
                        else{
                                d[i][j] = d[i][j - 1];
                                p[i][j] = 2;
                        }
                }
        }
        string res = "";
        int n = s.size(), m = t.size();
        while(n && m){
                if(p[n][m] == 3){
                        res += s[n - 1];
                }
                int dif = p[n][m];
                if(dif & 1){
                        n -= 1;
                }
                if(dif & 2){
                        m -= 1;
                }
        }
        reverse(res.begin(), res.end());
        cout << res << "\n";
}



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

int main() {
  string S1; cin >> S1; // 入力文字列１
  string S2; cin >> S2; // 入力文字列２
  string S3; cin >> S3; // 入力文字列３
  cout << S1.at(0) << S2.at(0) << S3.at(0) << endl;
}



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

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

int main(){
  int n;
  cin >> n;
  vector<double> v;
  rep(i,n){
    double a;
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(),v.end());

  double sum = 0;
  for(int i=1; i<n; i++){
    v[i] = 0.5*(v[i]+v[i-1]);
  }
  printf("%.10g\n", v[n-1]);
  return 0;
}

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

#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)

const int maxN = 1e5 + 1;

int main() {
  FASTIO;
  int k;
  cin >> k;
  vector<string> v;
  //adj[0].push_back(1), adj[1].push_back(0), adj[1].push_back(2), adj[2].push_back(1);
  v.push_back("1"), v.push_back("2"), v.push_back("3"), v.push_back("4"), v.push_back("5"), v.push_back("6"), v.push_back("7");
  v.push_back("8"), v.push_back("9");
  int wtf = 0;
  string now = "";
  for (int i = 10; i < maxN; i++) {
    now = v[wtf];
    int n = (int) now.size();
    int aux = (now[n - 1] - '0');
    string sos = now;
    aux--;
    int d = (now[n - 2] - '0');
    if (aux >= 0) {
      now += (aux + '0');
      v.push_back(now);
    }
    aux++;
    now = sos;
    if (aux <= 9) {
      now += (aux + '0');
      v.push_back(now);
    }
    aux++;
    now = sos;
    if (aux <= 9) {
      now += (aux + '0');
      v.push_back(now);
    }
    wtf++;
  }
  cout << v[k - 1] << endl;
  return 0;
}

Measured memory_bytes: 22384
n = int(input())
A = list(map(int, input().split()))
M = 10 ** 9 + 7
ans = 0
B = [A[0]]
for j in range(1,n):
    B.append(A[j]+B[j-1])
for i in range(n-1):
    ans += A[i] * (B[-1]-B[i])
    ans %= M
ans %= M
print(ans)

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

int main(){
    int N,L;
    cin >> N >> L;
    string s[N];
    for(int i=0;i<N;i++) cin >> s[i];
    sort(s,s+N);
    string g="";
    for(int i=0;i<N;i++) g+=s[i];
    cout << g << endl;
    return 0;
}

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

int main() {
	string o,e, result="";
	cin>>o>>e;
	
	for(int i=0; i<e.size();i++){
		result+=o[i];
		result+=e[i];
	}
	if(o.size()-e.size()) result+=o.back();
	cout<<result;
	return 0;
}

Measured memory_bytes: 256
N,K,Q = map(int, input().split())
point = [0]*N
A = [0]*Q
for i in range(Q):
    _ = int(input())
    point[_-1] += 1

for i in range(N):
    point[i] += K-Q

for ans in point:
    if ans > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 8632
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int h,w;
    char map[100][100];
    char copy[100][100];
    char copy2[100][100];
    cin >> h >> w;
    int cnt = 0;
    int H=0;
    char c;
    rep(i,h){
        cnt=0;
        rep(j,w){
            cin >> map[i][j];//y,x
            if(map[i][j] == '#'){
                cnt++;
            }
        }
        if(cnt>0){
            rep(k,w){
                copy[H][k] = map[i][k];
            }
            H++;
        }
    }
    
    int W=0;
    rep(i,w){
        cnt = 0;
        rep(j,H){
            if(copy[j][i] == '#'){
                cnt++;
            }
        }

        if(cnt > 0){
            
            rep(k,H){
                copy2[k][W] = copy[k][i]; 
            }
            W++;
        }
    }

    rep(i,H){
        rep(j,W){
            cout << copy2[i][j];
        }
        cout << endl;
    }

    return 0;
}

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

int main()
{
	int n, m;
	int A[100][100], b[100], c[100];

	for (int i = 0; i < 100; i++){
		c[i] = 0;
	}

	cin >> n >> m;

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

	for (int i = 0; i < m; i++){
		cin >> b[i];
	}

	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			c[i] += A[i][j] * b[j];
			
		}
	}

	for (int i = 0; i < n; i++){
		cout << c[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3108
import Data.List
main :: IO ()
main = do
    _ <- getLine
    ls <- fmap read . words <$> getLine :: IO [Int]
    let ls' = (\n -> (head n,length n)) <$> (group . sort) ls
    print $ foldl' (\current -> \(n,count)-> if n > count then current + count else current + (count - n)) 0 ls'


Measured memory_bytes: 39548
#include <iostream>
#include <map>
#include <set>

using namespace std;

typedef pair<int, int> P;

int main(){
    long H, W, N;
    P xy[9];
    xy[0] = P(-1, -1), xy[1] = P(0, -1), xy[2] = P(1, -1);
    xy[3] = P(-1, 0), xy[4] = P(0, 0), xy[5] = P(1, 0);
    xy[6] = P(-1, 1), xy[7] = P(0, 1), xy[8] = P(1, 1);
    map<P, int> m;
    cin >> H >> W >> N;
    for(int i = 0; i < N; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        for(int j = 0; j < 9; j++){
            if(a+xy[j].first >= 0 && a+xy[j].first < H && b+xy[j].second >= 0 && b+xy[j].second < W){
                if(m.count(P(a+xy[j].first, b+xy[j].second)) == 0){
                    m[P(a+xy[j].first, b+xy[j].second)] = 1;
                }else{
                    m[P(a+xy[j].first, b+xy[j].second)]++;
                }
            }
        }
    }
    long ans[10] = {0};
    ans[0] = (H-2)*(W-2);
    for(auto iter = m.begin(); iter!= m.end(); iter++){
        //cout << iter->first.first << ' ' << iter->first.second << ' ' << iter->second << endl;
        int x = iter->first.first;
        int y = iter->first.second;
        if(x > 0 && x < H-1 && y > 0 && y < W-1){
            ans[iter->second]++;
            ans[0]--;
        }
    }
    for(int i = 0; i < 10; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 42496
def calc_min_op(n, stone, left_red):
    ans = float('inf')
    for i in range(n+1):
        # stone[:i] は R, stone[i:] は W にするときの最小回数
        left_excess_w = i - left_red[i]
        right_excess_r = left_red[n] - left_red[i]
        operations = max(left_excess_w, right_excess_r)
        ans = min(ans, operations)
    return ans


def main():
    n = int(input())
    stone = input()
    # stone[:i] のうち R であるものの数
    left_red = [0] * (n + 1)
    for i in range(1, n + 1):
        left_red[i] = left_red[i-1] + (1 if stone[i-1] == 'R' else 0)
    print(calc_min_op(n, stone, left_red))


if __name__ == '__main__':
    main()

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

signed main() {
    int x, y;
    cin >> x >> y;

    for(int a=0; a<=x; ++a) {
        for(int b=0; b<=x; ++b) {
            int c = x - a - b;
            if(10000*a+5000*b+1000*c==y && c>=0) {
                cout << a << " " << b << " " << c << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}



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

int main(void){
  char s[10005];
  int i,n;
  scanf("%s",s);
  n=strlen(s);
  if(s[n-1]=='s'){
    s[n]='e';
    s[n+1]='s';
  }else{
    s[n]='s';
  }
  printf("%s",s);

  return 0;
}

Measured memory_bytes: 1740
while True:
    n = int(input())
    if n == 0:
        break
    sum_ = 0
    max_ = 0
    min_ = 1000
    for i in range(n):
        tmp = int(input())
        sum_ += tmp
        max_ = max(max_, tmp)
        min_ = min(min_, tmp)
    sum_ -= max_
    sum_ -= min_
    print(int(sum_/(n-2)))


Measured memory_bytes: 5588
import collections

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def prime_factorization(n):
    X = []
    while n % 2 == 0:
        X.append(2)
        n = n / 2
    f = 3
    while f*f <= n:
        if n % f == 0:
            X.append(f)
            n = n / f
        else:
            f += 2
    if n != 1:
        X.append(n)
    X.append(1)
    return X


A, B = map(int, input().split())

g = gcd(A,B)
L = prime_factorization(g)

c = collections.Counter(L)
ans = len(c)

print(ans)

Measured memory_bytes: 3316
#include<stdio.h>
int main(void)
{
	int n,a,c[10],i,k,h;
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<10;i++)  c[i]=0;
		for(i=0;i<n;i++){
			scanf("%d",&a);
			c[a]++;
		}
		for(i=0;i<10;i++){
			if(c[i]==0)  printf("-\n");
			else{
				for(k=c[i];k>0;k--){
					printf("*");
				}
				printf("\n");
			}
		}
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 2532
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	int h = 0;
	for (int m = n; m > 0; m /= 10)
	{
		h += m % 10;
	}

	println((n % h == 0 ? "Yes" : "No"));
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
map<int,int> f;
int n;
int a[200005];
long long tot;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        f[i-a[i]]++;
    }
    for(int i=1;i<=n;i++)
    {
        tot+=f[i+a[i]];
    }
    cout<<tot;
    return 0;
}


Measured memory_bytes: 21412
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;

int main() {
	int i, A[3], x[3], max,sum, tmp;
	cin >> A[0] >> A[1] >> A[2];
	x[0] = abs( A[2] - A[0]);
	x[1] = abs(A[0] - A[1]);
	x[2] = abs(A[1] - A[2]);
	max = x[2];
	sum = x[2];
	for (i = 0; i < 2; i++) {
		if (max < x[i]) {
			max = x[i];
		}
		sum += x[i];
	}
	cout << sum-max << endl;
}

Measured memory_bytes: 384
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
//~ #pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(),x.end()
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define erase_duplicates(x) sort(all(x)); (x).resize(distance((x).begin(), unique(all(x))));


using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<
T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<" = "<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#define cerr if(0)cout
#endif

const int maxn = (1e6)+7;
const int maxk = 20;
const int inf = (1e9)+7;
const LL LLinf = ((LL)1e18)+7LL;
const LD eps = 1e-9;
const LL mod = 1e9+7;

// ***************************** CODE ***************************** //

int main()
{
	_upgrade
  int n;
  cin>>n;
  string s;
  cin>>s;
  int licz = 0;
  for(auto v : s)
    licz += (v == 'R' ? 1 : -1);
  cout<<(licz > 0 ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

struct State{
    int y, x, c, bit, n;
    State(int y, int x, int c, int bit, int n) : y(y), x(x), c(c), bit(bit), n(n) {}
};

bool memo[22][22][(1<<11)];

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

        vector<string> field(h);
        int N = 0, sy = -1, sx = -1;
        for(int i=0;i<h;i++){
            cin >> field[i];
            for(int j=0;j<w;j++){
                if(field[i][j] == 'o'){
                    sy = i;
                    sx = j;
                }else if(field[i][j] == '*'){
                    field[i][j] = '0' + N;
                    N++;
                }
            }
        }

        const int dd[] = {0, 1, 0, -1, 0};
        queue<State> que;
        que.emplace(sy, sx, 0, 0, 0);
        memset(memo, 0, sizeof(memo));

        while(que.size()){
            State s = que.front();
            if(s.n == N) break;
            que.pop();

            for(int k=0;k<4;k++){
                int ny = s.y + dd[k], nx = s.x + dd[k+1];
                if(ny < 0 || h <= ny || nx < 0 || w <= nx || field[ny][nx] == 'x') continue;
                int nbit = s.bit, nn = s.n;
                if('0' <= field[ny][nx] && field[ny][nx] <= '9'){
                    if((s.bit&(1 << (field[ny][nx] - '0'))) == 0) nn++;
                    nbit |= 1 << (field[ny][nx] - '0');
                }
                if(!memo[ny][nx][nbit]){
                    memo[ny][nx][nbit] = true;
                    que.emplace(ny, nx, s.c + 1, nbit, nn);
                }
            }
        }

        if(que.size() > 0) cout << que.front().c << endl;
        else cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 4328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;cin>>n>>k;
    vector<ll> p(n);rep(i,n)cin>>p[i];
    vector<ll> s(n+1);s[0]=0;
    for(int i=0; i<n; i++){
        s[i+1]=s[i]+p[i];
    }
    ll M = 0;
    for(int i=0; i<=n-k; i++){
        M = max(s[i+k]-s[i],M);
    }
    //cout<<M<<endl;
    cout<<setprecision(12)<<(k+M)/2.0;
    return 0;
}

Measured memory_bytes: 3328
import sys
input = sys.stdin.readline

def main():
    N,K = map(int,input().split())
    V = list(map(int,input().split()))
    
    ans = -(10**10)
    for pick in range(min(N+1,K+1)):
        throw = min(pick,K-pick)
        for left in range(pick+1):
            right = pick-left
            p = []
            minus = 0
            for i in range(left):
                if V[i] < 0:
                    minus += 1
                p.append(V[i])
            for i in range(right):
                if V[-i-1] < 0:
                    minus += 1
                p.append(V[-i-1])
            p.sort()
            if minus >= throw:
                rest = p[throw:]
            else:
                rest = p[minus:]
            ans = max(ans,sum(rest))
    
    print(ans)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
h, w = map(int, input().split())
#s = [['#' for _ in range(w+2)]] + [list('#' + input() + '#') for _ in range(h)] + [['#' for _ in range(w+2)]]
s = [list(input()) for _ in range(h)]

n = h * w
m = [[float('inf') for _ in range(n)] for _ in range(n)]

for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            m[i * w + j][i * w + j] = 0

#for x in m: print(x)
for i in range(h):
    for j in range(w-1):
        if s[i][j] == '.':
            if s[i][j+1] == '.':
                m[i * w + j][i * w + j + 1] = 1
                m[i * w + j + 1][i * w + j] = 1

for i in range(h-1):
    for j in range(w):
        if s[i][j] == '.':
            if s[i+1][j] == '.':
                m[i*w+j][(i+1)*w+j] = 1
                m[(i+1)*w+j][i*w+j] = 1

def warshall_floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

m = warshall_floyd(m)
ans = 0
for i in range(n):
    for j in range(n):
        if m[i][j] != float('inf'):
            ans = max(ans, m[i][j])

print(ans)

Measured memory_bytes: 135176
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int solve() {
    int64_t N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (auto& i : A) {
        cin >> i;
        i--;
    }
    vector<int> visited(N, -1);
    int current = 0, cnt = 0;
    visited[current] = 0;
    while (cnt < K && visited[A[current]] == -1) {
        cnt++;
        visited[A[current]] = visited[current] + 1;
        current = A[current];
    }
    if (cnt == K) return current + 1;
    int x = (K - visited[A[current]]) % (visited[current] + 1 - visited[A[current]]);
    int ans = A[current];
    for (int i = 0; i < x; i++) ans = A[ans];
    return ans + 1;
}
int main() {
    cout << solve() << endl;
}


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

int main(){
    int N, M, C, ans = 0;
    int B[105];
    cin >> N >> M >> C;
    
    for (int i = 0; i < M; ++i) cin >> B[i];
    
    for (int i = 0; i < N; ++i) {
        int sum = 0;
        for (int k = 0; k < M; ++k) {
            int A;
            cin >> A;
            sum += A * B[k];
        }
        sum += C;
        if (sum > 0) ans++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v) for (auto&& V : v)
#define all(x) (x).begin(), (x).end()
using lint = long long;
const int INF = 1 << 29;
const double EPS = 1e-9;
using namespace std;

int main(void) {
  char c;
  cin >> c;
  cout << (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' ? "vowel" : "consonant") << endl;
  return 0;
}

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

#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define forup(i,l,r) for (register int i = l ; i <= r ; i += lowbit(i))
#define fordown(i,id) for (register int i = id ; i ; i -= lowbit(i))
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define lowbit(x) (x&(-x))

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pr;

const ld inf = 2e18;
const int N = 3e6 + 10;
const int maxn = 100020;
const ll mod = 1e9 + 7;

inline ll power(ll x,ll y){
	y = ((y % (mod - 1)) + (mod - 1)) % (mod - 1);
//	if ( y < 0 ) return power(power(x,-y),mod - 2);
	ll res = 1;
	while ( y ){
		if ( y & 1 ) res = res * x % mod;
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}

int main(){
	int n,k;
	cin>>n>>k;
	if ( k > (n + 1) / 2 ) puts("NO");
	else puts("YES");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;


int main(){
   IOS;
 //    #ifndef ONLINE_JUDGE
 //        freopen("in.txt",  "r",  stdin);
 //        freopen("out.txt", "w", stdout);
 //    #endif
   
   long int n;
   cin>>n;
   long int ans = 0;

   for(long int i = 1; i <= n; i++){
    for(long int j = 1; j <= n; j++){
      long int g = __gcd(i,j);
      for(long int k = 1; k <= n; k++){
        ans += __gcd(k,g);
      }
    }
   }

   cout<<ans;
   return 0;
}

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

public class Hello
{
    static void Main()
    {
        int num = int.Parse(Console.ReadLine());
        int fx = num;
        int amari = 0;


        while (num > 0)
        {
            amari += num % 10;
            num /= 10;
        }

        if (fx % amari == 0) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}

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

bool solve() {
  int H, W, N;
  cin >> H >> W >> N;
  int r, c;
  cin >> r >> c;
  string S, T;
  cin >> S >> T;
  bool ans = true;
  // 上
  int cr = r, cc = c;
  rep(i, 0, N) {
    if(S[i] == 'U') cr--;
    if(cr <= 0) ans = false;
    if(T[i] == 'D' && cr < H) cr++;
  }
  // 下
  cr = r, cc = c;
  rep(i, 0, N) {
    if(S[i] == 'D') cr++;
    if(cr > H) ans = false;
    if(T[i] == 'U' && cr > 1) cr--;
  }
  // 左
  cr = r, cc = c;
  rep(i, 0, N) {
    if(S[i] == 'L') cc--;
    if(cc <= 0) ans = false;
    if(T[i] == 'R' && cc < W) cc++;
  }
  // 右
  cr = r, cc = c;
  rep(i, 0, N) {
    if(S[i] == 'R') cc++;
    if(cc > W) ans = false;
    if(T[i] == 'L' && cc > 1) cc--;
  }
  return ans;
}

int main() {
  cout << (solve() ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("myfile.in","r",stdin);freopen ("myfile.out","w",stdout);
#define mod 1000000007
using namespace std;

ll n,ar[N],sum;


int main()
{
	fast;
	int a,b,c;
	cin>>a>>b>>c;
	cout<<min(c,b/a);
}

Measured memory_bytes: 256
class WeightedUnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n + 1)]
        self.rank = [0 for _ in range(n + 1)]
        self.weight = [0 for _ in range(n + 1)]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            y = self.find(self.parent[x])
            self.weight[x] += self.weight[self.parent[x]]
            self.parent[x] = y
            return y

    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)

        if self.rank[rx] < self.rank[ry]:
            self.parent[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        else:
            self.parent[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def diff(self, x, y):
        return self.weight[x] - self.weight[y]


N, M = map(int, input().split())
items = []
for i in range(M):
    items.append(tuple(map(int, input().split())))

wu = WeightedUnionFind(N)

for i in range(M):
    l, r, d = items[i]
    if wu.same(l, r):
        if d == wu.diff(l, r):
            continue
        else:
            print("No")
            exit()
    else:
        wu.union(l, r, d)

print("Yes")


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> a = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int input = sc.nextInt();
			a.add(input);
		}
		List<Integer> b = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int input = sc.nextInt();
			b.add(input);
		}
		List<Integer> c = new ArrayList<>();
		for (int i = 0; i < n - 1; i++) {
			int input = sc.nextInt();
			c.add(input);
		}
		int size = a.size();
		int sum = b.stream().mapToInt(Integer::valueOf).sum();
		int beforeA = -2;

		for (int i = 0; i < size; i++) {
			int tempA = a.get(i) - 1;
			if (beforeA + 1 == tempA) {
				sum += c.get(beforeA);
			}
			beforeA = tempA;
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 27092
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }

    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 namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<vector<S> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;


int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//


    // input
    cout << fixed << setprecision(10);
    int N, M;cin >> N >> M;
    vector<int> e(N, INTINF);
    rep(i, M){
        int a, b; cin >> a >> b;
        a--; b--;
        e[min(a, b)]=min(e[min(a, b)], max(a, b) );
    }
    // print(e);
    int ans = 0;
    int bef = e[0];
    rep(i, N-1){
        if(e[i] ==INTINF) continue;
        if(bef <= i){
            bef = e[i+1];
            ans++;
        }
        if(bef > e[i]){
            bef = e[i];
        }
    }
    print(ans + 1);
    
    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;


int main(){
  int A, B, M;
  cin >> A >> B >> M;
  
  vector<int> a(A);
  vector<int> b(B);
  rep(i, A){
    cin >> a.at(i);
  }
  rep(i, B){
    cin >> b.at(i);
  }
  
  vector<vector<int>> c(M, vector<int>(3));
  rep(i, M){
    cin >> c.at(i).at(0) >> c.at(i).at(1) >> c.at(i).at(2);
  }
  
  int minA = *std::min_element(a.begin(), a.end());
  int minB = *std::min_element(b.begin(), b.end());
  
  vector<int> off(M + 1);
  rep(i,M){
    off.at(i) = a.at(c.at(i).at(0)-1) + b.at(c.at(i).at(1)-1) - c.at(i).at(2);
  }
  off.at(M) = minA + minB;
  
  int min = *std::min_element(off.begin(), off.end());
  cout << min << endl;
}




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

typedef long long ll;

int main(){
	// freopen("input.txt","r",stdin);
	int n;
	ll a,b,c;
	cin>>n>>a>>b>>c;
	vector<string> s(n);
	vector<char> ans;
	for(int i=0;i<n;++i) cin>>s[i];
	for(int i=0;i<n;++i){
		if(s[i]=="AB"){
			if(!a&&!b) return cout<<"No",0;
			if(a==1&&b==1&&!c&&i<(n-1)){
				if(s[i+1]=="AC"){
					++a;
					--b;
					ans.push_back('A');
				}
				else if(s[i+1]=="BC"){
					++b;
					--a;
					ans.push_back('B');
				}
				else{
					++a;
					--b;
					ans.push_back('A');
				}
			}
			else if(a>b){
				--a;
				++b;
				ans.push_back('B');
			}
			else{
				--b;
				++a;
				ans.push_back('A');
			}
		}
		else if(s[i]=="AC"){
			if(!a&&!c) return cout<<"No",0;
			if(a==1&&c==1&&!b&&i<(n-1)){
				if(s[i+1]=="AB"){
					++a;
					--c;
					ans.push_back('A');
				}
				else if(s[i+1]=="BC"){
					++c;
					--a;
					ans.push_back('C');
				}
				else{
					++a;
					--c;
					ans.push_back('A');
				}
			}
			else if(a>c){
				--a;
				++c;
				ans.push_back('C');
			}
			else{
				--c;
				++a;
				ans.push_back('A');
			}
		}
		else{
			if(!b&&!c) return cout<<"No",0;
			if(b==1&&c==1&&!a&&i<(n-1)){
				if(s[i+1]=="AB"){
					++b;
					--c;
					ans.push_back('B');
				}
				else if(s[i+1]=="AC"){
					++c;
					--b;
					ans.push_back('C');
				}
				else{
					++b;
					--c;
					ans.push_back('B');
				}
			}
			else if(b>c){
				--b;
				++c;
				ans.push_back('C');
			}
			else{
				++b;
				--c;
				ans.push_back('B');
			}
		}
	}
	cout<<"Yes"<<endl;
	for(int i=0;i<(int)ans.size();++i) cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 6744
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifdef LOCAL
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define debug(x) ;
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n, k, h[SIZE];
  int dp[SIZE];

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

  for(int i=0;i<n;i++) scanf("%d", h+i);
  for(int i=0;i<=n;i++) dp[i] = INF;
  dp[0] = 0;

  for(int i=0;i<n-1;i++){
    for(int j=1;j<=k;j++)
      if(i+j < n) dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
  }

  cout << dp[n-1] << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main () {
    vector<int> x;
    int N, cnt=0;
    cin >> N;
    for (int i=0;i<N;i++){
        int a;
        cin >> a;
        x.push_back(a);
    }
    sort(x.begin(),x.end());
    for (int i=0;i<N-1;i++)
        cnt+=x[i];
    cnt>x[N-1] ? cout << "Yes" : cout << "No";
    return 0;
}

Measured memory_bytes: 256
import sys
S = input()
d = {}
for i in range(26):
    d[i] = 0
for i in range(len(S)):
    d[ord(S[i]) - ord('a')] = 1

for i in range(26):
    if d[i] == 0:
        print(chr(ord('a') + i))
        sys.exit()

print("None")



Measured memory_bytes: 3188