akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define ll long long int 
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i)) 
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'
 
 
 
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
 map<ll,ll>m;
ll ar[1000005];
int main()
{
	_fastio
	string s,t;
	cin>>s>>t;
	ll cn=0;
	for0(i,s.size())
	{
		if(s[i]!=t[i])
			cn+=1;
	}
	cout<<cn<<en;
}

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

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

    int h = 0;
    for (int i = 1; i < b - a; i++) {
        h += i;
    }

    cout << h - a << endl;
    return 0;
}


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

int main() {
	int N, A, a = 0, ans = INT_MAX;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A;
		a += A;
		ans = min(a / (1 + i), ans);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3116
/*
		@Author :- Gaurav Bharti
		National Institute of Technology, Jamshedpur.
*/
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define empb emplace_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define mapii map<int,int> 
#define mapll map<ll,ll>
#define all(a) a.begin(),a.end()
#define test ll t; cin>>t; while(t--)
#define prec(n) fixed<<setprecision(n)
#define jaldibazi ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007




int main(){
	jaldibazi;

    ll x, k, d;cin >> x >> k >> d;
    x = abs(x);
    ll n = x / d;
    if(k <= n){
        cout << x - d * k << endl;
        return 0;
    }
    ll rem = k - n;
    ll pos = x - (d*n);
    if(rem % 2 == 0){
        cout << pos << endl;
    }
    else{
        cout << abs(pos-d) << endl;
    }

	return 0;
}


Measured memory_bytes: 3604
N = int(input())
h = list(map(int, input().split()))

initial_gr_list = [h]

num = 0
def func(gr_list):
    global num
    n_gr_list = [] # 仕切り後のgr listの箱
    n2_gr_list = [] # 再帰的に次やる予定のgr listの箱
    
    num_ima = int(num) # 今のステップ数をメモっておく。
    
    # 1. まず仕切りごとにgrに分ける。
    for gr in gr_list:
        if gr == []:
            pass
        else:  
            n_gr = []
            #print(gr)
            for i, x in enumerate(gr):
                #print(n_gr)
                if x == 0:
                    n_gr_list.append(n_gr) # 0は仕切り。ここまででgrのlistに追加。
                    n_gr = [] # ここからあたらしいgrが始まる。
                elif i == len(gr)-1: # grの最後のとき。
                    n_gr.append(x)  # 今これはゼロじゃない。n_rgにしまう。
                    n_gr_list.append(n_gr)  # n_grをgr listに追加。
                    n_gr = [] # たぶんいらないけど、一応初期化
                else:
                    n_gr.append(x) # 仕切りでも最後でもないときはn_grにしまう。
    #print('n_gr_list')
    #print(n_gr_list)
    
    # 2. 仕切りごとにminとる
    for n_gr in n_gr_list:
        if n_gr ==[]:
            pass
        else:
            gm = min(n_gr)
            num += gm  # ステップ数を足す。
            n2_gr = [max(x - gm, 0) for x in n_gr]
            n2_gr_list.append(n2_gr)
            #print('n2_gr')
            #print(n2_gr)
    #print('n2_gr_list')
    #print(n2_gr_list)

    if sum(sum(x) for x in n2_gr_list) == 0: # 要素が全部ゼロならおわり。
        return
    else:
        func(n2_gr_list) #再帰的にやる。

func(initial_gr_list)

print(num)


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

int main() {
  int N,x=1;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  for(int i=1;i<N;i++){
    if(a.at(i-1)-a.at(i))x++;
  }
cout<<x<<endl;
}


Measured memory_bytes: 256
import sys;      from decimal import Decimal
import math;     from itertools import combinations, product
import bisect;   from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 6 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)

def Main():
    n = read_int()
    testimony = [[] for _ in range(n)]
    ans = 0

    for i in range(n):
        for _ in range(read_int()):
            x, y = read_ints()
            testimony[i].append((x-1, y))
    
    for bit in range(1 << n):
        flag = True
        for i in range(n):
            if (bit >> i) & 1:
                for x, y in testimony[i]:
                    if (bit >> x) & 1 != y:
                        flag = False
                        break
                else:
                    continue
                break
        
        if flag:
            ans = max(ans, bin(bit).count('1'))
    
    print(ans)


if __name__ ==  '__main__':
    Main()

Measured memory_bytes: 9836
//=====================================================
// 
// (setq backup-inhibited t)
// (setq auto-save-default nil)
// 
// (column-number-mode t)
// (setq-default tab-width 2 indent-tabs-mode nil)
// 
// (global-set-key "\C-h" 'delete-backward-char)
// 
// (setq indent-line-function 'indent-relative-maybe)
// (global-set-key "\C-m" 'newline-and-indent)
// 
//=====================================================

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

