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

int main() {

  const long long int c_max = 10000000;

  long long int n, m, s, g1, g2, b1, b2, c;

  while( true ) {

    cin >> n >> m >> s >> g1 >> g2;

    if ( n == 0 ) break;
    s--;
    g1--;
    g2--;

    long long int map[100][100];

    for ( long long int i = 0; i < n; i++ ) {
      for ( long long int j = 0; j < n; j++ ) {
	if ( i == j ) {
	  map[i][j] = 0;
	}else {
	  map[i][j] = c_max;
	}
      }
    }

    for ( long long int i = 0; i < m; i++ ) {
      cin >> b1 >> b2 >> c;
      map[b1-1][b2-1] = c;
    }

    for ( long long int i = 0; i < n; i++ ) {
      for ( long long int j = 0; j < n; j++ ) {
	for ( long long int k = 0; k < n; k++ ) {
	  map[j][k] = min( map[j][k], map[j][i] + map[i][k] );
	}
      }
    }

    /*
    for ( long long int i = 0; i < n; i++ ) {
      for ( long long int j = 0; j < n; j++ ) {
	cout << map[i][j] << " ";
      }
      cout << endl;
    }
    */

    long long int ans = c_max;

    for ( long long int i = 0; i < n; i++ ) {
      ans = min( ans, map[s][i] + map[i][g1] + map[i][g2] );
    }

    cout << ans << endl;

  }

  return 0;

}

Measured memory_bytes: 1232
# require 'pry'
BINF = -(10**12)
N = gets.to_i
robots = []
N.times do
  s, t = gets.split.map(&:to_i)
  robots << [s + t, s - t]
end
robots.sort_by!{|x|x}
# p robots
t = BINF
count = 0
# binding.pry
robots.each do |robo|
  if t > robo[1]
    next
  end
  count += 1
  t = robo[0]
end
puts count


Measured memory_bytes: 12664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


// 1白
// 2黒

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,now;
	cin >> n;
	vector<int> co(n,0);
	vector<vector<P>> tree;
	tree.resize(n);
	FOR(i,0,n-1){
		int a,b,w;
		cin >> a >> b >> w;
		a--;b--;
		tree[a].push_back({b,w&1});
		tree[b].push_back({a,w&1});
	}
	queue<int> q;
	q.push(0);
	co[0] = 1;
	while(!q.empty()){
		now = q.front();
		q.pop();
		for(auto to:tree[now]){
			if(co[to.first]==0){
				if(to.second){
					co[to.first] = 3 - co[now];
				}else{
					co[to.first] = co[now];
				}
				q.push(to.first);
			}
		}
	}
	FOR(i,0,n){
		cout << co[i]-1 << endl;
	}
}


Measured memory_bytes: 8320
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

int gcd(int a, int b) {
    if (b > a) return gcd(b, a);
    else if (b == 0) return a;
    else return gcd(b, a % b);
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    string S, T;
    cin >> S >> T;
    int ans = N * M / gcd(N, M);
    int original = ans;
    rep(k, 10) {
        map<int, char> mp;
        int S1 = ans / N;
        int T1 = ans / M;
        rep(i, N) mp[ans/N * i] = S[i];
        bool check = true;
        rep(i, M) {
            auto itr = mp.find(T1 * i);
            if (itr == mp.end()) continue;
            //cout << mp[T1 * i] << " " << T[i] << endl;
            if (mp[T1 * i] != T[i]) {
                check = false;
                break;
            }
        }
        if (!check) {
            ans = original * (k + 1);
            continue;
        }
        cout << ans << endl;
        return 0;

    }
    cout << -1 << endl;



    return 0;
}


Measured memory_bytes: 6144
#include <stdio.h>

int main(){
   int i,j,n,a[2000],t[2000],ta[2000];
   long s,kk,kk1,k;
 
   scanf("%d %ld",&n,&k);
   for (i=0;i<n;i++) scanf("%d",&a[i]);
   for (i=0;i<n;i++) {
      t[i]=ta[i]=0;
      for (j=0;j<i;j++)
         if (a[j]>a[i]) t[i]++;
      for (j=i+1;j<n;j++)
         if (a[j]>a[i]) ta[i]++;
   }
   s=0;kk=(k*(k+1)/2)%1000000007;
   kk1=(k*(k-1)/2)%1000000007;
   for (i=0;i<n;i++)
      s=(s+t[i]*kk+ta[i]*kk1)%1000000007;
   printf("%ld",s);
   return 0;
}


Measured memory_bytes: 128
S = str(input())

Dp = [[0 for _ in range(13)] for _ in range(len(S)+1)]
Dp[0][0] = 1

mod = 1000000007

