akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 2e9;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

int mean(const vi& v) {
    return accumulate(all(v), 0) / v.size();
}

int median(const vi& v) {
    int n = v.size();
    if (n % 2) {
        return v[n / 2];
    } else {
        return (v[(n - 1) / 2] + v[n / 2]) / 2;
    }
}

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

    int n, m;
    cin >> n >> m;
    int ma_diff = -inf;
    vi v(n);
    vi ans;
    rep(i, n + 1) {
        int t = abs(mean(v) - median(v));
        if (t > ma_diff) {
            ma_diff = t;
            ans = v;
        }
        if (i < n) {
            v[i] = m;
        }
    }

    rep(i, n) {
        cout << (i != 0 ? " " : "") << ans[i];
    }
    cout << endl;

}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#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()

const ll INF = 1LL<<60;

int N;
int P[5010];
int H[5010];
bool us[5010];
ll dp[5010][5010];

int main() {
	cin >> N;
	rep(i, N) cin >> H[i] >> P[i];
	vector<pii> vec;

	rep(i, N) {
		vec.eb(mp(H[i] + P[i], i));
	}
	
	sort(ALL(vec));

	rep(i, 5010) rep(j, 5010) dp[i][j] = INF;
	dp[0][0] = 0;

	rep(i, N) {
		int p = vec[i].se;
		rep(j, N) if (dp[i][j] != INF) {
			dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
			if (dp[i][j] <= H[p]) {
				dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + P[p]);
			}
		}
	}

	int ret = 0;
	rep(i, 5010) if (dp[N][i] != INF) {
		ret = i;
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 196480
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val stack = Stack<String>()
    stack.push(sc.next())
    while (true) {
        val input = sc.next()
        if (input == "=") break
        try {
            val a = Integer.parseInt(input)
            val op = stack.pop()
            val b = Integer.parseInt(stack.pop())
            stack.push(
                when (op) {
                    "+" -> b+a
                    "-" -> b-a
                    "*" -> b*a
                    else -> b/a
                }.toString()
            )
        }
        catch (e: NumberFormatException) {
            stack.push(input)
        }
    }
    println(stack.pop())
}


Measured memory_bytes: 25632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll check = 0;
    if (abs(a - c) <= d) {
        cout << "Yes\n";
        return 0;
    } else if (abs(a - b) <= d && abs(b - c) <= d) {
        cout << "Yes\n";
        return 0;
    }

    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3532
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