pair<bool,int> valid(string& s, int i = 0) {
  if (s[i] != 'm') return make_pair(true, i);
  auto res1 = valid(s, i+1);
  if (!res1.first || res1.second >= s.size()-1 || s[res1.second] != 'e') return make_pair(false, 0);
  auto res2 = valid(s, res1.second + 1);
  if (!res2.first || res2.second >= s.size() || s[res2.second] != 'w') return make_pair(false, 0);
  return make_pair(true, res2.second + 1);
}

int main() {
  string s;
  cin >> s;
  auto res = valid(s);
  if(res.first && res.second == s.size())
    cout << "Cat" << endl;
  else
    cout << "Rabbit" << endl;
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <iomanip>
#include <unordered_map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <functional>
#include <iterator>

using namespace std;

int main() {

  int n;
  cin >> n;
  vector<int> vs(n);
  
  for (int i = 0; i < n; i++) {
    cin >> vs[i];
  }
  
  sort(vs.begin(), vs.end());
  long double result = vs[0];
  for (int i = 1; i < n; i++) {
    result = (vs[i]+result)/2.0l;
  }
  
  cout << fixed << setprecision(6) << result << endl;

  return 0;
}


Measured memory_bytes: 256
import itertools,math

N = int(input())

town_list = []
for i in range(N):
    town_list.append(list(map(lambda x: int(x), input().split())))

jyunretsu = list(itertools.permutations(range(N)))

total_sum = 0
for j in jyunretsu:
    previous_town_number = None
    sum = 0
    for count, town_number in enumerate(j):
        if count == 0:
            previous_town_number = town_number
            continue

        sum += math.sqrt((town_list[town_number][0]-town_list[previous_town_number][0])**2 + (town_list[town_number][1]-town_list[previous_town_number][1])**2)
        previous_town_number = town_number

    total_sum += sum

print(total_sum/len(jyunretsu))

Measured memory_bytes: 7972
#include <stdio.h>

int main()
{
    int num = 3;
    int a[num];

    unsigned int i,j;
    int temp;
 
    scanf("%d%d%d",&a[0],&a[1],&a[2]);
    
    for(i=0;i<num;i++)
    {
        for(j=i+1;j<num;j++)
        {
            if(a[i]>a[j])
            {
                temp = a[j];
                a[j] = a[i];
                a[i] = temp;
            }
        } 
        
    }
    
    printf("%d %d %d\n",a[0],a[1],a[2]);
   

    return 0;
}

Measured memory_bytes: 596
#include<iostream>
#define INT long long int
using namespace std;
int main(){
	INT a,b,c,d,f,i;
	cin>>a>>b;
	INT p[100000];
	for(i=0;i<a;i++)
		cin>>p[i];
	f=0;
	for(i=0;i<a-1;i++){
		if(p[i]+p[i+1]>=b){
			f=1;
			c=i;
			break;
		}
	}
	if(f){
		cout<<"Possible"<<endl;
		for(i=0;i<c;i++)
			cout<<i+1<<endl;
		for(i=a-2;i>c;i--)
			cout<<i+1<<endl;
		cout<<c+1<<endl;
	}else{
		cout<<"Impossible"<<endl;
	}
}

Measured memory_bytes: 1536
X,Y=map(int,input().split())
for i in range(0,101):
  if (X-i)>=0 and i*2+(X-i)*4==Y:
    print('Yes')
    #print(1,i)
    exit()
  elif (X-i)>=0 and i*4+(X-i)*2==Y:
    print('Yes')
    #print(2,i)
    exit()
print('No')

Measured memory_bytes: 9120
n = int(input())
x = input()

original_pop_count = x.count('1')
one_pop_count = original_pop_count - 1 # 0になりうる
zero_pop_count = original_pop_count + 1

one_mod = 0
zero_mod = 0
for b in x:
    if one_pop_count != 0:
        one_mod = (one_mod * 2 + int(b)) % one_pop_count
    zero_mod = (zero_mod * 2 + int(b)) % zero_pop_count

# f の前計算
f = [0] * 220000
pop_count = [0] * 220000
for i in range(1, 220000):
    pop_count[i] = pop_count[i // 2] + i % 2
    f[i] = f[i % pop_count[i]] + 1

# n-1, n-2, ..., 0
for i in range(n-1, -1, -1):
    if x[n-i-1] == '1':
        if one_pop_count != 0:
            nxt = one_mod
            nxt -= pow(2, i, one_pop_count)
            nxt %= one_pop_count
            print(f[nxt] + 1)
        else:
            print(0)
    elif x[n-i-1] == '0':
        nxt = zero_mod
        nxt += pow(2, i, zero_pop_count)
        nxt %= zero_pop_count
        print(f[nxt] + 1)

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

using namespace std;

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

    vector<int> onPair;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;

        a--; // fix 0-start
        onPair.emplace_back(a);
    }

    vector<int> onHist(N, 0);

    int onSwitch = 0; // 0-start
    int count = 0;
    while (onSwitch != 1) {
        onHist[onSwitch]++;

        int nextOn = onPair[onSwitch];
        if (onHist[nextOn] != 0) {
            count = -1;
            break;
        }

        count++;
        onSwitch = nextOn;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 1144
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef vector < int > vint;
typedef pair < int, int > pii;
typedef pair < int, bool > pib;
typedef unsigned long long ull;

#define PB push_back
#define MP make_pair
#define RANGE(V) V.begin(), V.end()
#define FOR(i,n) for(int i=0;i<n;++i)
#define FORN(i,n) for(int i=1;i<=n;++i)
#define debug(x) cerr<<#x<<":"<<x<<"\n";
#define FORS(i,n) for(int i=0;i<n.length();++i)
const int INF = INT_MAX;
const int MAX = 10000001;
const int M = 1000000007;
int mod{ 1000000007 };

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//freopen("input.txt", "r", stdin);
	int t;
	t = 1;
	while (t--) {
		
		int d, t, s;
			cin >> d >> t >> s;
			double time = (double)d/ s;
			if (t >= time) cout << "Yes";
			else cout << "No";
			cout << endl;
		
		}
	return 0;
}






Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
const int MAXN = 2e3, MAXM = 3e4 + 5, BOUND = 2e5, MOD = 1e9 + 7, INF = 0x3f3f3f3f, base = 10000;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0), eps = 1e-9;
#define mid l + ((r-l)>>1)
#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define lc(x) ch[x][0]
#define pii pair<int,int>
#define vi vector<int>
#define R register
#define RR register int
#define rc(x) ch[x][1]
#define rep(i,a,b) for(RR i=(a);i<=(b);++i)
#define random(a,b) ((a)+rand()%((b)-(a)+1))
int n, m, k, a[MAXN];
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m >> k;
	rep(i, 1, 10) {
		k = k * n - m;
		cout << k << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>


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

  int n;
  cin>>n;
  int l=0,r=n;
  string sl,sr;

  cout<<0<<endl;
  cin>>sl;
  if(sl=="Vacant"){
    return 0;
  }
  cout<<n-1<<endl;
  cin>>sr;
  if(sr=="Vacant"){
    return 0;
  }

  while(true){
    int m=(r+l)/2;
    string s;
    cout<<m<<endl;
    cin>>s;
    if(s=="Vacant"){
      return 0;
    }
    if((m-l)%2==0&&sl!=s||(m-l)%2&&sl==s){
      sr=s;
      r=m;
    }else{
      sl=s;
      l=m;
    }
  }


}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define ff first
#define ss second
#define all(v) (v).begin(), (v).end()
#define mod (int)(998244353)
#define PI 3.14159265358979323846264338327950L
#define debug(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << "[ " << *it << " = " << a << " ] ";
    err(++it, args...);
}

