akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String word = input.readLine();

        int[] freq = new int[26];

        for (int i = 0; i < word.length(); i++) {
            if (freq[word.charAt(i) - 'a'] == -1)
                freq[word.charAt(i) - 'a'] = 0;
            freq[word.charAt(i) - 'a']++;
        }
        boolean state = true;
        for (int i = 0; i < 26; i++) {
            if (freq[i] % 2 != 0) {
                state = false;
                break;
            }
        }

        System.out.println(state?"Yes": "No");

    }
}


Measured memory_bytes: 21076
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n,m;
  cin >> n >> m;
  vector<int> p(m);
  vector<string> s(m);
  rep(i,m){
    cin >> p[i] >> s[i];
  }

  vector<bool> f(n+1,false);
  vector<int> cnt(n+1,0);
  rep(i,m){
    if(s[i]=="AC"){
      if(!f[p[i]]){
	f[p[i]] = true;
      }
    }
    else{
      if(!f[p[i]]){
	cnt[p[i]]++;
      }
    }
  }

  int ac = 0;
  int wa = 0;
  rep1(i,n){
    if(f[i]){
      ac++;
      wa += cnt[i];
    }
  }
  cout << ac << " ";
  cout << wa << "\n";
  
  
  return 0;
}


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

int main(){
    int N; cin >> N;
    vector<pair<long long, pair<long long, long long>>> A(N);
    for (int i = 0; i < N; i++) cin >> A[i].second.first;
    for (int i = 0; i < N; i++) cin >> A[i].second.second;
    for (int i = 0; i < N; i++) A[i].first = A[i].second.first - A[i].second.second;
    sort(A.begin(), A.end()); 
    long long lack = 0, ans = 0;
    for (int i = 0; i < N; i++) {
        if (A[i].first >= 0) continue;
        lack += -A[i].first;
        ans++;
    }

    for (int i = N - 1; i >= 0; i--) {
        if (lack <= 0) break;
        if (A[i].first < 0 && lack > 0) { ans = -1; break; }
        long long satis = A[i].first;
        lack -= satis; ans++;
    }
    cout << ans << '\n';
    return 0;
} 

Measured memory_bytes: 2560
N, M = map(int, input().split())
X = list(map(int, input().split()))

if N >= M:
    print(0)
    exit(0)

X.sort()

L = [abs(X[i] - X[i + 1]) for i in range(0, M - 1)]
L.sort(reverse=True)

ans = (X[-1] - X[0]) - sum(L[:N - 1])
print(ans)


Measured memory_bytes: 57384
const main = (input) => {
  input = input.split(' ');
  const N = parseInt(input[0], 10);
  const A = parseInt(input[1], 10);
  const B = parseInt(input[2], 10);
  
  if (N*A>B) {
    console.log(B);
  }else if(N*A==B){
    console.log(B);
  }else{
    console.log(N*A);
  }
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
/*Let's start.............*/
#define   ll                long long
#define   pb                push_back
#define   ff                first
#define   ss                second
#define   srt(v)            sort(v.begin(),v.end())
#define   inf               2000000000000000
#define   mxn               1000009
#define   pi                acos(-1)
#define   MOD               1000000007
#define   db(x)             printf("### VALUE: (%lld) ###\n",(ll)x)
#include  <bits/stdc++.h>
using namespace std;

ll dp[202][202][202];
int main()
{
    ll k;
    cin >> k;
    ll sum = 0;
    for(ll i = 1;i <= k;i++){
        for(ll j = 1;j <= k;j++){
            for(ll l = 1;l <= k;l++){
            vector<ll> v;
               v.pb(i);
               v.pb(j);
               v.pb(l);
               sort(v.begin(),v.end());
               ll x,y,z;
               x = v[0];
               y = v[1];
               z = v[2];
               if(dp[x][y][z] == 0){
                dp[x][y][z] = __gcd(__gcd(x,y),z);
               }
               sum += dp[x][y][z];
            }
        }
    }
    cout << sum << endl;
    return 0;
}
/*
".....but the truth is that you can increase it slightly."
Day 27
*/



Measured memory_bytes: 35772
#include <bits/stdc++.h>
using namespace std;
 
#define ull     		unsigned long long int
#define ll      		long long int
#define loop(i,s,e)     for(ll i=(s);i<(e);i++)
#define rloop(i,s,e)    for(ll i=(s);i>=(e);i--)
#define scan(any)       for(auto &i:any) cin>>i;
#define print(any)      for(auto i:any) cout<<i<<" "; nl;
#define nl              cout<<'\n'
#define pi 3.141592654
#define hell 1000000007
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define IP(n) int n;cin>>n
#define IP2(a, b) int a,b;cin>>a>>b
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define all(v) (v).begin(), (v).end()
#define sz(x) (int)x.size()
#define set(a,n) memset(a,n,sizeof(a))
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
const int INF = 1<<29;
inline int two(int n) { return 1 << n; }
inline int last_bit(int n) { return n & (-n); }
inline int test(int n, int b) { return (n>>b)&1; }
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline void set_bit(int & n, int b) { n |= two(b); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////////////////
int main()
{
  int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  vector<int>v1(a);
  vector<int>v2(b);
  vector<int>v3(c);
  scan(v1);
  scan(v2);
  scan(v3);
  sort(all(v1));
  sort(all(v2));
  sort(all(v3),greater<int>());
  priority_queue<int,vector<int>,greater<int>>p1(v1.begin()+a-x,v1.end());
  priority_queue<int,vector<int>,greater<int>>p2(v2.begin()+b-y,v2.end());
  
  for(auto i:v3)
  {
    if(i<=p1.top() and i<=p2.top())
      break;
    if(p1.top()<p2.top())
    {  p1.pop();
    p1.push(i);
    }
    else
    {
       p2.pop();
    p2.push(i);
    }
    }
    long long int s=0;
    while(!p1.empty())
    {
      s+=p1.top();
      p1.pop();
    }
    while(!p2.empty())
    {
      s+=p2.top();
      p2.pop();
    }
    cout<<s;
    
return 0;
}

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

int main()
{
  int n;
  string s;
  cin >> n >> s;
  
  int alph1[27] = {0},alph2[26] = {0};
  int ans = 0, maxans = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(j <= i){
        alph1[s[j] - 'a'] = 1;
      }else{
        alph2[s[j] - 'a'] = 1;
      }//else
    }//for
    
    for(int i = 0; i < 27; i++){
      if(alph1[i] == 1 && alph2[i] == 1){
        ans++;
      }
    }
    if(ans > maxans){
      maxans = ans;
    }
    
    ans = 0;
    for(int i = 0; i < 27; i++){
      alph1[i] = 0;
      alph2[i] = 0;
    }
  }//for
  
  cout << maxans << endl;      
      
}

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