for i in range(len(S)):
    for j in range(13): # 遷移前のインデックス
        if S[i] != "?":
            Dp[i+1][(j*10+int(S[i]))%13] += Dp[i][j]
        else:
            for k in range(10):
                Dp[i+1][(j*10+k)%13] += Dp[i][j]
    for j in range(13):
        Dp[i+1][j] = Dp[i+1][j]%mod
        
print(Dp[-1][5])

Measured memory_bytes: 96212
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main(int argc , char **argv)
{
	(void)argc;
	(void)argv;

	int his[100002] = {};

	int N;
	cin >> N;
	int maxVal = 0;
	for(int i=0;i<N;i++){
		int a;
		cin >> a;
		a++;
		if (maxVal < a){maxVal=a;}
		his[a]++;
	}

	int cntMax = 0;
	for(int i=1;i<=maxVal;i++)
	{
		int num = his[i-1] + his[i] + his[i+1];
		if (cntMax < num){cntMax = num;}
	}

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

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define N 5005
#define M 205
#define ll long long
using namespace std;

int n,m,tail[M],a[N][M],q[N][M];
ll ans,s[N],now[N],tg[N];
int main(){
	scanf("%d%d",&n,&m);
	int i,j;
	for (i=2; i<=n; i++){
		scanf("%d",&j); s[i]=s[i-1]+j;
	}
	for (i=1; i<=n; i++){
		memset(tg,0,sizeof(tg));
		for (j=1; j<=m; j++){
			scanf("%d",&a[i][j]);
			int &k=tail[j];
			for (; k && a[i][j]>=a[q[k][j]][j]; k--){
				tg[q[k-1][j]+1]+=a[i][j]-a[q[k][j]][j];
				tg[q[k][j]+1]-=a[i][j]-a[q[k][j]][j];
			}
			tg[i]+=a[i][j]; q[++k][j]=i;
		}
		for (j=1; j<=i; j++){
			tg[j]+=tg[j-1]; now[j]+=tg[j];
			ans=max(ans,now[j]-s[i]+s[j]);
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

int f(int x){
  int cnt = 0;
  while (true){
    if(x&1)break;
    x>>=1;
    cnt++;
  }
  return cnt;
}

int main() {
  int n,mn=32;
  cin>>n;
  for (int i = 0; i < n; ++i) {
    int a;
    cin>>a;
    mn=min(f(a),mn);
  }
  cout<<mn<<endl;
}


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

int dfs(vector<vector<int>> &t, vector<vector<int>> &edge_id, vector<int> &be_white, int u, int parent, int v){
	if(u == v){
		return 1;
	}
	for(int i = 0; i < t[u].size(); i++){
		if(t[u][i] != parent){
			if(dfs(t, edge_id, be_white, t[u][i], u, v) == 1){
				be_white[edge_id[u][i]] = 1;
				return 1;
			}
		}
	}
	return 0;
}

signed main(){
	int N, M, i, S;
	scanf("%lld", &N);
	vector<vector<int>> t(N, vector<int>(0)), edge_id(N, vector<int>(0));
	for(i = 0; i < N - 1; i++){
		int a, b;
		scanf("%lld%lld", &a, &b);
		a--;
		b--;
		t[a].push_back(b);
		edge_id[a].push_back(i);
		t[b].push_back(a);
		edge_id[b].push_back(i);
	}
	scanf("%lld", &M);
	vector<int> u(M), v(M);
	for(i = 0; i < M; i++){
		scanf("%lld%lld", &u[i], &v[i]);
		u[i]--;
		v[i]--;
	}
	int ans = 0;
	for(S = 0; S < (1 << M); S++){
//		printf("S = %lld\n", S);
		vector<int> be_white(N - 1, 0);
		int violation_count = 0;
		for(i = 0; i < M; i++){
			if((S | (1 << i)) == S){
				int res = dfs(t, edge_id, be_white, u[i], -1, v[i]);
				violation_count++;
			}
		}
/*		for(i = 0; i < N - 1; i++){
			printf("%lld ", be_white[i]);
		}
		printf("\n");
*/		int be_white_count = 0;
		for(i = 0; i < N - 1; i++){
			be_white_count += be_white[i];
		}
		if(violation_count % 2 == 0){
			ans += (1ll << (N - 1 - be_white_count));
		}
		else{
			ans -= (1ll << (N - 1 - be_white_count));
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){

    int s,m=0,h=0;
    cin >> s;

    while(s>=60){
        if(s<3600){
            m=s/60;
            s%=60;
        }
        else if(s>=3600){
            h=s/3600;
            s%=3600;
        }
    }
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int A,B;
    cin >> A >> B;
    int ans = -1;
    rep(i,1020){
        int A_tax = i * 8 / 100;
        int B_tax = i * 10 / 100;
        if (A_tax == A && B_tax == B){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=200010;
const ll mod=1e9+7;

int main(){
  string s,t;
  cin >> s >> t;
  int ans = 0;
  int n=s.size();
  rep(i,n){
    if(s[i]!=t[i]){
      ans++;
    }
  }
  cout << ans << ln;
  return 0;
}

Measured memory_bytes: 3912
#include<cstdio>
#include<cassert>
#include<cstring>
#include<cmath>
using namespace std;
const int maxl = 3e5 + 10;
const int maxn = 600 + 10; 
typedef long long ll;
inline ll sqr(ll x) { return x * x;}
int n;
int col1[maxn][maxn]; // color
int col2[maxn][maxn];
ll sqt[maxl];
int cr[2];
void dfs(int col[][maxn],int r,int c,int k,ll d){
	col[r][c] = k;
	for(ll i = -r;r + i < 2 * n;i++){
		if(d - sqr(i) < 0) continue;
		ll j = sqt[d - sqr(i)];
		if(j == -1) continue;
		if(j + c < n * 2){
			if(col[r + i][c + j] == -1)  dfs(col,r + i,c + j,k ^ 1,d);	
		} 
		if(c - j >= 0){
			if(col[r + i][c - j] == -1) dfs(col,r + i,c - j,k ^ 1,d);
		}
		
	}
}
int main(){
	memset(col1,-1,sizeof(col1));
	memset(col2,-1,sizeof(col2));
	memset(sqt,-1,sizeof(sqt));
	ll d1,d2;
	scanf("%d%lld%lld",&n,&d1,&d2);
	for(ll i = 0;i * i < maxl;i++) sqt[i * i] = i;
	for(int i = 0;i < 2 * n;i++) for(int j = 0;j < 2 * n;j++)if(col1[i][j] == -1) dfs(col1,i,j,0,d1);
	for(int i = 0;i < 2 * n;i++) for(int j = 0;j < 2 * n;j++) if(col2[i][j] == -1) dfs(col2,i,j,0,d2);
	int cnt = 0;
	for(int i = 0;i < 2 * n;i++){
		for(int j = 0;j < 2 * n;j++){
			if(cnt < n * n && col1[i][j] == col1[0][0] && col2[i][j] == col2[0][0]){
				printf("%d %d\n",i,j);
				++cnt;
			}
		}
	}
	assert(cnt == n * n); 
	return 0;
}

Measured memory_bytes: 39808
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI A(N), B(N);
	REP(i, N) {
		cin >> A[i];
		B[i] = A[i];
	}
	SORT(B);
	int cnt = 0;
	REP(i, N) {
		if (A[i] != B[i])cnt++;
	}
	if (cnt > 2) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val a = Array(n) { sc.nextInt() }
    var streak = 0
    var prev = -1
    var ans = 0
    for (i in 0 until n) {
        if (prev != a[i]) {
            prev = a[i]
            ans += streak / 2
            streak = 1
        } else {
            streak++
        }
    }
    ans += streak / 2
    println(ans)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


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

int n, l[105];

int main(){
    scanf("%d", &n);
    for (int i = 0; i < n; ++i){
        scanf("%d", &l[i]);
    }
    int ans = 0;
    for (int i = 0; i < n; ++i){
        for (int j = i + 1; j < n; ++j){
            for (int k = j + 1; k < n; ++k){
                if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
                if (l[i] + l[j] > l[k]){
                    if (l[j] + l[k] > l[i]){
                        if (l[k] + l[i] > l[j]){
                            ++ans;
                        }
                    }
                }
            }
        }
    }
    cout<<ans;
}


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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int N, K;
	cin >>N >>K;
	cout <<N+1-K <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

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

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

int main() {
	int l, r; scanf("%d%d", &l, &r);
	
	std::set<int> st;
	for(int i = l; i < std::min(l + 2019 * 2, r + 1); i++) st.insert(i % 2019);
	
	int ans = 1 << 30;
	for(auto i: st) for(auto j: st) if(i < j) ans = std::min(ans, i * j % 2019);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};
vector<int>a(4,-1);
bool ans(int deg,vector<int> &notd,int n){//deg重（上限4）ループの再帰関数
  if(deg==0){
    if(n<=0) return true;
    else 
    return false;
  }
  for(int i : notd){
    a.at(deg-1)=i;
    if(ans(deg-1,notd,n-i*pow(10,deg-1))) return true;    
  }
  return false;
}

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> d(k),notd;
  rep(i,k)
    cin>>d.at(i);
  rep(i,10){
    if(find(all(d),i)==d.end())
      notd.push_back(i);
  }
  string s=to_string(n);
  int deg=s.size();
  a.assign(deg,-1);
  
  if(!ans(deg,notd,n)){
    if(notd.at(0)!=0)
      cout<<notd.at(0);
    else
      cout<<notd.at(1);
    rep(i,deg)
      cout<<notd.at(0);
    cout<<endl;
    return 0;
  }
  rep(i,deg)
    cout<<a.at(deg-1-i);
  cout<<endl;
}

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

using namespace std;


int main(int argc, char const *argv[])
{
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); ++i)
	{
		if (s[i]=='1') s[i] = '9';
		else if (s[i]=='9') s[i] = '1';
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        char[] d = S.toCharArray();
        int minC = Integer.MAX_VALUE;
        int maxF = Integer.MIN_VALUE;
        for (int i = 0; i < d.length; i++) {
            if (d[i] == 'C') {
                minC = i;
                break;
            }
        }
        for (int i = d.length-1; 0 <= i; i--) {
            if (d[i] == 'F') {
                maxF = i;
                break;
            }
        }
        if (minC < maxF) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var count = 0;
        for (int i = 0; i < n - 1; i++)
            if (a[i + 1] > a[i]) count++;
        Console.WriteLine(count);
    }
}



Measured memory_bytes: 16764
n,k = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]

memo = [0]*n

def dp(n,k,l,memo):
    for i in range(1,n):
        memo[i] = min(memo[j] + abs(l[i]-l[j]) for j in range(max(i-k,0), i))
            
    return memo

ans = dp(n,k,l,memo)

print(ans[n-1])


Measured memory_bytes: 13980
grid = [list(map(int,input().split()))for i in range(3)]


for a1 in range(-10000,10001):
    b1 = grid[0][0] - a1
    a2 = grid[1][0] - b1
    a3 = grid[2][0] - b1
    b2 = grid[0][1] - a1
    b3 = grid[0][2] - a1

    if a2+b2 == grid[1][1] and a2+b3 == grid[1][2] and a3+b2 == grid[2][1] and a3+b3 == grid[2][2]:
        print('Yes')
        break
else:print('No')




Measured memory_bytes: 38768
#include<stdio.h>
int main(void) {
	int n, m;
	int ans = 0;
	int i, j;

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


	if (n < m) {
		printf("0\n");
	}
	else {
		printf("10\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define Num 100000

int A[Num];

void assign() {
    int i;
    for(i = 0 ; i < Num ; i++)
        A[i] = i;
}

int dsf(int n) {
    /*被リンクの親は常に自分を返し続ける*/
    if(A[n] == n)
        return n;
    /*リンクしているならそのリンクを崩さないように*/
    else
        return A[n] = dsf(A[n]);
}

void LINK(int s , int t) {
    s = dsf(s);
    t = dsf(t);
    
    /*リンクして入れば被リンクの親の名がつく*/
    A[t] = s;
}

int main(void)
{
    int n , m , q;
    int s , t , u , v;
    int i;
    
    assign();
    
    scanf("%d %d" , &n , &m);
    
    for(i = 0 ; i < m ; i++) {
        scanf("%d %d" , &s , &t);
        
        LINK(s , t);
    }
    
    scanf("%d" , &q);
    
    for(i = 0 ; i < q ; i++) {
        scanf("%d %d" , &u , & v);
        
        if(dsf(u) == dsf(v))
            puts("yes");
        else
            puts("no");
    }

    return 0;
}



Measured memory_bytes: 2136
N = int(input())
S = []

for i in range(N):
    s = input()
    S.append(''.join(sorted(s)))

S.sort()
count = 0
sw = 0
series = []
for i in range(1, len(S)):
    if S[i-1]==S[i]:
        sw = 1
        count += 1
    else:
        if sw==1:
            count += 1
            series.append(count)
            count = 0
            sw = 0
if sw==1:
    count += 1
series.append(count)

count = int(sum([c * (c-1)/2 for c in series]))

print(count)

Measured memory_bytes: 10700
# include <stdio.h>
# include <ctype.h>
# define LENGE 128

int main(void) {
    char str[LENGE];
    char n;

    scanf("%s", &n);

    if(isupper(n)) {
        printf("A\n");
    }
    if(islower(n)) {
        printf("a\n");
    }
}


Measured memory_bytes: 1592
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
typedef long long ll;
typedef pair<ll, ll> P;
template<typename T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

// ////////////////////////////////////////////

constexpr ll INF = (1ll << 60);
constexpr ll MOD = 998244353ll;

using graph = vector<vector<ll>>;

int main() {
    ll n, m;
    cin >> n >> m;
    graph G(n);
    REP(i, m) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    queue<P> que;
    vector<ll> seen(n, -1);
    que.push(make_pair(-1, 0));
    while(!que.empty()){
        P pai = que.front();
        ll prev = pai.first, nowv = pai.second;
        que.pop();
        if(seen[nowv] != -1) continue;
        if(prev != -1){
            seen[nowv] = prev;
        }
        for(ll v : G[nowv]){
            que.push(make_pair(nowv, v));
        }
    }

    REP(i, n){
        if(i == 0) continue;
        if(seen[i] == -1){
            cout << "No" << endl;
            return 0;
        }
        seen[i] ++;
    }

    cout << "Yes" << endl;

    REP(i, n){
        if(i == 0) continue;
        cout << seen[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 18572
#include<bits/stdc++.h>
using namespace std;
int H,W,d[22][22],D,r,i,j,k,l,t[22][22];
char c;
void move(int i,int j,int n){
	if(t[i][j]&&(d[i][j]>n||d[i][j]==-1)){
		d[i][j]=n;
		move(i+1,j,n+1);
		move(i-1,j,n+1);
		move(i,j+1,n+1);
		move(i,j-1,n+1);
	}
}
main(){
	cin>>H>>W;
	for(i=1;i<=H;i++)for(j=1;j<=W;j++){
		cin>>c;
		t[i][j]=(c=='.');
	}
	for(i=1;i<=H;i++)for(j=1;j<=W;j++){
		for(k=1;k<=H;k++)for(l=1;l<=W;l++)d[k][l]=-1;
		move(i,j,0);
    D=0;
		for(k=1;k<=H;k++)for(l=1;l<=W;l++)D=max(D,d[k][l]);
		r=max(D,r);
	}
	cout<<r;
}


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

#define    int                      long long int

#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    ppi                      pair <int , pii>               
#define    sp(x)                    setprecision(x)
  
int32_t main()
{
    speed upp
    int n,a,b,m;
    cin>>n>>a>>b;
    m=min(a-1,n-b) + 1;
    if((b-a)%2==0)
        m=(b-a)/2;
    else
        m=m+(b-a-1)/2;
    cout<<m;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>


#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

void warshall_floyd(int n, vector<vector<int>>&d){
    rep(k, n){
        rep(i, n){
            rep(j, n){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}


const ll INF = 1e12;
int main(){
    int n;
    cin >> n;
    VEC(ll, a, n);

    ll res = 0;
    int r = 0;
    ll rui_sum = 0,rui_xor = 0;
    for(int l = 0; l < n; l++){
        while(r < n && (rui_sum + a[r]) == (rui_xor ^ a[r])){
          //cout << rui_sum + a[r] << " " << (rui_xor ^ a[r]) << endl;
            rui_sum += a[r];
            rui_xor ^= a[r];
            r++;
        }
      //cout << l << " " << r << endl;
        res += r - l;
        if(r == l)r++;
        else {
            rui_sum -= a[l];
            rui_xor ^= a[l];
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
using namespace std;
int main() {
	long long x, y; cin >> x >> y;
	long long ans = 0;
	if (abs(x) < abs(y)) {
		if (x < 0) {
			ans++;
			x = -x;
		}
		ans += abs(y) - abs(x);
		x += abs(y) - abs(x);
	}
	if (abs(x) > abs(y)) {
		if (x > 0) {
			ans++;
			x = -x;
		}
		ans += abs(x) - abs(y);
		x += abs(x) - abs(y);
	}
	if (x*y < 0)ans++;
	cout << ans << endl;
	return 0;
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


 
signed main() {
    int X, Y;
    cin>>X>>Y;
    
    if(X%Y==0){cout<<-1<<endl; return 0;}
    
    for(int i=1;;i++){
        int N = X*i;
        if(N%Y!=0){cout << N << endl; return 0;}
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,m;
  while(cin>>n>>m,n||m){
    int ba = 1;
    int s[n+1];
    for(int i=1;i<=n;i++) cin >> s[i];
    int d[m+1];
    for(int i=1;i<=m;i++) cin >> d[i];
    for(int i=1;i<=m;i++){
      ba += d[i];
      if(ba>=n){
	cout << i << endl;
	break;
      }
      ba += s[ba];
      if(ba>=n){
	cout << i << endl;
	break;
      }
    }
  }
  return 0;
}

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

string str;
int ans;

int main() {
  while (cin >> str) {
    bool check = true;
    for (int i = 0; i < (int)str.size() / 2; ++i) {
      if (str[i] != str[str.size() - 1 - i]) {
        check = false;
        break;
      }
    }
    if (check) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

vvint g;
int n;

int dfs(set<int> path, int v, int p = -1) {
    int res = 0;
    path.insert(v);
    if (path.size() == n) return 1;
    for (int n_v : g[v]) {
        if (n_v == p) continue;
        if (path.find(n_v) != path.end()) continue;
        res += dfs(path,n_v,v);
    }
    return res;
}

int main() {
    int m; cin >> n >> m;
    g.resize(n);
    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    set<int> path;
    cout << dfs(path,0) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<array>
#include<cassert>
#include<list>

using namespace std;

#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);

#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)

#define DEB(X) if(mode==1)cout<< #X <<": "<<X<<" ";
#define DEB2(X) if(mode==1)cout<<X<<" ";
#define ARDEB(i,X) if(mode==1)cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define FORDEB(n,X) if(mode==1)for(int i=0;i<(n);i++)ARDEB(i,X)
#define END if(mode==1)cout<<endl;

typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
struct P2{int x,y;};
//struct edge{int from,cost,to;};

const int MOD7=1000000007;
const int INF=100000000;
int mode=0;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<(a-c)/(b+c)<<endl;
	return 0;
}

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

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)

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

  cin >> a >> b >> c >> d;
  
  if (abs(c-a) <= d || (abs(b-a) <= d && abs(b-c) <= d))
    {
      cout << "Yes" << endl;
      return 0;
    }

  cout << "No" << endl;
  return 0;
  
}

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

int main() {
    int n;
    cin >> n;
    int evencnt = 0;
    rep(i, n){
        int a;
        cin >> a;
        if(a&1) continue;
        evencnt++;
    }
    cout << pow(3, n) - pow(2, evencnt) << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);

    	String a=sc.next();
    	String b=sc.next();

    	if(a.equals("H")) {
    		System.out.println(b);
    	}else {

    		if(b.equals("H")) {
    			System.out.println("D");
    		}else {
    			System.out.println("H");
    		}
    	}


    }
}


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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

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

    int k;
    cin>>k;
    int ans=0;
    for(int a=1;a<=k;a++)
        for(int b=1;b<=k;b++)
            for(int c=1;c<=k;c++)
                ans+=__gcd(__gcd(a,b),c);
    cout<<ans;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<string.h>
#include <stdio.h>
#include<math.h>
#include<functional>

#define INTMAX_MAX 10000
#define INTMAX_MIN -10000

using namespace std;



int main(){
    
    
    int count = 0;
    pair<double, double> xy[100];
    while(cin>>count){
        
        if(count==0)break;
        for(int i=0; i<count; i++)scanf("%lf,%lf",&xy[i].first,&xy[i].second);
        sort(xy,xy+count);
        int now = 0;
        int end = count;
        while(now<end-1){
            double max = INTMAX_MIN;
            int max_n = now;
            for(int i=now+1; i<end; i++){
                double temp;
                double x = xy[i].first-xy[now].first;
                double y = xy[i].second-xy[now].second;
                if(x==0){
                    if(y>0)temp=INTMAX_MAX;
                    else temp= INTMAX_MIN+1;
                }else{
                    temp = y/x;
                }
                if(temp>max){
                    max = temp;
                    max_n = i;
                }
            }
            now = max_n;
            count--;
        }
        now = 0;
        while(now<end-1){
            double min = INTMAX_MAX;
            int min_n = now;
            for(int i=now+1; i<end; i++){
                double temp;
                double x = xy[i].first-xy[now].first;
                double y = xy[i].second-xy[now].second;
                if(x==0){
                    if(y>0)temp=INTMAX_MAX-1;
                    else temp= INTMAX_MIN;
                }else{
                    temp = y/x;
                }
                if(temp<min){
                    min = temp;
                    min_n = i;
                }
            }
            now = min_n;
            count--;
        }
        cout<<count<<endl;
        
        
    }
    
    
    

        


}

Measured memory_bytes: 1276
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
deviation_temperature = float('inf')
candidate_cite = -1

for i in range(N):
	tmp = T - H[i] * 0.006
	if abs(tmp - A) < deviation_temperature:
		deviation_temperature = abs(tmp - A)
		candidate_cite = i + 1
		
print(candidate_cite)

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

const int N = 1e5 + 5;


vector<int> g[N];
int st[N], dr[N];
bool f[N], red[N];

int n;


static void dfs(int u, int far = 0) {
	for (auto v: g[u]) if (v != far) {
		red[v] = red[u] ^ true;
		dfs(v, u); } }

static bool pairup(int u) {
	if (f[u]) return false;
	f[u] = true;

	for (auto v: g[u]) if (!dr[v]) {
		st[u] = v;
		dr[v] = u; 
		return true; }

	for (auto v: g[u]) if (pairup(dr[v])) {
		st[u] = v;
		dr[v] = u;
		return true; }

	return false; }


int main() {
#ifdef HOME
	freopen("agc14d.in", "r", stdin);
	freopen("agc14d.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int matching(0);
	bool flag;

	cin >> n;
	for (int a, b, i = 1; i < n; ++i) {
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a); }

	if (n % 2) {
		cout << "First\n";
		return 0; }

	dfs(1);

	do {
		flag = false;
		for (int i = 1; i <= n; ++i) if (red[i]) {
			if (!st[i] && pairup(i)) {
				flag = true;
				matching+= 1; } }
		memset(f, 0x00, sizeof f); }	
	while (flag);

	cout << (matching == n / 2 ? "Second" : "First") << endl;

	return 0; }


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

int main(){
  int N; cin >> N;
  if(N<10){
    cout << N << endl;
  }
  if(10<= N && N<100){
    cout << 9 << endl;
  }
  if(100<=N && N<1000){
    cout << N-90 << endl;
  }
  if(1000<=N && N<10000){
    cout << 909 << endl;
  }
  if(10000<=N && N<100000){
    cout << N-9090 << endl;
  }
  if(N==100000){
    cout << 90909 << endl;
  }
}


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

		static void solve() {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int m = sc.nextInt();
			int x = sc.nextInt();
			int y = sc.nextInt();
			int check = 0;
			int narray[] = new int [n];
			int marray[] = new int [m];
			String res = "War";
			for(int i = 0;i<n;i++) {
				narray[i] = sc.nextInt();
			}
			for(int i = 0;i<m;i++) {
				marray[i] = sc.nextInt();
			}
			for(int z = x+1;z<=y;z++) {
				for(int i = 0;i<n;i++) {
					if(narray[i]<z) {
						check++;
					}
				}
				for(int i = 0;i<m;i++) {
					if(marray[i]>=z) {
						check++;
					}
				}
				if(check==n+m) {
					res = "No War";
				}
				else {
					check = 0;
				}
		}
			sc.close();
			System.out.println(res);
		
		}
	public static void main(String[] args) {
		solve();
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int N;
string S;
int main(){
    cin>>N;
    map<string,int>m;
    for(int i=0;i<N;i++){
        cin>>S;
        m[S]=1;
    }
    cout<<m.size()<<endl;
    return 0;
}

Measured memory_bytes: 19256
N = int(input())
A = [int(input()) for _ in range(N)]

D = {a:i for i,a in enumerate(sorted(A))}

A = [D[A[i]] for i in range(N)]

count = 0

for i in range(N):
    if i%2 == 0 and A[i]%2 != 0:
        count += 1

print(count)

Measured memory_bytes: 19876
#include <stdio.h>
int main() 
{
	unsigned long long int n,sum=0,i;
	scanf("%llu",&n);
	unsigned long long int a[n];
	for(i=1;i<=n;i++)
	{
	    scanf("%llu",&a[i]);
	    sum=sum+a[i];
	}
	printf("%llu",(sum-n));
	return 0;
}

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

int main()
{
	string str;
	int answer;

	cin >> str >> answer;

	bool flagL = false;
	bool flagM = false;

	int ansL = str[0] - '0';

	for (int i = 1; i < str.size(); i += 2) {
		if (str[i] == '+') {
			ansL += str[i + 1] - '0';
		}
		else if (str[i] == '*') {
			ansL *= str[i + 1] - '0';
		}
	}

	if (ansL == answer) {
		flagL = true;
	}

	int ansM = 0;
	vector<int> num;
	vector<char> calc;

	for (int i = 0; i < str.size(); i++) {
		if (str[i] == '+') {
			calc.push_back(str[i]);
		}
		else if (str[i] == '*') {
			calc.push_back(str[i]);
		}
		else {
			num.push_back(str[i] - '0');
		}
	}

	while (true) {
		bool flag = false;

		for (int i = 0; i < calc.size(); i++) {
			if (calc[i] == '*') {
				num[i] = num[i] * num[i + 1];
				num.erase(num.begin() + i + 1);
				calc.erase(calc.begin() + i);
				flag = true;
				break;
			}
		}

		if (flag == true) {
			continue;
		}
		else {
			for (int i = 0; i < num.size(); i ++) {
				ansM += num[i];
			}

			if (ansM == answer) {
				flagM = true;
			}

			break;
		}
	}

	if (flagL == true && flagM == true) {
		cout << "U" << endl;
	}
	else if (flagL == true) {
		cout << "L" << endl;
	}
	else if (flagM == true) {
		cout << "M" << endl;
	}
	else {
		cout << "I" << endl;
	}

	return 0;
}

Measured memory_bytes: 3208
N = int(input())
red = []
blue = []
for i in range(N):
    red.append(list(map(int, input().split())))
for j in range(N):
    blue.append(list(map(int, input().split())))

blue2 = sorted(blue, key=lambda x: x[0])
count = 0
for k in blue2:
    temp = -1
    pop = -1
    num = -1
    for l in red:
        num += 1
        if l[1] < k[1] and l[0] < k[0]:
            if l[1] > temp:
                temp = l[1]
                pop = num
    if temp >= 0:
        red.pop(pop)
        count += 1
print(count)

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

int main() {
  ll n;
  cin >> n;
  map<ll, int> m;

  ll ntmp = n;
  for (ll i=2; i*i<=n; i++) {
    if (ntmp % i == 0) {
      int j = 0;
      while ((ntmp % i == 0) && (ntmp > 0)) {
        j++;
        ntmp /= i;
      }
      m[i] = j;
    }
  }
  if (ntmp > 1) m[ntmp] = 1;

  int ans = 0;
  map<ll, int>::iterator ite;
  for (ite = m.begin(); ite != m.end(); ite++) {
    //cout << ite->first << " " << ite->second << endl;
    int x = ite->second;
    int i = 1;
    while (x >= i) {
      x -= i;
      i++;
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

/*
1101
0111101101
*/

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
int main(){
  int N,i,j,k;scanf("%d",&N);
  int L[N];
  for(i=0;i<N;i++) scanf("%d",&L[i]);
  sort(L,L+N);
  int ans = 0;
  for(i=0;i<N-2;i++){
    for(j=i+1;j<N-1;j++){
      for(k=j+1;k<N;k++) ans += L[i] != L[j] && L[i] != L[k] && L[j] != L[k] && L[i]+L[j] > L[k];
    }
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 3812
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


func main() {
	sc.Split(bufio.ScanWords)

	a, b := nextInt(), nextInt()
	if a > b {
		a, b = b, a
	}
	k := (b-a)/2

	if 2 * k == b - a {
		fmt.Println(a+k)
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n,w;
    cin>>n>>w;
    vector<long long> v(n);
    vector<long long> q(n);

    for(long long i=0;i<n;i++)
    {
        cin>>q[i]>>v[i];
    }

    // for(auto i:v)
    //     cout<<i<<" ";
    // cout<<endl;

    // for(auto i:q)
    //     cout<<i<<" ";
    //     cout<<endl;
    long long dp[n+1][w+1];
    for(long long i=0;i<=n;i++)
    {
        for(long long j=0;j<=w;j++)
        {
            dp[i][j]=0;
        }
    }

    // for(int i=0;i<=n;i++)
    // {
    //     for(int j=0;j<=n;j++)
    //         cout<<dp[i][j]<<" ";
    //         cout<<endl;
    // }

    for(long long i=1;i<=n;i++)
    {
        for(long long j=1;j<=w;j++)
        {
            if(j>=q[i-1])
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-q[i-1]]+v[i-1]);
            else
            {
                dp[i][j]=dp[i-1][j];
            }
            // cout<<dp[i][j]<<" ";
            
        }
    }

    cout<<dp[n][w];
    return 0;
}


Measured memory_bytes: 79104
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

int main()
{
	int w;cin>>w;
	int n;cin>>n;
	vector<int>P(w+1);
	for ( int i=0; i<=w; i++ )
		P[i]=i;
	for ( int i=0; i<n; i++ )
	{
		int a,b;
		char c;
		cin>>a>>c>>b;
		swap(P[a],P[b]);

	}
	for ( int i=1; i<=w; i++ )
		cout << P[i]<<endl;
	return 0;



}

Measured memory_bytes: 0
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Debug = System.Diagnostics.Debug;
using static System.Math;
using System.Runtime.CompilerServices;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        int n = NextInt;
        var x = NextInt;
        int cur = 0;
        int res = 1;
        for (int i = 0; i < n; i++)
        {
            cur += NextInt;
            if (cur <= x) res++;
        }
        Console.WriteLine(res);
    }

    static readonly TextReader In = Console.In;
    static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0;
            int next = In.Read();
            int rev = 1;
            while (45 > next || next > 57) next = In.Read();
            if (next == 45) { next = In.Read(); rev = -1; }
            while (48 <= next && next <= 57)
            {
                res = res * 10 + next - 48;
                next = In.Read();
            }
            return res * rev;
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdlib>

using namespace std;

typedef long long ll;
const long long INF = 1e9;

int main()
{
    int n; cin >> n;
    vector<ll> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    vector<ll> dp(100010, INF);

    dp[0] = 0;
    for (int i = 1; i < n; i++)
    {
        //隣にジャンプ
        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1])); 
        //1つ飛ばして
        if(i > 1) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2])); 
    }

    cout << dp[n - 1] << endl;
    return 0;    
}


Measured memory_bytes: 1792
N=int(input())
AB=[list(map(int, input().split())) for _ in range(N)]

AB.sort(key=lambda x:(x[0]+x[1]),reverse=True)

s=0
for i,v in enumerate(AB):
    if i%2:
        s = s - v[1]
    else:
        s = s + v[0]
print(s)


Measured memory_bytes: 32224
r, g, b, n = gets.split.map(&:to_i)
cnt = 0
(n / r + 1).times do |i|
  (n / g + 1).times do |j|
    cnt += 1 if (n - r * i - g * j) % b == 0 && n - r * i - g * j >= 0
  end
end
puts cnt

Measured memory_bytes: 1788