signed main(){

    fastIO

    int t = 1;
    // cin >> t;
    while (t--){
    	int a[5];
    	for (int i = 0; i < 5; i++) {
    		cin >> a[i];
    		if (a[i] == 0) {
    			cout << i+1 << endl;
    		}
    	}

    }
    
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = abs(a[0] - a[n-1]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long
#define MOD 1000000007
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
 
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
 

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

ll dp[100001][2];

void dfs(int prev, int current, vector<vector<int>> &edges)
{
  ll white = 1;
  ll black = 1;
  for(int next: edges[current])
  {
    if(prev == next) continue;
    dfs(current, next, edges);
    ll black_mul = dp[next][0];
    ll white_mul = dp[next][1];

    black *= white_mul;
    black %= MOD;
    ll tmp = (black_mul + white_mul) % MOD;
    white *= tmp;
    white %= MOD;
  }

  dp[current][0] = black;
  dp[current][1] = white;
  return;
}

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<int>> edges(n);
    for(int i=0;i<n-1;++i)
    {
      int x, y;
      cin >> x >> y;
      x--; y--;
      edges[x].push_back(y);
      edges[y].push_back(x);
    }
    dfs(-1, 0, edges);

    cout << (dp[0][0] + dp[0][1]) % MOD << endl;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
char block[1010][1010];

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

int wrapx[5]={-2,-1,0,1,2};
int wrapy[5]={-2,-1,0,1,2};
int main(){
    long long h,w;
    cin>>h>>w;
    int ch,cw;
    cin>>ch>>cw;
    int dh,dw;
    cin>>dh>>dw;

    int warp=0;
    rep2(i,h){
        rep2(k,w){
            cin>>block[i][k];
        }
    }
    queue<int>q;
    queue<int>Q;
    q.push(ch);
    q.push(cw);
    //Q.push(ch);
    //Q.push(cw);
    //bool reached[1010][1010];
    long long  dist[1010][1010];

    rep2(i,h)rep2(k,w)dist[i][k]=INF;

    dist[ch][cw]=0;

    
        

while(!q.empty()){

    //コスト0で行ける範囲にたどり着く
    while(!q.empty()){
        int nowy=q.front();
        q.pop();
        int nowx=q.front();
        q.pop();
        //if(block[nowy][nowx]=='#')continue;
        Q.push(nowy);
        Q.push(nowx);
        rep(i,4){
            int ny=nowy+dy[i];
            int nx=nowx+dx[i];
            

            if(ny<1 || ny>h || nx<1 ||nx>w || block[ny][nx]=='#'){
                continue;
            }
            else if(dist[ny][nx]>dist[nowy][nowx]){
                dist[ny][nx]=dist[nowy][nowx];
                
                q.push(ny);
                q.push(nx);
            }
        }
    }
    //コスト+1しないといけない範囲を探索
    while(!Q.empty()){
        int i=Q.front();
        Q.pop();
        int k=Q.front();
        Q.pop();

            
                rep(l,5)
                {
                    rep(p,5)
                    {
                        if(abs(wrapy[l])+abs(wrapx[p])<=1)continue;

                        int ny=i+wrapy[l];
                        int nx=k+wrapx[p];

                            if(ny<1 || ny>h || nx<1 ||nx>w || block[ny][nx]=='#'){
                                continue;
                            }
                            //ワープして行ける範囲でコスト0の幅優先探索
                            else if(dist[ny][nx]>dist[i][k]+1){
                            dist[ny][nx]=dist[i][k]+1;
                            q.push(ny);
                            q.push(nx);
                            }
                    }
                }
            
            
    }
    
}

    
    if(dist[dh][dw]==INF){
        cout<<"-1"<<endl;
    }
    else{
        cout<<dist[dh][dw]<<endl;
    }
    // rep2(i,h){
    //     rep2(k,w){
    //         if(dist[i][k]==INF){
    //             cout<<"INF ";
    //         }
    //         else{
    //             cout<<dist[i][k]<<"    ";
    //         }
    //     }
    //     cout<<endl;
    // }


    return 0;

}
/*


*/


Measured memory_bytes: 12484
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

void solve()
{
    int n, i;
    cin >> n >> i;
    cout << n - i + 1 << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


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

const int size = 1 << 17;
int segval[1 << 18], segid[1 << 18];
void init(){
	for (int i = 0; i < size; i++) segid[i + size - 1] = i;
}
void update(int i, int x){
	int k = i + size - 1;
	segval[k] += x;
	while (k){
		k = (k - 1) / 2;
		int t = segval[k * 2 + 1] >= segval[k * 2 + 2] ? k * 2 + 1 : k * 2 + 2;
		segval[k] = segval[t];
		segid[k] = segid[t];
	}
}
int get(){
	return segid[0];
}

int n, r, l;
int d[1000002], t[1000002], x[1000002];
int a[100000];

int main()
{
	scanf("%d %d %d", &n, &r, &l);
	init();
	for (int i = 1; i <= r; i++){
		scanf("%d %d %d", d + i, t + i, x + i);
	}
	t[r + 1] = l;
	
	for (int i = 1; i <= r + 1; i++){
		a[get()] += t[i] - t[i - 1];
		update(d[i] - 1, x[i]);
	}
	
	int res = 0;
	for (int i = 0; i < n; i++){
		if (a[res] < a[i]) res = i;
	}
	printf("%d\n", res + 1);
}

Measured memory_bytes: 14780
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 0;
        int ans = 0;

        while(true){
            ans = heihou(count);
            if(ans > n){
                ans = heihou(count-1);
                break;
            }
            count++;
        }

        System.out.println(ans);
    }

    int heihou(int num){
        return num*num;
    }
}

Measured memory_bytes: 22100
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MAX_S_LEN=2e5;
string S;
ll dp[MAX_S_LEN+1][4];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>S;
	REP(i,S.size()){
		REP(j,min(4ll,i+1)){
			if(j==i){
				dp[i+1][j]=1;
			}else{
				dp[i+1][j]=-MAX_S_LEN-1;
				REP(k,min(4ll,i-j)){
					if(S.substr(i-j,j+1)!=S.substr(i-j-k-1,k+1)){
						dp[i+1][j]=max(dp[i+1][j],dp[i-j][k]+1);
					}
				}
			}
		}
	}
	cout<<*max_element(dp[S.size()],dp[S.size()]+4)<<endl;
}