int main() {
        int N, K;
        cin >> N >> K;
        double x, ff = 0;
        //
        for (int i = 1; i <= N; i++) {
                x = 1.0;
                for (int v = i; v < K; v *= 2) {
                        x /= double(2.0);
                }
                ff += x / double(N);
        }
        cout << fixed << setprecision(12) << ff << endl;
        return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

int main()
{

    while (true) {
        string s;

        cin >> s;

        if (s == "-") { break; }

        int a = s.size();

        int m, n = 0;

        cin >> m;

        vector<int> k(m);

        for (int j = 0; j < m; ++j) {
            cin >> k.at(j);
            s = s.substr(k.at(j), a - k.at(j) + 1) + s.substr(0, k.at(j));
        }
        cout << s << endl;

    }

}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
typedef pair<int,P> PP;

void Main() {
  ll n;
  R n;
  ll d[n][n],c[n][n];       
  rep(i,n) {
    rep(j,n) {
      R d[i][j];
      c[i][j]=d[i][j];
    }
  }
  rep(k,n)rep(i,n)rep(j,n) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
  rep(i,n) {
    rep(j,n) {
      if(d[i][j]!=c[i][j]) {
        pr(-1);
        return;
      }
    }
  }
  ll ans=0;
  priority_queue<PP,vector<PP>,greater<PP> > que; 
  rep(i,n)REP(j,i+1,n) que.push(PP(d[i][j],P(i,j)));
  rep(i,n){
    rep(j,n) c[i][j]=MAX;
    c[i][i]=0;
  }
  while(!que.empty()) {
    PP p=que.top();que.pop();
    int x=p.S.F,y=p.S.S;
    if(c[x][y]<=d[x][y]) continue;
    ans+=p.F;
    rep(i,n)rep(j,n) {
      c[i][j]=min(c[i][j],c[i][x]+p.F+c[y][j]);
      c[i][j]=min(c[i][j],c[i][y]+p.F+c[x][j]);
    }
  }
  pr(ans);
}

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


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

int main() {
  int n;
  cin >> n;
  if (n== 2 || n== 3){
    cout << n <<endl;
    return 0;
  }
  bool ok = true;
  while (ok){
    for (n; n<1000000;n++){
      for(int i = sqrt(n); i>=2; i--){
        if (n%i == 0){
          break;
        }
        if (n%2 != 0 && i == 2){
        cout << n << endl;
        return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll h, w;
  cin >> h >> w;
  if(h == 1 || w == 1)
    cout << 1 << endl;
  else
    cout << (h * w + 1) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){

    string S;

    cin >> S;

    for(int i=0;i<=2;i++){
        if(S[i]==S[i+1]){
            cout << "Bad"<<endl;
            return 0;
        }
    }

    cout << "Good"<<endl;

    return 0;
}

Measured memory_bytes: 256
using System;

class ABC072A
{
	static public void Main(string[] args)
	{
		int X, t;
		string[] vals = Console.ReadLine().Split(' ');
		X = int.Parse(vals[0]);
		t = int.Parse(vals[1]);

		int r = X - t;
		if(r >= 0)
		{
			Console.WriteLine(r);
		}
		else
		{
			Console.WriteLine(0);
		}
	}
}


Measured memory_bytes: 11092
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll a, b, c;
	cin>>a>>b>>c;
	cout<<a<<" "<<b<<" "<<3*c-a-b<<endl;
	cout<<4*c-2*a-b<<" "<<c<<" "<<-2*c+2*a+b<<endl;
	cout<<-c+a+b<<" "<<2*c-b<<" "<<2*c-a<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
int main(){
    using namespace std;
    int x,ans,i,j;
    ans = 1;
    cin >> x;
    if(x==1){
        cout << 1 << endl;
        return 0;
    }
    for(i=2;i<=x;i++){
        for(j=2;j<=x;j++){
            if(pow(i,j)<=x){
                if(ans<pow(i,j)){
                    ans = pow(i,j);
                }
            }else{break;}
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
N = int(input())

N_digit = [0, 0, 0, 0, 0, 0, 0, 0, 0]
M = N

for i in range(0,9):
	N_digit[i] = M // (10**(8 - i))
	M = N % (10**(8 - i))


digit_sum = sum(N_digit)

#print(N_digit)
#print(digit_sum)

if N % digit_sum == 0:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3316
#include <iostream>
#include <string>

using namespace std;

class Dice {
public:
    Dice(int32_t top, int32_t bottom, int32_t north, int32_t east, int32_t west, int32_t south) {
        t = top;
        b = bottom;
        n = north;
        e = east;
        w = west;
        s = south;
    }

    void rotate(uint8_t dir) {
        int32_t temp;
        switch (dir) {
            case 'N':
                temp = t;
                t = s;
                s = b;
                b = n;
                n = temp;
                break;
            case 'E':
                temp = t;
                t = w;
                w = b;
                b = e;
                e = temp;
                break;
            case 'W':
                temp = t;
                t = e;
                e = b;
                b = w;
                w = temp;
                break;
            case 'S':
                temp = t;
                t = n;
                n = b;
                b = s;
                s = temp;
                break;
        }
    }

    int32_t get_val(uint8_t face) {
        switch (face) {
            case 't': return t;
            case 'b': return b;
            case 'n': return n;
            case 'e': return e;
            case 'w': return w;
            case 's': return s;
        }

        return 0;
    }

private:
    int32_t t, b, n, e, w, s;
};

int main() {
    int32_t t, b, n, e, w, s;
    string op;

    cin >> t >> s >> e >> w >> n >> b >> op;

    Dice d(t, b, n, e, w, s);

    for (uint8_t dir : op) {
        d.rotate(dir);
    }

    cout << d.get_val('t') << endl;

    return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    ll H, W, N;
    cin >> H >> W >> N;
    vector<ll> ans(10, 0);
    
    if (N == 0) {
        cout << (H-2) * (W-2) << endl;
        for (int i = 1; i <= 9; i++) {
            cout << 0 << endl;
        }
        return 0;
    }
    
    multiset<pair<ll, ll>> q;
    for (int i = 0; i < N; i++) {
        ll s, t;
        cin >> s >> t;
        for (int j = -1; j <= 1; j++) {
            for (int k = -1; k <= 1; k++) {
                if (s+j >=2 && s+j <= H-1 && t+k >= 2 && t+k <= W-1) {
                    q.insert({s+j, t+k});
                }
            }
        }
    }
    auto it = q.begin();
    auto u = *it;
    ll x = u.first, y = u.second;
    it++;
    int cnt = 1;
    while (true) {
        auto sq = *it;
        if (sq.first == x && sq.second == y) cnt++;
        else {
            ans[cnt]++;
            cnt = 1;
        }
        x = sq.first;
        y = sq.second;
        it++;
        if (it == q.end()) {
            ans[cnt]++;
            break;
        }
    }
    
    ans[0] = (H-2) * (W-2);
    for (int i = 1; i <= 9; i++) ans[0] -= ans[i];
    for (int i = 0; i <= 9; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 56448
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,i;
    cin>>n>>m;
    ll x,y;
    ll pref[n+1];
    memset(pref,0,sizeof(pref));
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        pref[x]++;
        if(y!=n)
            pref[y+1]--;
    }
    ll cnt=0;
    for(i=1;i<=n;i++)
    {
        pref[i]+=pref[i-1];
        if(pref[i]==m)
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  vector<int> r(n);
  int sum = 0;
  for(int i=0; i<n; i++) {
    cin >> l.at(i) >> r.at(i);
    sum += r.at(i) - l.at(i) + 1;
  }
  
  cout << sum << endl;
  
}

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

int main(){
  double ans;
  double n;
  cin >> n;
  vector<double> v(n,0);
  r(i,n)cin >> v.at(i);
  sort(v.begin(),v.end());
  ans=(v.at(0)+v.at(1))/2;
  r(i,n-2){
    ans=(ans+v.at(i+2))/2;
  }
  printf("%.8lf\n",ans);
}

Measured memory_bytes: 256
N, M = map(int, input().split())
a, b, c, d = [], [], [], []
for i in range(N):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)
for i in range(M):
    ci, di = map(int, input().split())
    c.append(ci)
    d.append(di)

for i in range(N):
    check = int(1e9)
    point = -1
    for j in range(M):
        dis = abs(a[i]-c[j]) + abs(b[i]-d[j])
        if dis < check:
            check = dis
            point = j+1
    print(point)

Measured memory_bytes: 3064
#include<cstdio>

#define fr(i,a,b) for(register int i=a;i<=b;i++)
#define fmin(a,b) ((a)<(b)?(a):(b)) 
#define st (n*2+1)
#define ed (n*2+2)
#define p1(x) (x)
#define p2(x) (n+x)
#define MAXN 10000010

int n,a[110],b[110],ans,cnt=1,head[310],d[310],gap[1010];

struct edge{
//	int from;
	int to,flow,next;
}e[200010];

inline int v_in(){
	char ch=getchar();int sum=0,f=1;
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') sum=(sum<<3)+(sum<<1)+(ch^48),ch=getchar();
	return sum*f;
}

inline void add(int u,int v,int w){
	e[++cnt].to=v;
//	e[cnt].from=u;
	e[cnt].flow=w;
	e[cnt].next=head[u];
	head[u]=cnt;
	e[++cnt].to=u;
//	e[cnt].from=v;
	e[cnt].flow=0;
	e[cnt].next=head[v];
	head[v]=cnt;
}

int sap(int u,int flow){
	//printf("%d %d\n",u,flow);
	if (u==ed) return flow;
	int res=flow;
	for(register int i=head[u],v=e[i].to;i!=0;i=e[i].next,v=e[i].to)
		if(e[i].flow&&d[u]==d[v]+1){
			//printf("*");
			int t=sap(v,fmin(res,e[i].flow));
			e[i].flow-=t;
			e[i^1].flow+=t;
			res-=t;
			if (!res) return flow;
		}
	gap[d[u]]--;
	if(!gap[d[u]]) d[st]=2*n+2;
	d[u]++;
	gap[d[u]]++;
	return flow-res;
}

int main(){
	n=v_in();
	fr(i,1,n) a[i]=v_in(),b[i]=v_in(),add(st,p1(i),1);
	fr(i,1,n){
		int c=v_in(),d=v_in();
		add(p2(i),ed,1);
		fr(j,1,n) if(a[j]<c&&b[j]<d) add(p1(j),p2(i),1);
	}
	//fr(i,2,cnt) printf("%d %d %d %d\n",e[i].from,e[i].to,e[i].flow,e[i].next);
	gap[0]=2*n+2;
	while (d[st]<2*n+2) ans+=sap(st,MAXN);
	printf("%d\n",ans);
	return 0;
}
/*
3
2 0
3 1
1 3
4 2
0 4
5 5
*/ 

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  double x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  
  cout << fixed << setprecision(4) << sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) << endl;
 
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    for (auto &&a : s)
        cin >> a;
    sort(s.begin(), s.end());
    //for(auto&& a : s)cout << a << endl;
    int count = 0, max = 0, j = 0;
    int memo[200000][2];
    for (int i = 0; i < n; i++)
    {
        count++;
        if (i + 1 < n)
        {
            if (s[i] != s[i + 1])
            {
                memo[j][0] = i;
                memo[j][1] = count;
                j++;
                if (count > max)
                {
                    max = count;
                }
                count = 0;
            }
        }else{
            memo[j][0] = i;
                memo[j][1] = count;
                j++;
                if (count > max)
                {
                    max = count;
                }
                count = 0;
        }
    }
    for (int i = 0; i < j; i++)
    {
        if (memo[i][1] == max)
        {
            cout << s[memo[i][0]] << endl;
        }
    }
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#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 bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
    for(auto &e:t) fill_v(e,v);
}

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

  cout << max( a * b, c * d ) << endl;

  return 0;
}


Measured memory_bytes: 256
fun main(args:Array<String>?): Unit {
    var count = 0
    for (c in readLine()!!.trim()){
        if (c == '*') {
            println(count)
            return
        }else {
            when(c){
                '(' -> ++count
                ')' -> --count
                else -> Unit
            }
        }
    }
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i; j < n; ++j) {
            bool flg = true;
            for (int k = 0; k < j - i + 1; ++k) {
                if (!(s[i + k] == 'A' || s[i + k] == 'C' || s[i + k] == 'G' || s[i + k] == 'T')) flg = false;
            }
            if (flg) {
                ans = max(ans, j - i + 1);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//i ll be the king
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
int main()
{
	sync;
	ll n,k;
	cin>>n>>k;
	ll arr[n];
	input(arr,n);
	ll dp[k+1]={0};
	for(ll i=1;i<=k;i++)
	{
		for(ll j=0;j<n;j++)
		if(i>=arr[j]&&dp[i-arr[j]]==0)
		dp[i]=1;	
	}
	if(dp[k])
	cout<<"First";
	else
	cout<<"Second";
}

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

int main() {
  string a;
  cin >> a;
  int sum = 0;
  rep(i, a.size()){
    int s = a.at(i) - '0';
    sum += s;
    
  }
  
  if(sum % 9 == 0){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
  
  
}
 
 //vector<int> a(3);
 //a.at(0);
 //a.size();
 //vector<vector<int>> a(3, vector<int>(3));
 //uint64_t sum = 0;
 //max(a, b);
 //min(a, b);
 //swap(a, b);
 //sort(vec.begin(), vec.end());  昇順
 //reverse(vec.begin(), vec.end());  降順


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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;
const int   mod = 998244353;

void add(int &a,int b)  {
    a += b;
    if (a >= mod)
        a -= mod;
}
void sub(int &a,int b)  {
    a -= b;
    if (a <  0)
        a += mod;
}
int mul(int a,int b)    {
    return  1ll * a * b % mod;
}
int Pow(int a,int b)    {
    int ans = 1;
    while (b)   {
        if(b & 1)   ans = mul(ans,a);
        a = mul(a,a);   b >>= 1;
    }
    return  ans;
}
int inv(int a,int p)    {
    return  a == 1 ? 1 : p - 1ll * p * inv(p % a,a) / a;
}

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

vector<int> g[N];

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

    int n;  cin >> n;

    auto calc = [&]()   {
        int m;  cin >> m;

        set<int> S;
        set<int> R;

        for(int i = 1 ; i <= n ; ++i)   {
            g[i].clear();
            S.insert(i);
        }
        for(int i = 1 ; i <= m ; ++i)   {
            int x;  cin >> x;
            int y;  cin >> y;

            g[x].pb(y);
            g[y].pb(x);
        }
        vector<int> res;

        while (S.size() || R.size())    {
            int val = 0;

            while (S.size())    {
                int x = (*S.rbegin());
                S.erase(x);

                add(val,Pow(10,18 * x));

                for(int u : g[x])
                    if (S.count(u)) {
                        S.erase(u);
                        R.insert(u);
                    }
            }
            res.pb(val);
            S.swap(R);
        }
        return  res;
    };
    vector<int> v1 = calc();
    vector<int> v2 = calc();
    vector<int> v3 = calc();

    int S = 0;

    S = max(S,sz(v1));
    S = max(S,sz(v2));
    S = max(S,sz(v3));

    v1.resize(S);
    v2.resize(S);
    v3.resize(S);

    vector<vi>  ok(S,vi(S,1));

    int ans = 0;

    for(int i = 0 ; i < S ; ++i)    {
        vector<bool> used(S,0);

        for(int j = 0 ; j < S ; ++j)
        for(int k = 0 ; k < S ; ++k)    if (ok[j][k] && !used[k])   {
            int val = 1;
            val = mul(val,v3[i]);
            val = mul(val,v2[j]);
            val = mul(val,v1[k]);

            add(ans,val);

            ok[j][k] = 0;
            used [k] = 1;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 14464
package main
import "fmt"
func main(){
	array := [32]int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}

	var a int
	fmt.Scan(&a)
	fmt.Println(array[a-1])
}


Measured memory_bytes: 512
N = int(input())
List = list(map(int, input().split()))

if (List.count(0)!=0)|((sum(x<0 for x in List)%2==0)):
    print(sum([abs(List[i]) for i in range(N)]))

else:
    nList = [abs(List[i]) for i in range(N)]
    print(sum(nList)-2*min(nList))

Measured memory_bytes: 14332
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <functional>
#include <list>
#include <iomanip>
#include <cctype>
#include <math.h>
#include <utility>
#include <numeric>

#define REP(i,first,end) for(int i = first; i < end; i++)
#define rep(i,end) for(int i = 0; i < end; i++)

typedef long long ll;
#define mod =1000000007;

using namespace std;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int a;
    cin >> a;
    
    string s;
    cin >> s;
    
    if (a >= 3200){
        cout << s << endl;
    }
    else {
        cout << "red" << endl;
    }
}
    




Measured memory_bytes: 256
def main():
  N, K = map(int, input().split())
  R, S, P = map(int, input().split())
  T = input()

  set_rsp = set(['r', 's', 'p'])

  def vict_output(c):
    if c == 'r':
        output = 'p'
        point = P
    elif c == 's':
        output = 'r'
        point = R
    else:
        output = 's'
        point = S
    return output, point

  history = []
  score = 0
  for i in range(len(T)):
      # print('i: {}, T[i]: {}, pre_K_output: {}'.format(i, T[i], history[i-K:i-K+1]))
      # print('history: {}'.format(history))
      output, point = vict_output(T[i])
      if i >= K:
          # print('if1')
          pre_K_output = history[i - K]
          # K手前と等しかった場合
          if output == pre_K_output:
              # print('if2')
              point = 0
              # K手先に有利になるように見る
              if (i + K) <= (len(T) - 1):
                  # print('if3')
                  output, _ = vict_output(T[i + K])
                  if output == pre_K_output:
                        # print('if4')
                        # pre_K_input, _ = vict_output(pre_K_output)
                        # pre_K_input, _ = vict_output(pre_K_input)
                        # rest = list(set_rsp - set(pre_K_input))
                        # o1, p1 = vict_output(rest[0])
                        # o2, p2 = vict_output(rest[1])
                        o1, p1 = vict_output(pre_K_output)
                        o2, p2 = vict_output(o1)
                        # print('rest: {}'.format(rest))
                        # print('o1:{}, o2:{}'.format(o1, o2))
                        if (p1 > p2):
                            output = o1
                            # point = p1
                        else:
                            output = o2
                            # point = p2
                  else:
                        output, _ = vict_output(output)
                        output, _ = vict_output(output)
              else:
                  # この場合K手前の手以外ならなんでも良い
                  output, _ = vict_output(list(set_rsp - set(pre_K_output))[0])
                  # K手前以外のの手で最も得点が大きい手を選ぶ

      # print('output: {}, point: {}'.format(output, point))
      score += point
      history.append(output)

  # print(history)
  print(score)

if __name__ == '__main__':
    main()


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

using namespace std;

const int INF = 1 << 30;

const int mod = 1e9 + 7;

int main()
{
  int N, T[100000], A[100000];

  cin >> N;
  for(int i = 0; i < N; i++) cin >> T[i];
  for(int i = 0; i < N; i++) cin >> A[i];

  bool lock[100000] = {};

  lock[0] = true;
  for(int i = 1; i < N; i++) {
    if(T[i - 1] < T[i]) lock[i] = true;
  }
  lock[N - 1] = true;
  for(int i = N - 2; i >= 0; i--) {
    if(A[i + 1] < A[i]) lock[i] = true;
  }

  {
    int big = 0;
    for(int i = 0; i < N; i++) {
      big = max(big, min(T[i], A[i]));
      if(T[i] != big) {
        cout << 0 << endl;
        return (0);
      }
    }
    big = 0;
    for(int i = N - 1; i >= 0; i--) {
      big = max(big, min(T[i], A[i]));
      if(A[i] != big) {
        cout << 0 << endl;
        return (0);
      }
    }
  }

  int mult = 1;
  for(int i = 0; i < N; i++) {
    if(lock[i]) continue;
    mult = 1LL * mult * min(T[i], A[i]) % mod;
  }

  cout << mult << endl;

}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, res;
vector<ll> A(100010);
vector<int> color;  //color[i] := 各色についてi+1番目に最右値の大きいもの

/* A内のval未満の最大値が格納されている添え字を返す*/
/*color内の値が降順整列であることに注意*/
int tree_search(int l, int r, int val){
	if(l == r) return l;

	int c = (r - l) / 2 + l;  //lとcの間
	if(val <= color[c]) return tree_search(c+1, r, val);  //color[c]は条件を満たさない
        else if(val > color[c]) return tree_search(l, c, val);  //color[c]も条件を満たす

}



ll color_n(int num){  //範囲設定num
 ll cn = 0, j;  //cnは(色の数-1)
 color.push_back(A[0]);  //color最右値を決定

 for(ll i = 1; i < num; i++){
  if(A[i] > color[0]) color[0] = A[i]; //最も最右値の高い色を使用
  else if(A[i] <= color[0] && A[i] > color[cn]){ 
   j = tree_search(0, cn, A[i]);
   color[j] = A[i]; 
  }  //条件を満たす最大色値を使用
  else { color.push_back(A[i]); cn += 1; } //新色追加
  
 }

 return (cn+1);
}



int main(){
 cin >> N;
 for(int i = 0; i < N; i++) cin >> A[i];

 res = color_n(N);  //使う色数
 //for(ll i = 0; i < color.size(); i++) cout << color[i] << endl;
 cout << res << endl;
 return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
#else

#endif

const double pi_greco = 3.14159265358979323846;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Togliere nei problemi con query online

    int A, B, H, M;
    cin >> A >> B >> H >> M;
    H %= 12;

    double t1 = 2*pi_greco*(H/12.0 + M/(12.0*60));
    double t2 = 2*pi_greco*M/60;

    
    double res = sqrt((double)A*(double)A + (double)B*(double)B - 2*(double)A*(double)B*cos(t2-t1));
    if (res < 0) res = - res;
    cout.precision(20);
    cout << res << "\n";
}


Measured memory_bytes: 4240
a = list(map(int,input().split()))
a.sort()

if (a[2] - a[0]) % 2 == 1 and (a[2] - a[1]) % 2 == 1:
    print(str((a[2] - a[0]) // 2 + (a[2] - a[1]) // 2 + 1)) 
elif (a[2] - a[0]) % 2 != 0 or (a[2] - a[1]) % 2 != 0:
    print(str((a[2] - a[0]) // 2 + (a[2] - a[1]) // 2 + 2))
else:
    print(str((a[2] - a[0]) // 2 + (a[2] - a[1]) // 2))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 100005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m;
    cin >> n >> m;
    if(n * 500 >= m){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

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

int main(){
	ll n, k;
	cin >> n >> k;
	vector<pair<ll, ll>>ab(n);
	for (ll i = 0;i < n;i++) {
		ll a, b;
		cin >> a >> b;
		ab[i] = make_pair(a, b);
	}
	sort(ab.begin(), ab.end());
	for (ll i = 0;i < n;i++) {
		k -= ab[i].second;
		if (k <= 0) {
			cout << ab[i].first << endl;
			return 0;
		}
	}



	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main()
{
	int T=10000000, N=0, W[101] = {0},A=0,B=0;
	cin >> N ;
	for (int i = 0; i < N; i++)
	{
		cin >> W[i];
	}
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j <= i; j++)
		{
			A = A + W[j];
		}
		for (int x = N-1; x >i; x--)
		{
			B = B + W[x];
		}
		if (T != min(T, abs(A - B)))
		{
			T = abs(A - B);
		}
		A = 0;
		B = 0;
	}
	cout << T;
	return 0;
}

Measured memory_bytes: 256
program prob5
    implicit none
    integer::i, j, l, r, n, cnt
    character(len=100)::S
    character(len=300)::ans
    read(*,*) n
    read(*,*) S
    ans = ""
    l = 0
    r = 0
    cnt = 0
    do i = 1, n
        if(S(i:i) .eq. "(") then
            ans = trim(ans) // "("
            cnt = cnt + 1
        else
            ans = trim(ans) // ")"
            cnt = cnt - 1
            if(cnt < 0) then
                ans = "(" // trim(ans)
                cnt = 0
            end if
        end if
    end do
    if(cnt > 0) then
        do i = 1, cnt
            ans = trim(ans) // ")"
        end do
    end if
    write(*,'(a)') trim(ans)
    stop
end program

Measured memory_bytes: 2800
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
int main(){
    int N,M; cin >> N >> M;
    int AC_sum=0;
    int WA_sum=0;
    
    vector <bool> A(N);
    rep(i,N+1) A[i]=false;
    int WA[N];
    rep(i,N+1) WA[i]=0;
    
    rep(i,M){
        int p;
        string S;
        cin >> p >> S;
        
        if (S=="AC" && A[p]==false){
            A[p]=true;
            AC_sum++;
            WA_sum+=WA[p];
        }
        if (S=="WA" && A[p]==false) WA[p]++;
    }
    
    cout << AC_sum << " " << WA_sum << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
string s,t;
int dp[3010][3010];
string ans="";
signed main(){
	cin>>s>>t;
	rep(i,s.size()){
		rep(j,t.size()){
			if(s[i]==t[j])dp[i+1][j+1]=dp[i][j]+1;
			else dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
		}
	}
	for(int i=s.size(),j=t.size();i>0&&j>0;){
		if(dp[i][j-1]==dp[i][j])j--;
		else if(dp[i-1][j]==dp[i][j])i--;
		else{
			if(s[i-1]==t[j-1])ans=s[i-1]+ans;
			i--,j--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 35584
Module Module086A
    Sub Main(ByVal args() As String)
        Dim Result As Integer
        Dim arr(2) As String
        arr = Split(Console.ReadLine())

        Result = arr(0) * arr(1)
        If Result Mod 2 = 0 Then
            Console.Write("Even")
        Else
            Console.Write("Odd")
        End If
    End Sub
End Module


Measured memory_bytes: 13532
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        boolean flag = false;
        for(int i = a;i <= b;i++){
            if(i%k == 0){
                flag = true;
            }
        }
        if(flag){
            System.out.println("OK");
        }else{
            System.out.println("NG");
        }
    }
}

Measured memory_bytes: 35708
// Why do we fall ? So we can learn to pick ourselves up.
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ll = new int[n];
        for(int i=0; i<n; i++){
            ll[i] = sc.nextInt();
        }
        Arrays.sort(ll);
        int ss = 0;
        for(int i=0; i<n-2; i++){
            int k = i+2;
            for(int j=i+1; j<n; j++){
                while(k<n && ll[i]+ll[j] > ll[k]){
                    ++k;
                }
                if(k>j){
                    ss += k-j-1;
                }
            }
        }
        System.out.println(ss);
    }
}


Measured memory_bytes: 27144
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*int find(int a){
     if(a==par[a])return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);
     if(a==b)return ;
     par[b]=a;
}
ll modexpo(ll a,ll b)
{
     ll ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
*/
vector<int> adj[100005];
int indeg[100005];
int par[100005];
int main(){
     int n,m;
     cin>>n>>m;
     for(int i=1;i<=n+m-1;i++){
          int a,b;cin>>a>>b;
          adj[a].pb(b);indeg[b]++;
     }
     queue<int> q;
     for(int i=1;i<=n;i++)if(indeg[i]==0){q.push(i);break;}
     while(!q.empty()){
          int x=q.front();q.pop();
          for(int child:adj[x]){
               indeg[child]--;
               if(indeg[child]==0){
                    q.push(child);par[child]=x;
               }
          }
     }
     for(int i=1;i<=n;i++)cout<<par[i]<<"\n";


}
 
 
 
 

























Measured memory_bytes: 9772
#include <bits/stdc++.h>
#define ll long long
#define rep(a, b, c, i) for (int i = a; i < b; i += c)
#define ff first
#define ss second
#define newl "\n"


using namespace std;

class AirConditioner{
public:
	string turn(int x){
		return x >= 30 ? "Yes" : "No";
	}
};

int main(){
	int t;
	cin >> t;
	AirConditioner ac;
	cout << ac.turn(t) << newl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef pair<string, int> psi;
typedef pair<psi,int> ppi;
#define ff first
#define ss second

bool comp(const ppi &a, const ppi &b){
    return (a.ff.ff<b.ff.ff) || (a.ff.ff == b.ff.ff && a.ff.ss>b.ff.ss);
}

int main(){
    vector<ppi> v;
    int scr, n;
    string city;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> city >> scr;
        v.push_back({{city,scr},i});
    }
    sort(v.begin(),v.end(),comp);
    for(int i = 0; i < n; i++) cout << v[i].second << endl;
    return 0;
}

Measured memory_bytes: 256
#B
N, D = map(int, input().split())
List=[[int(j) for j in input().split()] for i in range(N)]
count =0
pp =0

for j in range(1,N):
    for i in range(j,N):
        pp= pp + 1
        combined1 = sum([(x-y)**2 for (x, y) in zip(List[j-1], List[i])])**0.5
        flg =combined1.is_integer()
        #print(List[i])
        if flg ==True:
            count =count+1

print(count)



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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N, K; cin >> N >> K;
  vector<ll> r(K+1,1);
  repr(i,1,K+1) {
    ll p2 = 1, now = i;
    while (p2<=N) {
      if (N&p2) r[i] = (r[i]*now)%MOD;
      now = now*now%MOD;
      p2 *= 2;
    }
  }
  // debug(all(r));
  ll result = 0;
  vector<ll> n(K+1,0);
  per(i,K+1) {
    if (i==0) break;
    n[i] = r[K/i];
    for (int j=i*2; j<=K; j+=i) n[i] = (n[i]-n[j]+MOD)%MOD;
    result = (result+n[i]*i) % MOD;
  }
  // debug(all(n));

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 4716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc162/abc162_e.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

ll dp[100010];

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod = MOD) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, K;
  cin >> N >> K;

  memset(dp, 0, 100010 * sizeof(ll));

  for (int i = K; i >= 1; i--) {
    dp[i] = modpow(K / i, N);
    for (int j = 2 * i; j <= K; j += i) {
      dp[i] -= dp[j];
    }
    dp[i] = (dp[i] % MOD + MOD) % MOD;
  }

  ll ans = 0;
  rep(i, K+1) {
    ans += i * dp[i] % MOD;
    ans %= MOD;
  }

  cout << ans << endl;
}

Measured memory_bytes: 4432
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>

#define div 1000000000+7

typedef long long ll;

using namespace std;

void solve() {
    string s;
    cin >> s;
    cout << "ABC" + s << endl;

}

int main() {
    solve();
    return 0;
}


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

int main(){
  int a, b, c, t = 0, e = 0, temp;
  int i, j, k;
  cin>>a>>b>>c;

  while(1){
    if(t%60 <= c && c <= t%60 + a){//cout<<t<<endl;
	  t = t/60 * 60 + c ;
	  break;
	}
    if(t/60 >= 1 && t%60 ==0){
      t = -1;
      break;
    }
	t += a + b;
  }
  
  
  cout<<t<<endl;
  return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> X(N);
  
  for (int i = 0; i < X.size(); i++) {
    string S;
    int P;
    cin >> S >> P;
    X.at(i) = make_tuple(S, P, i + 1);
  }
  typedef tuple<string, int, int> item;
  sort(X.begin(), X.end(), 
       [](const item& x, const item& y) {
         if (get<0>(x) != get<0>(y)) {
           return get<0>(x) < get<0>(y);
         }
         return get<1>(x) > get<1>(y);
       }
      );
  
  for (auto x: X) {
    // string S;
    // int P;
    int i;
    tie(ignore, ignore, i) = x;
    
    cout << i << endl;
    // cout << S << " / " << P << " / " <<  i << endl;
  }
}

Measured memory_bytes: 256