int main() {
	int n;
	cin >> n;
	vll a(n);
	Loop(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	vll s(n);
	Loop(i, n) {
		if (i == 0) s[i] = a[i];
		else s[i] = s[i - 1] + a[i];
	}
	int ans = 1;
	Loopr(i, n - 1) {
		if (s[i + 1] <= s[i] * 3) ans++;
		else break;
	}
	cout << ans << endl;
	return 0;
}

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

#define fr(i,n) for(i=0;i<n;i++)
#define frs(i,a,n) for(i=a;i<n;i++)
#define frv(i,n) for(i=n-1;i>=0;i--)

#define ne cout<<"\n";
#define cas(i) cout<<"Case #"<<i<<": "

#define vpi vector <pair <int,int> >
#define vpin(v,a,b) v.push_back(make_pair(a,b))
#define vsort(v) sort(v.begin(),v.end());

int dis(int a, int b)
{
    if(a-b<0) return b-a;
    return a-b;
}
int main()
{
    int T,tt,N,i,j;
    int A,B;
    cin>>A>>B;
    cout<<A*B<<"\n";
    return 0;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
typedef double          D;
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define pb              push_back
#define GCD(a, b)       __gcd(a, b)
#define PI              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define Rep(i,a,b)      for(int i = a; i <= b; i++)
#define rep(i,a,b)      for(int i = a; i >= b; i--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)

#define si(x)           scanf("%d",&x)
#define pi(x)           printf("%d",x)
#define ss(str)         scanf("%s",str)
#define pl(x)           printf("%lld",x)
#define sl(x)           scanf("%lld",&x)
#define sii(x,y)        scanf("%d %d",&x,&y)
#define sll(x,y)        scanf("%lld %lld",&x,&y)
#define siii(x,y,z)     scanf("%d %d %d",&x,&y,&z)
#define slll(x,y,z)     scanf("%lld %lld %lld",&x,&y,&z)
using namespace std;



/*
int bs(int l,int r)
{
    int mid,res=inf;

    while(l<=r)
    {
        mid=l+(r-l)/2;

    }

    return res;
}*/

//--------------------------code starts here---------------------------------------


int main()
{
   int t;
   S s;
   si(t);
   map<string,int> mp;

   while(t--)
   {
       cin>>s;
       mp[s]++;

   }

   printf("AC x %d\n",mp["AC"]);
   printf("WA x %d\n",mp["WA"]);
   printf("TLE x %d\n",mp["TLE"]);
   printf("RE x %d\n",mp["RE"]);

   return 0;

}



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

using namespace std;

#define EPS 1e-8
typedef complex<double> Point;

int main(){
  int N;
  while(cin >> N,N){
    Point p[N];
    for(int i = 0 ; i < N ; i++){
      cin >> p[i].real() >> p[i].imag();
    }
    int res = 1;
    for(int i = 0 ; i < N-1 ; i++){
      for(int j = i+1 ; j < N ; j++){
        Point np = p[j]-p[i];
        double d = abs(np);
        if(d + EPS > 2.0){ continue; }
        np /= d;
        np *= Point(0,1);
        Point cp = (p[i]+p[j])/2.0;
        Point v = sqrt(1.0-d*d/4.0)*np;
        for(int k = 0 ; k < 2 ; k++){
          int cnt = 2;
          np *= (-1);
          Point center = cp + v;
          for(int l = 0 ; l < N ; l++){
            if(i == l || j == l) continue;
            Point diff = center-p[l];
            if(norm(diff) < 1.0 + EPS){
              cnt++;
            }
          }
          res = max(res,cnt);
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1260
from collections import deque

N, M, *AB = map(int, open(0).read().split())

E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
    E[a].append(b)

shortest = N + 1
ans = []
for s in range(1, N + 1):
    D = [-1] * (N + 1)
    P = [-1] * (N + 1)

    D[s] = 0
    Q = deque([s])
    while Q:
        p = Q.popleft()
        for c in E[p]:
            if D[c] < 0:
                D[c] = D[p] + 1
                P[c] = p
                Q.append(c)

    for t in range(1, N + 1):
        if t == s or D[t] < 0:
            continue

        for v in E[t]:
            if v != s:
                continue

            T = [s]
            cur = t
            while cur != s:
                T.append(cur)
                cur = P[cur]

            if shortest > len(T):
                shortest = len(T)
                ans = T

if shortest == N + 1:
    print(-1)
else:
    print(len(ans))
    print("\n".join(map(str, ans)))

Measured memory_bytes: 49500
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
	scanf("%d",&n);
	while(n){
		if(n%10==7){
			printf("Yes\n");
			return 0;
		}
		n/=10;
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;

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

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main() {
  int n;
  cin >> n;
  set<string> st;
  rep (i, n) {
    string tmp;
    cin >> tmp;
    st.insert(tmp);
  }
  cout << st.size() << endl;
  return 0;
}

Measured memory_bytes: 19116
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "Yes\n";
string no = "No\n";

int main() {
	ll h,w,m;
	cin>>h>>w>>m;
	vector<int> row(h, 0), col(w,0);
	set< pair<int, int> > st;
	for(ll i=0;i<m;i++) {
		ll hi, wi;
		cin>>hi>>wi;
		hi--, wi--;
		row[hi]++;
		col[wi]++;
		st.insert({hi, wi});
	}
	ll ans1 = *max_element(row.begin(), row.end()), ans2 = *max_element(col.begin(), col.end());
	vector<ll> maxrow, maxcol;
	for(ll i=0;i<h;i++) {
		if(row[i] == ans1) maxrow.PB(i);
	}
	for(ll i=0;i<w;i++) {
		if(col[i] == ans2) maxcol.PB(i);
	}
	for(ll i=0;i<maxrow.size();i++) {
		for(ll j=0;j<maxcol.size();j++) {
			if(st.find({maxrow[i], maxcol[j]}) == st.end()) {
				cout<<ans1+ans2<<endl;
				return 0;
			}
		}
	}
	cout<<ans1+ans2-1<<endl;
}

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

using namespace std;

int main(){
    int a=0,b=0,c=0,d=0,n;
    string s;
    cin>>n;
    for(int i=1;i<=n;i++){
    	cin>>s;
    	if(s=="AC")a++;
    	if(s=="WA")b++;
    	if(s=="TLE")c++;
    	if(s=="RE")d++;
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<b<<endl;
	cout<<"TLE x "<<c<<endl;
	cout<<"RE x "<<d<<endl;
    return 0;
}

Measured memory_bytes: 3628
from collections import Counter
from itertools import combinations
n,*ll = map(int, open(0).read().split())
c = Counter(ll)

ans = 0
for a in combinations(c, 3):
    x,y,z = sorted(a)
    if z < y + x:
        ans += c[z] * c[y] * c[x]

print(ans)

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

using namespace std;

#define MOD 1000000007

int main() {
	int n; cin >> n;
	vector<vector<int> > a(n, vector<int>(n));
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			cin >> a[i][j];
	vector<long long> dp(1 << n);
	dp[0] = 1;
	for (int i = 0; i < (1 << n); ++i) {
		int cnt = __builtin_popcount(i);
		for (int j = 0; j < n; ++j)
			if (!(i & (1 << j)) && a[cnt][j])
				(dp[i | (1 << j)] += dp[i]) %= MOD;
	}
	cout << dp[(1 << n) - 1] << endl;

	return 0;
}

Measured memory_bytes: 16640
#include<stdio.h>

int main(){
  int n;
  char s[30007];
  int cnt = 0;
  int i;
  int hk,tk,ok;
  int a,b,c;

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

  for(i = 0;i <= 999;i++){
    a = 0;
    b = 0;
    c = 0;
    hk = i / 100;
    tk = (i / 10) % 10;
    ok = i % 10;

    while(s[a] != '\0' && s[a] != (hk + '0')) a++;
    if(a >= n) continue;

    b = a + 1;
    while(s[b] != '\0' && s[b] != (tk + '0')) b++;
    if(b >= n) continue;

    c = b + 1;
    while(s[c] != '\0' && s[c] != (ok + '0')) c++;
    if(c >= n) continue;

    cnt++;
  }

  printf("%d\n", cnt);


  return 0;
}


Measured memory_bytes: 128
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator


inf = float('inf')


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_list_of_int():
    return [int(i) for i in input().split()]


def get_char_list():
    return list(input().strip())


# inputs
A, B, Q = 0, 0, 0
S = []
T = []
X = []


def set_inputs():
    global A, B, Q, S, T, X
    A, B, Q = get_list_of_int()
    for _ in range(A):
        S.append(get_int())
    for _ in range(B):
        T.append(get_int())
    for _ in range(Q):
        X.append(get_int())


def main():
    set_inputs()

    for i in range(Q):
        nsi = bisect_left(S, X[i])
        if nsi == 0:
            ns = inf
        else:
            ns = X[i] - S[nsi-1]
        psi = bisect_left(S, X[i])
        if psi == A:
            ps = inf
        else:
            ps = S[nsi] - X[i]
        nti = bisect_left(T, X[i])
        if nti == 0:
            nt = inf
        else:
            nt = X[i] - T[nti-1]
        pti = bisect_left(T, X[i])
        if pti == B:
            pt = inf
        else:
            pt = T[nti] - X[i]
        print(min(max(ns, nt), max(ps, pt), ns * 2 + pt, ns + pt * 2, nt * 2 + ps, nt + ps * 2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 123000
#include <iostream>
#include <string.h>
#include <vector>

using namespace std;

#define MAX 114

vector<int> G[MAX];
int col[MAX];
bool found;

void dfs(int v)
{
    col[v] = 0;
    for(int i = 0 ; i < (int)G[v].size() ; i++){
        int to = G[v][i];
        if(col[to] == -1){
            dfs(to);
        }else if(col[to] == 0){
            found = true;            
            return;
        }
    }
    col[v] = 1;
}
    
int main()
{
    int M, N;
    cin >> M >> N;
    
    auto canGraph = [=](){
        int lb[MAX][MAX], ub[MAX][MAX];
        for(int i = 0 ; i < MAX ; i++){
            for(int j = 0 ; j < MAX ; j++){
                lb[i][j] = -1;
                ub[i][j] = 101;
            }
        }
        int K, s, t;
        string cond;
        bool possible = 1;
        for(int i = 0 ; i < M ; i++){
            cin >> K;
            for(int j = 0 ; j < K ; j++){
                cin >> s >> cond >> t;
                --s;
                if(cond == ">="){
                    lb[i][s] = max(lb[i][s], t);
                }else{
                    ub[i][s] = min(ub[i][s], t);
                }
            }
            for(int j = 0 ; j < N ; j++){
                if(lb[i][j] > ub[i][j]){
                    possible = 0;
                    break;
                }
            }
        }

        if(!possible) return false;

        auto isConnect = [=](int from, int to){
            for(int i = 0 ; i < N ; i++){
                if(ub[from][i] < lb[to][i]){
                    return true;
                }
            }
            return false;
        };
        
        for(int from = 0 ; from < M ; from++){
            for(int to = 0 ; to < M ; to++){
                if(from == to) continue;
                if(isConnect(from, to)){
                    G[from].push_back(to);
                }
            }
        }
        found = false;
        memset(col, -1, sizeof(col));
        for(int i = 0 ; i < M ; i++){
            if(col[i] == -1){
                dfs(i);
            }
        }                                       
        return !found;
    };
    
    cout << (canGraph() ? "Yes" : "No") << endl;
    return 0;
}

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

int main()
{
    int n, AC = 0, WA = 0, TLE = 0, RE = 0;
    string result;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> result;
        if (result == "AC")
            AC++;
        if (result == "WA")
            WA++;
        if (result == "TLE")
            TLE++;
        if (result == "RE")
            RE++;
    }
    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
    return 0;
}

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

int main() {
  int n,m,ans=0;
  cin >> n >> m;
  vector<int> e(m);
  for(int i=0;i<n;i++) {
    int k;
    cin >> k;
    for(int j=0;j<k;j++) {
      int a;
      cin >> a;
      e.at(a-1)++;
    };
  };
  for(int i=0;i<m;i++) {
    if(e.at(i)==n) ans++;
  };
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

int main() {
    string a;
    getline(cin,a);
    for (int i = 0; i < a.size(); ++i) {
        if(isupper(a[i]))
            a[i] = tolower(a[i]);
        else if(islower(a[i]))
            a[i] = toupper(a[i]);
    }
    cout << a << endl;

    return 0;
}

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

struct node
{
	int c;
	int a[15]; 
}book[15];
int b[15];
int main()
{
	int n,m,x;
	cin>>n>>m>>x;
	for(int i=0;i<n;i++)
	{
		cin>>book[i].c;
		for(int j=0;j<m;j++) cin>>book[i].a[j];
	}
	int ans=2e9;
	for(int i=0;i<(1<<n);i++)
	{
		memset(b,0,sizeof b);
		int sum=0;
		for(int j=0;j<n;j++)
		{
			if(i>>j&1)
			{
				sum+=book[j].c;
				for(int k=0;k<m;k++) b[k]+=book[j].a[k];
			}
			bool flag=1;
			for(int j=0;j<m;j++) if(b[j]<x) flag=0;
			if(flag) ans=min(ans,sum);
		}
	}
	if(ans==2e9) cout<<"-1";
	else cout<<ans;
	return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
int main(void){
	int h,w,i,j;
	
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0&&w==0){
			break;
		}
		
		for(i=0;i<w;i++){
			printf("#");
		}
		printf("\n");
		for(i=0;i<h-2;i++){
			printf("#");
			for(j=0;j<w-2;j++){
				printf(".");
			}
			printf("#\n");
		}
		for(i=0;i<w;i++){
			printf("#");
		}
		printf("\n\n");
	}
	return 0;
}

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

//#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

const int INF = 1 << 29;

signed main() {
	int w, h;
	while (cin >> w >> h && w) {
		VV data(h, V(w));
		rep(i, h) rep(j, w) {
			char c; cin >> c;
			if (c < '0' || c > '9') data[i][j] = -1;
			else data[i][j] = c - '0';
		}
		vector<vector<string>> dp(h, vector<string>(w));
		auto comp = [](string& a, string& b) {
			return a.size() != b.size() ? a.size() < b.size()
				: a < b;
		};
		string ans = "";
		rep(i, h) rep(j, w) {
			string a = to_string(data[i][j]);
			string b = a;
			if (a == "-1") continue;
			if (i - 1 >= 0 && dp[i - 1][j] != "-1") a = dp[i - 1][j] + to_string(data[i][j]);
			if (j - 1 >= 0 && dp[i][j - 1] != "-1") b = dp[i][j - 1] + to_string(data[i][j]);
			string x = comp(a, b) ? b : a;
			if (x != "0") {
				dp[i][j] = x;
				if (comp(ans, x)) ans = x;
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 3252
#include<bits/stdc++.h>
using namespace std;
#define sx 200007
int main()
{
    map<string,int> m;
    m["SUN"]=7;
    m["MON"]=6;
    m["TUE"]=5;
    m["WED"]=4;
    m["THU"]=3;
    m["FRI"]=2;
    m["SAT"]=1;
    string s;
    cin>>s;
    cout<<m[s]<<endl;
    return 0;
}


Measured memory_bytes: 3608
fun main(arg: Array<String>) {
    val (N, M) = listOfInt()
    val G = Array(N) { IntArray(N) { 100000007 } }
    val E = Array(N) { IntArray(N) }
    repeat(N) { n -> G[n][n] = 0 }
    repeat(M) {
        val (a, b, c) = listOfInt(-1, -1, 0)
        G[a][b] = c; G[b][a] = c
        E[a][b] = c; E[b][a] = c
    }
    for (k in 0 until N)
    for (n in 0 until N)
    for (m in 0 until N)
        G[n][m] = Math.min(G[n][m], G[n][k] + G[k][m])
    val A = Array(N) { IntArray(N) }
    for (s in 0 until N)
    for (t in 0 until N)
    for (n in 0 until N)
    for (m in 0 until N) {
        if (s == t) continue
        if (n == m) continue
        if (G[s][t] == G[s][n] + E[n][m] + G[m][t]) A[n][m] += 1
    }
    var ans = 0
    for (n in 0 until N)
        for (m in 0 until N) {
            if (A[n][m] == 0 && E[n][m] != 0) ans += 1
        }
    println(ans / 2)
}

fun next() = readLine()!!
fun nextInt(offset: Int = 0) = Integer.parseInt(next()) + offset
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }
fun listOfLong() = listOfString().map(String::toLong)
fun tripleIntIntLong() = listOfLong().let { Triple(it[0].toInt(), it[1].toInt(), it[2]) }
fun listOfInt(vararg offset: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + offset[index % offset.size] }


Measured memory_bytes: 42620
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
int main() {
	int N;
	cin >> N;
	map<int, int> cnt;
	for (int i = 1; i <= N; i++) {
		int M = i;
		for (int j = 2; j*j <= M; j++) {
			while (M%j == 0) {
				M /= j;
				cnt[j]++;
			}
		}
		if (M != 1) cnt[M]++;
	}
	LL ans = 1;
	for (auto itr = cnt.begin(); itr != cnt.end(); itr++) {
		ans = (ans*(itr->second+1)) % MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	h := scanInt()
	w := scanInt()

	ss := make([][]rune, h)
	for i := 0; i < h; i++ {
		ss[i] = scanRunes()
	}

	dp := make([]int, h*w)

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			dp[i*w+j] = 1<<31-1
		}
	}
	dp[0] = 0

	if ss[0][0] == '#' {
		dp[0] = 1
	}

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if i==0&&j==0 {
				continue
			}

			if j-1>=0 {
				if ss[i][j-1] == '.' && ss[i][j] == '#' {
					dp[i*w+j] = dp[i*w+j-1]+1
				} else {
					dp[i*w+j] = dp[i*w+j-1]
				}
			}

			if i-1>=0 {
				if ss[i-1][j] == '.' && ss[i][j] == '#' {
					dp[i*w+j] = min(dp[i*w+j],dp[(i-1)*w+j]+1)
				} else {
					dp[i*w+j] = min(dp[i*w+j],dp[(i-1)*w+j])
				}
			}
		}
	}

	// for i := 0; i < h; i++ {
	// 	for j := 0; j < w; j++ {
	// 		fmt.Fprintf(wr, "%d ", dp[i*w+j])
	// 	}
	// 	fmt.Fprintln(wr)
	// }

	fmt.Fprintln(wr, dp[h*w-1])

}



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

using namespace std;

const int maxn = 310;

int n, k;
int dp[maxn][maxn][maxn];
string s;

int main(){
	cin >> s;
	n = s.length();
	cin >> k;
	for (int i = 0; i < n; i++){
		for (int j = 0; j <= k; j++){
			dp[i][i+1][j] = 1;
		}
	}

	for (int i = 2; i <= n; i++){
		for (int j = 0; j <= n-i; j++){
			for (int z = 0; z <= k; z++){
				dp[j][j+i][z] = max(dp[j][j+i-1][z], dp[j+1][j+i][z]);
				if (s[j] == s[j+i-1])
					dp[j][j+i][z] = max(dp[j][j+i][z], dp[j+1][j+i-1][z] + 2);
				if (z > 0)
					dp[j][j+i][z] = max(dp[j][j+i][z], dp[j+1][j+i-1][z-1] + 2);
			}
		}
	}

	cout << dp[0][n][k] << endl;
	return 0;
}


Measured memory_bytes: 112768
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
#define PI 3.14159265358979323846
using namespace std;
typedef long long ll;

#define MAX 1000000000000


int main(void) {
	int a, b, c, k; cin >> a >> b >> c >>k;
	if (k <= a) {
		cout << k<<endl;
	}
	else if (k <= a+b) {
		cout << a<<endl;
	}
	else {
		cout << a - (k - a - b) << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
n = int(input())
an = list(map(int, input().split()))
s = 1
flg = False
for a in an:
  s = s * a
  if s > 10**18 or s< 0:
    flg = True
    break
if 0 in an:
  print(0)
elif flg:
  print(-1)
else:
  print(s)


Measured memory_bytes: 21660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = (int)1.01e9;

const int N = 310;

int dp[N][N][N];

void upd(int &x, int y) {
    x = max(x, y);
}

int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif

    string s;
    int k;
    while (cin >> s >> k) {
        int n = s.length();

        memset(dp, -1, sizeof(dp));
        dp[1][n][0] = 0;
        for (int len = n - 1; len >= 0; len--) {
            for (int i = 0; i + len <= n + 1; i++) {
                int j = i + len;

                for (int t = 0; t <= k; t++) {
                    if (dp[i][j][t] == -1) continue;
                    //if (s[i - 1] == s[j - 1] && t < k) {
                    {
                        int delta = 1 + (i != j);
                        int cost = s[i - 1] != s[j - 1];
                        if (t + cost <= k) {
                            upd(dp[i + 1][j - 1][t + cost], dp[i][j][t] + delta);
                        }
                    }
                    upd(dp[i + 1][j][t], dp[i][j][t]);
                    upd(dp[i][j - 1][t], dp[i][j][t]);
                }
            }
        }
        int ans = 0;
        for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) for (int t = 0; t < N; t++) upd(ans, dp[i][j][t]);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 116736
#include <bits/stdc++.h>
using namespace std;
#define Mx 200001
typedef long long L;
L n,a1,a2,c;
L fun(L id){
    return (id*id*id*id*id);
}
void solve(){
    for(L i=1;i<=300;i++){
        a1=fun(i);
        c=(n-a1);
        if(c>0){
            for(L j=1;j<=300;j++){
                if(fun(j)==c){
                    printf("%lld -%lld\n",i,j);
                    return ;
                }
                if(fun(j)>c)break;
            }
        }else if(c<0){
            for(L j=1;j<=300;j++){
                if(fun(j)==abs(c)){
                    printf("%lld %lld\n",i,j);
                    return ;
                }
                if(fun(j)>abs(c))break;
            }
        }else{
            printf("%lld 0\n",i);
        }
    }
}
int main()
{
    scanf("%lld",&n);
    solve();
    return 0;
}
/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 3780
#include<cstdio>

using namespace std;

int main(){
	
	int a,b[100],c[100],d[100];
	
	scanf("%d",&a);
	
	for(int i=0;i<a;i++) scanf("%d %d",&b[i],&c[i]);
	
	for(int i=0;i<a;i++){
		if(b[i]%c[i]==0){
			d[i]=c[i];
		}else d[i]=b[i]%c[i];
	}

	for(int i=0;i<a;i++) printf("%d\n",d[i]);

	return 0;
	
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 998244353;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

vector<vector<int32>> to;

int64 dfs(int32 x){
    int64 res = 1;
    for(int32 y : to[x]){
        res *= dfs(y);
        res %= MOD;
    }
    res++;
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<pii> xd(n);
    REP(i,n)cin >> xd[i].first >> xd[i].second;
    sort(ALL(xd));
    to.resize(n);
    stack<int32> st;
    FORR(i,n-1,0){
        while(!st.empty() && xd[st.top()].first < xd[i].first + xd[i].second){
            to[i].emplace_back(st.top());
            st.pop();
        }
        st.emplace(i);
    }
    int64 ans = 1;
    while(!st.empty()){
        int32 r = st.top();st.pop();
        ans *= dfs(r);
        ans %= MOD;
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 23680
#include <stdio.h>

int main(){
  int n,q,s[100000],t[50000],i,left,right,mid,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&s[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&t[i]);

  for(i=0;i<q;i++){
    left=0;
    right=n;
    mid=(left+right)/2;
    while(left<right){
      if(t[i]>s[mid]) left=mid+1;
      else if(t[i]<s[mid]) right=mid;
      else{
	count++;
	break;
      }
      mid=(left+right)/2;
    }
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2348
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int N, P;
    string S;
    cin >> N;
    pair<pair<string, int>, int> p[N];
    
    for(int i = 0; i < N; i++){
        cin >> S >> P;
        p[i] = make_pair(make_pair(S, -P), i);
    }
    sort(p, p+N);
    for(int i = 0; i < N; i++){
        cout << p[i].second + 1 << endl;
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;


int main() {
	
	string p;
	int x;
	cin >> p ;

	long long int ans = 0;
	int n=p.size();

	for (int i = 0; i < 1<<n-1; i++) {
		long long int y = p[0] - '0';
		for (int j = 0; j < n - 1; j++) {
			if (i & 1 << j) {
				ans += y; y = 0;
			}
			y = y * 10 + p[j + 1] - '0';
		}
		ans += y;
	}
	cout << ans << endl;
	
	return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    char A[3];
    int a=0;
    int b=0;
    int c=0;
    scanf("%s",A);
    if (A[0]==A[1])
    {a=1;
}
if (A[1]==A[2])
    {b=1;
}
if(A[0]==A[2])
{c=1;
}
    if (a==1&&b==1&&c==1)
    {
       printf("No");
    }else{
        printf("Yes");
    }
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, D;
    cin >> N >> D;
    int ans = 0;
    rep(i, N) {
        int X, Y; cin >> X >> Y;
        if(X * X + Y * Y <= D * D) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
  int N,K;
  cin>>N>>K;
  int cnt=0;
  for(int i=0;i<N;i++){
    int h;
    cin>>h;
    if(h>=K)cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

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

int main() {
  int n,l,ans = 0;
  bool flag = false;
  cin >> n >> l;
  vector<int> r(n);
  rep(i,n) {
    r[i] = l+i;
    ans += r[i];
    if(r[i] == 0) flag = true;
  }
  if(flag) {
    cout << ans << endl;
    return 0;
  }else if(r[0] < 0) ans -= r[n-1];
  else if(r[0] > 0) ans -= r[0];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
#define SIZE 10005
vector< ll > dp[SIZE];
ll height[SIZE];
ll n ,m;
vector< int > graph[SIZE];
vector< int > ans;
vector< int > vis(SIZE,0);
void dfs(int u){
	vis[u] = true;
	for(auto v : graph[u])
	{
		if(!vis[v])
			dfs(v);
	}
	ans.push_back(u);
}
int main(){
	dhoom;
	cin >> n >> m;
	for(int i = 0 ; i < m ; i++)
	{
		int u , v;
		cin >> u >> v;
		graph[u].push_back(v);
	}
	for(int i = 0 ;i < n ; i++){
		if(!vis[i]){
			dfs(i);
		}
	}
	reverse(ans.begin() , ans.end());
	for(int i = 0 ;i < n ; i++)	
	{
		cout << ans[i] << endl;
	}
	
    return 0;
}




Measured memory_bytes: 4108
n = int(input())
s = []
for _ in range(n):
    i = int(input())
    s.append(i)
s.sort()
ans = sum(s)
if ans % 10 == 0:
    for i in s:
        if i % 10 != 0:
            ans -= i
            print(ans)
            break
    else:
        print(0)
else:
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int a,b,c;
signed main(){
    cin>>a>>b>>c;
    if(a==b&&b==c&&c==a)puts("No");
    else if(a!=b&&b!=c&&a!=c)puts("No");
    else puts("Yes");
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,c = map(int,readline().split())
*a, = map(int,readline().split())
*b, = map(int,readline().split())

M = 401
MOD = 10**9+7

powsum = []
for i in range(M):
    res = [pow(j,i,MOD) for j in range(M)]
    for j in range(1,M):
        res[j] = (res[j]+res[j-1])%MOD
    powsum.append(res)

dp = [0]*(c+1) # dp[i][k] = i まで見て k次斉次式
dp[0] = 1

for ai,bi in zip(a,b):
    ndp = [0]*(c+1)
    for k in range(c+1):
        for j in range(k+1):
            ndp[k] += (powsum[j][bi]-powsum[j][ai-1])*dp[k-j]%MOD
        ndp[k] %= MOD

    dp = ndp

print(dp[c]%MOD)




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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

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


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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define PB push_back
#define F first
#define S secon

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

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

	string s; cin >> s;
	cout << s.substr(0, 3) << '\n';

	return 0;
}


Measured memory_bytes: 3612
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
        int A = stdIn.nextInt();
	int B = stdIn.nextInt();
	int tem = A+B;
	if(tem%2==0){
	    System.out.println(tem/2);
	}else{
	    System.out.println("IMPOSSIBLE");
	}
    }
}


Measured memory_bytes: 22740
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<cmath>
#include<cstdio>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
typedef pair<int, int> P;
ll junretu(ll x, ll y) {
	ll ans;
	ans = 1;
	for (ll i = x; i >= x - y + 1; i--) {
		ans *= i;
		ans %= 1000000007;
	}
	if (ans == 0) {
		ans = 1;
	}
	return ans;
}



int main() {
	ll i, j, k, l, m, n, sum, flag, cc,M,X,H,W,N,K;
	cin >> N>>K;
	vector<ll>h(N);
	ll inf = 1000000000;
	ll ans[100001];
	REP(i, 0, N+1) {
		ans[i] = inf;
	}
	REP(i, 0, N) {
		cin >> h[i];
	}
	ans[0] = 0;
	REP(i, 0, N) {
		REP(j, 1, K + 1) {
			if (i + j <= N - 1) {
				ans[i + j] = fmin(ans[i + j], ans[i] + abs(h[i] - h[i+j]));
				//cout << i + j << "段目 " << j << "とび　" << ans[i + j] << endl;
			}
			else
				break;
		}
		
	}
	
	output(ans[N - 1]);


	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void)
{
  int count=0;
  char pre[3], ac[3];
  scanf("%s", pre);
  scanf("%s", ac);
  
  for(int i=0; i<3; i++)
  {
    if(pre[i]==ac[i]) count++;
  }
  
  printf("%d", count);
  
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

template<typename T>
T upmin(const T& l, const T& r) {//SegmentTreeのupdate関数
    T res;
    res = min(l,r);
    return res;
}
template<typename T>
T upmax(const T& l, const T& r) {//SegmentTreeのupdate関数
    T res;
    res = max(l,r);
    return res;
}

template<typename T>
class SegmentTree {
public:
    using F = function<T(T&, T&)>;
    vector<T> seg;
    int sz = 1;
    T unit;
    F up;
    //T (*up)(const T& l,const T& r);
    SegmentTree(const int& n, F up,const T& unit = 0) {
        this->unit = unit;
        //int sz = 1;
        while (sz < n) sz <<= 1;
        seg.resize(sz * 2, unit);
        this->up = up;
    }
    void set(const int& k, const T& x) {//左からk番目の葉にxを代入する
        seg[sz - 1 + k] = x;
    }
    T get(const int& k) {//左からk番目の葉を得る
        return seg[sz - 1 + k];
    }
    void update(int k, const T& v) {// k 番目の値をvに変更
        k += sz - 1;
        seg[k] = v;
        while (k > 0) {
            k = (k - 1) / 2;
            seg[k] = up(seg[2 * k + 1], seg[2 * k + 2]);
        }
    }
    T query(const int& a, const int& b,const int& k, const int& l, const int& r) {//[a,b)のupの合成を求める(a,b,0,0,sz)のように使う
        if (r <= a || b <= l) {
            return unit;
        }
        if (a <= l && r <= b) {
            return seg[k];
        }
        else {
            T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return up(vl, vr);
        }
    }
};

int main(){
    int n;
    cin >> n;
    vector<P> p(n);
    REP(i,n){
        cin >> p[i].first;
        p[i].second = i;
    }
    sort(all(p));
    
    SegmentTree<int> sgmin(n,upmin<int>,n);
    SegmentTree<int> sgmax(n,upmax<int>,-1);
    ll res = 0;
    int sz = sgmin.sz;
    Rep(i,n){
        int t = p[i].second-sgmax.query(0,p[i].second,0,0,sz);
        int t2 = sgmin.query(p[i].second+1,sz,0,0,sz)-p[i].second;
        res+=(double)t*t2*(i+1);
        sgmax.update(p[i].second,p[i].second);
        sgmin.update(p[i].second,p[i].second);
    }
    put(res);
    return 0;
}


Measured memory_bytes: 5888
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>
#include <time.h>
#include <stdio.h>

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

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) a.begin(), a.end()

template<typename T>
void vdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		if (i == size - 1) {
			cout << da[i] << endl;
		}
		else {
			cout << da[i] << ' ';
		}
	}
}
template<typename T>
void vvdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		vdeb(da[i]);
	}
}

void gene(vector<int> &da, vector<int> &ans, int be){
	vector<bool> ju(201000,false);
	rip(i,da.size(),be){
		if(ju[da[i]]){
			while(ans.back() != da[i]){
				ju[ans.back()] = false;
				ans.pop_back();
			}
			ans.pop_back();
			ju[da[i]] = false;
		}
		else{
			ans.push_back(da[i]);
			ju[da[i]] = true;
		}
	}
	return;
}

const int M = 201000;

int main(){
	ll n, k; cin >> n >> k;
	vector<int> da(n);
	rip(i,n,0) cin >> da[i];
	vector<int> to(M), ot(M);
	rip(i,M,0) {to[i] = i;ot[i] = i;}
	//vdeb(da);
	rip(i,n,0){
		to[ot[da[i]]] = 0;
		to[ot[0]] = da[i];
		swap(ot[da[i]], ot[0]);
	}
	int co = 1, now = to[0];
	while(now){
		co++;
		now = to[now];
	}
	co = k%co;
	now = 0;
	rip(i,co,0){
		now = to[now];
	}
	int be = n-1;
	while(be>-1){
		if(da[be] == now){
			break;
		}
		be--;
	}
	//vdeb(to);
	if(be == -1){
		cout << endl;
		return 0;
	}
	vector<int> ans(0);
	gene(da, ans, be);
	vdeb(ans);
	//vdeb(ot);
}

Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	string s; cin>>s;
	int n=s.size();
	rep(i,n-1) if(s[i]=='A'&&s[i+1]=='C') return cout<<"Yes"<<endl,0;
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
from heapq import *
n,m = map(int,input().split())
a = [[int(i) for i in input().split()] for _ in range(n)]
a.sort(key=lambda x:x[0])
ans = 0
PQ = []
heapify(PQ)
idx = 0
for i in range(1,m+1):
    while idx < n and a[idx][0] <= i:
        heappush(PQ,-a[idx][1])
        idx += 1
    if PQ: ans -= heappop(PQ)
print(ans)

Measured memory_bytes: 25736