Measured memory_bytes: 6804
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int total = 0;
		int[] donut = new int[N];
		int cheapest = Integer.MAX_VALUE;
		for (int i=0; i<N; i++){
			donut[i] = sc.nextInt();
			cheapest = Math.min(cheapest, donut[i]);
			X-=donut[i];
			total++;
		}
		total+=X/cheapest;
		System.out.println(total);
	}

}

Measured memory_bytes: 36008
// Problem : B - Easy Linear Programming
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define fastio                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define db1(x) cout << #x << "=" << x << endl
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z)                                                       \
  cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define dbp(x) \
  cout << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
#define dbv(v)                         \
  {                                    \
    cout << #v << " : ";               \
    for (auto x : v) cout << x << ' '; \
    cout << endl;                      \
  }
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rep2(i, a, b) for (int i = a; i >= b; i--)
#define die(x) return cout << x << '\n', 0;

using namespace std;

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

int32_t main() {
  fastio;
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
  int testcases;
  testcases = 1;
  // cin >> testcases;

  while (testcases--) {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int t = 0;
    if (a >= k) {
      t = k;
      die(t);
    } else {
      if (a + b >= k) {
        t = a;
        die(t);
      } else {
        k -= (a + b);
        t = a - k;
        die(t);
      }
    }
  }

  return 0;
}


