akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << min(a,b) + min(c,d) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define INF 1073741824
#define ll long long
#define PI (2*acos(0.0))
using namespace std;
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> 
void dbg_out(Head H, Tail... T) { 
    cerr << ' ' << H;
     dbg_out(T...); 
}
#define dbg(...) cerr << '(' << #__VA_ARGS__ << ')'<<':', dbg_out(__VA_ARGS__)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define vi vector<int>
#define vll vector<ll>
#define on(val,pos) val|(1<<pos)
#define off(val,pos) val&(~(1<<pos))
#define check(val,pos) (val&(1<<pos))
#define all(n) n.begin(),n.end()
//first four adjacent,second four corner
//int row[8]={0,-1,0,1,1,-1,-1,1};
//int col[8]={-1,0,1,0,-1,-1,1,1};
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main(){
    int i,j,k,n,m,val,t=0,test;
    //freopen("000input.txt","r",stdin);
    double a,b,c;
    cin>>a>>b>>c;
    if(a/c<=b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    //free();   //if pointer array
    return 0;
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
int main() {
	int l, r, d;
	cin>>l>>r>>d;
	if(l%d==0 || r%d==0)
	cout<<((r-l)/d)+1;
	else
	cout<<((r-l)/d);
	return 0;
}

Measured memory_bytes: 3588
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

a,b,c,d=get_i
puts max(max(a*d,b*c),max(a*c,b*d))

Measured memory_bytes: 14424
#include <bits/stdc++.h>
#define cina(a, n) for (int i = 0; i < n; ++i){ cin >> a[i]; }
#define ll long long

using namespace std;

int main () {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	int a, sum = 0;
	for (int i = 0; i < m; ++i) {
		cin >> a;
		sum += a;
	}
	if (sum <= n) {
		cout << n - sum;
	} else {
		cout << -1;
	}
	return 0;
}

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

struct Edge{
	  int t,d;
	  Edge(int to, int dis){
			t = to; d = dis;
	  }
};
typedef long long ll;
typedef vector<vector<ll> > Adj_Mat;


bool contain(int mask, int pos){
	  return ( mask & (1<<pos) ) != 0;
}

int main(){

	  // Input Graph
	  int V,E;
	  cin >> V >> E;

	  Adj_Mat G(V,vector<ll>(V,INT_MAX));
	  for(int i=0; i<E; i++){
			int s,t,d; cin >> s >> t >> d;
			G[s][t] = d;
	  }

	  ll ans = INT_MAX;
	  // Dynamic Programming for TSP
	  for(int st=0; st<V; st++){

			ll dp[ (1<<V) ][ V ];
			for(int i=0; i<(1<<V); i++)
				  for(int j=0; j<V; j++)
						dp[i][j] = INT_MAX;
			dp[ 0 ][ st ] = 0;

			for(int S=1; S<(1<<V); S++)
				  for(int v=0; v<V; v++)
						if( contain(S,v) )
							  for(int j=0; j<V; j++)
									dp[S][v] = min(dp[S][v], dp[S-(1<<v)][j] + G[j][v]);
			ans = min(ans,dp[ (1<<V)-1 ][st]);
	  }
	  if( ans >= 1e+9 ) ans = -1;
	  cout << ans << endl;
}

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

using namespace std;
using ll = long long;

int main() {
  vector<vector<int> > as(3, vector<int>(3));
  vector<vector<bool> > op(3, vector<bool>(3, false));
  rep(i, 3) rep(j, 3) { cin >> as[i][j]; }

  int n;
  cin >> n;
  rep(i, n) {
    int b;
    cin >> b;
    rep(j, 3) rep(k, 3) {
      if (as[j][k] == b) {
        op[j][k] = true;
      }
    }
  }
  rep(i, 3) {
    if (op[i][0] && op[i][1] && op[i][2]) {
      cout << "Yes" << endl;
      return 0;
    }
    if (op[0][i] && op[1][i] && op[2][i]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if (op[0][0] && op[1][1] && op[2][2]) {
    cout << "Yes" << endl;
    return 0;
  }
  if (op[2][0] && op[1][1] && op[0][2]) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3604
// Problem : C - Repsept
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#define lli long long int
#define pb push_back
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,a,n) for(i=a;i<n;i++)
#define all(v) (v.begin(),v.end())
#define ppb pop_back
#define vsz v.size()
#define pi 3.141592653589793238
using namespace std;
int main()
{
	lli t,count=7,n,i;
	cin>>n;
	for(i=0;i<1000000;i++){
		if(count%n==0){
			cout<<i+1;
			return 0;
		}
		count*=10;
		count+=7;
		count%=n;
	}
	cout<<"-1";
	return 0;
}

Measured memory_bytes: 3564
#include<stdio.h>

int main(void){
    int num, min=1000000, max=-1000000, tmp;
    long int sum=0;
    scanf("%d", &num);
    for(int i=0; i<num; i++){
        scanf("%d", &tmp);
        if(min > tmp) min = tmp;
        if(max < tmp) max = tmp;
        sum += tmp;
    }
    printf("%d %d %ld\n", min, max, sum);
    return 0;
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
 int a,b,c,d;
 cin>>a>>b>>c>>d;
 if(a+b>c+d){
 cout<<"Left"<<endl;
 }
 else if (a+b<c+d){
 cout<<"Right"<<endl;
 }
else {
	cout<<"Balanced"<<endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)
#define int long long
#define debug(var) cout << "[" << #var << "] " << var << endl
//using ll = long long;

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=998244353;

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

    if ((b-a) % 2 == 0) {
        cout << (b-a)/2 << endl;
        exit(0);
    }

    int result = 0;
    if (a-1 <= n-b) {
        result += a;
        result += (b-a-1)/2;
        cout << result << endl;
        exit(0);
    } else {
        result += n-b+1;
        result += (n-a-(n-b+1))/2;
        cout << result << endl;
        exit(0);
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    if (a%3==0||b%3==0||(a+b)%3==0) {
      System.out.println("Possible");
    }else{
      System.out.println("Impossible");
    }
  }
}


Measured memory_bytes: 20692
N, M = map(int, input().split())
a = [-1]*N
f = True
for i in range(M):
    s, c = map(int, input().split())
    if a[s-1] != -1 and a[s-1] != c:
        f = False
        break
    elif N != 1 and s == 1 and c == 0:
        f = False
        break
    else:
        a[s-1] = c
if not f:
    print(-1)
else:
    result = ''
    for i in range(N):
        if a[i] != -1:
            result += str(a[i])
        else:
            if i == 0 and N != 1:
                result += '1'
            elif i == 0 and N == 0:
                result += '0'
            else:
                result += '0'
    print(int(result))

Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define mem(dp,a) memset(dp,a,sizeof dp);
#define all(a) a.begin(),a.end()
#define sall(a) sort(all(a))
#define X first
#define Y second
typedef long long int ll;
typedef pair<ll,ll> pp;

#define debug(x) cout << #x << " :: "<< x <<"\n";
#define debug2(x,y) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\n";
#define debug3(x,y,z) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\t" << #z << " :: " << z << "\n";
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree< pp , null_type,less< pp >, rb_tree_tag,tree_order_statistics_node_update>

ll power(ll b, ll exp){
    ll res = 1;
    while(exp > 0){
        if(exp % 2){
            res = 1LL * res * b % mod;
        }
        b = 1LL * b * b % mod;
        exp /= 2;
    }
    return res;
}

int main()
{
    boost
    ll n,cnt=0;
    cin >> n;
    vector<ll> a(n+1);
    for(ll i=1;i<=n;i++) {
        cin >> a[i];
        if( (i&1) && (a[i]&1) )
            cnt++;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 3616
import sys
import math


N,K=map(int,input().split())
r,s,p=map(int,input().split()) 
t=input()
ans=0
for i in range(K):
    j=i
    tmp=[0,0,0]
    while j<N:
        if t[j]=='r':
            tmp=[max(tmp[1],tmp[2]),max(tmp[0],tmp[2]),max(tmp[0],tmp[1])+p]
        elif t[j]=='s':
            tmp=[max(tmp[1],tmp[2])+r,max(tmp[0],tmp[2]),max(tmp[0],tmp[1])]
        else:
            tmp=[max(tmp[1],tmp[2]),max(tmp[0],tmp[2])+s,max(tmp[0],tmp[1])]
        j+=K
        
    ans+=max(tmp)

print(ans)


Measured memory_bytes: 3316
def In():
  return map(int, raw_input().split())

def D(a, b): # diatance between a and b
  return ((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2) ** .5

def f(P, O): # make a vector from O to P
  return P[0] - O[0], P[1] - O[1]

def dot(a, b): #inner product of vectors a and b
  return a[0] * b[0] + a[1] * b[1]

def cross(a, b): #cross product of vectors a and b
  return a[0] * b[1] - a[1] * b[0]

def ab2c(a, b, c): # distance from point c to segment a-b
  if dot(f(c, a), f(b, a)) < 0:
    return D(a, c)
  if dot(f(c, b), f(a, b)) < 0:
    return D(b, c)
  return abs(cross(f(b, a), f(c, a))) / D(b, a)

def isIn(P, O, P1, P2): # check if point P is in triangle O-P1-P2
  a11, a21 = f(P1, O)
  a12, a22 = f(P2, O)
  x0, y0 = f(P, O)
  det = 1.0 * a11 * a22 - a12 * a21
  x = (a22 * x0 - a12 * y0) / det
  y = (-a21 * x0 + a11 * y0) / det
  return 0 <= x <= 1 and 0 <= y <= 1 and 0 <= x + y <= 1
def check(P4, r, P1, P2, P3):
  if max([D(P4, P1), D(P4, P2), D(P4, P3)]) <= r:
    return 2
  h1 = ab2c(P1, P2, P4)
  h2 = ab2c(P2, P3, P4)
  h3 = ab2c(P3, P1, P4)
  if isIn(P4, P1, P2, P3):
    if min([h1, h2, h3]) >= r:
      return 1
  elif min([h1, h2, h3]) > r:
    return 0
  return 3

while 1:
  P1 = In()
  if P1[0] == P1[1] == 0:
    break
  P2 = In()
  P3 = In()
  P4 = In()
  r = int(raw_input())
  print 'dabc'[check(P4, r, P1, P2, P3)]

Measured memory_bytes: 4448
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N,L = inputlist()
li = [0]*N
for i in range(N):
    li[i] = L+i
ans = -1
d = 10**18
s = sum(li)
for i in range(N):
    sa = s
    sa -=li[i]
    da = abs(s-sa)
    if da < d:
        ans = sa
        d = da
print(ans)

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


#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define len(s) s.length()
#define forp(i,a,b) for( i=a;i<=b;i++)
#define rep(i,n)    for( i=0;i<n;i++)
#define ren(i,n)    for( i=n-1;i>=0;i--)
#define forn(i,a,b) for( i=a;i>=b;i--)
#define on cout<<endl
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define all(v) v.begin(),v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ret return 0
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100001
#define SIZ 1000001
#define SIZE 200001

typedef long long  ll;
typedef long double  ldo;
typedef double  db ;
using namespace std;
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define w(x)            int x; cin>>x; while(x--)

void c_p_c()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
ll dp[100005];
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   c_p_c();
   ll n,w;
   cin>>n>>w;
   vector <pair<ll,ll>> v(n+1);
   for(int i=1;i<=n;i++){
      cin>>v[i].first>>v[i].second;
   }
   memset(dp,0,sizeof(dp));
   for(int j=1;j<=n;j++){
      for(int i=w;i>=0;i--){
         if (i-v[j].first>=0){
            dp[i]=max({dp[i-v[j].first]+v[j].second,dp[i]});
         }
      }
   }
   ll ans=0;
   for(int i=0;i<=w;i++){
     // cout<<dp[i]<<" ";
      ans=max(dp[i],ans);
   }
   cout<<ans;
   return 0;
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(max(a, b), min(a, b)); }

int main() {
        /* input */
    int N;  cin >> N;
    vector<ll> a(N); rep(i, N) cin >> a[i];

    // 方針：少なくとも m = LCM-1 の時，f の各項が最大値 a[i]-1 を取るので，f は最大となる．

    ll ans = 0;
    rep(i, N) {
        ans += a[i] - 1;
    }

    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main(){
	
	string x;
	cin >> x;
	int a,b,c,d;
	
	a=(int)(x[0]-'0');
	b=(int)(x[1]-'0');
	c=(int)(x[2]-'0');
	d=(int)(x[3]-'0');
	
	char q,w,e;
	q=w=e=NULL;
	for(int A=1;A<=2;A++){
		for(int B=1;B<=2;B++){
			for(int C=1;C<=2;C++){
				int res=a;
				if(A==1)res+=b;
				if(A==2)res-=b;
				
				if(B==1)res+=c;
				if(B==2)res-=c;
				
				if(C==1)res+=d;
				if(C==2)res-=d;
				
				if(res==7){
					if(A==1)q='+';
					if(A==2)q='-';
				
					if(B==1)w='+';
					if(B==2)w='-';
					
					if(C==1)e='+';
					if(C==2)e='-';
					break;
				}
			}
		}
	}
				
	cout << a << q << b << w << c << e << d << "=7" << endl; 	
	
	return 0;
}


Measured memory_bytes: 256
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
B = list(map(int, input().split()))
B.sort(reverse=True)
C = list(map(int, input().split()))
C.sort(reverse=True)

AB = []
for b in B:
    for a in A:
        AB.append(a+b)
AB.sort(reverse=True)
AB = AB[:K+1]

ABC = []
for c in C:
    for ab in AB:
        ABC.append(ab+c)
ABC.sort(reverse=True)
for i in range(K):
    print(ABC[i])

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    UnionFind(int N) : par(N),siz(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++){
             par[i] = i;
             siz[i] = 1;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        // merge technique（小を大にくっつける）
        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    ll size(ll x){
        return siz[root(x)];
    }
};

signed main()
{   
    gearup;
    ll n,m; cin >> n >> m;

    UnionFind uf(n);
    rep(i,m){
        int a,b,c; cin >> a >> b >> c;
        uf.unite(--a,--b);
    }
    set<ll> res;
    rep(i,n){
        res.insert(uf.root(i));
    }
    out(res.size());
}


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

typedef pair <int, int> ii;

const int Maxn = 100005;

int n, m;
ii lr[Maxn];

int main()
{
    scanf("%d %d", &n, &m);
    int mn = 0, mx = n;
    for (int i = 0; i < m; i++) {
        scanf("%d %d", &lr[i].first, &lr[i].second);
        mn = max(mn, lr[i].first);
        mx = min(mx, lr[i].second);
    }
    cout << max(0, mx - mn + 1) << endl;
    return 0;
}


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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979

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


bool my_cp(pair<int, int> a, pair<int, int> b){
  return (double)b.first / (double)(b.second+1) < (double)a.first / (double)(a.second+1);
}


ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}

int N;

void dfs(string s, char m, int N){
  size_t len = s.length();
  if(len == N){
    cout << s << endl;
  }else{
    for(char c = 'a'; c <= m; c++){
      dfs(s + c, ((c == m)? (m + 1) : m), N);
    }
  }
}


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}





// substr(start, len)

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

  map <string, int> m;

  rep(i, 0, N){
    string s;
    cin >> s;

    m[s] = 1;
  }

  cout << m.size() << endl;


  
  // cout << setprecision(8) << ans << endl;  // For double
  // CHECK if it's possible to overflow!!
}

Measured memory_bytes: 19224
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main()
{
    ll n,i,s=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
       if(i%3!=0&&i%5!=0)
       {
           s+=i;
       }
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3612
s = list(input())
t = [0]* (len(s)+1)

for i in range(len(s)):
    if s[i] == "<":
        t[i+1] = max(t[i]+1,t[i+1])
for i in range(len(s)-1,-1,-1):
    if s[i] ==">":
        t[i] = max(t[i+1]+1,t[i])
print(sum(t))



"""
S = input()
n = len(S) + 1
num = [0] * n
for i in range(n-1):
    if S[i] == '<':
        num[i + 1] = max(num[i] + 1, num[i + 1])
for i in range(n - 2, -1, -1):
    if S[i] == '>':
        num[i] = max(num[i + 1] + 1, num[i])
print(sum(num))
"""


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

int	main()
{
	int	A, B;
	cin >> A >> B;
	bool	is_found = false;
	for (int i = 0; i < 2000; ++i) {
		if (static_cast<int>(i * 1.08) - i == A) {
			if (static_cast<int>(i * 1.10) - i == B) {
				cout << i << endl;
				is_found = true;
				break;
			}
		}
	}
	if (!is_found)
		cout << -1 << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var k, n int
	fmt.Scanf("%d %d", &k, &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}
	answer := minPath(k, n, a)
	fmt.Println(answer)
}

func minPath(k, n int, a []int) int {
	maxDistance := 0
	for i := 0; i < n-1; i++ {
		if distance := a[i+1] - a[i]; distance > maxDistance {
			maxDistance = distance
		}
	}
	if distance := k - a[n-1] + a[0]; distance > maxDistance {
		maxDistance = distance
	}
	return k - maxDistance
}


Measured memory_bytes: 6784
#pragma GCC optimize ("O3")

#include <cstdio>
#include <cstdint>
using namespace std;

int main() {
    const int m_max = 200000;
    const int q_max = 100000;

    int N, M, Q;
    scanf("%d%d%d", &N, &M, &Q);

    int16_t L[m_max], R[m_max];

    for (int i = 0; i < M; i++) {
        scanf("%hd%hd", &L[i], &R[i]);
    }

    int ans[q_max];
    int16_t p[q_max], q[q_max];

    for (int i = 0; i < Q; i++) {
        scanf("%hd%hd", &p[i], &q[i]);
    }

    for (int i = 0; i < Q; i++) {
        ans[i] = 0;
    }
  
    const int Q1 = Q / 6 * 6;
  
    for (int i = 0; i < Q1; i += 6) {
        for (int j = 0; j < M; j++) {
            ans[i] += (p[i] <= L[j] & R[j] <= q[i]);
            ans[i + 1] += (p[i + 1] <= L[j] & R[j] <= q[i + 1]);
            ans[i + 2] += (p[i + 2] <= L[j] & R[j] <= q[i + 2]);
            ans[i + 3] += (p[i + 3] <= L[j] & R[j] <= q[i + 3]);
            ans[i + 4] += (p[i + 4] <= L[j] & R[j] <= q[i + 4]);
            ans[i + 5] += (p[i + 5] <= L[j] & R[j] <= q[i + 5]);
        }
    }
  
    for (int i = Q1; i < Q; i++) {
        for (int j = 0; j < M; j++) {
            ans[i] += (p[i] <= L[j] & R[j] <= q[i]); 
        }
    }

    for (int i = 0; i < Q; i++) {
        printf("%d\n", ans[i]);
    }
}


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

class A
{
    static void Main() 
    {
#if DEBUG
        string exampleInput =
        @"99999";
        Console.SetIn(new System.IO.StringReader(exampleInput));
#endif

        int n = int.Parse(Console.ReadLine());
        if (n % 2 == 0) Console.WriteLine(n / 2 - 1);
        else Console.WriteLine(n / 2);
        Console.Out.Flush();
    }
}

Measured memory_bytes: 11092
import sys
import math
import collections
from collections import deque
#n = int(input())
n, k, q = map(int, sys.stdin.readline().split())
#s = input()
#x = list(map(int, sys.stdin.readline().split()))

c = [0 for i in range(n)]
for i in range(q):
    a = int(input())
    c[a-1] += 1


for i in range(1, n+1):
    if k - q + c[i-1] > 0:
        print("Yes")
    else:
        print("No")
    


Measured memory_bytes: 5064
# include <iostream>
# include <string>
using namespace std;
typedef long long ll;

bool allCharSame(string s){
  char c = s[0];
  for(int i=1; i<s.size(); i++) if(s[i] != c) return false;
  return true;
}

int main(){
  string s;
  ll k;

  cin >> s >> k;
  if(allCharSame(s)){
    cout << s.size() * k / 2 << endl;
  }
  else{
    ll front = 0;
    while(s[front] == s[front+1]) front++;
    front++;

    ll back = s.size()-1;
    while(s[back] == s[back-1]) back--;
    back = s.size()-back;

    ll ans = 0;
    if(s[0] == s[s.size()-1]) {
      ans += (front+back)/2 * (k-1);
    }
    else {
      ans += ((front/2) + (back/2)) * (k-1);
    }
    ans += (front/2) + (back/2);

    ll left = front;
    ll right = left;
    while(left < s.size()-back){
      while(right + 1 < s.size()-back && s[left] == s[right+1]) right++;
      ans += ((right-left+1)/2)*k;
      left = right+1;
      right = left;
    }

    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1e18;

int main() {
  ll a[5];
  for(ll i=0;i<5;i++) {
    cin >> a[i];
  }
  ll mi=-1;
  for(ll i=0;i<5;i++) {
    if(a[i]%10) {
      if(mi<0) mi=a[i]%10;
      else mi=min(a[i]%10,mi);
    }
  }
  ll ans=0;
  for(ll i=0;i<5;i++) {
    ans+=(a[i]+9)/10*10;
  }
  if(mi>0) {
    ans+=mi-10;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int a,b;
  cin>>a>>b;
  string s;
  cin>>s;
  int n=s.size();
  bool c=true;
  rep(i,n){
    if(i==a && s[i]!='-')c=false;
    if(i!=a && (s[i]<'0' || s[i]>'9'))c=false;
  }
  if(c)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

}


Measured memory_bytes: 256
<?php
list($n, $water_out_time) = explode(" ", trim(fgets(STDIN)));
$t = explode(" ", trim(fgets(STDIN)));

$total = 0;
for ($i = 0; $i < $n; $i++) {
    $total += $water_out_time;
    if ($i == 0) {
        continue;
    }
    if ($t[$i-1] + $water_out_time > $t[$i]) {
        $total -= $water_out_time - ($t[$i] - $t[$i-1]);
    }
}
echo $total.PHP_EOL;


Measured memory_bytes: 40396
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){

  CIN(x,y);
  auto f = [&](int x1){
    int x2;
  if(x1==1||x1==3||x1==5||x1==7||x1==8||x1==10||x1==12)
    x2=0;
  else if(x1==2)
    x2=1;
  else x2=2;
  return x2;
  };
  Yes(f(x)==f(y));
  
  

  return 0;
}

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

int main()
{
  ll h,w;
  cin >> h >> w;

  ll n1 = (w==1) ? 1 : h/2 + h%2;
  ll n2 = h/2;

  ll m1 = (h==1) ? 1: w/2 + w%2;

  ll res = n1 * m1 + n2 * (w/2);

  cout << res << endl;
}

Measured memory_bytes: 256
from collections import deque
def solve():
    H,W = map(int,input().split())
    Ch,Cw = map(lambda x:int(x)-1,input().split())
    Dh,Dw = map(lambda x:int(x)-1,input().split())
    A = [list(input()) for _ in range(H)]
    V = [[-1]*W for _ in range(H)]
    d = ((1,0),(0,1),(-1,0),(0,-1))

    def bfs_2d(sy,sx,v):
        que = deque()
        V[sy][sx] = v
        que.append((sy,sx))

        while que:
            uh, uw = que.popleft()
            for dy, dx in d:
                next_h = uh+dy
                next_w = uw+dx
                if 0 <= next_h < H and 0 <= next_w < W \
                    and A[next_h][next_w] == '.' \
                    and V[next_h][next_w] == -1:
                    V[next_h][next_w] = v
                    que.append((next_h,next_w))
    
    vertex = 0
    for h in range(H):
        for w in range(W):
            if A[h][w] == '#' or V[h][w] != -1:
                continue
            bfs_2d(h,w,vertex)
            vertex += 1

    G = [[] for _ in range(vertex)]
    used = [set() for _ in range(vertex)]
    for h in range(H):
        for w in range(W):
            if A[h][w] == '#':
                continue
            for dh in range(-2, 2+1):
                for dw in range(-2, 2+1):
                    if h + dh < 0 or H <= h + dh or w + dw < 0 or W <= w + dw:
                        continue
                    if A[h+dh][w+dw] == "#":
                        continue
                    if V[h][w] == V[h+dh][w+dw]:
                        continue
                    if V[h+dh][w+dw] in used[V[h][w]]:
                        continue
                    G[V[h][w]].append((V[h+dh][w+dw]))
                    used[V[h][w]].add((V[h+dh][w+dw]))
    
    # s = V[Ch][Cw]
    # g = V[Dh][Dw]

    # dist = [-1 for _ in range(vertex)]
    # que = deque()
    # dist[s] = 0
    # que.append(s)
    # while que:
    #     u = que.popleft()
    #     for v in G[u]:
    #         if dist[v] != -1:
    #             continue
    #         dist[v] = dist[u] + 1
    #         que.append(v)
    
    # print(dist[g])

    start_area_num = int(V[Ch][Cw])
    goal_area_num = int(V[Dh][Dw])

    dist = [-1] * vertex
    visited = [False] * vertex
    dist[start_area_num] = 0
    visited[start_area_num] = True

    q = deque()
    q.append(start_area_num)
    while len(q) > 0:
        cur_area_num = q.popleft()
        if cur_area_num == goal_area_num:
            print(dist[cur_area_num])
            return
        
        for next_area_num in G[cur_area_num]:
            if not visited[next_area_num]:
                dist[next_area_num] = dist[cur_area_num] + 1
                visited[next_area_num] = True
                q.append(next_area_num)
    else:
        print(-1)

if __name__ == '__main__':
    solve()


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/04  Problem: ABC 100 C / Link: http://abc100.contest.atcoder.jp/tasks/abc100_c  ----- */


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

	LL N; 
	cin >> N;
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}

	LL ans = 0LL;
	for (auto b : a) {
		while (b % 2 == 0) {
			b /= 2;
			ans++;
		}
	}
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e8;
using namespace std;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl



int main(void)
{
	int a, b, k;
	int ans=0;
	int count = 0;
	cin >> a >> b >> k;

	for (int i = a;i > 0;i--)
	{
		if (a%i == 0 && b%i == 0)
		{
			count++;
			if(count==k)
			ans = i;
		}
	}


	cout << ans << endl;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M, C = map(int, readline().split())
    B = list(map(int, readline().split()))
    A = [list(map(int, readline().split())) for _ in range(N)]

    ans = 0
    for a in A:
        p = C
        for i in range(M):
            p += a[i] * B[i]
        if p > 0:
            ans += 1

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9064
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

template <typename T>
struct Edge {
    int to; T cap, cost; int rev;
    Edge(int t, T c, int r) : to(t), cap(c), rev(r) {}
    Edge(int t, T ca, T co, int r) : to(t), cap(ca), cost(co), rev(r) {}
};

template <typename T>
struct Flow {
    vector< vector< Edge<T> > > G;
    int n;
    vector<bool> used;
    Flow(int _n) : G(_n), n(_n), used(_n, false) {}

    // G[e.to][e.rev] ??§?????????????????§??????
    void add_edge(int from, int to, T cap) {
        G[from].push_back(Edge<T>(to, cap, G[to].size()));
        G[to].push_back(Edge<T>(from, 0, G[from].size() - 1));
    }

    T dfs(int v, int t, T f) {
        if(v == t) return f;
        used[v] = true;
        for(int i=0; i < G[v].size(); i++) {
            Edge<T> &e = G[v][i];
            if(!used[e.to] && e.cap > 0) {
                T d = dfs(e.to, t, min(f, e.cap));
                if(d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    T max_flow(int s, int t) {
        T flow = 0;
        while(1) {
            fill(used.begin(), used.end(), false);
            T f = dfs(s, t, INF);
            if(f == 0) return flow;
            flow += f;
        }
    }
};

signed main() {
    int X, Y, E; cin >> X >> Y >> E;
    int x, y;
    int s = X+Y, t = s+1;

    Flow<int> fl(X + Y + 2);
    rep(i,0,X) fl.add_edge(s, i, 1);
    rep(i,0,Y) fl.add_edge(X+i, t, 1);
    rep(i,0,E) {
        cin >> x >> y;
        fl.add_edge(x, X+y, 1);
    }
    cout << fl.max_flow(s, t) << endl;
    return 0;
}

Measured memory_bytes: 3804
fun main() {
    val (n, K) = readLine()!!.split(" ").map { it.toInt() }
    val s = Array(K) {
        readLine()!!.split(" ").map { it.toInt() }.let {
            Pair(it[0], it[1])
        }
    }

    val mod = 998244353L

    val dp = MutableList(n + 1) { 0L }
    val dpSum = MutableList(n + 1) { 0L }
    dp[1] = 1L

    for (i in 1 until n + 1) {
        for ((l, r) in s) {
            dp[i] = (dp[i] + ((if ((i - l) > 0) dpSum[i - l] else 0L) - (if ((i - r - 1) > 0) dpSum[i - r - 1] else 0L)) + mod) % mod
        }
        dpSum[i] = (dpSum[i - 1] + dp[i] + mod) % mod
    }
    println(dp[n])
}

Measured memory_bytes: 68652
#include <iostream>
#include <unordered_map>
using lint = int64_t;
using P = std::pair<lint, lint>;

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

class union_find {
private:

	static const lint array_size = 2 * 100010;
	lint par[array_size], rank[array_size], size[array_size];

public:

	void init(lint n) noexcept {
		if (array_size <= n) return;
		for (lint i = 0; i < n; ++i) {
			par[i] = i;
			rank[i] = 0;
			size[i] = 1;
		}
	}

	lint root(lint x) noexcept {
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	bool same(lint x, lint y) noexcept { return root(x) == root(y); }

	void unite(lint x, lint y) noexcept {
		x = root(x); y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) {
			par[x] = y;
			size[y] += size[x];
		}
		else {
			par[y] = x;
			if (rank[x] == rank[y]) ++rank[x];
			size[x] += size[y];
		}
	}
};

namespace std {
	template<class T1, class T2>
	struct hash<pair<T1, T2>> {
		size_t operator()(const pair<T1, T2>& value) const noexcept {
			auto hash1 = hash<T1>{}(value.first);
			auto hash2 = hash<T2>{}(value.second);

			size_t seed = hash<string>{}(to_string(hash1) + to_string(hash2));
			return seed;
		}
	};
}

lint n, k, l;
std::unordered_map<P, lint>mp;
union_find a, b;
int main() {
	std::cin >> n >> k >> l;
	a.init(n), b.init(n);
	rep(i, k) {
		lint p, q;
		std::cin >> p >> q;
		a.unite(p - 1, q - 1);
	}
	rep(i, l) {
		lint r, s;
		std::cin >> r >> s;
		b.unite(r - 1, s - 1);
	}
	rep(i, n) mp[P(a.root(i), b.root(i))]++;
	rep(i, n) std::cout << mp[P(a.root(i), b.root(i))] << " \n"[i == n - 1];
}

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

using ll = long long;
using Pi = pair < int, int >;

constexpr int INF = (1 << 30) - 1;
constexpr int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
constexpr int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

template < typename T > T gcd(T a, T b) { return ( b ? gcd(b, a % b) : a ); }
template < typename T > T lcm(T a, T b) { return ( a / gcd(a, b) * b ); }

int N, K;
int rui[3005][3005] = {};

void checkR ( int x, int y )
{
	rui[y][x]++;
	rui[y + K][x]--;
	rui[y][x + K]--;
	rui[y + K][x + K]++;
}

int main()
{
	
	cin >> N >> K;
	for ( int i = 0; i < N; i++ ) {
		int x, y;
		char c;
		cin >> x >> y >> c;
		if ( c == 'B' ) {
			x += K;
		}
		x %= (K * 2), y %= (K * 2);
		
		checkR(x, y);
		checkR((x + K) % (K * 2), (y + K) % (K * 2));
	}
	
	for ( int i = 0; i < K * 3; i++ ) {
		for ( int j = 0; j < K * 3; j++ ) {
			if ( i > 0 ) rui[i][j] += rui[i - 1][j];
			if ( j > 0 ) rui[i][j] += rui[i][j - 1];
			if ( i > 0 && j > 0 ) rui[i][j] -= rui[i - 1][j - 1];
		}
	}
	
	int maxv = 0;
	for ( int i = 0; i < K * 2; i++ ) {
		for ( int j = 0; j < K * 2; j++ ) {
			int val = rui[i][j];
			if ( i < K ) {
				if ( j < K ) val += rui[i + K * 2][j] + rui[i][j + K * 2];
				else val += rui[i + K * 2][j];
			} else {
				if ( j < K ) val += rui[i][j + K * 2];
			}
			maxv = max(maxv, val);	
		}
	}
	
	cout << maxv << endl;

	return ( 0 );
}


Measured memory_bytes: 35456
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<ctime>
#define INF 1e9
using namespace std;
const int maxn=123;
int n,k,ans;
int main()
{
	scanf("%d%d",&n,&k);
	while(n)
	{
		n/=k;
		ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
using namespace std;
 
int main(){
    int a,b,x,y;
    double z;
    scanf("%d %d", &a, &b);
    x = a / b;
    y = a % b;
    z = 1.0 * a / b;
    printf("%d %d %.5lf\n",x,y,z);

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i,n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  int mx = 0;
  for(auto p : mp) mx = max(mx, p.second);
  for(auto p : mp) {
    if (p.second != mx) continue;
    cout << p.first << endl;
  }
  return 0;
}


Measured memory_bytes: 25216
#include<cstdio>
int p[100005];
int pos[100005];

int find(int u){
    if(p[u]==u) return u;
    else return p[u] = find(p[u]);
}

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i = 1; i <= n; i++){
        int u;
        scanf("%d",&u);
        pos[u] = i;
        p[i] = i;
    } 
    for(int i = 0; i < m; i++){
        int u,v;
        scanf("%d%d",&u,&v);
        int x = find(u), y = find(v);
        p[x] = y;
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int cur = pos[i];
        if(find(cur)==find(i)) ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 2508
lst1 = input().split()

A = int(lst1[0])
B = int(lst1[1])
M = int(lst1[2])

list_A = input().split()
list_B = input().split()

for i in range(A):
   list_A[i] = int(list_A[i])

for i in range(B):
   list_B[i] = int(list_B[i])

result = min(list_A) + min(list_B)

list_M = []

for i in range(M):
   lst2 = input().split()
   n = list_A[int(lst2[0]) - 1] + list_B[int(lst2[1]) - 1] - int(lst2[2])
   if n < result:
      result = n

print(result)

Measured memory_bytes: 25116
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as M
import Data.List
 
main = do
  [n, k] <- map read . words <$> getLine
  as <- B.words <$> B.getLine
  let dict = mkDict as
  print $ solve k dict
 
mkDict = foldr (\x y -> M.insertWith (const succ) x 1 y) M.empty
 
solve k dict = sum . drop k . sortBy (flip compare) $ M.elems dict

Measured memory_bytes: 53628
import sys
input = sys.stdin.readline
from collections import deque
n,m,s,t = map(int,input().split())
egg = [[] for i in range(n)]
es = [[] for i in range(n)]
for i in range(m):
  u,v,a,b = map(int,input().split())
  es[u-1].append([a,v-1])
  es[v-1].append([a,u-1]) 
  egg[u-1].append([b,v-1])
  egg[v-1].append([b,u-1]) 

es = tuple(es)
egg = tuple(egg)

import heapq
def dijkstra_heap(s,edge):
    #始点sから各頂点への最短距離
    d = [10**18] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

ES = dijkstra_heap(s-1,es)
EDGE = dijkstra_heap(t-1,egg)
cost = 0
chk = [0]*n
for i in range(n-1,-1,-1):
  cost = max(cost,10**15-ES[i]-EDGE[i])
  chk[i] = cost
chk = tuple(chk)
print(*chk, sep="\n")

Measured memory_bytes: 129356
#include <cstdio>
#include <cstring>
char s[200001];
int main()
{
    int len,a,b;
    scanf("%s",s);
    len=strlen(s);
    for(int i=0;i<len;i++)
        if(s[i]=='A')
        {
            a=i;
            break;
        }
    for(int i=len-1;i>=0;i--)
        if(s[i]=='Z')
        {
            b=i;
            break;
        }
    printf("%d\n",b-a+1);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

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

  vector<uint64_t> a(N), b(N), c(N);
  N_TIMES(n, N) { cin >> a[n] >> b[n] >> c[n]; }

  vector<vector<uint64_t>> dp(N + 1, vector<uint64_t>(3, 1e+12));
  dp[0] = {{ 0, 0, 0 }};

  N_TIMES(n, N) {
    dp[n + 1][0] = max(dp[n][1] + b[n], dp[n][2] + c[n]);
    dp[n + 1][1] = max(dp[n][0] + a[n], dp[n][2] + c[n]);
    dp[n + 1][2] = max(dp[n][0] + a[n], dp[n][1] + b[n]);
  }

  cout << *max_element(dp[N].begin(), dp[N].end()) << endl;

  return 0;
}

Measured memory_bytes: 8064
N=int(input())
A=[int(input()) for i in range(N)]

"""
import random
N=10
A=[random.randint(1,10) for i in range(N)]
print(A)
"""

import bisect
from collections import deque
D=deque([A[0]])

for a in A[1:]:
    if a<=D[0]:
        D.appendleft(a)

    else:
        x = bisect.bisect_right(D,a-1)
        D[x-1]=a

    #print(D)

print(len(D))
    

    


Measured memory_bytes: 54360