Measured memory_bytes: 3592
import java.util.Scanner;

class Rectangle {
	private int _virtical;
	private int _horizontal;
	
	public Rectangle() {
		
	}
	
	public Rectangle(int virtical, int horizontal) {
		_virtical = virtical;
		_horizontal = horizontal;
	}
	
	public int getArea() {
		return _virtical * _horizontal;
	}
	
	public int getPerimeter() {
		return _virtical * 2 + _horizontal * 2;
	}
}
public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		Rectangle rectangle = new Rectangle(scan.nextInt(), scan.nextInt());
		System.out.println(rectangle.getArea() + " " + rectangle.getPerimeter());
	}

}



Measured memory_bytes: 26136
color_list = [0]*9

x = input()

score_lists = list(map(int, input().split()))

for i in score_lists:
    if i < 400:
        color_list[0] = 1
    elif i < 800:
        color_list[1] = 1
    elif i < 1200:
        color_list[2] = 1
    elif i < 1600:
        color_list[3] = 1
    elif i < 2000:
        color_list[4] = 1
    elif i < 2400:
        color_list[5] = 1
    elif i < 2800:
        color_list[6] = 1
    elif i < 3200:
        color_list[7] = 1
    else:
        color_list[8] = color_list[8] + 1

ans_min = color_list[0] + color_list[1] + color_list[2] + color_list[3] + color_list[4]\
     + color_list[5] + color_list[6] + color_list[7]

if ans_min == 0 and color_list[8] != 0:
    ans_min = 1

ans_max = color_list[0] + color_list[1] + color_list[2] + color_list[3] + color_list[4]\
     + color_list[5] + color_list[6] + color_list[7] + color_list[8]

print(ans_min, ans_max)

Measured memory_bytes: 3064
/**
                    Unmesh Kumar
     Indian Institute of Technology,Roorkee CSE'22
""If everything seems under control then you are not going fast enough!""

**/



#include <iostream>
#include <bits/stdc++.h>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <map>
#include <iterator>
#include <iomanip>
#include <queue>
#include <utility>

using namespace std;
#define ll long long int
#define c(x) ll x;cin>>x
#define cc(x,y) ll x,y;cin>>x>>y
#define ccc(x,y,z) ll x,y,z; cin>>x>>y>>z
#define db long double
#define fast cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
#define inf 200000000000000
#define mod 1000000007
#define eps 1e-7
#define PI 3.1415926535897932385
#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define len(x) (ll)(x).size()
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define print(arr,n) rep(i,n) cout<<arr[i]<<" "; cout<<endl
#define print2(arr,n,m) rep(i,n){ rep(j,m) cout<<arr[i][j]<<" "; cout<<endl; }
#define dyn1(arr,n) ll* arr=new ll[n]; rep(i,n) arr[i]=0;
#define dyn2(arr,n,m) ll** arr=new ll*[(n)]; rep(i,n) arr[i]=new ll[m]; rep(i,n) rep(j,m) arr[i][j]=0
#define carr(arr,n) rep(i,n) cin>>arr[i]
#define carr2(arr,n,m) rep(i,n) rep(j,m) cin>>arr[i][j]
#define debug(a) cout<<" :: "<<#a<<" == "<<a<<endl
#define debug2(a,b) cout<<" :: "<<#a<<" == "<<a<<" :: "<<#b<<" == "<<b<<endl
typedef pair<int,int> ii;
typedef vector<ii> vii;

inline ll maxim(ll a,ll b) {if(a>b) return a; else return b;}
inline ll minim(ll a,ll b) {if(a<b) return a; else return b;}
inline bool equals(double a, double b){ return fabs(a - b) < 1e-9; }
ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }


ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1) res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res;
}
map<string,ll> m;



int modInverse(int a, int m)
{
    int m0 = m;
    int y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        // q is quotient
        int q = a / m;
        int t = m;
        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;
        // Update y and x
        y = x - q * y;
        x = t;
    }
    // Make x positive
    if (x < 0)
       x += m0;
    return x;
}



ll arr[200001];
ll dp[100001];
ll y[100001];

int main()
{
  fast;
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  cout<<setprecision(10)<<fixed;
  dyn2(c,2005,2005);
  rep(o,2001)
  {
    c[o][0]=1;
  }
  rep(o,2001)
  {
    c[o][o]=1;
  }
  rep(o,2001)
  {
    fr(p,1,o-1)
    {
      c[o][p]=(c[o-1][p]+c[o-1][p-1])%mod;
    }
  }
  cc(n,k);
  fr(i,1,k)
  {
    cout<<(c[k-1][i-1]*c[n-k+1][i])%mod<<endl;
  }
  return 0;
}


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

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

int main() {
    ll n, m;
    string s, t;
    cin >> n >> m >> s >> t;
    ll ans = lcm(n, m);
    ll g = gcd(n, m);
    for (ll k = 0; k < g; k++) {
        if (s[k * n / g] != t[k * m / g]) {
            ans = -1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define meme(a,v)    memset((a), (v), sizeof (a))
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define anal         '\n'
#define mod 1000000007
//const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
  


//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
      
int main(){
I_AM_SPEED;


//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
          
       int x;
       cin >> x;
       int mov = 0, angle = 0;
       while(true){
           mov++;
           angle += x;
           if(angle%360 == 0){
               cout << mov << anal;
               return 0;
           }
          
       }

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//printclock; 
return  0 ;      
}        



   

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 200005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
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...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


bool vis[N];

void solve(){
    int n, m; cin>>n>>m;
    int si = 1;
    int ei = n;
    int i = 0;
    vector<pii> vect;
    while(i<m && si<ei){
        int v1 = ei-si;
        int v2 = n-v1;
        if(!vis[v1] && !vis[v2] && v1!=v2){
            vect.pb({si, ei});
            vis[v1] = true;
            vis[v2] = true;
            si++;
            ei--;
            i++;
        }
        else{
            si++;
        }
    }
    for(pii p: vect){
        cout<<p.F<<" "<<p.S<<"\n";
    }
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1;
    while(t--){
        solve();
    }
    return 0;
}





Measured memory_bytes: 5644
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        String T = sc.next(), P = sc.next();
                        int ans = 0;
                        for (int i = 0; i <= T.length() - P.length(); i++) {
                                if (T.substring(i, i + P.length()).equals(P)) {
                                        System.out.println(i);
                                }
                        }
                }
        }
}

Measured memory_bytes: 26440
#include<iostream>
#include<string>
using namespace std;
int main(){

  string S;
  cin>>S;
  char check='a';
  bool flag=0;
  for(check='a';check<='z';check++){
  
    flag=1;
    for(size_t i=0;i<=S.length()-1;i++){
    
      if(S[i]==check){
      
        flag=0;
        break;
      }
    }
    if(flag==1){
    
      cout<<check;
      return 0;
    }
  }
  cout<<"None";
  return 0;
}

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


int main()
{
    int n;
    cin>>n;
    int A[n];
    for(int i=0;i<n;i++)
        cin>>A[i];
    sort(A,A+n);
    int a,b=1000000000;
    if(A[n-1]%2==0)
    {
        a=A[n-1]/2;
        int mini=1000000000,in;
        for(int i=0;i<n-1;i++)
        {
           if(fabs(A[i]-a)<mini)
           {
               mini=fabs(A[i]-a);
               in=i;
           }
        }
        cout<<A[n-1]<<" "<<A[in]<<endl;
    }
    else
    {
        a=A[n-1]/2;
        b=a+1;
        //cout<<a<<" "<<b<<endl;
        int mini=1000000000,in;
        //cout<<mini<<endl;
        for(int i=0;i<n;i++)
        {
            if(fabs(A[i]-a)<mini)
            {
                mini=fabs(A[i]-a);
                in=i;
            }
            if(fabs(A[i]-b)<mini)
            {
                mini=fabs(A[i]-b);
                in=i;
            }
            //cout<<mini<<endl;
        }
        cout<<A[n-1]<<" "<<A[in]<<endl;
    }

}


Measured memory_bytes: 640
import java.util.*;

/**
 * Created by Santa on 2016/10/16.
 */
public class Main {

    static int N;
    static long A;
    static long B;
    static long C;
    static int[] map;





    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        String s = scanner.next();

        int a = 0;
        int b = 0;

        int c = 0;

        for (int i = 0; i < N; i++) {
            if(s.charAt(i) == 'W'){
                a++;
            }
        }
        b = N - a;
        c = b;

        int min = 99999999;
        for (int i = 0; i < N; i++) {
            if(s.charAt(i) == 'E'){
                c--;
            }
            min = Math.min(min, c);

            if(s.charAt(i) == 'W'){
                c++;
            }

        }

        System.out.println(min);

    }



}



Measured memory_bytes: 29488
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll k, x ;
  cin >> k >> x;
  ll st = x - k + 1;
  ll end = x + k - 1;
  for(ll i = st; i <=end; i++) cout << i << " ";
  return 0;
} //good night.

Measured memory_bytes: 256
//1W153021 KOYA IWASE
#include<stdio.h>
void selectionsort(int a[],int N);//??¢??°??£?¨?
static int cnt=0;//???????????°????¨????
int main(){
  int N;
  scanf("%d",&N);
  int a[N];
  for(int i=0;i<N;i++){
    scanf("%d",&a[i]);
  }
  selectionsort(a,N);//??¢??°????????????
  int j=0;
  for(int i=0;i<N;i++){//???????????????
    if(j++>0)printf(" ");
    printf("%d",a[i]);
  }
  printf("\n");
  printf("%d\n",cnt);
}
void selectionsort(int a[],int N){//???????????????
  int minj=0;
  for(int i=0;i<N;i++){//???????°???????????´??????????????????°?????§????´?????????????
    minj=i;
    for(int j=i;j<N;j++){
      if(a[j]<a[minj]){
        minj=j;
      }
    }
    if(i!=minj){//i==minj???????°???????????´?????????????????????§????????????????????????
      int temp=a[i];
      a[i]=a[minj];
      a[minj]=temp;
      cnt++;//?????????????????§?????????????????????
    }
  }
}

Measured memory_bytes: 1768
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=100005;
int nxt[N],pre[N],ans[N];
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  string s;
  cin>>s;
  int curr=-1;
  nxt[sz(s)-1]=-1;
  repv(i,0,sz(s)-1)
    {
      if(s[i]=='R' && s[i+1]=='L') curr=i;
      if(s[i]=='R') nxt[i]=curr;
      else nxt[i]=-1;
    }
  pre[0]=curr=-1;
  rep(i,1,sz(s))
    {
      if(s[i]=='L' && s[i-1]=='R') curr=i;
      if(s[i]=='L') pre[i]=curr;
      else pre[i]=-1;
    }
  rep(i,0,sz(s))
    {
      if(s[i]=='R')
	{
	  int diff=nxt[i]-i;
	  if(diff&1) ans[nxt[i]+1]++;
	  else ans[nxt[i]]++;
	}
      else
	{
	  int diff=i-pre[i];
	  if(diff&1) ans[pre[i]-1]++;
	  else ans[pre[i]]++;
	}
    }
  rep(i,0,sz(s)) cout<<ans[i]<<" "; cout<<endl;
  return 0 ;
}


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

int main() {

    int n;
    cin >> n;

    vector<int> p(n);
    for(int i = 0; i < n; ++i){
        cin >> p.at(i);
    }
    int out = 0;

    for(int i = 1; i < n -1 ; ++i){

        if(p.at(i) >= p.at(i-1) && p.at(i) <= p.at(i+1))++out;
        if(p.at(i) <= p.at(i-1) && p.at(i) >= p.at(i+1))++out;
    }

    cout << out << endl;

}

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

using namespace std;

const int inf = 1e9+10;

struct Edge {
    int from,to,weight;

    Edge(int f,int t,int w)
    {
        from=f;to=t;weight=w;
    }

    bool operator < (const Edge &x) const
    {
        return weight < x.weight;
    }
};

int edmonds(vector<Edge> &G, int V, int R)
{
    vector<Edge> minInEdge(V,Edge(-1, -1, inf));
    for (int i=0;i<G.size();i++)
    {
        const Edge &e = G[i];
        minInEdge[e.to] = min(minInEdge[e.to], e);
    }
    minInEdge[R] = Edge(-1, R, 0);

    vector<int> group(V, 0);
    vector<bool> visited(V, false), isCycleGroup(V, false);
    int cnt = 0;
    for (int i = 0; i < V; i++)
    {
        if (visited[i])
            continue;

        int node = i;
        vector<int> path;
        while (node != -1 && !visited[node])
        {
            visited[node] = true;
            path.push_back(node);
            node = minInEdge[node].from;
        }

        bool isCycle = false;
        for (int i=0;i<path.size();i++)
        {
            int v = path[i];
            group[v] = cnt;
            if (v == node)
                isCycleGroup[cnt] = isCycle = true;
            if (!isCycle)
                cnt++;
        }

        if (isCycle)
            cnt++;
    }

    if (cnt == V)
    {
        int answer = 0;
        for (Edge e : minInEdge)
            answer += e.weight;
        return answer;
    }

    int answer = 0;
    for (int i=0;i<minInEdge.size();i++)
    {
        Edge &e = minInEdge[i];
        if (isCycleGroup[group[e.to]])
            answer += e.weight;
    }


    vector<Edge> n_G;
    for (int i=0;i<G.size();i++)
    {
        const Edge &e = G[i];
        int u = group[e.from], v = group[e.to], w = e.weight;
        if (u == v)
            continue;
        else
            n_G.push_back(Edge(u, v, w - (isCycleGroup[v] ? minInEdge[e.to].weight : 0)));
    }

    return answer + edmonds(n_G, cnt, group[R]);
}

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

    int v,e,r;
    cin>>v>>e>>r;

    vector<Edge> G;
    for(int i=0;i<e;i++)
    {
        int s,t,w;
        cin>>s>>t>>w;
        G.push_back(Edge(s,t,w));
    }

    cout<<edmonds(G,v,r)<<endl;

    return 0;
}



Measured memory_bytes: 3380
#include<bits/stdc++.h>
using namespace std;
#define INF 0x7FFFFFFF

int main(){
    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;
    if(s==u)cout << a-1 << " " << b << endl;
    else cout << a << " " << b-1 << endl;
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	int count = 0;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		for (; a % 2 == 0; a /=2) count++;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

ll m, d;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> m >> d;
  ll ans = 0;
  rep(i, 1, m+1) {
    rep(j, 22, d+1) {
      ll d1 = j/10;
      ll d2 = j%10;
      if (d1<2||d2<2) continue;
      if (i==d1*d2) ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N - 1];
    int[] b = new int[N - 1];
    for (int i = 0; i < N - 1; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
    }
    sc.close();

    @SuppressWarnings("unchecked")
    List<int[]>[] g = new List[N + 1];
    g[0] = Collections.emptyList();
    for (int i = 0; i < N - 1; i++) {
      if (g[a[i]] == null) g[a[i]] = new ArrayList<>();
      g[a[i]].add(new int[] {b[i], i});
      if (g[b[i]] == null) g[b[i]] = new ArrayList<>();
      g[b[i]].add(new int[] {a[i], i});
    }
    int K = 0;
    for (List<int[]> e : g) K = Integer.max(K, e.size());

    int[] c = new int[N - 1];
    Deque<int[]> q = new ArrayDeque<>();
    q.addLast(new int[] {1, -1});
    while (!q.isEmpty()) {
      int[] n = q.pollFirst();
      int cno = n[0];
      int pid = n[1];

      int ec = 1;
      List<int[]> es = g[cno];
      for (int[] e : es) {
        int dno = e[0];
        int did = e[1];
        if (did == pid) continue;

        if (-1 < pid && ec == c[pid]) ec++;
        if (K < ec) ec = 1;
        c[did] = ec++;
        q.addLast(new int[] {dno, did});
      }
    }

    System.out.println(K);
    StringBuffer buf = new StringBuffer();
    for (int i : c) buf.append(i).append(System.lineSeparator());
    System.out.println(buf);
  }
}

Measured memory_bytes: 74260
n, m, l = map(int, input().split())
A = [[]] * n
B = [[]] * m
C = [[0 for i in range(l)] for j in range(n)]
for i in range(n):
    A[i] = list(map(int, input().split()))
for i in range(m):
    B[i] = list(map(int, input().split()))
for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
        if j != l - 1:
            print(C[i][j], end = ' ')
        else:
            print(C[i][j], end = '')
    print('')



Measured memory_bytes: 7052
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int a,b;
int main()
{
  ll ans;

  cin >> a >> b;

  ans = a*b;
  cout << ans << endl;
  return 0;
}


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

#define max(a, b) (((a) > (b)) ? (a) : (b))

int flag[1000001];

int main(void) {
	int i;
	int q;

	scanf("%d", &q);

	while (q--) {
		int n;
		int cnt;

		scanf("%d", &n);

		memset(flag, 0, sizeof flag);
		cnt = 0;
		while (n > 9) {
			char str[8];
			int len;
			int max;

			flag[n] = 1;

			sprintf(str, "%d", n);
			len = strlen(str);

			max = 0;
			for (i = 1; i < len; i++) {
				char substr1[7], substr2[7];

				strncpy(substr1, str, i);
				substr1[i] = '\0';
				strcpy(substr2, str + i);

				max = max(max, atoi(substr1) * atoi(substr2));
			}
			n = max;

			if (flag[n]) {
				cnt = -1;
				break;
			}

			cnt++;
		}

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

	return 0;
}

Measured memory_bytes: 4532
H, N = map(int, input().split())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    
#import numpy as np
#dp = np.zeros([N+1, H+1])
#dp[0, 1:] = np.inf
dp = [[0]*(H+1) for _ in range(N+1)]
for j in range(1, H+1):
	dp[0][j] = float('inf')

for i in range(0, N):
    for j in range(1, H+1):        
        dp[i+1][j] = min(dp[i][j], dp[i+1][max(0, j-A[i])] + B[i])
        
print(int(dp[-1][-1]))

Measured memory_bytes: 119388